summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/dbuscomm_maemo.cpp257
-rw-r--r--src/location/dbuscomm_maemo_p.h128
-rw-r--r--src/location/dbusserver_maemo.cpp90
-rw-r--r--src/location/dbusserver_maemo_p.h93
-rw-r--r--src/location/gconfitem.cpp364
-rw-r--r--src/location/gconfitem_p.h166
-rw-r--r--src/location/landmarks/landmarks.pri88
-rw-r--r--src/location/landmarks/qlandmark.cpp500
-rw-r--r--src/location/landmarks/qlandmark.h115
-rw-r--r--src/location/landmarks/qlandmark_p.h91
-rw-r--r--src/location/landmarks/qlandmarkabstractrequest.cpp428
-rw-r--r--src/location/landmarks/qlandmarkabstractrequest.h113
-rw-r--r--src/location/landmarks/qlandmarkabstractrequest_p.h81
-rw-r--r--src/location/landmarks/qlandmarkattributefilter.cpp270
-rw-r--r--src/location/landmarks/qlandmarkattributefilter.h81
-rw-r--r--src/location/landmarks/qlandmarkboxfilter.cpp164
-rw-r--r--src/location/landmarks/qlandmarkboxfilter.h81
-rw-r--r--src/location/landmarks/qlandmarkboxfilter_p.h83
-rw-r--r--src/location/landmarks/qlandmarkcategory.cpp246
-rw-r--r--src/location/landmarks/qlandmarkcategory.h93
-rw-r--r--src/location/landmarks/qlandmarkcategory_p.h84
-rw-r--r--src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp144
-rw-r--r--src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h73
-rw-r--r--src/location/landmarks/qlandmarkcategoryfetchrequest.cpp166
-rw-r--r--src/location/landmarks/qlandmarkcategoryfetchrequest.h78
-rw-r--r--src/location/landmarks/qlandmarkcategoryfilter.cpp127
-rw-r--r--src/location/landmarks/qlandmarkcategoryfilter.h75
-rw-r--r--src/location/landmarks/qlandmarkcategoryfilter_p.h82
-rw-r--r--src/location/landmarks/qlandmarkcategoryid.cpp171
-rw-r--r--src/location/landmarks/qlandmarkcategoryid.h83
-rw-r--r--src/location/landmarks/qlandmarkcategoryid_p.h84
-rw-r--r--src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp179
-rw-r--r--src/location/landmarks/qlandmarkcategoryidfetchrequest.h77
-rw-r--r--src/location/landmarks/qlandmarkcategoryremoverequest.cpp166
-rw-r--r--src/location/landmarks/qlandmarkcategoryremoverequest.h74
-rw-r--r--src/location/landmarks/qlandmarkcategorysaverequest.cpp135
-rw-r--r--src/location/landmarks/qlandmarkcategorysaverequest.h73
-rw-r--r--src/location/landmarks/qlandmarkexportrequest.cpp208
-rw-r--r--src/location/landmarks/qlandmarkexportrequest.h80
-rw-r--r--src/location/landmarks/qlandmarkfetchbyidrequest.cpp140
-rw-r--r--src/location/landmarks/qlandmarkfetchbyidrequest.h71
-rw-r--r--src/location/landmarks/qlandmarkfetchrequest.cpp206
-rw-r--r--src/location/landmarks/qlandmarkfetchrequest.h79
-rw-r--r--src/location/landmarks/qlandmarkfilter.cpp227
-rw-r--r--src/location/landmarks/qlandmarkfilter.h108
-rw-r--r--src/location/landmarks/qlandmarkfilter_p.h110
-rw-r--r--src/location/landmarks/qlandmarkid.cpp174
-rw-r--r--src/location/landmarks/qlandmarkid.h83
-rw-r--r--src/location/landmarks/qlandmarkid_p.h86
-rw-r--r--src/location/landmarks/qlandmarkidfetchrequest.cpp218
-rw-r--r--src/location/landmarks/qlandmarkidfetchrequest.h80
-rw-r--r--src/location/landmarks/qlandmarkidfilter.cpp153
-rw-r--r--src/location/landmarks/qlandmarkidfilter.h73
-rw-r--r--src/location/landmarks/qlandmarkidfilter_p.h82
-rw-r--r--src/location/landmarks/qlandmarkimportrequest.cpp222
-rw-r--r--src/location/landmarks/qlandmarkimportrequest.h82
-rw-r--r--src/location/landmarks/qlandmarkintersectionfilter.cpp176
-rw-r--r--src/location/landmarks/qlandmarkintersectionfilter.h74
-rw-r--r--src/location/landmarks/qlandmarkintersectionfilter_p.h82
-rw-r--r--src/location/landmarks/qlandmarkmanager.cpp1473
-rw-r--r--src/location/landmarks/qlandmarkmanager.h220
-rw-r--r--src/location/landmarks/qlandmarkmanager_p.cpp171
-rw-r--r--src/location/landmarks/qlandmarkmanager_p.h92
-rw-r--r--src/location/landmarks/qlandmarkmanagerengine.cpp1389
-rw-r--r--src/location/landmarks/qlandmarkmanagerengine.h199
-rw-r--r--src/location/landmarks/qlandmarkmanagerenginefactory.cpp105
-rw-r--r--src/location/landmarks/qlandmarkmanagerenginefactory.h70
-rw-r--r--src/location/landmarks/qlandmarknamefilter.cpp138
-rw-r--r--src/location/landmarks/qlandmarknamefilter.h72
-rw-r--r--src/location/landmarks/qlandmarknamefilter_p.h85
-rw-r--r--src/location/landmarks/qlandmarknamesort.cpp119
-rw-r--r--src/location/landmarks/qlandmarknamesort.h69
-rw-r--r--src/location/landmarks/qlandmarknamesort_p.h81
-rw-r--r--src/location/landmarks/qlandmarkproximityfilter.cpp171
-rw-r--r--src/location/landmarks/qlandmarkproximityfilter.h79
-rw-r--r--src/location/landmarks/qlandmarkproximityfilter_p.h84
-rw-r--r--src/location/landmarks/qlandmarkremoverequest.cpp163
-rw-r--r--src/location/landmarks/qlandmarkremoverequest.h74
-rw-r--r--src/location/landmarks/qlandmarkrequests_p.h257
-rw-r--r--src/location/landmarks/qlandmarksaverequest.cpp137
-rw-r--r--src/location/landmarks/qlandmarksaverequest.h71
-rw-r--r--src/location/landmarks/qlandmarksortorder.cpp193
-rw-r--r--src/location/landmarks/qlandmarksortorder.h94
-rw-r--r--src/location/landmarks/qlandmarksortorder_p.h112
-rw-r--r--src/location/landmarks/qlandmarkunionfilter.cpp178
-rw-r--r--src/location/landmarks/qlandmarkunionfilter.h75
-rw-r--r--src/location/landmarks/qlandmarkunionfilter_p.h83
-rw-r--r--src/location/liblocationwrapper.cpp377
-rw-r--r--src/location/liblocationwrapper_p.h121
-rw-r--r--src/location/location.pro197
-rw-r--r--src/location/maps/maps.pri95
-rw-r--r--src/location/maps/qgeomaneuver.cpp321
-rw-r--r--src/location/maps/qgeomaneuver.h114
-rw-r--r--src/location/maps/qgeomaneuver_p.h85
-rw-r--r--src/location/maps/qgeomapcircleobject.cpp340
-rw-r--r--src/location/maps/qgeomapcircleobject.h110
-rw-r--r--src/location/maps/qgeomapcircleobject_p.h66
-rw-r--r--src/location/maps/qgeomapcustomobject.cpp286
-rw-r--r--src/location/maps/qgeomapcustomobject.h94
-rw-r--r--src/location/maps/qgeomapcustomobject_p.h65
-rw-r--r--src/location/maps/qgeomapdata.cpp836
-rw-r--r--src/location/maps/qgeomapdata.h171
-rw-r--r--src/location/maps/qgeomapdata_p.h110
-rw-r--r--src/location/maps/qgeomapgroupobject.cpp309
-rw-r--r--src/location/maps/qgeomapgroupobject.h87
-rw-r--r--src/location/maps/qgeomapgroupobject_p.h73
-rw-r--r--src/location/maps/qgeomapobject.cpp534
-rw-r--r--src/location/maps/qgeomapobject.h154
-rw-r--r--src/location/maps/qgeomapobject_p.h90
-rw-r--r--src/location/maps/qgeomapobjectengine_p.cpp1179
-rw-r--r--src/location/maps/qgeomapobjectengine_p.h175
-rw-r--r--src/location/maps/qgeomapobjectinfo.cpp264
-rw-r--r--src/location/maps/qgeomapobjectinfo.h97
-rw-r--r--src/location/maps/qgeomapobjectinfo_p.h78
-rw-r--r--src/location/maps/qgeomapoverlay.cpp114
-rw-r--r--src/location/maps/qgeomapoverlay.h81
-rw-r--r--src/location/maps/qgeomapoverlay_p.h76
-rw-r--r--src/location/maps/qgeomappingmanager.cpp264
-rw-r--r--src/location/maps/qgeomappingmanager.h103
-rw-r--r--src/location/maps/qgeomappingmanager_p.h79
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp431
-rw-r--r--src/location/maps/qgeomappingmanagerengine.h124
-rw-r--r--src/location/maps/qgeomappingmanagerengine_p.h91
-rw-r--r--src/location/maps/qgeomappixmapobject.cpp222
-rw-r--r--src/location/maps/qgeomappixmapobject.h91
-rw-r--r--src/location/maps/qgeomappixmapobject_p.h64
-rw-r--r--src/location/maps/qgeomappolygonobject.cpp209
-rw-r--r--src/location/maps/qgeomappolygonobject.h90
-rw-r--r--src/location/maps/qgeomappolygonobject_p.h66
-rw-r--r--src/location/maps/qgeomappolylineobject.cpp175
-rw-r--r--src/location/maps/qgeomappolylineobject.h86
-rw-r--r--src/location/maps/qgeomappolylineobject_p.h64
-rw-r--r--src/location/maps/qgeomaprectangleobject.cpp299
-rw-r--r--src/location/maps/qgeomaprectangleobject.h101
-rw-r--r--src/location/maps/qgeomaprectangleobject_p.h65
-rw-r--r--src/location/maps/qgeomaprouteobject.cpp224
-rw-r--r--src/location/maps/qgeomaprouteobject.h92
-rw-r--r--src/location/maps/qgeomaprouteobject_p.h64
-rw-r--r--src/location/maps/qgeomaptextobject.cpp375
-rw-r--r--src/location/maps/qgeomaptextobject.h115
-rw-r--r--src/location/maps/qgeomaptextobject_p.h70
-rw-r--r--src/location/maps/qgeoroute.cpp323
-rw-r--r--src/location/maps/qgeoroute.h105
-rw-r--r--src/location/maps/qgeoroute_p.h94
-rw-r--r--src/location/maps/qgeoroutereply.cpp271
-rw-r--r--src/location/maps/qgeoroutereply.h103
-rw-r--r--src/location/maps/qgeoroutereply_p.h85
-rw-r--r--src/location/maps/qgeorouterequest.cpp488
-rw-r--r--src/location/maps/qgeorouterequest.h170
-rw-r--r--src/location/maps/qgeorouterequest_p.h87
-rw-r--r--src/location/maps/qgeoroutesegment.cpp277
-rw-r--r--src/location/maps/qgeoroutesegment.h99
-rw-r--r--src/location/maps/qgeoroutesegment_p.h87
-rw-r--r--src/location/maps/qgeoroutingmanager.cpp419
-rw-r--r--src/location/maps/qgeoroutingmanager.h98
-rw-r--r--src/location/maps/qgeoroutingmanager_p.h76
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.cpp468
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.h110
-rw-r--r--src/location/maps/qgeoroutingmanagerengine_p.h90
-rw-r--r--src/location/maps/qgeosearchmanager.cpp682
-rw-r--r--src/location/maps/qgeosearchmanager.h119
-rw-r--r--src/location/maps/qgeosearchmanager_p.h101
-rw-r--r--src/location/maps/qgeosearchmanagerengine.cpp515
-rw-r--r--src/location/maps/qgeosearchmanagerengine.h114
-rw-r--r--src/location/maps/qgeosearchmanagerengine_p.h89
-rw-r--r--src/location/maps/qgeosearchreply.cpp344
-rw-r--r--src/location/maps/qgeosearchreply.h108
-rw-r--r--src/location/maps/qgeosearchreply_p.h88
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp430
-rw-r--r--src/location/maps/qgeoserviceprovider.h96
-rw-r--r--src/location/maps/qgeoserviceprovider_p.h102
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.cpp166
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.h80
-rw-r--r--src/location/maps/qgraphicsgeomap.cpp809
-rw-r--r--src/location/maps/qgraphicsgeomap.h172
-rw-r--r--src/location/maps/qgraphicsgeomap_p.h80
-rw-r--r--src/location/maps/tiled/makepoly_p.h138
-rw-r--r--src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp106
-rw-r--r--src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h86
-rw-r--r--src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp100
-rw-r--r--src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h85
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata.cpp1428
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata.h115
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata_p.h168
-rw-r--r--src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp137
-rw-r--r--src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h82
-rw-r--r--src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp259
-rw-r--r--src/location/maps/tiled/qgeotiledmapobjectinfo_p.h109
-rw-r--r--src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp188
-rw-r--r--src/location/maps/tiled/qgeotiledmappingmanagerengine.h83
-rw-r--r--src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h82
-rw-r--r--src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp91
-rw-r--r--src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h85
-rw-r--r--src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp138
-rw-r--r--src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h90
-rw-r--r--src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp130
-rw-r--r--src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h88
-rw-r--r--src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp147
-rw-r--r--src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h90
-rw-r--r--src/location/maps/tiled/qgeotiledmapreply.cpp329
-rw-r--r--src/location/maps/tiled/qgeotiledmapreply.h103
-rw-r--r--src/location/maps/tiled/qgeotiledmapreply_p.h80
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest.cpp266
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest.h90
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest_p.h84
-rw-r--r--src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp144
-rw-r--r--src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h90
-rw-r--r--src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp169
-rw-r--r--src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h94
-rw-r--r--src/location/maps/tiled/tiled.pri40
-rw-r--r--src/location/notificationcallback_s60_p.h74
-rw-r--r--src/location/notificationmonitorcallback_s60_p.h73
-rw-r--r--src/location/notificationsatellitecallback_s60_p.h75
-rw-r--r--src/location/projwrapper_p.cpp267
-rw-r--r--src/location/projwrapper_p.h129
-rw-r--r--src/location/qgeoaddress.cpp322
-rw-r--r--src/location/qgeoaddress.h99
-rw-r--r--src/location/qgeoaddress_p.h82
-rw-r--r--src/location/qgeoareamonitor.cpp214
-rw-r--r--src/location/qgeoareamonitor.h93
-rw-r--r--src/location/qgeoareamonitor_polling.cpp123
-rw-r--r--src/location/qgeoareamonitor_polling_p.h91
-rw-r--r--src/location/qgeoareamonitor_s60.cpp289
-rw-r--r--src/location/qgeoareamonitor_s60_p.h119
-rw-r--r--src/location/qgeoboundingarea.cpp109
-rw-r--r--src/location/qgeoboundingarea.h76
-rw-r--r--src/location/qgeoboundingbox.cpp804
-rw-r--r--src/location/qgeoboundingbox.h122
-rw-r--r--src/location/qgeoboundingbox_p.h80
-rw-r--r--src/location/qgeoboundingcircle.cpp294
-rw-r--r--src/location/qgeoboundingcircle.h94
-rw-r--r--src/location/qgeoboundingcircle_p.h80
-rw-r--r--src/location/qgeocoordinate.cpp638
-rw-r--r--src/location/qgeocoordinate.h127
-rw-r--r--src/location/qgeocoordinate_p.h77
-rw-r--r--src/location/qgeoinfothread_wince.cpp409
-rw-r--r--src/location/qgeoinfothread_wince_p.h151
-rw-r--r--src/location/qgeoplace.cpp269
-rw-r--r--src/location/qgeoplace.h96
-rw-r--r--src/location/qgeoplace_p.h104
-rw-r--r--src/location/qgeopositioninfo.cpp332
-rw-r--r--src/location/qgeopositioninfo.h120
-rw-r--r--src/location/qgeopositioninfosource.cpp551
-rw-r--r--src/location/qgeopositioninfosource.h107
-rw-r--r--src/location/qgeopositioninfosource_geocluemaster.cpp556
-rw-r--r--src/location/qgeopositioninfosource_geocluemaster_p.h141
-rw-r--r--src/location/qgeopositioninfosource_maemo.cpp206
-rw-r--r--src/location/qgeopositioninfosource_maemo5.cpp369
-rw-r--r--src/location/qgeopositioninfosource_maemo5_p.h129
-rw-r--r--src/location/qgeopositioninfosource_maemo_p.h110
-rw-r--r--src/location/qgeopositioninfosource_s60.cpp954
-rw-r--r--src/location/qgeopositioninfosource_s60_p.h310
-rw-r--r--src/location/qgeopositioninfosource_simulator.cpp166
-rw-r--r--src/location/qgeopositioninfosource_simulator_p.h85
-rw-r--r--src/location/qgeopositioninfosource_wince.cpp179
-rw-r--r--src/location/qgeopositioninfosource_wince_p.h104
-rw-r--r--src/location/qgeopositioninfosourcefactory.cpp131
-rw-r--r--src/location/qgeopositioninfosourcefactory.h72
-rw-r--r--src/location/qgeosatelliteinfo.cpp277
-rw-r--r--src/location/qgeosatelliteinfo.h111
-rw-r--r--src/location/qgeosatelliteinfosource.cpp413
-rw-r--r--src/location/qgeosatelliteinfosource.h86
-rw-r--r--src/location/qgeosatelliteinfosource_gypsy.cpp369
-rw-r--r--src/location/qgeosatelliteinfosource_gypsy_p.h140
-rw-r--r--src/location/qgeosatelliteinfosource_maemo.cpp153
-rw-r--r--src/location/qgeosatelliteinfosource_maemo5.cpp245
-rw-r--r--src/location/qgeosatelliteinfosource_maemo5_p.h119
-rw-r--r--src/location/qgeosatelliteinfosource_maemo_p.h97
-rw-r--r--src/location/qgeosatelliteinfosource_s60.cpp708
-rw-r--r--src/location/qgeosatelliteinfosource_s60_p.h280
-rw-r--r--src/location/qgeosatelliteinfosource_simulator.cpp106
-rw-r--r--src/location/qgeosatelliteinfosource_simulator_p.h80
-rw-r--r--src/location/qgeosatelliteinfosource_wince.cpp169
-rw-r--r--src/location/qgeosatelliteinfosource_wince_p.h98
-rw-r--r--src/location/qlocationconnection_simulator.cpp135
-rw-r--r--src/location/qlocationconnection_simulator_p.h80
-rw-r--r--src/location/qlocationdata_simulator.cpp97
-rw-r--r--src/location/qlocationdata_simulator_p.h111
-rw-r--r--src/location/qlocationutils.cpp354
-rw-r--r--src/location/qlocationutils_p.h105
-rw-r--r--src/location/qmlbackendao_s60.cpp478
-rw-r--r--src/location/qmlbackendao_s60_p.h163
-rw-r--r--src/location/qmlbackendmonitorao_s60.cpp157
-rw-r--r--src/location/qmlbackendmonitorao_s60_p.h119
-rw-r--r--src/location/qmlbackendmonitorcreatetriggerao_s60.cpp404
-rw-r--r--src/location/qmlbackendmonitorcreatetriggerao_s60_p.h113
-rw-r--r--src/location/qmlbackendmonitorinfo_s60.cpp157
-rw-r--r--src/location/qmlbackendmonitorinfo_s60_p.h108
-rw-r--r--src/location/qmlbackendtriggerchangeao_s60.cpp349
-rw-r--r--src/location/qmlbackendtriggerchangeao_s60_p.h96
-rw-r--r--src/location/qnmeapositioninfosource.cpp611
-rw-r--r--src/location/qnmeapositioninfosource.h100
-rw-r--r--src/location/qnmeapositioninfosource_p.h180
293 files changed, 55163 insertions, 0 deletions
diff --git a/src/location/dbuscomm_maemo.cpp b/src/location/dbuscomm_maemo.cpp
new file mode 100644
index 00000000..09c13549
--- /dev/null
+++ b/src/location/dbuscomm_maemo.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dbuscomm_maemo_p.h"
+
+#include <iostream>
+using namespace std;
+
+QTM_BEGIN_NAMESPACE
+
+const QString DBusComm::positioningdService = QString("com.nokia.positioningd.client");
+const QString DBusComm::positioningdPath = QString("/com/nokia/positioningd/client");
+const QString DBusComm::positioningdInterface = QString("com.nokia.positioningd.client");
+
+DBusComm::DBusComm(QObject *parent) : QObject(parent),
+ minimumUpdateInterval(1000),
+ availablePositioningMethods(QGeoPositionInfoSource::AllPositioningMethods)
+{
+}
+
+
+int DBusComm::init()
+{
+ if (!QDBusConnection::sessionBus().isConnected()) {
+ cerr << "Cannot connect to the D-BUS session bus.\n";
+ return -1;
+ }
+
+ // Application auto-start by dbus may take a while, so try
+ // connecting a few times.
+
+ int cnt = 10;
+ positioningdProxy = new QDBusInterface(positioningdService,
+ positioningdPath,
+ positioningdInterface,
+ QDBusConnection::sessionBus());
+
+ while (cnt && (positioningdProxy->isValid() == false)) {
+ // cout << "Connecting to positioning daemon..." << endl;
+ usleep(200000);
+ positioningdProxy = new QDBusInterface(positioningdService,
+ positioningdPath,
+ positioningdInterface,
+ QDBusConnection::sessionBus());
+ cnt--;
+ }
+
+ if (positioningdProxy->isValid() == false) {
+ cerr << "DBus connection to positioning daemon failed.\n";
+ return -1;
+ }
+ serviceDisconnectWatcher = new QDBusServiceWatcher (positioningdService, QDBusConnection::sessionBus(),
+ QDBusServiceWatcher::WatchForUnregistration, this);
+
+ QObject::connect(serviceDisconnectWatcher, SIGNAL(serviceUnregistered ( const QString &)),
+ this,SLOT(onServiceDisconnect(const QString &)));
+
+ serviceConnectWatcher = new QDBusServiceWatcher (positioningdService, QDBusConnection::sessionBus(),
+ QDBusServiceWatcher::WatchForRegistration, this);
+
+ QObject::connect(serviceConnectWatcher, SIGNAL(serviceRegistered ( const QString &)),
+ this,SLOT(onServiceConnect(const QString &)));
+
+
+ if (createUniqueName() == false) { // set myService, myPath
+ return -1;
+ }
+
+ dbusServer = new DBusServer(&serverObj, this);
+ QDBusConnection::sessionBus().registerObject(myPath, &serverObj);
+ if (!QDBusConnection::sessionBus().registerService(myService)) {
+ cerr << qPrintable(QDBusConnection::sessionBus().lastError().message()) << endl;
+ return -1;
+ }
+
+ sendDBusRegister();
+
+ return 0;
+}
+
+
+void DBusComm::onServiceDisconnect(const QString &name)
+{
+ Q_UNUSED(name);
+ emit serviceDisconnected();
+}
+
+
+void DBusComm::onServiceConnect(const QString &name)
+{
+ Q_UNUSED(name);
+ sendDBusRegister();
+ emit serviceConnected();
+}
+
+
+void DBusComm::receivePositionUpdate(const QGeoPositionInfo &update)
+{
+ emit receivedPositionUpdate(update);
+}
+
+
+void DBusComm::receiveSatellitesInView(const QList<QGeoSatelliteInfo> &info)
+{
+ emit receivedSatellitesInView(info);
+}
+
+
+void DBusComm::receiveSatellitesInUse(const QList<QGeoSatelliteInfo> &info)
+{
+ emit receivedSatellitesInUse(info);
+}
+
+
+void DBusComm::receiveSettings(QGeoPositionInfoSource::PositioningMethod methods, qint32 interval)
+{
+ availablePositioningMethods = methods;
+ minimumUpdateInterval = interval;
+}
+
+
+bool DBusComm::sendDBusRegister()
+{
+ QDBusMessage reply = positioningdProxy->call("registerListener",
+ myService.toAscii().constData(),
+ myPath.toAscii().constData());
+ if (reply.type() == QDBusMessage::ReplyMessage) {
+ QList<QVariant> values = reply.arguments();
+ clientId = values.takeFirst().toInt();
+ quint32 m = values.takeFirst().toUInt();
+ availablePositioningMethods = (QGeoPositionInfoSource::PositioningMethod) m;
+ minimumUpdateInterval = values.takeFirst().toUInt();
+ } else {
+ cerr << endl << "DBus error:\n";
+ cerr << reply.errorName().toAscii().constData() << endl;
+ cerr << reply.errorMessage().toAscii().constData() << endl;
+ return false;
+ }
+
+ return true;
+}
+
+
+QGeoPositionInfoSource::PositioningMethods DBusComm::availableMethods() const
+{
+ return availablePositioningMethods;
+}
+
+
+int DBusComm::minimumInterval() const
+{
+ return minimumUpdateInterval;
+}
+
+
+bool DBusComm::sendConfigRequest(Command command, QGeoPositionInfoSource::PositioningMethods method,
+ int interval) const
+{
+ QDBusReply<int> reply;
+ reply = positioningdProxy->call("configSession", clientId, command, int(method), interval);
+
+ //cout << "sessionConfigRequest cmd: cmd:" << command << " method: ";
+ //cout << method << " interval: " << interval << "\n";
+
+ if (reply.isValid()) {
+ int n = reply.value();
+ } else {
+ cerr << endl << "DBus error:\n";
+ cerr << reply.error().name().toAscii().constData() << endl;
+ cerr << reply.error().message().toAscii().constData() << endl;
+ return false;
+ }
+
+ return true;
+}
+
+
+QGeoPositionInfo& DBusComm::requestLastKnownPosition(bool satelliteMethodOnly)
+{
+ QDBusReply<QByteArray> reply;
+ reply = positioningdProxy->call("latestPosition", satelliteMethodOnly);
+ static QGeoPositionInfo update;
+
+ if (reply.isValid()) {
+ // cout << "requestLastKnownPosition(): received update\n";
+ QByteArray message = reply.value();
+ QDataStream stream(message);
+ stream >> update;
+ } else {
+ cerr << endl << "DBus error:\n";
+ cerr << reply.error().name().toAscii().constData() << endl;
+ cerr << reply.error().message().toAscii().constData() << endl;
+ update = QGeoPositionInfo();
+ }
+
+ return update;
+}
+
+
+bool DBusComm::createUniqueName()
+{
+ QFile uuidfile("/proc/sys/kernel/random/uuid");
+ if (!uuidfile.open(QIODevice::ReadOnly)) {
+ cerr << "UUID file failed.";
+ return false;
+ }
+
+ QTextStream in(&uuidfile);
+ QString uuid = 'I' + in.readLine();
+ uuid.replace('-', 'I');
+ myService = "com.nokia.qlocation." + uuid;
+ myPath = "/com/nokia/qlocation/" + uuid;
+
+ return true;
+}
+
+#include "moc_dbuscomm_maemo_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/dbuscomm_maemo_p.h b/src/location/dbuscomm_maemo_p.h
new file mode 100644
index 00000000..e37b6ecf
--- /dev/null
+++ b/src/location/dbuscomm_maemo_p.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DBUSCOMM_MAEMO_H
+#define DBUSCOMM_MAEMO_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QObject>
+#include <QtCore/QTimer>
+#include <QtDBus/QtDBus>
+
+#include "qgeopositioninfo.h"
+#include "qgeosatelliteinfo.h"
+#include "qgeopositioninfosource.h"
+#include "qgeosatelliteinfosource.h"
+#include "dbusserver_maemo_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class DBusComm: public QObject, DBusServerIF
+{
+ Q_OBJECT
+
+
+public:
+ enum Command {CommandStart = 1, CommandStop = 2, CommandOneShot = 3,
+ CommandSetMethods = 4, CommandSetInterval = 8,
+ CommandSatStart = 16, CommandSatStop = 32, CommandSatOneShot = 48};
+
+ DBusComm(QObject *parent = 0);
+ int init();
+ bool sendDBusRegister();
+ bool sendConfigRequest(Command command, QGeoPositionInfoSource::PositioningMethods method,
+ int interval) const;
+ QGeoPositionInfo& requestLastKnownPosition(bool satelliteMethodOnly);
+ QGeoPositionInfoSource::PositioningMethods availableMethods() const;
+ int minimumInterval() const;
+
+Q_SIGNALS:
+ void receivedPositionUpdate(const QGeoPositionInfo &update);
+ void receivedSatellitesInView(const QList<QGeoSatelliteInfo> &update);
+ void receivedSatellitesInUse(const QList<QGeoSatelliteInfo> &update);
+
+ void serviceDisconnected();
+ void serviceConnected();
+
+private:
+ static const QString positioningdService;
+ static const QString positioningdPath;
+ static const QString positioningdInterface;
+
+ // from DBusServerIF
+ void receivePositionUpdate(const QGeoPositionInfo &update);
+ void receiveSatellitesInView(const QList<QGeoSatelliteInfo> &info);
+ void receiveSatellitesInUse(const QList<QGeoSatelliteInfo> &info);
+ void receiveSettings(QGeoPositionInfoSource::PositioningMethod methods, qint32 interval);
+
+ QDBusInterface *positioningdProxy;
+ DBusServer* dbusServer;
+ QObject serverObj;
+ QString myService;
+ QString myPath;
+ int clientId;
+ int minimumUpdateInterval;
+ QGeoPositionInfoSource::PositioningMethods availablePositioningMethods;
+ QDBusServiceWatcher *serviceDisconnectWatcher;
+ QDBusServiceWatcher *serviceConnectWatcher;
+ bool createUniqueName();
+
+ Q_DISABLE_COPY(DBusComm)
+
+private Q_SLOTS:
+ void onServiceDisconnect(const QString &name);
+ void onServiceConnect(const QString &name);
+
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/dbusserver_maemo.cpp b/src/location/dbusserver_maemo.cpp
new file mode 100644
index 00000000..2f533a75
--- /dev/null
+++ b/src/location/dbusserver_maemo.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dbusserver_maemo_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+DBusServer::DBusServer(QObject *obj, DBusServerIF *iface) : QDBusAbstractAdaptor(obj),
+ interface(iface)
+{
+}
+
+
+Q_NOREPLY void DBusServer::positionUpdate(const QByteArray &message)
+{
+ static QGeoPositionInfo update;
+ QDataStream stream(message);
+ stream >> update;
+
+ interface->receivePositionUpdate(update);
+}
+
+
+Q_NOREPLY void DBusServer::currentSettings(quint32 methods, quint32 interval)
+{
+ QGeoPositionInfoSource::PositioningMethod m = (QGeoPositionInfoSource::PositioningMethod) methods;
+ interface->receiveSettings(m, interval);
+}
+
+
+Q_NOREPLY void DBusServer::satellitesInViewUpdate(const QByteArray &message)
+{
+ static QList<QGeoSatelliteInfo> update;
+ QDataStream stream(message);
+ stream >> update;
+
+ interface->receiveSatellitesInView(update);
+}
+
+
+Q_NOREPLY void DBusServer::satellitesInUseUpdate(const QByteArray &message)
+{
+ static QList<QGeoSatelliteInfo> update;
+ QDataStream stream(message);
+ stream >> update;
+
+ interface->receiveSatellitesInUse(update);
+}
+
+#include "moc_dbusserver_maemo_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/dbusserver_maemo_p.h b/src/location/dbusserver_maemo_p.h
new file mode 100644
index 00000000..55764617
--- /dev/null
+++ b/src/location/dbusserver_maemo_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DBUSSERVER_MAEMO_H
+#define DBUSSERVER_MAEMO_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDBus/QDBusAbstractAdaptor>
+#include "qgeopositioninfo.h"
+#include "qgeopositioninfosource.h"
+#include "qgeosatelliteinfo.h"
+
+QTM_BEGIN_NAMESPACE
+
+class DBusServerIF {
+public:
+ virtual void receivePositionUpdate(const QGeoPositionInfo &update) = 0;
+ virtual void receiveSettings(QGeoPositionInfoSource::PositioningMethod methods, qint32 interval) = 0;
+ virtual void receiveSatellitesInView(const QList<QGeoSatelliteInfo> &update) = 0;
+ virtual void receiveSatellitesInUse(const QList<QGeoSatelliteInfo> &update) = 0;
+};
+
+
+class DBusServer: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.nokia.qlocation.updates")
+
+public:
+ DBusServer(QObject *obj, DBusServerIF *interface);
+
+public Q_SLOTS:
+ Q_NOREPLY void positionUpdate(const QByteArray &update);
+ Q_NOREPLY void satellitesInViewUpdate(const QByteArray &update);
+ Q_NOREPLY void satellitesInUseUpdate(const QByteArray &update);
+ Q_NOREPLY void currentSettings(quint32 methods, quint32 interval);
+
+private:
+ Q_DISABLE_COPY(DBusServer)
+ DBusServerIF *interface;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/gconfitem.cpp b/src/location/gconfitem.cpp
new file mode 100644
index 00000000..cb9d938a
--- /dev/null
+++ b/src/location/gconfitem.cpp
@@ -0,0 +1,364 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QString>
+#include <QStringList>
+#include <QByteArray>
+#include <QVariant>
+#include <QtDebug>
+
+#include "gconfitem_p.h"
+
+#include <glib.h>
+#include <gconf/gconf-value.h>
+#include <gconf/gconf-client.h>
+
+struct GConfItemPrivate {
+ QString key;
+ QVariant value;
+ guint notify_id;
+
+ static void notify_trampoline(GConfClient*, guint, GConfEntry *, gpointer);
+};
+
+#define withClient(c) for(GConfClient *c = (g_type_init(), gconf_client_get_default()); c; g_object_unref(c), c=NULL)
+
+static QByteArray convertKey(QString key)
+{
+ if (key.startsWith('/'))
+ return key.toUtf8();
+ else {
+ qWarning() << "Using dot-separated key names with GConfItem is deprecated.";
+ qWarning() << "Please use" << '/' + key.replace('.', '/') << "instead of" << key;
+ return '/' + key.replace('.', '/').toUtf8();
+ }
+}
+
+static QString convertKey(const char *key)
+{
+ return QString::fromUtf8(key);
+}
+
+static QVariant convertValue(GConfValue *src)
+{
+ if (!src) {
+ return QVariant();
+ } else {
+ switch (src->type) {
+ case GCONF_VALUE_INVALID:
+ return QVariant(QVariant::Invalid);
+ case GCONF_VALUE_BOOL:
+ return QVariant((bool)gconf_value_get_bool(src));
+ case GCONF_VALUE_INT:
+ return QVariant(gconf_value_get_int(src));
+ case GCONF_VALUE_FLOAT:
+ return QVariant(gconf_value_get_float(src));
+ case GCONF_VALUE_STRING:
+ return QVariant(QString::fromUtf8(gconf_value_get_string(src)));
+ case GCONF_VALUE_LIST:
+ switch (gconf_value_get_list_type(src)) {
+ case GCONF_VALUE_STRING: {
+ QStringList result;
+ for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
+ result.append(QString::fromUtf8(gconf_value_get_string((GConfValue *)elts->data)));
+ return QVariant(result);
+ }
+ default: {
+ QList<QVariant> result;
+ for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
+ result.append(convertValue((GConfValue *)elts->data));
+ return QVariant(result);
+ }
+ }
+ case GCONF_VALUE_SCHEMA:
+ default:
+ return QVariant();
+ }
+ }
+}
+
+static GConfValue *convertString(const QString &str)
+{
+ GConfValue *v = gconf_value_new(GCONF_VALUE_STRING);
+ gconf_value_set_string(v, str.toUtf8().data());
+ return v;
+}
+
+static GConfValueType primitiveType(const QVariant &elt)
+{
+ switch (elt.type()) {
+ case QVariant::String:
+ return GCONF_VALUE_STRING;
+ case QVariant::Int:
+ return GCONF_VALUE_INT;
+ case QVariant::Double:
+ return GCONF_VALUE_FLOAT;
+ case QVariant::Bool:
+ return GCONF_VALUE_BOOL;
+ default:
+ return GCONF_VALUE_INVALID;
+ }
+}
+
+static GConfValueType uniformType(const QList<QVariant> &list)
+{
+ GConfValueType result = GCONF_VALUE_INVALID;
+
+ foreach(const QVariant &elt, list) {
+ GConfValueType elt_type = primitiveType(elt);
+
+ if (elt_type == GCONF_VALUE_INVALID)
+ return GCONF_VALUE_INVALID;
+
+ if (result == GCONF_VALUE_INVALID)
+ result = elt_type;
+ else if (result != elt_type)
+ return GCONF_VALUE_INVALID;
+ }
+
+ if (result == GCONF_VALUE_INVALID)
+ return GCONF_VALUE_STRING; // empty list.
+ else
+ return result;
+}
+
+static int convertValue(const QVariant &src, GConfValue **valp)
+{
+ GConfValue *v;
+
+ switch (src.type()) {
+ case QVariant::Invalid:
+ v = NULL;
+ break;
+ case QVariant::Bool:
+ v = gconf_value_new(GCONF_VALUE_BOOL);
+ gconf_value_set_bool(v, src.toBool());
+ break;
+ case QVariant::Int:
+ v = gconf_value_new(GCONF_VALUE_INT);
+ gconf_value_set_int(v, src.toInt());
+ break;
+ case QVariant::Double:
+ v = gconf_value_new(GCONF_VALUE_FLOAT);
+ gconf_value_set_float(v, src.toDouble());
+ break;
+ case QVariant::String:
+ v = convertString(src.toString());
+ break;
+ case QVariant::StringList: {
+ GSList *elts = NULL;
+ v = gconf_value_new(GCONF_VALUE_LIST);
+ gconf_value_set_list_type(v, GCONF_VALUE_STRING);
+ foreach(const QString &str, src.toStringList())
+ elts = g_slist_prepend(elts, convertString(str));
+ gconf_value_set_list_nocopy(v, g_slist_reverse(elts));
+ break;
+ }
+ case QVariant::List: {
+ GConfValueType elt_type = uniformType(src.toList());
+ if (elt_type == GCONF_VALUE_INVALID)
+ v = NULL;
+ else {
+ GSList *elts = NULL;
+ v = gconf_value_new(GCONF_VALUE_LIST);
+ gconf_value_set_list_type(v, elt_type);
+ foreach(const QVariant &elt, src.toList()) {
+ GConfValue *val = NULL;
+ convertValue(elt, &val); // guaranteed to succeed.
+ elts = g_slist_prepend(elts, val);
+ }
+ gconf_value_set_list_nocopy(v, g_slist_reverse(elts));
+ }
+ break;
+ }
+ default:
+ return 0;
+ }
+
+ *valp = v;
+ return 1;
+}
+
+void GConfItemPrivate::notify_trampoline(GConfClient*,
+ guint,
+ GConfEntry *,
+ gpointer data)
+{
+ GConfItem *item = (GConfItem *)data;
+ item->update_value(true);
+}
+
+void GConfItem::update_value(bool emit_signal)
+{
+ QVariant new_value;
+
+ withClient(client) {
+ GError *error = NULL;
+ QByteArray k = convertKey(priv->key);
+ GConfValue *v = gconf_client_get(client, k.data(), &error);
+
+ if (error) {
+ qWarning() << error->message;
+ g_error_free(error);
+ new_value = priv->value;
+ } else {
+ new_value = convertValue(v);
+ if (v)
+ gconf_value_free(v);
+ }
+ }
+
+ if (new_value != priv->value) {
+ priv->value = new_value;
+ if (emit_signal)
+ emit valueChanged();
+ }
+}
+
+QString GConfItem::key() const
+{
+ return priv->key;
+}
+
+QVariant GConfItem::value() const
+{
+ return priv->value;
+}
+
+QVariant GConfItem::value(const QVariant &def) const
+{
+ if (priv->value.isNull())
+ return def;
+ else
+ return priv->value;
+}
+
+void GConfItem::set(const QVariant &val)
+{
+ withClient(client) {
+ QByteArray k = convertKey(priv->key);
+ GConfValue *v;
+ if (convertValue(val, &v)) {
+ GError *error = NULL;
+
+ if (v) {
+ gconf_client_set(client, k.data(), v, &error);
+ gconf_value_free(v);
+ } else {
+ gconf_client_unset(client, k.data(), &error);
+ }
+
+ if (error) {
+ qWarning() << error->message;
+ g_error_free(error);
+ } else if (priv->value != val) {
+ priv->value = val;
+ emit valueChanged();
+ }
+
+ } else
+ qWarning() << "Can't store a" << val.typeName();
+ }
+}
+
+void GConfItem::unset()
+{
+ set(QVariant());
+}
+
+QList<QString> GConfItem::listDirs() const
+{
+ QList<QString> children;
+
+ withClient(client) {
+ QByteArray k = convertKey(priv->key);
+ GSList *dirs = gconf_client_all_dirs(client, k.data(), NULL);
+ for (GSList *d = dirs; d; d = d->next) {
+ children.append(convertKey((char *)d->data));
+ g_free(d->data);
+ }
+ g_slist_free(dirs);
+ }
+
+ return children;
+}
+
+QList<QString> GConfItem::listEntries() const
+{
+ QList<QString> children;
+
+ withClient(client) {
+ QByteArray k = convertKey(priv->key);
+ GSList *entries = gconf_client_all_entries(client, k.data(), NULL);
+ for (GSList *e = entries; e; e = e->next) {
+ children.append(convertKey(((GConfEntry *)e->data)->key));
+ gconf_entry_free((GConfEntry *)e->data);
+ }
+ g_slist_free(entries);
+ }
+
+ return children;
+}
+
+GConfItem::GConfItem(const QString &key, QObject *parent)
+ : QObject(parent)
+{
+ priv = new GConfItemPrivate;
+ priv->key = key;
+ withClient(client) {
+ update_value(false);
+ QByteArray k = convertKey(priv->key);
+ gconf_client_add_dir(client, k.data(), GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ priv->notify_id = gconf_client_notify_add(client, k.data(),
+ GConfItemPrivate::notify_trampoline, this,
+ NULL, NULL);
+ }
+}
+
+GConfItem::~GConfItem()
+{
+ withClient(client) {
+ QByteArray k = convertKey(priv->key);
+ gconf_client_notify_remove(client, priv->notify_id);
+ gconf_client_remove_dir(client, k.data(), NULL);
+ }
+ delete priv;
+}
diff --git a/src/location/gconfitem_p.h b/src/location/gconfitem_p.h
new file mode 100644
index 00000000..9a33cef6
--- /dev/null
+++ b/src/location/gconfitem_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GCONFITEM_H
+#define GCONFITEM_H
+
+#include <QVariant>
+#include <QStringList>
+#include <QObject>
+
+/*!
+
+ \brief GConfItem is a simple C++ wrapper for GConf.
+
+ Creating a GConfItem instance gives you access to a single GConf
+ key. You can get and set its value, and connect to its
+ valueChanged() signal to be notified about changes.
+
+ The value of a GConf key is returned to you as a QVariant, and you
+ pass in a QVariant when setting the value. GConfItem converts
+ between a QVariant and GConf values as needed, and according to the
+ following rules:
+
+ - A QVariant of type QVariant::Invalid denotes an unset GConf key.
+
+ - QVariant::Int, QVariant::Double, QVariant::Bool are converted to
+ and from the obvious equivalents.
+
+ - QVariant::String is converted to/from a GConf string and always
+ uses the UTF-8 encoding. No other encoding is supported.
+
+ - QVariant::StringList is converted to a list of UTF-8 strings.
+
+ - QVariant::List (which denotes a QList<QVariant>) is converted
+ to/from a GConf list. All elements of such a list must have the
+ same type, and that type must be one of QVariant::Int,
+ QVariant::Double, QVariant::Bool, or QVariant::String. (A list of
+ strings is returned as a QVariant::StringList, however, when you
+ get it back.)
+
+ - Any other QVariant or GConf value is essentially ignored.
+
+ \warning GConfItem is as thread-safe as GConf.
+
+*/
+
+class GConfItem : public QObject
+{
+ Q_OBJECT
+
+public:
+ /*! Initializes a GConfItem to access the GConf key denoted by
+ \a key. Key names should follow the normal GConf conventions
+ like "/myapp/settings/first".
+
+ \param key The name of the key.
+ \param parent Parent object
+ */
+ explicit GConfItem(const QString &key, QObject *parent = 0);
+
+ /*! Finalizes a GConfItem.
+ */
+ virtual ~GConfItem();
+
+ /*! Returns the key of this item, as given to the constructor.
+ */
+ QString key() const;
+
+ /*! Returns the current value of this item, as a QVariant.
+ */
+ QVariant value() const;
+
+ /*! Returns the current value of this item, as a QVariant. If
+ * there is no value for this item, return \a def instead.
+ */
+ QVariant value(const QVariant &def) const;
+
+ /*! Set the value of this item to \a val. If \a val can not be
+ represented in GConf or GConf refuses to accept it for other
+ reasons, the current value is not changed and nothing happens.
+
+ When the new value is different from the old value, the
+ changedValue() signal is emitted on this GConfItem as part
+ of calling set(), but other GConfItem:s for the same key do
+ only receive a notification once the main loop runs.
+
+ \param val The new value.
+ */
+ void set(const QVariant &val);
+
+ /*! Unset this item. This is equivalent to
+
+ \code
+ item.set(QVariant(QVariant::Invalid));
+ \endcode
+ */
+ void unset();
+
+ /*! Return a list of the directories below this item. The
+ returned strings are absolute key names like
+ "/myapp/settings".
+
+ A directory is a key that has children. The same key might
+ also have a value, but that is confusing and best avoided.
+ */
+ QList<QString> listDirs() const;
+
+ /*! Return a list of entries below this item. The returned
+ strings are absolute key names like "/myapp/settings/first".
+
+ A entry is a key that has a value. The same key might also
+ have children, but that is confusing and is best avoided.
+ */
+ QList<QString> listEntries() const;
+
+signals:
+ /*! Emitted when the value of this item has changed.
+ */
+ void valueChanged();
+
+private:
+ friend struct GConfItemPrivate;
+ struct GConfItemPrivate *priv;
+
+ void update_value(bool emit_signal);
+};
+
+#endif // GCONFITEM_H
diff --git a/src/location/landmarks/landmarks.pri b/src/location/landmarks/landmarks.pri
new file mode 100644
index 00000000..061cdc51
--- /dev/null
+++ b/src/location/landmarks/landmarks.pri
@@ -0,0 +1,88 @@
+
+INCLUDEPATH += landmarks
+
+PUBLIC_HEADERS += \
+ landmarks/qlandmark.h \
+ landmarks/qlandmarkabstractrequest.h \
+ landmarks/qlandmarkattributefilter.h \
+ landmarks/qlandmarkboxfilter.h \
+ landmarks/qlandmarkcategory.h \
+ landmarks/qlandmarkcategoryfetchrequest.h \
+ landmarks/qlandmarkcategoryfetchbyidrequest.h \
+ landmarks/qlandmarkcategoryfilter.h \
+ landmarks/qlandmarkcategoryid.h \
+ landmarks/qlandmarkcategoryidfetchrequest.h \
+ landmarks/qlandmarkcategoryremoverequest.h \
+ landmarks/qlandmarkcategorysaverequest.h \
+ landmarks/qlandmarkexportrequest.h \
+ landmarks/qlandmarkfetchrequest.h \
+ landmarks/qlandmarkfetchbyidrequest.h \
+ landmarks/qlandmarkfilter.h \
+ landmarks/qlandmarkid.h \
+ landmarks/qlandmarkidfetchrequest.h \
+ landmarks/qlandmarkidfilter.h \
+ landmarks/qlandmarkimportrequest.h \
+ landmarks/qlandmarkintersectionfilter.h \
+ landmarks/qlandmarkmanager.h \
+ landmarks/qlandmarkmanagerengine.h \
+ landmarks/qlandmarkmanagerenginefactory.h \
+ landmarks/qlandmarknamefilter.h \
+ landmarks/qlandmarknamesort.h \
+ landmarks/qlandmarkproximityfilter.h \
+ landmarks/qlandmarkremoverequest.h \
+ landmarks/qlandmarksaverequest.h \
+ landmarks/qlandmarksortorder.h \
+ landmarks/qlandmarkunionfilter.h
+
+PRIVATE_HEADERS += \
+ landmarks/qlandmark_p.h \
+ landmarks/qlandmarkabstractrequest_p.h \
+ landmarks/qlandmarkboxfilter_p.h \
+ landmarks/qlandmarkcategory_p.h \
+ landmarks/qlandmarkcategoryfilter_p.h \
+ landmarks/qlandmarkcategoryid_p.h \
+ landmarks/qlandmarkfilter_p.h \
+ landmarks/qlandmarkid_p.h \
+ landmarks/qlandmarkidfilter_p.h \
+ landmarks/qlandmarkintersectionfilter_p.h \
+ landmarks/qlandmarkmanager_p.h \
+ landmarks/qlandmarknamefilter_p.h \
+ landmarks/qlandmarkproximityfilter_p.h \
+ landmarks/qlandmarkrequests_p.h \
+ landmarks/qlandmarksortorder_p.h \
+ landmarks/qlandmarkunionfilter_p.h
+
+SOURCES += \
+ landmarks/qlandmark.cpp \
+ landmarks/qlandmarkabstractrequest.cpp \
+ landmarks/qlandmarkattributefilter.cpp \
+ landmarks/qlandmarkboxfilter.cpp \
+ landmarks/qlandmarkcategory.cpp \
+ landmarks/qlandmarkcategoryfetchrequest.cpp \
+ landmarks/qlandmarkcategoryfetchbyidrequest.cpp \
+ landmarks/qlandmarkcategoryfilter.cpp \
+ landmarks/qlandmarkcategoryid.cpp \
+ landmarks/qlandmarkcategoryidfetchrequest.cpp \
+ landmarks/qlandmarkcategoryremoverequest.cpp \
+ landmarks/qlandmarkcategorysaverequest.cpp \
+ landmarks/qlandmarkexportrequest.cpp \
+ landmarks/qlandmarkfetchrequest.cpp \
+ landmarks/qlandmarkfetchbyidrequest.cpp \
+ landmarks/qlandmarkfilter.cpp \
+ landmarks/qlandmarkid.cpp \
+ landmarks/qlandmarkidfetchrequest.cpp \
+ landmarks/qlandmarkidfilter.cpp \
+ landmarks/qlandmarkimportrequest.cpp \
+ landmarks/qlandmarkintersectionfilter.cpp \
+ landmarks/qlandmarkmanager.cpp \
+ landmarks/qlandmarkmanager_p.cpp \
+ landmarks/qlandmarkmanagerengine.cpp \
+ landmarks/qlandmarkmanagerenginefactory.cpp \
+ landmarks/qlandmarknamefilter.cpp \
+ landmarks/qlandmarknamesort.cpp \
+ landmarks/qlandmarkproximityfilter.cpp \
+ landmarks/qlandmarkremoverequest.cpp \
+ landmarks/qlandmarksaverequest.cpp \
+ landmarks/qlandmarksortorder.cpp \
+ landmarks/qlandmarkunionfilter.cpp
+
diff --git a/src/location/landmarks/qlandmark.cpp b/src/location/landmarks/qlandmark.cpp
new file mode 100644
index 00000000..ff503ea1
--- /dev/null
+++ b/src/location/landmarks/qlandmark.cpp
@@ -0,0 +1,500 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmark.h"
+#include "qlandmark_p.h"
+
+#include "qlandmarkcategory_p.h"
+#include "qlandmarkcategoryid.h"
+#include "qlandmarkid.h"
+#include "qlandmarkid_p.h"
+
+#include "qgeoaddress.h"
+#include "qgeocoordinate.h"
+
+#include "qgeoplace.h"
+#include "qgeoplace_p.h"
+
+#include <QVariant>
+#include <QStringList>
+#include <QSet>
+#include <qnumeric.h>
+
+#ifdef LANDMARKPRIVATE_DEBUG
+#include <QDebug>
+#endif
+
+QTM_BEGIN_NAMESPACE
+uint qHash(const QLandmarkCategoryId& key) {
+ return qHash(key.localId()) + qHash(key.managerUri());
+}
+QTM_END_NAMESPACE
+
+QTM_USE_NAMESPACE
+
+// ----- QLandmarkPrivate -----
+
+QLandmarkPrivate::QLandmarkPrivate()
+ : QGeoPlacePrivate()
+{
+ type = QGeoPlacePrivate::LandmarkType;
+ radius = 0.0;
+}
+
+QLandmarkPrivate::QLandmarkPrivate(const QGeoPlacePrivate &other)
+ : QGeoPlacePrivate(other)
+{
+ type = QGeoPlacePrivate::LandmarkType;
+ radius = 0.0;
+}
+
+QLandmarkPrivate::QLandmarkPrivate(const QLandmarkPrivate &other)
+ : QGeoPlacePrivate(other),
+ name(other.name),
+ categoryIds(other.categoryIds),
+ description(other.description),
+ iconUrl(other.iconUrl),
+ radius(other.radius),
+ phoneNumber(other.phoneNumber),
+ url(other.url),
+ id(other.id)
+{
+}
+
+QLandmarkPrivate::~QLandmarkPrivate() {}
+
+QLandmarkPrivate& QLandmarkPrivate::operator= (const QLandmarkPrivate & other)
+{
+ QGeoPlacePrivate::operator =(other);
+ name = other.name;
+ description = other.description;
+ iconUrl = other.iconUrl;
+ radius = other.radius;
+ phoneNumber = other.phoneNumber;
+ url = other.url;
+ categoryIds = other.categoryIds;
+ id = other.id;
+
+ return *this;
+}
+
+bool QLandmarkPrivate::operator== (const QLandmarkPrivate &other) const
+{
+ bool radiusIsMatch = false;
+ if (qIsNaN(radius) && qIsNaN(other.radius))
+ radiusIsMatch = true;
+ else if (qFuzzyCompare(1 +radius, 1 + other.radius))
+ radiusIsMatch = true;
+ else
+ radiusIsMatch = false;
+
+#ifdef LANDMARKPRIVATE_DEBUG
+ qDebug() << "==" << (QGeoPlacePrivate::operator== (other));
+ qDebug() << "name:" << (name == other.name);
+ qDebug() << "description:" << (description == other.description);
+ qDebug() << "iconUrl:" << (iconUrl == other.iconUrl);
+ qDebug() << "radius:" << radiusIsMatch;
+ qDebug() << "phoneNumber:" << (phoneNumber == other.phoneNumber);
+ qDebug() << "url:" << (url == other.url);
+ qDebug() << "categoryIds:" << (categoryIds.toSet() == other.categoryIds.toSet());
+ qDebug() << "id" << (id == other.id);
+#endif
+
+ return (QGeoPlacePrivate::operator== (other)
+ && (name == other.name)
+ && (description == other.description)
+ && (iconUrl == other.iconUrl)
+ && radiusIsMatch
+ && (phoneNumber == other.phoneNumber)
+ && (url == other.url)
+ && (categoryIds.toSet() == other.categoryIds.toSet())
+ && (id == other.id));
+}
+
+/*!
+ \class QLandmark
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-main
+ \since 1.1
+
+ \brief The QLandmark class represents a point of interest.
+
+
+ Each QLandmark represents a location with a number of attributes or properties
+ such as name, description, phone number etc. Each QLandmark may also be associated with zero or more categories.
+ A category defines a type of landmark such as restaurant or
+ cinema. To set the category that a landmark belongs to, use
+ the setCategoryIds() or addCategoryId() functions. A landmark may
+ be removed from a category by using the removeCategoryId() function.
+
+ Some landmarks may be designated as read-only, e.g. a publically accessible
+ landmark server may not want some of its content to be editable.
+ Note, localization is only possible for landmarks that are read-only.
+
+ Each QLandmark is an in memory representation of a landmark;
+ it does not reflect the actual landmark state in persistent
+ storage until the appropriate synchronization method is called
+ on the QLandmarkManager(e.g. \l {QLandmarkManager::saveLandmark()} {saveLandmark()},
+ \l {QLandmarkManager::removeLandmark()} {removeLandmark()}).
+
+ Note that QLandmark inherits from QGeoPlace and thus has a viewport data field.
+ Most managers usually however ignore this field when saving the landmark.
+*/
+
+/*!
+ Constructs an new landmark.
+
+ A new landmark will be assigned with invalid QLandmarkId.
+*/
+QLandmark::QLandmark()
+ : QGeoPlace(new QLandmarkPrivate)
+{
+}
+
+/*!
+ Constructs a new landmark from \a other.
+
+ If \a other is not a landmark, the coordinates, address and viewport
+ get copied into the newly created landmark.
+
+ If \a other is a landmark, this function is equivalent to calling
+ QLandmark(const QLandmark &other).
+
+ This constructor allows (1) and c to take place.
+ /code
+ QGeoPlace geoPlace = lm1; //lm1 is a QLandmark
+ ...
+ QLandmark lm2 = geoPlace; //(1)lm2 is equivalent to lm1
+
+ QGeoPlace ordinaryPlace;
+ QLandmark lm3 = ordinarPlace; //(2)lm3 has the details of ordinaryPlace's coordinate, address and viewport.
+ /endcode
+*/
+QLandmark::QLandmark(const QGeoPlace &other)
+ : QGeoPlace(other)
+{
+ switch (other.d_ptr->type) {
+ case QGeoPlacePrivate::GeoPlaceType:
+ d_ptr = new QLandmarkPrivate(*(other.d_ptr.constData()));
+ break;
+ case QGeoPlacePrivate::LandmarkType:
+ // nothing extra to do here
+ break;
+ default:
+ d_ptr = new QLandmarkPrivate();
+ break;
+ }
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmark::QLandmark(const QLandmark &other)
+ : QGeoPlace(other)
+{
+}
+
+/*!
+ Destroys the landmark.
+*/
+QLandmark::~QLandmark()
+{
+}
+
+/*!
+ Assigns \a other to this landmark and returns a reference to this landmark.
+*/
+QLandmark &QLandmark::operator= (const QLandmark & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+inline QLandmarkPrivate* QLandmark::d_func()
+{
+ return reinterpret_cast<QLandmarkPrivate*>(d_ptr.data());
+}
+
+inline const QLandmarkPrivate* QLandmark::d_func() const
+{
+ return reinterpret_cast<const QLandmarkPrivate*>(d_ptr.constData());
+}
+
+/*!
+ Returns true if this landmark is equal to \a other, otherwise
+ returns false.
+
+ Two landmarks are considered equal if both the landmark details
+ and identifiers are equal.
+
+ \sa operator!=()
+*/
+bool QLandmark::operator== (const QLandmark &other) const
+{
+ Q_D(const QLandmark);
+ return *d == *(other.d_func());
+}
+
+/*!
+ \fn bool QLandmark::operator!= (const QLandmark &other) const
+
+ Returns true if this landmark not is equal to \a other, otherwise
+ returns false.
+
+ \sa operator==()
+*/
+
+/*!
+ Returns the name of the landmark.
+*/
+QString QLandmark::name() const
+{
+ Q_D(const QLandmark);
+ return d->name;
+}
+
+/*!
+ Sets the \a name of the landmark.
+
+ Using the default manager on the Symbian platform, the name is restricted to a length of 256 characters.
+*/
+void QLandmark::setName(const QString &name)
+{
+ Q_D(QLandmark);
+ d->name = name;
+}
+
+/*!
+ Returns a of list identifiers of categories that this landmark
+ belongs to.
+
+ \sa setCategoryIds()
+*/
+QList<QLandmarkCategoryId> QLandmark::categoryIds() const
+{
+ Q_D(const QLandmark);
+ return d->categoryIds;
+}
+
+/*!
+ Sets the categories that this landmark belongs to via
+ a list of \a categoryIds.
+
+ \sa addCategoryId(), removeCategoryId()
+
+*/
+void QLandmark::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds)
+{
+ Q_D(QLandmark);
+ d->categoryIds.clear();
+
+ // remove duplicates
+ for (int i = 0; i < categoryIds.size(); ++i) {
+ if (!d->categoryIds.contains(categoryIds.at(i)))
+ d->categoryIds.append(categoryIds.at(i));
+ }
+}
+
+/*!
+ Adds another category that this landmark will be associated
+ with via its \a categoryId.
+
+ \sa setCategoryIds(), removeCategoryId()
+*/
+void QLandmark::addCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmark);
+ if (!d->categoryIds.contains(categoryId))
+ d->categoryIds.append(categoryId);
+}
+
+/*!
+ Removes a category from a landmark, by using its \a categoryId.
+
+ \sa addCategoryId(), categoryIds()
+*/
+void QLandmark::removeCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmark);
+ d->categoryIds.removeAll(categoryId);
+}
+
+/*!
+ Returns a description of the landmark.
+*/
+QString QLandmark::description() const
+{
+ Q_D(const QLandmark);
+ return d->description;
+}
+
+/*!
+ Sets the \a description of the landmark.
+
+ Using the default manager on the Symbian platform, the description is restricted to a length of 4096 characters.
+*/
+void QLandmark::setDescription(const QString &description)
+{
+ Q_D(QLandmark);
+ d->description = description;
+}
+
+/*!
+ Returns the url of the landmark's icon.
+*/
+QUrl QLandmark::iconUrl() const
+{
+ Q_D(const QLandmark);
+ return d->iconUrl;
+}
+
+/*!
+ Sets the \a url of the landmark's icon.
+*/
+void QLandmark::setIconUrl(const QUrl &url)
+{
+ Q_D(QLandmark);
+ d->iconUrl = url;
+}
+
+/*!
+ Returns the coverage radius of the landmark. The unit of the radius is meters.
+
+ The coverage radius is relevant for large landmarks
+ such as cities. Note that landmark searches over a given area
+ do not factor in the coverage radius.
+*/
+qreal QLandmark::radius() const
+{
+ Q_D(const QLandmark);
+ return d->radius;
+}
+
+/*!
+ Sets the coverage \a radius of the landmark. The unit of the \a radius
+ is meters.
+*/
+void QLandmark::setRadius(qreal radius)
+{
+ Q_D(QLandmark);
+ if (!qIsNaN(radius) && radius >= 0.0)
+ d->radius = radius;
+ else
+ d->radius = 0.0;
+}
+
+/*!
+ Returns the phone number of the landmark.
+*/
+QString QLandmark::phoneNumber() const
+{
+ Q_D(const QLandmark);
+ return d->phoneNumber;
+}
+
+/*!
+ Sets the \a phoneNumber of the landmark.
+*/
+void QLandmark::setPhoneNumber(const QString &phoneNumber)
+{
+ Q_D(QLandmark);
+ d->phoneNumber = phoneNumber;
+}
+/*!
+ Returns the url of the landmark.
+*/
+QUrl QLandmark::url() const
+{
+ Q_D(const QLandmark);
+ return d->url;
+}
+
+/*!
+ Sets the \a url of the landmark.
+*/
+void QLandmark::setUrl(const QUrl &url)
+{
+ Q_D(QLandmark);
+ d->url = url;
+}
+
+/*!
+ Returns the identifier of the landmark.
+*/
+QLandmarkId QLandmark::landmarkId() const
+{
+ Q_D(const QLandmark);
+ return d->id;
+}
+
+/*!
+ Sets the \a id of the landmark.
+
+ Note that saving a new landmark using a QLandmarkManager
+ will automatically assign the landmark a valid identifier.
+*/
+void QLandmark::setLandmarkId(const QLandmarkId &id)
+{
+ Q_D(QLandmark);
+ d->id = id;
+}
+
+/*!
+ Clears all the data fields of the landmark.
+*/
+void QLandmark::clear()
+{
+ Q_D(QLandmark);
+ d->address.clear();
+ d->coordinate = QGeoCoordinate();
+ d->viewport = QGeoBoundingBox();
+ d->name.clear();
+ d->categoryIds.clear();
+ d->description.clear();
+ d->iconUrl.clear();
+ d->radius = 0.0;
+ d->phoneNumber.clear();
+ d->url.clear();
+ d->id = QLandmarkId();
+}
+
diff --git a/src/location/landmarks/qlandmark.h b/src/location/landmarks/qlandmark.h
new file mode 100644
index 00000000..a66898e9
--- /dev/null
+++ b/src/location/landmarks/qlandmark.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARK_H
+#define QLANDMARK_H
+
+#include "qmobilityglobal.h"
+
+#include <QObject>
+#include <QSharedDataPointer>
+#include <QVariant>
+#include <QStringList>
+#include <QUrl>
+#include "qgeoplace.h"
+#include "qlandmarkid.h"
+#include "qlandmarkcategoryid.h"
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkPrivate;
+class Q_LOCATION_EXPORT QLandmark : public QGeoPlace
+{
+public:
+ QLandmark();
+ QLandmark(const QGeoPlace &other);
+ QLandmark(const QLandmark &other);
+ ~QLandmark();
+
+ QLandmark &operator= (const QLandmark &other);
+ bool operator== (const QLandmark &other) const;
+ bool operator!= (const QLandmark &other) const {
+ return !(*this == other);
+ }
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QList<QLandmarkCategoryId> categoryIds() const;
+ void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds);
+ void addCategoryId(const QLandmarkCategoryId &categoryId);
+ void removeCategoryId(const QLandmarkCategoryId &categoryId);
+
+ QString description() const;
+ void setDescription(const QString &description);
+
+ QUrl iconUrl() const;
+ void setIconUrl(const QUrl &iconUrl);
+
+ qreal radius() const;
+ void setRadius(qreal radius);
+
+ QString phoneNumber() const;
+ void setPhoneNumber(const QString &phoneNumber);
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ QLandmarkId landmarkId() const;
+ void setLandmarkId(const QLandmarkId &id);
+
+ void clear();
+private:
+ QLandmarkPrivate* d_func();
+ const QLandmarkPrivate* d_func() const;
+};
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmark))
+
+Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmark), Q_MOVABLE_TYPE);
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmark_p.h b/src/location/landmarks/qlandmark_p.h
new file mode 100644
index 00000000..698b8b1a
--- /dev/null
+++ b/src/location/landmarks/qlandmark_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QLANDMARK_P_H
+#define QLANDMARK_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmark.h"
+#include "qlandmarkid.h"
+#include "qgeoplace_p.h"
+#include <QList>
+#include <QHash>
+#include <QSharedData>
+#include <QUrl>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkPrivate : public QGeoPlacePrivate
+{
+public:
+ QLandmarkPrivate();
+ QLandmarkPrivate(const QGeoPlacePrivate &other);
+ QLandmarkPrivate(const QLandmarkPrivate &other);
+ ~QLandmarkPrivate();
+
+ QLandmarkPrivate& operator= (const QLandmarkPrivate &other);
+
+ bool operator== (const QLandmarkPrivate &other) const;
+ virtual QGeoPlacePrivate* clone() const { return new QLandmarkPrivate(*this); }
+
+ QString name;
+ QList<QLandmarkCategoryId> categoryIds;
+ QString description;
+ QUrl iconUrl;
+ qreal radius;
+ QString phoneNumber;
+ QUrl url;
+ QLandmarkId id;
+ static QStringList commonKeys;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkabstractrequest.cpp b/src/location/landmarks/qlandmarkabstractrequest.cpp
new file mode 100644
index 00000000..afc97f43
--- /dev/null
+++ b/src/location/landmarks/qlandmarkabstractrequest.cpp
@@ -0,0 +1,428 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qlandmarkabstractrequest.h"
+#include "qlandmarkabstractrequest_p.h"
+#include "qlandmarkmanagerengine.h"
+#include "qlandmarkmanager_p.h"
+#include <QDebug>
+#include <QMutexLocker>
+
+QTM_USE_NAMESPACE
+
+QLandmarkAbstractRequestPrivate::QLandmarkAbstractRequestPrivate(QLandmarkManager *mgr)
+ : type(QLandmarkAbstractRequest::InvalidRequest),
+ state(QLandmarkAbstractRequest::InactiveState),
+ error(QLandmarkManager::NoError),
+ errorString(QString()),
+ manager(mgr)
+{
+}
+
+/*!
+ \class QLandmarkAbstractRequest
+ \brief The QLandmarkAbstractRequest class provides the interface
+ from which all asynchronous request classes inherit.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-request
+
+ It allows a client to asynchronously request some functionality of a
+ particular QLandmarkManager. Instances of the class will emit signals when
+ the state of the request changes, or when more results become available.
+
+ Clients should not attempt to create instances of this class directly, but
+ should instead use the use-case-specific classes derived from this class.
+
+ All such request classes have a similar interface: clients set the
+ parameters of the asynchronous call, then call the start() slot of the request. The manager
+ will then enqueue or begin to process the request, at which point the
+ request's state will transition from the \c InactiveState to \c ActiveState.
+ After any state transition, the request will emit the stateChanged()
+ signal. The manager may (if it supports it)
+ periodically update the request with results, at
+ which point the request will emit the resultsAvailable() signal. These
+ results are not guaranteed to have a stable ordering. Error information is
+ considered a result, so some requests will emit the resultsAvailable()
+ signal even if no results are possible from the request (for example, a
+ landmark remove request) when the manager updates the request with
+ information about any errors which may have occurred.
+
+ Clients can choose which signals they wish to handle from a request. If the
+ client is not interested in interim results, they can choose to handle only
+ the stateChanged() signal, and in the slot to which that signal is
+ connected, check whether the state has changed to the \c FinishedState
+ (which signifies that the manager has finished handling the request, and
+ that the request will not be updated with any more results). If the client
+ is not interested in any results (including error information), they may
+ choose to delete the request after calling \l start(), or simply may not
+ connect the the request's signals to any slots. (Please see the note
+ below if you are working on Symbian with QtMobility 1.1.0)
+
+ If the request is allocated via operator new, the client must delete the
+ request when they are no longer using it in order to avoid leaking memory.
+ That is, the client retains ownership of the request.
+
+ The client may delete a heap-allocated request in various ways: by deleting
+ it directly (but not within a slot connected to a signal emitted by the
+ request), or by using the deleteLater() slot to schedule the request for
+ deletion when control returns to the event loop (from within a slot
+ connected to a signal emitted by the request, for example \l
+ stateChanged()).
+
+ An active request may be deleted by the client, but the client will
+ not receive notifications about whether the request succeeded or not,
+ nor the results of the request.
+
+ Because clients retain ownership of any request object, and may delete a
+ request object at any time, the manager engine, implementers must be
+ careful to ensue that they do not assume that a request has not been
+ deleted at some time point during processing of a request, particularly
+ if the engine has a multithreaded implementation.
+*/
+
+QLandmarkAbstractRequestPrivate::~QLandmarkAbstractRequestPrivate()
+{
+}
+
+void QLandmarkAbstractRequestPrivate::notifyEngine(QLandmarkAbstractRequest* request)
+{
+ Q_ASSERT(request);
+ QLandmarkAbstractRequestPrivate* d = request->d_ptr;
+ if (d) {
+ QMutexLocker ml(&d->mutex);
+ QLandmarkManagerEngine *engine = QLandmarkManagerPrivate::getEngine(d->manager);
+ ml.unlock();
+ if (engine) {
+ engine->requestDestroyed(request);
+ }
+ }
+}
+
+/*!
+ \enum QLandmarkAbstractRequest::RequestType
+ Defines the possible types of asynchronous requests.
+ \value InvalidRequest An invalid request
+ \value LandmarkIdFetchRequest A request to fetch a list of landmark
+ identifiers.
+ \value CategoryIdFetchRequest A request to fetch a list of catgory
+ identifiers.
+
+ \value LandmarkFetchRequest A request to fetch a list of landmarks
+ \value LandmarkFetchByIdRequest A request to fetch a list of landmarks by id.
+ \value CategoryFetchRequest A request to fetch a list of categories
+ \value CategoryFetchByIdRequest A request to fetch a list of categories by id
+ \value LandmarkSaveRequest A request to save a list of landmarks.
+ \value LandmarkRemoveRequest A request to remove a list of landmarks.
+ \value CategorySaveRequest A request to save a list of categories.
+ \value CategoryRemoveRequest A request to remove a list of categories.
+ \value ImportRequest A request import landmarks.
+ \value ExportRequest A request export landmarks.
+*/
+
+/*!
+ \enum QLandmarkAbstractRequest::State
+ Defines the possible states of asynchronous requests.
+ \value InactiveState Operation not yet started.
+ \value ActiveState Operation started, not yet finished.
+ \value FinishedState Operation completed. (Can be mean either successful or
+ unsuccessful completion).
+*/
+
+/*!
+ Constructs a new, invalid asynchronous request with the given \a manager and \a parent.
+*/
+QLandmarkAbstractRequest::QLandmarkAbstractRequest(QLandmarkManager *manager, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLandmarkAbstractRequestPrivate(manager))
+{
+}
+
+/*!
+ \internal
+*/
+QLandmarkAbstractRequest::QLandmarkAbstractRequest(QLandmarkAbstractRequestPrivate *dd, QObject *parent)
+ : QObject(parent),
+ d_ptr(dd)
+{
+}
+
+/*!
+ Destroys the asynchronous request. Because the request object is effectiely a handle to a
+ request operation, the operation may continue or it may just be canceled, depending upon
+ the enine implementation, even though the request itself has been destroyed.
+ The sqlite engine continues the operation behind the scenes if the
+ request is destroyed whilst active. For the symbian engine see the note below.
+*/
+QLandmarkAbstractRequest::~QLandmarkAbstractRequest()
+{
+ QLandmarkAbstractRequestPrivate::notifyEngine(this);
+ delete d_ptr;
+}
+
+/*!
+ Returns the type of this asynchronous request.
+*/
+QLandmarkAbstractRequest::RequestType QLandmarkAbstractRequest::type() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->type;
+}
+
+/*!
+ Returns the state of the request
+*/
+QLandmarkAbstractRequest::State QLandmarkAbstractRequest::state()
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->state;
+}
+
+/*!
+ Returns true if the request is in the \c QLandmarkAbstractRequest::Inactive state;
+ otherwise, returns false.
+ \sa state()
+*/
+bool QLandmarkAbstractRequest::isInactive() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->state == QLandmarkAbstractRequest::InactiveState;
+}
+
+/*!
+ Returns true if the request is in the \c QLandmarkAbstractRequest::Active state;
+ otherwise, returns false.
+ \sa state()
+*/
+bool QLandmarkAbstractRequest::isActive() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->state == QLandmarkAbstractRequest::ActiveState;
+}
+
+/*!
+ Returns true if the request is in the \c QLandmarkAbstractRequest::Finished state;
+ otherwise, returns false.
+ \sa state()
+*/
+bool QLandmarkAbstractRequest::isFinished() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->state == QLandmarkAbstractRequest::FinishedState;
+}
+
+/*!
+ Returns the overall error of the most recent asynchronous operation.
+ \sa errorString()
+*/
+QLandmarkManager::Error QLandmarkAbstractRequest::error() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->error;
+}
+
+/*!
+ Returns a human readable string of the last error
+ that occurred. This error string is intended to be used
+ by developers only and should not be seen by end users.
+ \sa error()
+*/
+QString QLandmarkAbstractRequest::errorString() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->errorString;
+}
+
+/*!
+ Returns a pointer to the landmark manager which
+ this request operates on.
+*/
+QLandmarkManager *QLandmarkAbstractRequest::manager() const
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ return d_ptr->manager;
+}
+
+/*!
+ Sets the \a manager which this request operates on.
+
+ Note that if a NULL manager is set, the functions
+ start(), cancel() and waitForFinished() will return false and
+ error will be set to QLandmarkManager::InvalidManagerError.
+
+ A manager cannot be assigned while the request is in the
+ QLandmarkAbstractRequest::ActiveState.
+*/
+void QLandmarkAbstractRequest::setManager(QLandmarkManager *manager)
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ if (d_ptr->state == QLandmarkAbstractRequest::ActiveState && d_ptr->manager)
+ return;
+ d_ptr->manager = manager;
+}
+
+/*!
+ Attempts to start the request.
+
+ Returns true if the request was started, otherwise false. Trying to start a
+ request that is already active returns false.
+ \sa cancel().
+*/
+bool QLandmarkAbstractRequest::start()
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ if (!d_ptr->manager) {
+ d_ptr->error = QLandmarkManager::BadArgumentError;
+ d_ptr->errorString = "No manager assigned to landmark request object";
+ qWarning() << d_ptr->errorString;
+ return false;
+ }
+ QLandmarkManagerEngine *engine = d_ptr->manager->engine();
+ if (!engine) {
+ d_ptr->error = QLandmarkManager::InvalidManagerError;
+ d_ptr->errorString = "The manager is invalid";
+ return false;
+ }
+
+ if (d_ptr->state != QLandmarkAbstractRequest::ActiveState) {
+ ml.unlock();
+ return engine->startRequest(this);
+ }
+ else {
+ return false;
+ }
+}
+
+/*!
+ Notifies the request that it should be canceled.
+
+ Returns true if the request was successfully notified
+ that it should be canceled. The request may or may not honor
+ the cancel notification. Returns false if the notification
+ could not be made or the request is not in the
+ QLandmarkManager::Active state.
+
+ \sa start()
+*/
+bool QLandmarkAbstractRequest::cancel()
+{
+ QMutexLocker ml(&d_ptr->mutex);
+ if (!d_ptr->manager) {
+ d_ptr->error = QLandmarkManager::BadArgumentError;
+ d_ptr->errorString = "No manager assigned to landmark request object";
+ qWarning() << d_ptr->errorString;
+ return false;
+ }
+ QLandmarkManagerEngine *engine = d_ptr->manager->engine();
+
+ if(d_ptr->state == QLandmarkAbstractRequest::ActiveState) {
+ ml.unlock();
+ return engine->cancelRequest(this);
+ }
+ else
+ return false;
+}
+
+/*!
+ Blocks until the request has been completed or until \a msecs milliseconds
+ has elapsed. If \a msecs is zero or negative, this function will block indefinitely.
+
+ Returns true if the request was canceled or completed
+ within the given period, otherwise returns false. Some backends may be unable
+ to support this operation safely and will return false immediately.
+
+ (Note: This function is not supported for an import request
+ with the symbian manager which always returns false. As of
+ Qt Mobility 1.1.1 waitForFinished() is supported using the sqlite manager).
+
+ Note that any signals generated while waiting for the request to be complete
+ may be queued and delivered sometime after this function has returned, when
+ the calling thread's event loop is dispatched. If your code depends on
+ your slots being invoked, you may need to process events after calling
+ this function.
+*/
+bool QLandmarkAbstractRequest::waitForFinished(int msecs)
+{
+
+ QMutexLocker ml(&d_ptr->mutex);
+ if (!d_ptr->manager) {
+ d_ptr->error = QLandmarkManager::BadArgumentError;
+ d_ptr->errorString = "No manager assigned to landmark request object";
+ qWarning() << d_ptr->errorString;
+ return false;
+ }
+ QLandmarkManagerEngine *engine = d_ptr->manager->engine();
+
+ switch(d_ptr->state) {
+ case QLandmarkAbstractRequest::ActiveState:
+ ml.unlock();
+ return engine->waitForRequestFinished(this, msecs);
+ case QLandmarkAbstractRequest::FinishedState:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*!
+ \fn void QLandmarkAbstractRequest::resultsAvailable()
+ This signal is emitted when new results are available. Results
+ can include the operation error which may be accessed via error(),
+ or derived-class specific results which are accessible through
+ the derived class API.
+
+ \sa error()
+*/
+
+/*!
+ \fn void QLandmarkAbstractRequest::stateChanged(QLandmarkAbstractRequest::State newState)
+ This signal is emitted when the state of the request is changed. The new state of
+ the request will be contained in \a newState.
+*/
+
+#include "moc_qlandmarkabstractrequest.cpp"
+
+
+
+
+
diff --git a/src/location/landmarks/qlandmarkabstractrequest.h b/src/location/landmarks/qlandmarkabstractrequest.h
new file mode 100644
index 00000000..bd84e6d0
--- /dev/null
+++ b/src/location/landmarks/qlandmarkabstractrequest.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKABSTRACTREQUEST_H
+#define QLANDMARKABSTRACTREQUEST_H
+
+#include "qlandmarkmanager.h"
+#include <QObject>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkAbstractRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkAbstractRequest : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum State {
+ InactiveState = 0,
+ ActiveState,
+ FinishedState
+ };
+
+ enum RequestType {
+ InvalidRequest = 0,
+ LandmarkIdFetchRequest,
+ CategoryIdFetchRequest,
+ LandmarkFetchRequest,
+ LandmarkFetchByIdRequest,
+ CategoryFetchRequest,
+ CategoryFetchByIdRequest,
+ LandmarkSaveRequest,
+ LandmarkRemoveRequest,
+ CategorySaveRequest,
+ CategoryRemoveRequest,
+ ImportRequest,
+ ExportRequest
+ };
+
+ QLandmarkAbstractRequest(QLandmarkManager *manager, QObject *parent = 0);
+ virtual ~QLandmarkAbstractRequest();
+
+ RequestType type() const;
+
+ State state();
+ bool isInactive()const;
+ bool isActive() const;
+ bool isFinished() const;
+
+ QLandmarkManager::Error error() const;
+ QString errorString() const;
+
+ QLandmarkManager * manager() const;
+ void setManager(QLandmarkManager *manager);
+
+public Q_SLOTS:
+ bool start();
+ bool cancel();
+ bool waitForFinished(int msecs = 0);
+
+Q_SIGNALS:
+ void resultsAvailable();
+ void stateChanged(QLandmarkAbstractRequest::State newState);
+protected:
+ QLandmarkAbstractRequest(QLandmarkAbstractRequestPrivate *otherd, QObject *parent = 0);
+ QLandmarkAbstractRequestPrivate *d_ptr;
+private:
+ Q_DISABLE_COPY(QLandmarkAbstractRequest)
+ friend class QLandmarkManagerEngine;
+ friend class QLandmarkAbstractRequestPrivate;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkabstractrequest_p.h b/src/location/landmarks/qlandmarkabstractrequest_p.h
new file mode 100644
index 00000000..e1a56411
--- /dev/null
+++ b/src/location/landmarks/qlandmarkabstractrequest_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKABSTRACTREQUEST_P_H
+#define QLANDMARKABSTRACTREQUEST_P_H
+
+#include <QMutex>
+#include <QPointer>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkAbstractRequestPrivate(QLandmarkManager *mgr);
+
+ virtual ~QLandmarkAbstractRequestPrivate();
+ static void notifyEngine(QLandmarkAbstractRequest* request);
+
+ QLandmarkAbstractRequest::RequestType type;
+ QLandmarkAbstractRequest::State state;
+ QLandmarkManager::Error error;
+ QString errorString;
+ QPointer<QLandmarkManager> manager;
+ mutable QMutex mutex;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkattributefilter.cpp b/src/location/landmarks/qlandmarkattributefilter.cpp
new file mode 100644
index 00000000..5023bb14
--- /dev/null
+++ b/src/location/landmarks/qlandmarkattributefilter.cpp
@@ -0,0 +1,270 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkattributefilter.h"
+#include "qlandmarkfilter_p.h"
+#include <QHash>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkAttributeFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkAttributeFilterPrivate();
+ QLandmarkAttributeFilterPrivate(const QLandmarkAttributeFilterPrivate &other);
+
+ virtual ~QLandmarkAttributeFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate *other) const
+ {
+ //it is assumed that the types and superclass member variables already match
+ const QLandmarkAttributeFilterPrivate *od = static_cast<const QLandmarkAttributeFilterPrivate*>(other);
+ return (attributes == od->attributes)
+ && (flags == od->flags)
+ && (operationType == od->operationType);
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkAttributeFilter, QLandmarkFilter::AttributeFilter)
+
+ QHash<QString, QVariant> attributes;
+ QHash<QString, QLandmarkFilter::MatchFlags> flags;
+ QLandmarkAttributeFilter::OperationType operationType;
+};
+
+QLandmarkAttributeFilterPrivate::QLandmarkAttributeFilterPrivate()
+ : QLandmarkFilterPrivate(),
+ attributes(QHash<QString, QVariant>()),
+ flags(QHash<QString, QLandmarkFilter::MatchFlags>()),
+ operationType(QLandmarkAttributeFilter::AndOperation)
+
+{
+ type = QLandmarkFilter::AttributeFilter;
+}
+
+QLandmarkAttributeFilterPrivate::QLandmarkAttributeFilterPrivate(const QLandmarkAttributeFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ attributes(other.attributes),
+ flags(other.flags),
+ operationType(other.operationType)
+{
+}
+
+QLandmarkAttributeFilterPrivate::~QLandmarkAttributeFilterPrivate()
+{
+}
+
+/*!
+ \class QLandmarkAttributeFilter
+ \brief The QLandmarkAttributeFilter class provides filtering on various landmark attributes.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ You can provide various keys which describe the attribute(s) to search.
+ Precisely which keys may be used depends on the manager
+ and these can be retrieved by using QLandmarkManager::searchableLandmarkAttributeKeys().
+ The table below outlines some keys that may be used with the default managers on the
+ currently supported platforms. The match flags may be used for attributes which are
+ of string type (typically most, if not all searchable attributes are string types).
+
+ \table
+ \header
+ \o {3,1} Searchable attributes
+ \row
+ \o "city"
+ \o "country
+ \o "countryCode"
+ \row
+ \o "county"
+ \o "description"
+ \o "district"
+ \row
+ \o "name"
+ \o "state"
+ \o "phoneNumber"
+ \row
+ \o "postcode"
+ \o "street"
+ \o
+ \endtable
+
+ Please note that different platforms support different capabilities with the attribute filter.
+ \list
+ \o The S60 3.1, 3.2 and 5.0 platforms do not support an OR type attribute filter.
+ \o The S60 3.1, 3.2, 5.0 and Symbian platforms do not support the MatchContains flag.
+ \o The S60 3.1, 3.2, 5.0 and Symbian platforms do not support multiple attributes with an
+ AND type attribute filter(using a single attribute however is supported).
+ \endlist
+*/
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkAttributeFilter);
+
+/*!
+ \enum QLandmarkAttributeFilter::OperationType
+ Defines how the attribute criteria are combined if more than one attribute is defined.
+ \value AndOperation Landmarks must match all the attributes provided by the filter.
+ \value OrOperation Landmarks must match at least one attribute provided by the filter.
+*/
+
+/*!
+ Creates an attribute filter.
+*/
+QLandmarkAttributeFilter::QLandmarkAttributeFilter()
+ : QLandmarkFilter(new QLandmarkAttributeFilterPrivate)
+{
+}
+
+/*!
+ \fn QLandmarkAttributeFilter::QLandmarkAttributeFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new attribute filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkAttributeFilter::~QLandmarkAttributeFilter()
+{
+}
+
+/*!
+ Returns the value of the attribute corresponding to \a key.
+
+ If the attribute isn't set an invalid QVariant is returned.
+*/
+QVariant QLandmarkAttributeFilter::attribute(const QString &key) const
+{
+ Q_D(const QLandmarkAttributeFilter);
+ return d->attributes.value(key);
+}
+
+/*!
+ Sets the \a value of the attribute corresponding to \a key.
+
+ For string based attributes a set of matching \a flags can be provided
+ to define how the string values should be matched.
+ For non-string based attributes the \a flags are ignored.
+ The beahviour of the filter is undefined if an invalid QVariant is used as a \a value
+*/
+void QLandmarkAttributeFilter::setAttribute(const QString &key, const QVariant &value, QLandmarkFilter::MatchFlags flags)
+{
+ Q_D(QLandmarkAttributeFilter);
+ d->attributes[key] = value;
+ d->flags[key] = flags;
+}
+
+/*!
+ Sets the \a value of all the attributes correponding to those in \a keys.
+
+ For string based attributes a
+ set of matching \a flags can be provided to define how the string values should be matched.
+ For non-string based attributes the \a flags are ignored.
+ The behaviour of the filter is undefined if an invalid QVariant is used as \a value.
+*/
+void QLandmarkAttributeFilter::setAttributes(const QStringList &keys, const QVariant &value, QLandmarkFilter::MatchFlags flags)
+{
+ Q_D(QLandmarkAttributeFilter);
+ foreach(const QString &key, keys) {
+ d->attributes[key] = value;
+ d->flags[key] = flags;
+ }
+}
+
+/*!
+ Removes the attribute corresponding to \a key from the filter.
+*/
+void QLandmarkAttributeFilter::removeAttribute(const QString &key)
+{
+ Q_D(QLandmarkAttributeFilter);
+ d->attributes.remove(key);
+ d->flags.remove(key);
+}
+
+/*!
+ Clears all attributes from the filter.
+*/
+void QLandmarkAttributeFilter::clearAttributes()
+{
+ Q_D(QLandmarkAttributeFilter);
+ d->attributes.clear();
+ d->flags.clear();
+}
+
+/*!
+ Returns the keys of all attributes set in the filter.
+*/
+QStringList QLandmarkAttributeFilter::attributeKeys() const
+{
+ Q_D(const QLandmarkAttributeFilter);
+ return d->attributes.keys();
+}
+
+/*!
+ Returns the operation to be used by the filter when multiple attributes
+ are provided.
+*/
+QLandmarkAttributeFilter::OperationType QLandmarkAttributeFilter::operationType() const
+{
+ Q_D(const QLandmarkAttributeFilter);
+ return d->operationType;
+}
+
+/*!
+ Sets the operation to be used by the filter when multiple attributes
+ are provided to \a operationType.
+*/
+void QLandmarkAttributeFilter::setOperationType(QLandmarkAttributeFilter::OperationType operationType)
+{
+ Q_D(QLandmarkAttributeFilter);
+ d->operationType = operationType;
+}
+
+/*!
+ Returns the match flags for a particular \a key. The match flags are only take into consideration
+ when the attribute for a particular key is a string. In all other cases the match flags are ignored.
+*/
+QLandmarkFilter::MatchFlags QLandmarkAttributeFilter::matchFlags(const QString &key) const
+{
+ Q_D(const QLandmarkAttributeFilter);
+ return d->flags.value(key);
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkattributefilter.h b/src/location/landmarks/qlandmarkattributefilter.h
new file mode 100644
index 00000000..df519955
--- /dev/null
+++ b/src/location/landmarks/qlandmarkattributefilter.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKATTRIBUTEFILTER_H
+#define QLANDMARKATTRIBUTEFILTER_H
+
+#include "qlandmarkfilter.h"
+#include <QVariant>
+#include <QString>
+#include <QStringList>
+
+QTM_BEGIN_NAMESPACE
+class QLandmark;
+
+class QLandmarkAttributeFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkAttributeFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkAttributeFilter();
+ QLandmarkAttributeFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkAttributeFilter();
+
+ enum OperationType{AndOperation, OrOperation};
+
+ QVariant attribute(const QString &key) const;
+ void setAttribute(const QString &key, const QVariant &value, QLandmarkFilter::MatchFlags flags =0);
+ void setAttributes(const QStringList &key, const QVariant &value, QLandmarkFilter::MatchFlags flags=0);
+ void removeAttribute(const QString &key);
+ void clearAttributes();
+ QStringList attributeKeys() const;
+
+ QLandmarkFilter::MatchFlags matchFlags(const QString &key) const;
+
+ OperationType operationType() const;
+ void setOperationType(OperationType operationType);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkAttributeFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkboxfilter.cpp b/src/location/landmarks/qlandmarkboxfilter.cpp
new file mode 100644
index 00000000..d135ab11
--- /dev/null
+++ b/src/location/landmarks/qlandmarkboxfilter.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkboxfilter.h"
+#include "qlandmarkboxfilter_p.h"
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkBoxFilter
+ \brief The QLandmarkBoxFilter class is used to search for landmarks within a given bounding box.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ In order to be a valid filter, the region covered by the box filter must not cover one of the poles.
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkBoxFilter);
+
+/*!
+ Creates a filter that will search for landmarks within a bounding
+ box defined by the \a topLeft and \a bottomRight coordinates.
+*/
+QLandmarkBoxFilter::QLandmarkBoxFilter(const QGeoCoordinate &topLeft,
+ const QGeoCoordinate &bottomRight)
+ : QLandmarkFilter(new QLandmarkBoxFilterPrivate(QGeoBoundingBox(topLeft, bottomRight)))
+{
+}
+
+/*!
+ Creates a filter that will search for landmarks within the \a boundingBox.
+*/
+QLandmarkBoxFilter::QLandmarkBoxFilter(const QGeoBoundingBox &boundingBox)
+ : QLandmarkFilter(new QLandmarkBoxFilterPrivate(boundingBox))
+{
+}
+
+/*!
+ \fn QLandmarkBoxFilter::QLandmarkBoxFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new box filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkBoxFilter::~QLandmarkBoxFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Returns the filter's bounding box.
+*/
+QGeoBoundingBox QLandmarkBoxFilter::boundingBox() const
+{
+ Q_D(const QLandmarkBoxFilter);
+ return d->boundingBox;
+}
+
+/*!
+ Sets the \a boundingBox of the filter.
+*/
+void QLandmarkBoxFilter::setBoundingBox(const QGeoBoundingBox &boundingBox)
+{
+ Q_D(QLandmarkBoxFilter);
+ d->boundingBox = boundingBox;
+}
+
+/*!
+ Returns the top left coordinate of the box filter.
+*/
+QGeoCoordinate QLandmarkBoxFilter::topLeft()
+{
+ Q_D(const QLandmarkBoxFilter);
+ return d->boundingBox.topLeft();
+}
+
+/*!
+ Sets the \a topLeft coordinate of the box filter.
+*/
+void QLandmarkBoxFilter::setTopLeft(const QGeoCoordinate &topLeft)
+{
+ Q_D(QLandmarkBoxFilter);
+ d->boundingBox.setTopLeft(topLeft);
+}
+
+
+/*!
+ Returns the bottom right coordinate of the box filter.
+*/
+QGeoCoordinate QLandmarkBoxFilter::bottomRight()
+{
+ Q_D(const QLandmarkBoxFilter);
+ return d->boundingBox.bottomRight();
+}
+
+/*!
+ Sets the \a bottomRight coordinate of the box filter.
+*/
+void QLandmarkBoxFilter::setBottomRight(const QGeoCoordinate &bottomRight)
+{
+ Q_D(QLandmarkBoxFilter);
+ return d->boundingBox.setBottomRight(bottomRight);
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkBoxFilterPrivate::QLandmarkBoxFilterPrivate(const QGeoBoundingBox &box)
+ : QLandmarkFilterPrivate(),
+ boundingBox(box)
+{
+ type = QLandmarkFilter::BoxFilter;
+}
+
+QLandmarkBoxFilterPrivate::QLandmarkBoxFilterPrivate(const QLandmarkBoxFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ boundingBox(other.boundingBox) {}
+
+QLandmarkBoxFilterPrivate::~QLandmarkBoxFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkboxfilter.h b/src/location/landmarks/qlandmarkboxfilter.h
new file mode 100644
index 00000000..852dbf63
--- /dev/null
+++ b/src/location/landmarks/qlandmarkboxfilter.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKBOXFILTER_H
+#define QLANDMARKBOXFILTER_H
+
+#include "qlandmarkfilter.h"
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkBoxFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkBoxFilter : public QLandmarkFilter
+{
+public:
+
+ QLandmarkBoxFilter(const QGeoBoundingBox &boundingBox = QGeoBoundingBox());
+ QLandmarkBoxFilter(const QGeoCoordinate &topLeft,
+ const QGeoCoordinate &bottomRight);
+ QLandmarkBoxFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkBoxFilter();
+
+ QGeoBoundingBox boundingBox() const;
+ void setBoundingBox(const QGeoBoundingBox &boundingBox);
+
+ QGeoCoordinate topLeft();
+ void setTopLeft(const QGeoCoordinate &topLeft);
+
+ QGeoCoordinate bottomRight();
+ void setBottomRight(const QGeoCoordinate &bottomRight);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkBoxFilter)
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarkboxfilter_p.h b/src/location/landmarks/qlandmarkboxfilter_p.h
new file mode 100644
index 00000000..ed68dc85
--- /dev/null
+++ b/src/location/landmarks/qlandmarkboxfilter_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKBOXFILTER_P_H
+#define QLANDMARKBOXFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+#include "qgeoboundingbox.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class QLandmarkBoxFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkBoxFilterPrivate(const QGeoBoundingBox &boundingBox = QGeoBoundingBox());
+ QLandmarkBoxFilterPrivate(const QLandmarkBoxFilterPrivate &other);
+ virtual ~QLandmarkBoxFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate* other) const
+ {
+ const QLandmarkBoxFilterPrivate *od = static_cast<const QLandmarkBoxFilterPrivate*>(other);
+ return (boundingBox == od->boundingBox);
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkBoxFilter, QLandmarkFilter::BoxFilter);
+
+ QGeoBoundingBox boundingBox;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategory.cpp b/src/location/landmarks/qlandmarkcategory.cpp
new file mode 100644
index 00000000..d8d69075
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategory.cpp
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategory.h"
+#include "qlandmarkcategory_p.h"
+#include "qlandmarkcategoryid.h"
+
+#include <QStringList>
+#include <QVariant>
+
+#ifdef CATEGORYPRIVATE_DEBUG
+#include <QDebug>
+#endif
+
+QTM_USE_NAMESPACE
+
+// ----- QLandmarkCategoryPrivate -----
+
+QLandmarkCategoryPrivate::QLandmarkCategoryPrivate()
+ : QSharedData(),
+ name(QString()),
+ iconUrl(QUrl()),
+ id(QLandmarkCategoryId())
+{
+}
+
+QLandmarkCategoryPrivate::QLandmarkCategoryPrivate(const QLandmarkCategoryPrivate &other)
+ : QSharedData(other),
+ name(other.name),
+ iconUrl(other.iconUrl),
+ id(other.id)
+{
+}
+
+QLandmarkCategoryPrivate::~QLandmarkCategoryPrivate()
+{
+}
+
+QLandmarkCategoryPrivate& QLandmarkCategoryPrivate::operator= (const QLandmarkCategoryPrivate & other)
+{
+ name = other.name;
+ iconUrl = other.iconUrl;
+ id = other.id;
+
+ return *this;
+}
+
+bool QLandmarkCategoryPrivate::operator == (const QLandmarkCategoryPrivate &other) const
+{
+
+#ifdef CATEGORYPRIVATE_DEBUG
+ qDebug() << "name: " << (name == other.name);
+ qDebug() << "id:" << (id == other.id);
+#endif
+ return ((name == other.name)
+ && (iconUrl == other.iconUrl)
+ && (id == other.id));
+}
+
+/*!
+ \class QLandmarkCategory
+
+ \brief The QLandmarkCategory class designates a grouping of
+ landmarks of similar type.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-main
+ \since 1.1
+
+ Landmarks of similar type may be grouped together into categories,
+ e.g. restaurants, accommodation etc, a QLandmarkCategory object
+ represents one of these.
+
+ More than one category can be assigned to a landmark. Assignment
+ of a category to a landmark is achieved by using the QLandmark::setCategoryIds()
+ or QLandmark::addCategoryId() functions.
+
+ Some categories may be considered read-only by a manager and cannot
+ be saved. To see if a category is read only, the id of the cateory must be passed
+ into the QLandmarkManager::isReadOnly() function. Localization is only possible for categories that
+ are read-only.
+
+ A QLandmarkCategory instance is an in memory representation and may
+ not reflect the state of the category found in persistent storage,
+ until the appropriate synchronization method is called on the
+ QLandmarkManager(e.g.\l {QLandmarkManager::saveCategory()} {saveCategory()},
+ \l {QLandmarkManager::removeCategory()} {removeCategory()}).
+*/
+
+/*!
+ Constructs an empty category.
+
+ A new category will be assigned an invalid QLandmarkCategoryId.
+*/
+QLandmarkCategory::QLandmarkCategory()
+ : d(new QLandmarkCategoryPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmarkCategory::QLandmarkCategory(const QLandmarkCategory &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys the category.
+*/
+QLandmarkCategory::~QLandmarkCategory()
+{
+}
+/*!
+ Assigns \a other to this category and returns a reference to this category.
+*/
+QLandmarkCategory& QLandmarkCategory::operator= (const QLandmarkCategory & other)
+{
+ *d = *(other.d);
+ return *this;
+}
+
+/*!
+ Returns true if this category is equal to \a other, otherwise
+ returns false.
+
+ \sa operator!=()
+*/
+bool QLandmarkCategory::operator== (const QLandmarkCategory &other) const
+{
+ return (*d == *(other.d));
+}
+
+/*!
+ Returns true if this category is not equal to \a other, otherwise
+ returns false.
+
+ \sa operator==()
+*/
+bool QLandmarkCategory::operator!= (const QLandmarkCategory &other) const
+{
+ return !(*this == other);
+}
+
+/*!
+ Returns the name of the category.
+*/
+QString QLandmarkCategory::name() const
+{
+ return d->name;
+}
+
+/*!
+ Sets the \a name of the category.
+
+ Using the default manager on the Symbian platform, the catgory name is retricted to a length of 124 characters.
+*/
+void QLandmarkCategory::setName(const QString &name)
+{
+ d->name = name;
+}
+
+/*!
+ Returns the url of the category's icon.
+*/
+QUrl QLandmarkCategory::iconUrl() const
+{
+ return d->iconUrl;
+}
+
+/*!
+ Sets the \a url of the category's icon
+*/
+void QLandmarkCategory::setIconUrl(const QUrl &url)
+{
+ d->iconUrl = url;
+}
+
+
+/*!
+ Returns the identifier of the category.
+*/
+QLandmarkCategoryId QLandmarkCategory::categoryId() const
+{
+ return d->id;
+}
+
+/*!
+ Sets the \a id of the category.
+
+ Note that saving a new category using a QLandmarkManager
+ will automatically assign the category a valid identifier.
+*/
+void QLandmarkCategory::setCategoryId(const QLandmarkCategoryId &id)
+{
+ d->id = id;
+}
+
+/*!
+ Clears all the data fields of the category.
+*/
+void QLandmarkCategory::clear()
+{
+ d->name.clear();
+ d->iconUrl.clear();
+ d->id = QLandmarkCategoryId();
+}
diff --git a/src/location/landmarks/qlandmarkcategory.h b/src/location/landmarks/qlandmarkcategory.h
new file mode 100644
index 00000000..c694e0c8
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategory.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORY_H
+#define QLANDMARKCATEGORY_H
+
+#include "qmobilityglobal.h"
+#include <QVariant>
+#include <QSharedDataPointer>
+
+
+class QStringList;
+class QUrl;
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+class QLandmarkCategoryId;
+
+class QLandmarkCategoryPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategory
+{
+public:
+ QLandmarkCategory();
+ QLandmarkCategory(const QLandmarkCategory &other);
+ ~QLandmarkCategory();
+
+ QLandmarkCategory& operator= (const QLandmarkCategory &other);
+
+ bool operator==(const QLandmarkCategory &other) const;
+ bool operator!=(const QLandmarkCategory &other) const;
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QUrl iconUrl() const;
+ void setIconUrl(const QUrl &url);
+
+ QLandmarkCategoryId categoryId() const;
+ void setCategoryId(const QLandmarkCategoryId &id);
+
+ void clear();
+private:
+ QSharedDataPointer<QLandmarkCategoryPrivate> d;
+};
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkCategory))
+
+Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkCategory), Q_MOVABLE_TYPE);
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategory_p.h b/src/location/landmarks/qlandmarkcategory_p.h
new file mode 100644
index 00000000..a11bcac3
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategory_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORY_P_H
+#define QLANDMARKCATEGORY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkcategoryid.h"
+#include <QString>
+#include <QUrl>
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryPrivate : public QSharedData
+{
+public:
+ QLandmarkCategoryPrivate();
+ QLandmarkCategoryPrivate(const QLandmarkCategoryPrivate &other);
+ ~QLandmarkCategoryPrivate();
+
+ QLandmarkCategoryPrivate& operator= (const QLandmarkCategoryPrivate &other);
+
+ bool operator== (const QLandmarkCategoryPrivate &other) const;
+ // consider inline != in terms of ==?
+
+ QString name;
+ QUrl iconUrl;
+ QLandmarkCategoryId id;
+ static QStringList commonKeys;
+};
+
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp
new file mode 100644
index 00000000..3801b6dd
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryfetchbyidrequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkcategory.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryFetchByIdRequest
+ \brief The QLandmarkCategoryFetchByIdRequest class allows a client to asynchronously
+ request a list of categories by ID from a landmark manager.
+
+ The categories fetched by the manager should have a one-to-one correspondence to the
+ IDs passed into this class. That is, the nth category in the returned list should
+ have an ID which is equal to the nth ID in the list of IDs. Any invalid ID should
+ correspond to an empty QLandmarkCategory.
+
+ For a QLandmarkCategoryFetchByIdRequest, the resultsAvailable() signal will be emitted
+ as resultant categories are found (these are retrievable by calling categories()),
+ whenever individual items error out(individual errors may be retrieved by calling errorMap()),
+ as well as if an overall operation error occurred(which may be retrieved by calling
+ QLandmarkAbstractRequest::error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information
+ about he usage of request classes and ownership semantics.
+
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.2
+*/
+
+/*!
+ Creates a new a request object with the given \a manager and \a parent.
+*/
+QLandmarkCategoryFetchByIdRequest::QLandmarkCategoryFetchByIdRequest(QLandmarkManager *manager, QObject *parent)
+ :QLandmarkAbstractRequest(new QLandmarkCategoryFetchByIdRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkCategoryFetchByIdRequest::~QLandmarkCategoryFetchByIdRequest()
+{
+}
+
+/*!
+ Returns a list of identifiers of categories which are to be retrieved by this request.
+*/
+QList<QLandmarkCategoryId> QLandmarkCategoryFetchByIdRequest::categoryIds() const
+{
+ Q_D(const QLandmarkCategoryFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categoryIds;
+}
+
+/*!
+ Sets this request to retrieve a list of categories identified by \a categoryIds.
+*/
+void QLandmarkCategoryFetchByIdRequest::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds)
+{
+ Q_D(QLandmarkCategoryFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds = categoryIds;
+}
+
+/*!
+ Convenience function that sets a single category, specified by \a categoryId,
+ to be retrieved by this request.
+*/
+void QLandmarkCategoryFetchByIdRequest::setCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkCategoryFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds.clear();
+ d->categoryIds.append(categoryId);
+}
+
+/*!
+ Returns the list of categories fetched by this request
+*/
+QList<QLandmarkCategory> QLandmarkCategoryFetchByIdRequest::categories() const
+{
+ Q_D(const QLandmarkCategoryFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categories;
+}
+
+/*!
+ Returns the mapping of input category id list indices
+ to the errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkCategoryFetchByIdRequest::errorMap() const
+{
+ Q_D(const QLandmarkCategoryFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarkcategoryfetchbyidrequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h
new file mode 100644
index 00000000..802717aa
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfetchbyidrequest.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYFETCHBYIDREQUEST_H
+#define QLANDMARKCATEGORYFETCHBYIDREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+#include "qlandmarkcategoryid.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryFetchByIdRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryFetchByIdRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkCategoryFetchByIdRequest(QLandmarkManager *manager, QObject *parent=0);
+ ~QLandmarkCategoryFetchByIdRequest();
+
+ QList<QLandmarkCategoryId> categoryIds() const;
+ void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds);
+ void setCategoryId(const QLandmarkCategoryId &categoryId);
+
+ QList<QLandmarkCategory> categories() const;
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+
+private:
+ Q_DISABLE_COPY(QLandmarkCategoryFetchByIdRequest)
+ Q_DECLARE_PRIVATE(QLandmarkCategoryFetchByIdRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp b/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp
new file mode 100644
index 00000000..9406594b
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfetchrequest.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryfetchrequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkcategory.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryFetchRequest
+ \brief The QLandmarkCategoryFetchRequest class allows a client to asynchronously
+ request a list of categories from a landmark manager.
+
+ For a QLandmarkCategoryFetchRequest, the resultsAvailable() signal will be emitted
+ as resultant categories are found (these are retrievable by calling categories()),
+ as well as if an overall operation error occurred(which may be retrieved by calling
+ QLandmarkAbstractRequest::error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-request
+*/
+
+/*!
+ Creates a new category fetch request object with the given \a manager and \a parent.
+*/
+QLandmarkCategoryFetchRequest::QLandmarkCategoryFetchRequest(QLandmarkManager *manager, QObject *parent)
+ :QLandmarkAbstractRequest(new QLandmarkCategoryFetchRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkCategoryFetchRequest::~QLandmarkCategoryFetchRequest()
+{
+}
+
+/*!
+ Returns the list of categories that have been found during the
+ request.
+*/
+QList<QLandmarkCategory> QLandmarkCategoryFetchRequest::categories() const
+{
+ Q_D(const QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categories;
+}
+
+/*!
+ Returns the sorting of the categories.
+ By default the sorting is case insensitive and in ascending order
+ according to the category name.
+*/
+QLandmarkNameSort QLandmarkCategoryFetchRequest::sorting() const
+{
+ Q_D(const QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->sorting;
+}
+
+/*!
+ Sets \a nameSort to specify the sorting of the returned categories.
+*/
+void QLandmarkCategoryFetchRequest::setSorting(const QLandmarkNameSort &nameSort)
+{
+ Q_D(QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting = nameSort;
+}
+
+/*!
+ Returns the maximum number of categories to be returned. By default the limit
+ is -1 indicating that all categories should be retrieved.
+*/
+int QLandmarkCategoryFetchRequest::limit() const
+{
+ Q_D(const QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->limit;
+}
+
+/*!
+ Sets the maximum number of categories to be returned to \a limit.
+ A limit of -1 will retrieve all categories.
+
+ (A limit of 0 will retrieve no categories.)
+ */
+void QLandmarkCategoryFetchRequest::setLimit(int limit)
+{
+ Q_D(QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index offset for the request. By default the offset is 0.
+ The offset determines the first index which is retrieved, it is generally
+ used in conjunction with limit() to facilitate paging.
+
+ For example, if there are 10 categories in the landmark store, setting the offset
+ to 2 and limit to 5 will retrieve the 3rd to 7th categories inclusively. (The order of categories
+ is specified by the sorting field).
+*/
+int QLandmarkCategoryFetchRequest::offset() const
+{
+ Q_D(const QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->offset;
+}
+
+/*!
+ Sets the index \a offset for the request.
+*/
+void QLandmarkCategoryFetchRequest::setOffset(int offset) {
+ Q_D(QLandmarkCategoryFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->offset = offset;
+}
+
+#include "moc_qlandmarkcategoryfetchrequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkcategoryfetchrequest.h b/src/location/landmarks/qlandmarkcategoryfetchrequest.h
new file mode 100644
index 00000000..0b77bc11
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfetchrequest.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYFETCHREQUEST_H
+#define QLANDMARKCATEGORYFETCHREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+#include "qlandmarkcategoryid.h"
+#include "qlandmarknamesort.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryFetchRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryFetchRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkCategoryFetchRequest(QLandmarkManager *manager, QObject *parent=0);
+ ~QLandmarkCategoryFetchRequest();
+
+ QList<QLandmarkCategory> categories() const;
+
+ QLandmarkNameSort sorting() const;
+ void setSorting(const QLandmarkNameSort &nameSort);
+
+ int limit() const;
+ void setLimit(int limit);
+
+ int offset() const;
+ void setOffset(int offset);
+
+private:
+ Q_DISABLE_COPY(QLandmarkCategoryFetchRequest)
+ Q_DECLARE_PRIVATE(QLandmarkCategoryFetchRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryfilter.cpp b/src/location/landmarks/qlandmarkcategoryfilter.cpp
new file mode 100644
index 00000000..0bfeae5f
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfilter.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryfilter.h"
+#include "qlandmarkcategoryfilter_p.h"
+#include "qlandmarkcategoryid.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryFilter
+ \brief The QLandmarkCategoryFilter class is used to search for landmarks that
+ belong to a certain category.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-filter
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkCategoryFilter)
+
+/*!
+ Creates a filter that searches for landmarks that belong to the category
+ identified by \a categoryId.
+*/
+QLandmarkCategoryFilter::QLandmarkCategoryFilter(const QLandmarkCategoryId &categoryId)
+ : QLandmarkFilter(new QLandmarkCategoryFilterPrivate(categoryId))
+{
+}
+
+/*!
+ \fn QLandmarkCategoryFilter::QLandmarkCategoryFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new category filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkCategoryFilter::~QLandmarkCategoryFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Returns the category identifier that this filter matches by.
+*/
+QLandmarkCategoryId QLandmarkCategoryFilter::categoryId() const
+{
+ Q_D(const QLandmarkCategoryFilter);
+ return d->id;
+}
+
+/*!
+ Sets the category identifier that this filter matches by
+ to \a categoryId.
+*/
+void QLandmarkCategoryFilter::setCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkCategoryFilter);
+ d->id = categoryId;
+}
+
+/*!
+ Convenience function to set the \a category that this filter matches by.
+ It is equivalent to calling setCategory(category.categoryId()).
+*/
+void QLandmarkCategoryFilter::setCategory(const QLandmarkCategory &category)
+{
+ Q_D(QLandmarkCategoryFilter);
+ d->id = category.categoryId();
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkCategoryFilterPrivate::QLandmarkCategoryFilterPrivate(const QLandmarkCategoryId &id)
+ : id(id)
+{
+ type = QLandmarkFilter::CategoryFilter;
+}
+
+QLandmarkCategoryFilterPrivate::QLandmarkCategoryFilterPrivate(const QLandmarkCategoryFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ id(other.id) {}
+
+QLandmarkCategoryFilterPrivate::~QLandmarkCategoryFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkcategoryfilter.h b/src/location/landmarks/qlandmarkcategoryfilter.h
new file mode 100644
index 00000000..88df8700
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfilter.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYFILTER_H
+#define QLANDMARKCATEGORYFILTER_H
+
+#include "qlandmarkfilter.h"
+#include "qlandmarkcategoryid.h"
+#include "qlandmarkcategory.h"
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryId;
+
+class QLandmarkCategoryFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkCategoryFilter(const QLandmarkCategoryId &categoryId = QLandmarkCategoryId());
+ QLandmarkCategoryFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkCategoryFilter();
+
+ QLandmarkCategoryId categoryId() const;
+ void setCategoryId(const QLandmarkCategoryId &categoryId);
+ void setCategory(const QLandmarkCategory &category);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkCategoryFilter)
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryfilter_p.h b/src/location/landmarks/qlandmarkcategoryfilter_p.h
new file mode 100644
index 00000000..49b1b925
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryfilter_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYFILTER_P_H
+#define QLANDMARKCATEGORYFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryId;
+
+class QLandmarkCategoryFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkCategoryFilterPrivate(const QLandmarkCategoryId &id = QLandmarkCategoryId());
+ QLandmarkCategoryFilterPrivate(const QLandmarkCategoryFilterPrivate &other);
+ virtual ~QLandmarkCategoryFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate *other) const
+ {
+ const QLandmarkCategoryFilterPrivate *od = static_cast<const QLandmarkCategoryFilterPrivate*>(other);
+ return id == od->id;
+ }
+
+ QLandmarkCategoryId id;
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkCategoryFilter, QLandmarkFilter::CategoryFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryid.cpp b/src/location/landmarks/qlandmarkcategoryid.cpp
new file mode 100644
index 00000000..ba08fba6
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryid.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryid.h"
+#include "qlandmarkcategoryid_p.h"
+#include <QString>
+
+QTM_USE_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryId
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-main
+ \since 1.1
+
+ \brief The QLandmarkCategoryId class provides a unique identifier for
+ a category.
+
+ It consists of a manager URI which identifies the manager which contains
+ the category, and a manager specific local id for that category.
+*/
+
+/*!
+
+ Creates an invalid identifier.
+
+ The local id and manager URI are empty strings.
+*/
+QLandmarkCategoryId::QLandmarkCategoryId()
+ : d(new QLandmarkCategoryIdPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmarkCategoryId::QLandmarkCategoryId(const QLandmarkCategoryId &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys the identifier.
+*/
+QLandmarkCategoryId::~QLandmarkCategoryId()
+{
+}
+
+/*!
+ Returns true if the identifier is valid, meaning that both
+ a manager URI and local id have been set
+*/
+bool QLandmarkCategoryId::isValid() const
+{
+ return (!d->m_uri.isEmpty() && !d->m_localId.isEmpty());
+}
+
+/*!
+ Returns the local id of the category identifier.
+
+ This id is specific to a particular landmark manager.
+*/
+QString QLandmarkCategoryId::localId() const
+{
+ return d->m_localId;
+}
+
+/*!
+ Sets the local \a id of the category identifier.
+*/
+void QLandmarkCategoryId::setLocalId(const QString &id)
+{
+ d->m_localId = id;
+}
+
+/*!
+ Returns the URI of the manager which this category identifer
+ belongs to.
+*/
+QString QLandmarkCategoryId::managerUri() const
+{
+ return d->m_uri;
+}
+
+/*!
+ Sets the manager \a uri which this category identifier
+ belongs to.
+*/
+void QLandmarkCategoryId::setManagerUri(const QString &uri)
+{
+ d->m_uri = uri;
+}
+
+/*!
+ Assigns \a other to this category identifier and returns a reference
+ to this category identifier.
+*/
+QLandmarkCategoryId &QLandmarkCategoryId::operator=(const QLandmarkCategoryId & other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns true if this category identifer is equal to \a other, otherwise
+ returns false.
+
+ Two QLandmarkCategoryIds are considered equal if both have the same
+ manager URI and local id.
+
+ \sa operator!=()
+*/
+bool QLandmarkCategoryId::operator==(const QLandmarkCategoryId &other) const
+{
+ return ((d->m_localId == other.d->m_localId)
+ && (d->m_uri == other.d->m_uri));
+}
+
+/*!
+ Returns true if this category identifier is not equal to \a other,
+ otherwise returns false.
+
+ If either the manager URIs or local ids differ, then the
+ QLandmarkCategoryIds are not considered equal.
+
+ \sa operator==()
+*/
+bool QLandmarkCategoryId::operator!=(const QLandmarkCategoryId &other) const
+{
+ return !this->operator ==(other);
+}
diff --git a/src/location/landmarks/qlandmarkcategoryid.h b/src/location/landmarks/qlandmarkcategoryid.h
new file mode 100644
index 00000000..90e811d9
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryid.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYID_H
+#define QLANDMARKCATEGORYID_H
+
+#include "qmobilityglobal.h"
+#include <QMetaType>
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryIdPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryId
+{
+public:
+ QLandmarkCategoryId();
+ QLandmarkCategoryId(const QLandmarkCategoryId &other);
+ ~QLandmarkCategoryId();
+
+ bool isValid() const;
+ QString localId() const;
+ void setLocalId(const QString &id);
+
+ QString managerUri() const;
+ void setManagerUri(const QString &uri);
+
+ QLandmarkCategoryId &operator=(const QLandmarkCategoryId &other);
+ bool operator==(const QLandmarkCategoryId &other) const;
+ bool operator!=(const QLandmarkCategoryId &other) const;
+
+private:
+ QSharedDataPointer<QLandmarkCategoryIdPrivate> d;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkCategoryId))
+
+Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkCategoryId), Q_MOVABLE_TYPE);
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryid_p.h b/src/location/landmarks/qlandmarkcategoryid_p.h
new file mode 100644
index 00000000..0542b3e3
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryid_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYID_P_H
+#define QLANDMARKCATEGORYID_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include <QSharedData>
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryIdPrivate : public QSharedData
+{
+public:
+ QLandmarkCategoryIdPrivate()
+ : QSharedData() {
+ }
+
+ QLandmarkCategoryIdPrivate(const QLandmarkCategoryIdPrivate &other)
+ : QSharedData(other),
+ m_localId(other.m_localId),
+ m_uri(other.m_uri) {
+ }
+
+ ~QLandmarkCategoryIdPrivate() {
+ }
+
+ QString m_localId;
+ QString m_uri;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp b/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp
new file mode 100644
index 00000000..ddff967a
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryidfetchrequest.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryidfetchrequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkcategoryid.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryIdFetchRequest
+ \brief The QLandmarkCategoryIdFetchRequest class allows a client to asynchronously
+ request a list of category identifiers from a landmark manager.
+
+ For a QLandmarkCategoryIdFetchRequest, the resultsAvailable() signal will be emitted
+ as resultant category identifiers are found (these are retrievable by calling categoryIds()),
+ as well as if an overall operation error occurred(which may be retrieved by calling
+ QLandmarkAbstractRequest::error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-request
+*/
+
+/*!
+ Creates a new category identifier fetch request object with the given \a manager
+ aand \a parent.
+*/
+QLandmarkCategoryIdFetchRequest::QLandmarkCategoryIdFetchRequest(QLandmarkManager * manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkCategoryIdFetchRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkCategoryIdFetchRequest::~QLandmarkCategoryIdFetchRequest()
+{
+}
+
+/*!
+ Returns the list of category identifiers that have been found during the
+ request.
+*/
+QList<QLandmarkCategoryId> QLandmarkCategoryIdFetchRequest::categoryIds() const
+{
+ Q_D(const QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categoryIds;
+}
+
+/*!
+ Returns the sorting of the categories.
+ By default the sorting is case insensitive and in ascending order
+ according to the category name.
+*/
+QLandmarkNameSort QLandmarkCategoryIdFetchRequest::sorting() const
+{
+ Q_D(const QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->sorting;
+}
+
+/*!
+ Sets \a nameSort to specify the sorting of the returned category ids.
+*/
+void QLandmarkCategoryIdFetchRequest::setSorting(const QLandmarkNameSort &nameSort)
+{
+ Q_D(QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting = nameSort;
+}
+
+/*!
+ Returns the maximum number of category IDs to be returned. By default the limit is set to -1
+ indicating that IDs of all categories should be retrieved.
+*/
+int QLandmarkCategoryIdFetchRequest::limit() const
+{
+ Q_D(const QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->limit;
+}
+
+/*!
+ Sets the maximum number of category IDs to be returned to \a limit.
+
+ A limit of -1 indicates that IDs of all categories are to be retrieved.
+
+ (A limit of 0 will retrieve no categories.)
+ */
+void QLandmarkCategoryIdFetchRequest::setLimit(int limit)
+{
+ Q_D(QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index offset for the request. By default the offset is set to 0.
+ The offset determines the first index which is retrieved. it is generally
+ used in conjunction with limit() to facilitate paging.
+
+ For example, if there are 10 categories in the landmark store, setting the offset
+ to 2 and limit to 5 will retrieve the 3rd to 7th category ids inclusively. (The order
+ of category ids is specified by the sorting field).
+*/
+int QLandmarkCategoryIdFetchRequest::offset() const
+{
+ Q_D(const QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->offset;
+}
+
+/*!
+ Sets the index \a offset for the request.
+*/
+void QLandmarkCategoryIdFetchRequest::setOffset(int offset) {
+ Q_D(QLandmarkCategoryIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->offset = offset;
+}
+
+#include "moc_qlandmarkcategoryidfetchrequest.cpp"
+
+QTM_END_NAMESPACE
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/location/landmarks/qlandmarkcategoryidfetchrequest.h b/src/location/landmarks/qlandmarkcategoryidfetchrequest.h
new file mode 100644
index 00000000..b1615ae8
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryidfetchrequest.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYIDFETCHREQUEST_H
+#define QLANDMARKCATEGORYIDFETCHREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+#include "qlandmarknamesort.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryIdFetchRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryIdFetchRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkCategoryIdFetchRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkCategoryIdFetchRequest();
+
+ QList<QLandmarkCategoryId> categoryIds() const;
+
+ void setSorting(const QLandmarkNameSort &nameSort);
+ QLandmarkNameSort sorting() const;
+
+ int limit() const;
+ void setLimit(int limit);
+
+ int offset() const;
+ void setOffset(int offset);
+
+private:
+ Q_DISABLE_COPY(QLandmarkCategoryIdFetchRequest)
+ Q_DECLARE_PRIVATE(QLandmarkCategoryIdFetchRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkcategoryremoverequest.cpp b/src/location/landmarks/qlandmarkcategoryremoverequest.cpp
new file mode 100644
index 00000000..a310b109
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryremoverequest.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategoryremoverequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkcategoryid.h"
+#include <QMap>
+
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategoryRemoveRequest
+ \brief The QLandmarkCategoryRemoveRequest class allows a client to asynchronously
+ request that certain categories be removed from a landmark manager.
+
+ For a QLandmarkCategoryRemoveRequest, the resultsAvailable() signal will be emitted
+ when either an individual items error out (individaul errors may be retrieved
+ by calling errorMap()) or an overall operation error occurs(which may be
+ retrieved by calling QLandmarkAbstractRequest::error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Constructs a category remove request with the given \a manager and \a parent.
+*/
+QLandmarkCategoryRemoveRequest::QLandmarkCategoryRemoveRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkCategoryRemoveRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkCategoryRemoveRequest::~QLandmarkCategoryRemoveRequest()
+{
+}
+
+/*!
+ Returns the list of identifiers of categories which will be removed.
+*/
+QList<QLandmarkCategoryId> QLandmarkCategoryRemoveRequest::categoryIds() const
+{
+ Q_D(const QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categoryIds;
+}
+
+/*!
+ Sets the list of \a categoryIds of categories which will be removed.
+
+ \sa setCategories(), setCategoryId()
+*/
+void QLandmarkCategoryRemoveRequest::setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds)
+{
+ Q_D(QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds = categoryIds;
+}
+
+/*!
+ Convenience function to set the \a categoryId of a single category to be removed.
+ It is the equivalent of calling setCategoryIds() with a single \a categoryId
+ in the ID list.
+
+ \sa setCategory(), setCategoryIds()
+*/
+void QLandmarkCategoryRemoveRequest::setCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds.clear();
+ d->categoryIds.append(categoryId);
+}
+
+/*!
+ Convenience function to set the list of \a categories which will be removed.
+ This function effectively calls setCategoryIds() with the IDs of the
+ \a categories.
+
+ \sa setCategory(), setCategoryIds()
+*/
+void QLandmarkCategoryRemoveRequest::setCategories(const QList<QLandmarkCategory> &categories)
+{
+ Q_D(QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds.clear();
+ for (int i=0; i < categories.count(); ++i)
+ d->categoryIds.append(categories.at(i).categoryId());
+}
+
+/*!
+ Convenience function that sets a single \a category to be removed.
+ This function effectively calls setCategoryIds() with the ID of \a category.
+
+ \sa setCategories(), setCategoryId()
+*/
+void QLandmarkCategoryRemoveRequest::setCategory(const QLandmarkCategory &category)
+{
+ Q_D(QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryIds.clear();
+ d->categoryIds.append(category.categoryId());
+}
+
+/*!
+ Returns the mapping of input category ID list indices
+ to the errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkCategoryRemoveRequest::errorMap() const
+{
+ Q_D(const QLandmarkCategoryRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarkcategoryremoverequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkcategoryremoverequest.h b/src/location/landmarks/qlandmarkcategoryremoverequest.h
new file mode 100644
index 00000000..ef571ee0
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategoryremoverequest.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYREMOVEREQUEST_H
+#define QLANDMARKCATEGORYREMOVEREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategoryRemoveRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategoryRemoveRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkCategoryRemoveRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkCategoryRemoveRequest();
+
+ QList<QLandmarkCategoryId> categoryIds() const;
+ void setCategoryIds(const QList<QLandmarkCategoryId> &categoryIds);
+ void setCategoryId(const QLandmarkCategoryId &categoryId);
+
+ void setCategories(const QList<QLandmarkCategory> &categories);
+ void setCategory(const QLandmarkCategory &category);
+
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+private:
+ Q_DISABLE_COPY(QLandmarkCategoryRemoveRequest)
+ Q_DECLARE_PRIVATE(QLandmarkCategoryRemoveRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkcategorysaverequest.cpp b/src/location/landmarks/qlandmarkcategorysaverequest.cpp
new file mode 100644
index 00000000..3e27fb64
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategorysaverequest.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkcategorysaverequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkcategory.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkCategorySaveRequest
+ \brief The QLandmarkCategorySaveRequest class allows a client to asynchronously
+ request that certain categories be saved by a landmark manager.
+
+ For a QLandmarkCategorySaveRequest, the resultsAvailable() signal will be emitted
+ when either an individual items error out (individaul errors may be retrieved
+ by calling errorMap()), or an overall operation error occurs(which may be
+ retrieved by calling error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Constructs a category save request with the given \a manager and \a parent.
+*/
+QLandmarkCategorySaveRequest::QLandmarkCategorySaveRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkCategorySaveRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkCategorySaveRequest::~QLandmarkCategorySaveRequest()
+{
+}
+
+/*!
+ Returns the list of categories to be saved. If called after the save operation has
+ finished, any new categories saved will have had their QLandmarkCategoryId set.
+ (Categories which were updated or failed to save will remain unchanged, use the
+ errorMap() function to determine which particular categories failed to save.)
+*/
+QList<QLandmarkCategory> QLandmarkCategorySaveRequest::categories() const
+{
+ Q_D(const QLandmarkCategorySaveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categories;
+}
+
+/*!
+ Sets the list of \a categories to be saved.
+ \sa setCategory()
+*/
+void QLandmarkCategorySaveRequest::setCategories(const QList<QLandmarkCategory> &categories)
+{
+ Q_D(QLandmarkCategorySaveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categories = categories;
+}
+
+/*!
+ Convenience function to set a single \a category to be saved. This function
+ is the equivalent of calling setCategories() with a single \a category.
+
+ \sa setCategories()
+*/
+void QLandmarkCategorySaveRequest::setCategory(const QLandmarkCategory& category)
+{
+ Q_D(QLandmarkCategorySaveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categories.clear();
+ d->categories.append(category);
+}
+
+/*!
+ Returns the mapping of the input category list indices to the
+ errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkCategorySaveRequest::errorMap() const
+{
+ Q_D(const QLandmarkCategorySaveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarkcategorysaverequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkcategorysaverequest.h b/src/location/landmarks/qlandmarkcategorysaverequest.h
new file mode 100644
index 00000000..8a508f9c
--- /dev/null
+++ b/src/location/landmarks/qlandmarkcategorysaverequest.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKCATEGORYSAVEREQUEST_H
+#define QLANDMARKCATEGORYSAVEREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkCategory;
+
+class QLandmarkCategorySaveRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkCategorySaveRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkCategorySaveRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkCategorySaveRequest();
+
+ QList<QLandmarkCategory> categories() const;
+ void setCategories(const QList<QLandmarkCategory> &categories);
+ void setCategory(const QLandmarkCategory &category);
+
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+private:
+ Q_DISABLE_COPY(QLandmarkCategorySaveRequest)
+ Q_DECLARE_PRIVATE(QLandmarkCategorySaveRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkexportrequest.cpp b/src/location/landmarks/qlandmarkexportrequest.cpp
new file mode 100644
index 00000000..025f0a22
--- /dev/null
+++ b/src/location/landmarks/qlandmarkexportrequest.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkexportrequest.h"
+#include "qlandmarkrequests_p.h"
+#include <QIODevice>
+#include <QFile>
+
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkExportRequest
+ \brief The QLandmarkExportRequest class allows a client to asynchronously
+ request that a landmark manager export a set of landmarks.
+
+ For a QLandmarkExportRequest, the QLandmarkAbstractRequest::stateChanged()
+ signal will be emitted when the request is complete. The resultsAvailable() signal
+ will be emitted if an overall operational error occurs.
+
+ If no landmarks identifiers are set using setLandmarkIds() or
+ an empty list is passed in, then all the landmarks will be exported.
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Constructs a landmark export request with the given \a manager and \a parent.
+*/
+QLandmarkExportRequest::QLandmarkExportRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkExportRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkExportRequest::~QLandmarkExportRequest()
+{
+}
+
+/*!
+ Returns the device to which landmarks are written.
+*/
+QIODevice *QLandmarkExportRequest::device() const
+{
+ Q_D(const QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->device;
+}
+
+/*!
+ Sets the \a device to which landmarks are written.
+*/
+void QLandmarkExportRequest::setDevice(QIODevice *device)
+{
+ Q_D(QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->device = device;
+}
+
+/*!
+ If the currently assigned device is a QFile, or if setFileName() has
+ been called, this function returns the name of the file to be
+ written to. In all other cases, it returns an empty string.
+
+ \sa setFileName(), setDevice()
+*/
+QString QLandmarkExportRequest::fileName() const
+{
+ Q_D(const QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ QFile *file = qobject_cast<QFile *>(d->device);
+ return file ? file->fileName() : QString();
+}
+
+/*!
+ Sets the name of the file to be written to \a fileName. Internally,
+ QLandmarkExportRequest will create a QFile use this as the
+ device to export to.
+
+ \sa fileName(), setDevice()
+*/
+void QLandmarkExportRequest::setFileName(const QString &fileName)
+{
+ Q_D(QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->device = new QFile(fileName);
+}
+
+/*!
+ Returns the data format for the export operation.
+*/
+QString QLandmarkExportRequest::format() const
+{
+ Q_D(const QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->format;
+}
+
+/*!
+ Sets the data \a format for the export operation.
+*/
+void QLandmarkExportRequest::setFormat(const QString &format)
+{
+ Q_D(QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->format = format;
+}
+
+/*!
+ Returns the transfer option of the export request.
+ The transfer option defines how categories are treated
+ during the export operation. The default option is
+ QLandmarkManager::IncludeCategoryData.
+
+*/
+QLandmarkManager::TransferOption QLandmarkExportRequest::transferOption() const
+{
+ Q_D(const QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->option;
+}
+
+/*!
+ Sets the transfer \a option of the export request.
+ The transfer \a option defines how categories are treated
+ during the export operation.
+*/
+void QLandmarkExportRequest::setTransferOption(QLandmarkManager::TransferOption option)
+{
+ Q_D(QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->option = option;
+}
+
+/*!
+ Returns the list of identifiers of landmarks that will be exported.
+ By default the list of identifiers is empty, indicating that all
+ landmarks should be exported.
+*/
+QList<QLandmarkId> QLandmarkExportRequest::landmarkIds() const
+{
+ Q_D(const QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarkIds;
+}
+
+/*!
+ Sets the landmarks to be exported by specifying a list of
+ \a landmarkIds.
+*/
+void QLandmarkExportRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds)
+{
+ Q_D(QLandmarkExportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds = landmarkIds;
+}
+
+#include "moc_qlandmarkexportrequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkexportrequest.h b/src/location/landmarks/qlandmarkexportrequest.h
new file mode 100644
index 00000000..cfaa544d
--- /dev/null
+++ b/src/location/landmarks/qlandmarkexportrequest.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKEXPORTREQUEST_H
+#define QLANDMARKEXPORTREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+class QIODevice;
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkExportRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkExportRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkExportRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkExportRequest();
+
+ QIODevice *device() const;
+ void setDevice(QIODevice *device);
+
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ QString format() const;
+ void setFormat(const QString &format);
+
+ QLandmarkManager::TransferOption transferOption() const;
+ void setTransferOption(QLandmarkManager::TransferOption option);
+
+ QList<QLandmarkId> landmarkIds() const;
+ void setLandmarkIds(const QList<QLandmarkId> &landmarkIds);
+private:
+ Q_DISABLE_COPY(QLandmarkExportRequest)
+ Q_DECLARE_PRIVATE(QLandmarkExportRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkfetchbyidrequest.cpp b/src/location/landmarks/qlandmarkfetchbyidrequest.cpp
new file mode 100644
index 00000000..5a6c88dc
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfetchbyidrequest.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkfetchbyidrequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmark.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkFetchByIdRequest
+ \brief The QLandmarkFetchByIdRequest class allows a client to asynchronously
+ request a list of landmarks by id from a landmark manager.
+
+ For a QLandmarkFetchByIdRequest, the resultsAvailable() signal will be emitted when the resultant
+ landmarks (which may be retrieved by calling landmarks()) are updated,
+ whenever indiviual items error out(individual errors may be retrieved by
+ calling errorMap()), or when an overall operation error occurs(which may be
+ retrieved by calling error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Creates a new request object with the given \a manager \a parent.
+*/
+QLandmarkFetchByIdRequest::QLandmarkFetchByIdRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkFetchByIdRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkFetchByIdRequest::~QLandmarkFetchByIdRequest()
+{
+}
+
+/*!
+ Returns a list of identifiers of landmarks which are to be retrieved by this request.
+*/
+QList<QLandmarkId> QLandmarkFetchByIdRequest::landmarkIds() const
+{
+ Q_D(const QLandmarkFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarkIds;
+}
+
+/*!
+ Sets the \a landmarkIds to be retrieved by this request.
+*/
+void QLandmarkFetchByIdRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds)
+{
+ Q_D(QLandmarkFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds = landmarkIds;
+}
+
+/*!
+ Convenience function that sets a single landmark, specified by \a landmarkId,
+ to be retrieved by this request.
+
+*/
+void QLandmarkFetchByIdRequest::setLandmarkId(const QLandmarkId &landmarkId)
+{
+ Q_D(QLandmarkFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds.clear();
+ d->landmarkIds.append(landmarkId);
+}
+
+/*!
+ Returns the list of landmarks fetched by this request.
+
+*/
+QList<QLandmark> QLandmarkFetchByIdRequest::landmarks() const
+{
+ Q_D(const QLandmarkFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarks;
+}
+
+/*!
+ Returns the mapping of input landmark ID list indices
+ to the errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkFetchByIdRequest::errorMap() const
+{
+ Q_D(const QLandmarkFetchByIdRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarkfetchbyidrequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkfetchbyidrequest.h b/src/location/landmarks/qlandmarkfetchbyidrequest.h
new file mode 100644
index 00000000..ec745aab
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfetchbyidrequest.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKFETCHBYIDREQUEST_H
+#define QLANDMARKFETCHBYIDREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkFetchByIdRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkFetchByIdRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkFetchByIdRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkFetchByIdRequest();
+
+ QList<QLandmarkId> landmarkIds() const;
+ void setLandmarkIds(const QList<QLandmarkId> &ids);
+ void setLandmarkId(const QLandmarkId &id);
+
+ QList<QLandmark> landmarks() const;
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+private:
+ Q_DISABLE_COPY(QLandmarkFetchByIdRequest)
+ Q_DECLARE_PRIVATE(QLandmarkFetchByIdRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkfetchrequest.cpp b/src/location/landmarks/qlandmarkfetchrequest.cpp
new file mode 100644
index 00000000..3e8c7d5a
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfetchrequest.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkfetchrequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmarkfilter.h"
+#include "qlandmarkidfilter.h"
+#include "qlandmarksortorder.h"
+#include "qlandmark.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkFetchRequest
+ \brief The QLandmarkFetchRequest class allows a client to asynchronously
+ request a list of landmarks from a landmark manager.
+
+ For a QLandmarkFetchRequest, the resultsAvailable() signal will be emitted when the resultant
+ landmarks (which may be retrieved by calling landmarks()) are updated, as well as if
+ the overall operation error (which may be retrieved by calling error()) is updated.
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Creates a new landmark fetch request object with the given \a manager \a parent.
+*/
+QLandmarkFetchRequest::QLandmarkFetchRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkFetchRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkFetchRequest::~QLandmarkFetchRequest()
+{
+}
+
+/*!
+ Returns the filter which will be used to select the landmarks.
+
+ By default, the filter's type will be a QLandmarkFilter::DefaultFilter
+ and thus match all landmarks.
+*/
+QLandmarkFilter QLandmarkFetchRequest::filter() const
+{
+ Q_D(const QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->filter;
+}
+
+/*!
+ Sets the \a filter which will be used to select landmarks.
+*/
+void QLandmarkFetchRequest::setFilter(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->filter = filter;
+}
+
+/*!
+ Returns the sort ordering which is used to sort the result. By default
+ the sort order list is empty, thus no sorting will take place.
+*/
+QList<QLandmarkSortOrder> QLandmarkFetchRequest::sorting() const
+{
+ Q_D(const QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->sorting;
+}
+
+/*!
+ Sets the sort ordering of the request to \a sorting. This
+ function will only have an effect on the results if invoked
+ prior to calling \l QLandmarkAbstractRequest::start().
+*/
+void QLandmarkFetchRequest::setSorting(const QList<QLandmarkSortOrder> &sorting)
+{
+ Q_D(QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting = sorting;
+}
+
+/*!
+ Convenience function which sets the sort ordering of the request to a single \a sorting. This function
+ will only have an effect on results if invoked prior to calling
+ \l QLandmarkAbstractRequest::start().
+*/
+void QLandmarkFetchRequest::setSorting(const QLandmarkSortOrder &sorting)
+{
+ Q_D(QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting.clear();
+ d->sorting.append(sorting);
+}
+
+/*!
+ Returns the maximum number of landmarks to be returned. By default the limit
+ is -1 indicating that all landmarks matching the filter sould be retrieved.
+*/
+int QLandmarkFetchRequest::limit() const
+{
+ Q_D(const QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->limit;
+}
+
+/*!
+ Sets the maximum number of landmarks to be returned to \a limit.
+
+ A limit of -1 will retrieve all landmarks that match the filter.
+
+ (A limit of 0 will retrieve no landmarks.)
+ */
+void QLandmarkFetchRequest::setLimit(int limit)
+{
+ Q_D(QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index offset for the request. By default the offset is set to 0.
+ The offset determines the first index which is retrieved, it is generally
+ used in conjunction with limit() to facilitate paging.
+
+ For example, if there are 10 landmarks in the landmark store, setting the offset
+ to 2 and limit to 5 will retrieve the 3rd to 7th landmarks inclusively. (The order
+ of the landmarks is specified by the sorting field).
+*/
+int QLandmarkFetchRequest::offset() const
+{
+ Q_D(const QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->offset;
+}
+
+/*!
+ Sets the index \a offset for the request.
+*/
+void QLandmarkFetchRequest::setOffset(int offset) {
+ Q_D(QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->offset = offset;
+}
+
+/*!
+ Returns the list of landmarks which matched the
+ filter.
+*/
+QList<QLandmark> QLandmarkFetchRequest::landmarks() const
+{
+ Q_D(const QLandmarkFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarks;
+}
+
+#include "moc_qlandmarkfetchrequest.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkfetchrequest.h b/src/location/landmarks/qlandmarkfetchrequest.h
new file mode 100644
index 00000000..5a996217
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfetchrequest.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKFETCHREQUEST_H
+#define QLANDMARKFETCHREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkFetchRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkFetchRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkFetchRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkFetchRequest();
+
+ QLandmarkFilter filter() const;
+ void setFilter(const QLandmarkFilter &filter);
+
+ QList<QLandmarkSortOrder> sorting() const;
+ void setSorting(const QList<QLandmarkSortOrder> &sorting);
+ void setSorting(const QLandmarkSortOrder &sorting);
+
+ int limit() const;
+ void setLimit(int limit);
+
+ int offset() const;
+ void setOffset(int offset);
+
+ QList<QLandmark> landmarks() const;
+private:
+ Q_DISABLE_COPY(QLandmarkFetchRequest)
+ Q_DECLARE_PRIVATE(QLandmarkFetchRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkfilter.cpp b/src/location/landmarks/qlandmarkfilter.cpp
new file mode 100644
index 00000000..9e5566a0
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfilter.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkfilter.h"
+#include "qlandmarkfilter_p.h"
+
+#include "qlandmarkintersectionfilter.h"
+#include "qlandmarkunionfilter.h"
+
+#include "qlandmarkcategoryid.h"
+#include "qlandmarkid.h"
+#include "qgeocoordinate.h"
+
+#if !defined(Q_CC_MWERKS)
+template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone()
+{
+ return d->clone();
+}
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+QLandmarkFilterPrivate::QLandmarkFilterPrivate()
+ : QSharedData(),
+ type(QLandmarkFilter::DefaultFilter)
+{
+}
+
+QLandmarkFilterPrivate::QLandmarkFilterPrivate(const QLandmarkFilterPrivate &other)
+ : QSharedData(),
+ type(other.type)
+{
+}
+
+QLandmarkFilterPrivate::~QLandmarkFilterPrivate()
+{
+}
+
+/*!
+ \class QLandmarkFilter
+ \brief The QLandmarkFilter class serves as the base class for all filter classes.
+ Also serves as the default filter which retrieves all landmarks.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ This class is used as a parameter to search for landmarks, it allows selection of
+ landmarks which meet certain criteria. It is used with QLandmarkManager
+ for synchronous searches or the appropriate request classes for asynchronous
+ searches.
+
+ The QLandmarkFilter is primarily intended to serve as the base class
+ for all filter types. However it also has the type of a QLandmark::DefaultFilter,
+ and may thus be used as a filter to match all landmarks.
+
+*/
+
+/*!
+ \enum QLandmarkFilter::FilterType
+ Describes the type of the filter
+ \value InvalidFilter An invalid filter which matches nothing
+ \value DefaultFilter A filter which matches all landmarks.
+ \value IntersectionFilter A filter which performs an AND operation with its
+ constituent filters
+ \value UnionFilter A filter which performs an OR operation with its constiuent filters.
+ \value NameFilter A filter which matches landmarks based on name
+ \value ProximityFilter A filter which matches landmarks within a certain range of a given
+ coordinate.
+ \value CategoryFilter A filter which matches landmarks that belong to a given category
+ \value BoxFilter A filter which matches landmarks within a given bounding box.
+ \value AttributeFilter A filter which matches landmarks based on generic attributes.
+ \value LandmarkIdFilter A filter which matches landmarks based on a list of landmark ids.
+*/
+
+/*!
+ \enum QLandmarkFilter::MatchFlag
+ Describes the semantics of matching followed by the filter.
+ \value MatchExactly Performs QVariant-based matching. (For the Symbian and S60 platforms MatchExactly has the same semantics as MatchFixedString)
+ \value MatchContains The search term is contained in the item. (For the Symbian and S60 platforms, MatchContains is not supported)
+ \value MatchStartsWith The search term matches the start of the item.
+ \value MatchEndsWith The search term matches the end of the item.
+ \value MatchFixedString Performs string-based matching. String-based comparisons are case-insensitive unless the MatchCaseSensitive flag is also specified.
+ \value MatchCaseSensitive The search is case sensitive.
+*/
+
+/*!
+ Constructs an default landmark filter.
+*/
+QLandmarkFilter::QLandmarkFilter()
+ : d_ptr(new QLandmarkFilterPrivate)
+{
+}
+/*!
+ \internal
+*/
+QLandmarkFilter::QLandmarkFilter(QLandmarkFilterPrivate *dd)
+ : d_ptr(dd)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmarkFilter::QLandmarkFilter(const QLandmarkFilter &other)
+ : d_ptr(other.d_ptr)
+{
+}
+
+/*!
+ Assigns \a other to this filter and returns a reference to this filter.
+*/
+QLandmarkFilter &QLandmarkFilter::operator=(const QLandmarkFilter & other)
+{
+ if (this != &other)
+ d_ptr = (other.d_ptr);
+ return *this;
+}
+
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkFilter::~QLandmarkFilter()
+{
+}
+
+/*!
+ Returns the type of the filter.
+*/
+QLandmarkFilter::FilterType QLandmarkFilter::type() const
+{
+ return d_ptr->type;
+}
+
+/*!
+ \fn QLandmarkFilter::operator!=(const QLandmarkFilter &other) const
+ Returns true if this filter is not identical to \a other.
+
+ \sa operator==()
+*/
+
+/*!
+ Returns true if the filter has the same type and criteria as \a other.
+ \sa operator!=()
+*/
+bool QLandmarkFilter::operator==(const QLandmarkFilter& other) const
+{
+ /* Different types can't be equal */
+ if (other.type() != type())
+ return false;
+
+ /* Otherwise, use the virtual op == */
+ return d_ptr->compare(other.d_ptr);
+}
+
+/*!
+ \relates QLandmarkFilter
+ Returns a filter which is the intersection of the \a left and \a right filters
+ \sa QLandmarkIntersectionFilter
+ */
+const QLandmarkFilter operator&(const QLandmarkFilter &left, const QLandmarkFilter &right)
+{
+ /* TODO implement better handling when left or right is an intersection filter */
+
+ /* usual fallback case */
+
+ QLandmarkIntersectionFilter nif;
+ nif << left << right;
+ return nif;
+}
+
+/*!
+ \relates QLandmarkFilter
+ Returns a filter which is the union of the \a left and \a right filters
+ \sa QLandmarkUnionFilter
+ */
+const QLandmarkFilter operator|(const QLandmarkFilter &left, const QLandmarkFilter &right)
+{
+ /* TODO implement better handling when left or right is a union filter */
+ /* usual fallback case */
+
+ QLandmarkUnionFilter nuf;
+ nuf << left << right;
+ return nuf;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkfilter.h b/src/location/landmarks/qlandmarkfilter.h
new file mode 100644
index 00000000..29059569
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfilter.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKFILTER_H
+#define QLANDMARKFILTER_H
+
+#include "qmobilityglobal.h"
+#include <QSharedData>
+#include <Qt>
+
+QTM_BEGIN_NAMESPACE
+
+#define Q_DECLARE_LANDMARKFILTER_PRIVATE(Class) \
+ inline Class##Private* d_func(); \
+ inline const Class##Private* d_func() const; \
+ friend class Class##Private;
+
+class QLandmarkFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkFilter
+{
+
+friend class QLandmarkFilterPrivate;
+
+public:
+ enum FilterType {InvalidFilter, DefaultFilter,
+ NameFilter, ProximityFilter,
+ CategoryFilter, BoxFilter, IntersectionFilter,
+ UnionFilter, AttributeFilter,
+ LandmarkIdFilter
+ };
+
+ enum MatchFlag {
+ MatchExactly = Qt::MatchExactly, //0
+ MatchContains = Qt::MatchContains, //1
+ MatchStartsWith = Qt::MatchStartsWith, //2
+ MatchEndsWith = Qt::MatchEndsWith, //3
+ MatchFixedString = Qt::MatchFixedString, //8
+ MatchCaseSensitive = Qt::MatchCaseSensitive //16
+ };
+
+ Q_DECLARE_FLAGS(MatchFlags, MatchFlag)
+
+ QLandmarkFilter();
+ QLandmarkFilter(const QLandmarkFilter &other);
+ QLandmarkFilter &operator=(const QLandmarkFilter &other);
+ virtual ~QLandmarkFilter();
+
+ FilterType type() const;
+
+ bool operator==(const QLandmarkFilter &other) const;
+ bool operator!=(const QLandmarkFilter &other) const {
+ return !(*this == other);
+ }
+
+protected:
+ QLandmarkFilter(QLandmarkFilterPrivate *dd);
+ QSharedDataPointer<QLandmarkFilterPrivate> d_ptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QLandmarkFilter::MatchFlags);
+
+const Q_LOCATION_EXPORT QLandmarkFilter operator&(const QLandmarkFilter &left, const QLandmarkFilter &right);
+const Q_LOCATION_EXPORT QLandmarkFilter operator|(const QLandmarkFilter &left, const QLandmarkFilter &right);
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkFilter), Q_MOVABLE_TYPE);
+
+
+#endif
diff --git a/src/location/landmarks/qlandmarkfilter_p.h b/src/location/landmarks/qlandmarkfilter_p.h
new file mode 100644
index 00000000..a1780c1b
--- /dev/null
+++ b/src/location/landmarks/qlandmarkfilter_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKFILTER_P_H
+#define QLANDMARKFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter.h"
+#include <QSharedData>
+
+#define Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(Class) \
+ Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
+ const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \
+ Class::Class(const QLandmarkFilter& other) : QLandmarkFilter() { Class##Private::copyIfPossible(d_ptr, other); }
+
+#define Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(Class, Type) \
+ virtual QLandmarkFilterPrivate* clone() const { return new Class##Private(*this); } \
+ static void copyIfPossible(QSharedDataPointer<QLandmarkFilterPrivate>& d_ptr, const QLandmarkFilter& other) \
+ { \
+ if (other.type() == Type) \
+ d_ptr = extract_d(other); \
+ else \
+ d_ptr = new Class##Private(); \
+ }
+
+QTM_BEGIN_NAMESPACE
+class QLandmarkFilterPrivate : public QSharedData
+{
+public:
+ QLandmarkFilterPrivate();
+ QLandmarkFilterPrivate(const QLandmarkFilterPrivate &other);
+ virtual ~QLandmarkFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate* other) const {
+ return type == other->type;
+ }
+
+ /* Helper functions for C++ protection rules */
+ static const QSharedDataPointer<QLandmarkFilterPrivate>& extract_d(const QLandmarkFilter& other) {return other.d_ptr;}
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkFilter, QLandmarkFilter::DefaultFilter)
+
+ QLandmarkFilter::FilterType type;
+};
+
+QTM_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+#if defined(Q_CC_MWERKS)
+// This results in multiple symbol definition errors on all other compilers
+// but not having a definition here results in an attempt to use the unspecialized
+// clone (which fails because of the pure virtuals above)
+template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone()
+{
+ return d->clone();
+}
+#else
+template<> QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkFilterPrivate)>::clone();
+#endif
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkid.cpp b/src/location/landmarks/qlandmarkid.cpp
new file mode 100644
index 00000000..f857a3b4
--- /dev/null
+++ b/src/location/landmarks/qlandmarkid.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkid.h"
+#include "qlandmarkid_p.h"
+#include <QString>
+
+QTM_USE_NAMESPACE
+
+/*!
+ \class QLandmarkId
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-main
+ \since 1.1
+
+ \brief The QLandmarkId class provides a unique identifier for
+ a landmark.
+
+ It consists of a manager URI which identifies the manager which contains
+ the landmark, and a manager specific local id for that landmark.
+*/
+
+/*!
+
+ Creates an invalid identifier.
+
+ The local id and manager uri are empty strings.
+*/
+QLandmarkId::QLandmarkId()
+ : d(new QLandmarkIdPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmarkId::QLandmarkId(const QLandmarkId &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys the identifier.
+*/
+QLandmarkId::~QLandmarkId()
+{
+}
+
+/*!
+ Returns true if the identifier is valid, meaning that both
+ a manager URI and local id have been set.
+*/
+bool QLandmarkId::isValid() const
+{
+ return (!d->m_uri.isEmpty() && !d->m_localId.isEmpty());
+}
+
+/*!
+ Returns the local id of the landmark identifier.
+
+ This id is specific to a particular landmark manager.
+*/
+QString QLandmarkId::localId() const
+{
+ return d->m_localId;
+}
+
+/*!
+ Sets the local \a id of the landmark identifier.
+*/
+void QLandmarkId::setLocalId(const QString &id)
+{
+ d->m_localId = id;
+}
+
+/*!
+ Returns the URI of the manager which this landmark identifer
+ belongs to.
+*/
+QString QLandmarkId::managerUri() const
+{
+ return d->m_uri;
+}
+
+/*!
+ Sets the manager \a uri which this landmark identifier
+ belongs to.
+*/
+void QLandmarkId::setManagerUri(const QString &uri)
+{
+ d->m_uri = uri;
+}
+
+/*!
+ Assigns \a other to this landmark identifier and returns a reference
+ to this landmark identifier.
+*/
+QLandmarkId &QLandmarkId::operator=(const QLandmarkId & other)
+{
+ if (this != &other)
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns true if this landmark identifer is equal to \a other, otherwise
+ returns false.
+
+ Two QLandmarkIds are considered equal if both have the same
+ manager URI and local id.
+
+ \sa operator!=()
+*/
+bool QLandmarkId::operator==(const QLandmarkId &other) const
+{
+ return ((d->m_localId == other.d->m_localId)
+ && (d->m_uri == other.d->m_uri));
+}
+
+/*!
+ Returns true if this landmark identifier is not equal to \a other,
+ otherwise returns false.
+
+ If either the manager URIs or local ids differ, then the
+ QLandmarkIds are not considered equal.
+
+ \sa operator==()
+*/
+bool QLandmarkId::operator!=(const QLandmarkId &other) const
+{
+ return !this->operator ==(other);
+}
+
+
diff --git a/src/location/landmarks/qlandmarkid.h b/src/location/landmarks/qlandmarkid.h
new file mode 100644
index 00000000..248bec23
--- /dev/null
+++ b/src/location/landmarks/qlandmarkid.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKID_H
+#define QLANDMARKID_H
+
+#include "qmobilityglobal.h"
+#include <QMetaType>
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdPrivate;
+class Q_LOCATION_EXPORT QLandmarkId
+{
+public:
+ QLandmarkId();
+ QLandmarkId(const QLandmarkId &other);
+ ~QLandmarkId();
+
+ bool isValid() const;
+ void setLocalId(const QString &id);
+ QString localId() const;
+
+ QString managerUri() const;
+ void setManagerUri(const QString &managerUri);
+
+ QLandmarkId &operator=(const QLandmarkId &other);
+ bool operator==(const QLandmarkId &other) const;
+ bool operator!=(const QLandmarkId &other) const;
+private:
+ QSharedDataPointer<QLandmarkIdPrivate> d;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QLandmarkId))
+
+Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QLandmarkId), Q_MOVABLE_TYPE);
+
+#endif
diff --git a/src/location/landmarks/qlandmarkid_p.h b/src/location/landmarks/qlandmarkid_p.h
new file mode 100644
index 00000000..de4345b7
--- /dev/null
+++ b/src/location/landmarks/qlandmarkid_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKID_P_H
+#define QLANDMARKID_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include <QSharedData>
+#include <QString>
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdPrivate : public QSharedData
+{
+public:
+ QLandmarkIdPrivate()
+ : QSharedData(),
+ m_localId(QString()),
+ m_uri(QString()){
+ }
+
+ QLandmarkIdPrivate(const QLandmarkIdPrivate &other)
+ : QSharedData(other),
+ m_localId(other.m_localId),
+ m_uri(other.m_uri) {
+ }
+
+ ~QLandmarkIdPrivate() {
+ }
+
+ QString m_localId;
+ QString m_uri;
+};
+
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkidfetchrequest.cpp b/src/location/landmarks/qlandmarkidfetchrequest.cpp
new file mode 100644
index 00000000..5353d403
--- /dev/null
+++ b/src/location/landmarks/qlandmarkidfetchrequest.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkidfetchrequest.h"
+#include "qlandmarkfilter.h"
+#include "qlandmarksortorder.h"
+#include "qlandmarkrequests_p.h"
+
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkIdFetchRequest
+ \brief The QLandmarkIdFetchRequest class allows a client to asynchronously
+ request a list of landmark identifiers from a landmark manager.
+
+ For a QLandmarkIdFetchRequest, the resultsAvailable() signal will be emitted when the resultant
+ identifiers (which may be retrieved by calling landmarkIds()), are updated, as well as if
+ the overall operation error (which may be retrieved by calling error()) is updated.
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-request
+*/
+
+/*!
+ Creates a new landmark id fetch request object with the given \a manager and \a parent.
+*/
+QLandmarkIdFetchRequest::QLandmarkIdFetchRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkIdFetchRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkIdFetchRequest::~QLandmarkIdFetchRequest()
+{
+}
+
+/*!
+ Returns the filter which will be used to select the landmarks whose identifiers
+ will be returned.
+
+ By default, the filter's type will be a QLandmarkFilter::DefaultFilter
+ and thus match all landmarks.
+*/
+QLandmarkFilter QLandmarkIdFetchRequest::filter() const
+{
+ Q_D(const QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->filter;
+}
+
+/*!
+ Sets the \a filter which will be used to select landmark identifiers.
+
+*/
+void QLandmarkIdFetchRequest::setFilter(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->filter = filter;
+}
+
+/*!
+ Returns the sort ordering which is used to sort the result. By default the
+ sort order list is empty, thus no sorting will take place.
+*/
+QList<QLandmarkSortOrder> QLandmarkIdFetchRequest::sorting() const
+{
+ Q_D(const QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->sorting;
+}
+
+/*!
+ Sets the sort ordering of the request to \a sorting. This
+ function will only have an effect on the results if invoked
+ prior to calling QLandmarkAbstractRequest::start().
+*/
+void QLandmarkIdFetchRequest::setSorting(const QList<QLandmarkSortOrder> &sorting)
+{
+ Q_D(QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting = sorting;
+}
+
+/*!
+ Convenience function to set the sort ordering of the request to a single \a sorting. This
+ function will only have an effect on the results if invoked
+ prior to calling QLandmarkAbstractRequest::start().
+*/
+void QLandmarkIdFetchRequest::setSorting(const QLandmarkSortOrder &sorting)
+{
+ Q_D(QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->sorting.clear();
+ d->sorting.append(sorting);
+}
+
+/*!
+ Returns the maximum number of landmark IDs to be returned. By default
+ the limit is set to -1 indicating that IDs of all landmarks are to be retrieved.
+*/
+int QLandmarkIdFetchRequest::limit() const
+{
+ Q_D(const QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->limit;
+}
+
+/*!
+ Sets the maximum number of landmarks to be returned to \a limit.
+
+ A limit of -1 indicates that IDs of all landmarks are to be retrieved.
+
+ (A limit of 0 will retrieve no landmark IDs.)
+ */
+void QLandmarkIdFetchRequest::setLimit(int limit)
+{
+ Q_D(QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index offset for the request. By default the offset is set to 0.
+ The offset determines the first index which is retrieved, it is generally used
+ in conjunction with limit() to facilitate paging.
+
+ For example, if there are 10 landmarks in the landmark store, setting the offset
+ to 2 and limit to 5 will retrieve the 3rd and 7th landmark ids inclusively. (The order
+ of the landmark ids is sepecified by the sorting field).
+*/
+int QLandmarkIdFetchRequest::offset() const
+{
+ Q_D(const QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->offset;
+}
+
+/*!
+ Sets the index \a offset for the request.
+*/
+void QLandmarkIdFetchRequest::setOffset(int offset) {
+ Q_D(QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ d->offset = offset;
+}
+
+/*!
+ Returns the list of identifiers of landmarks which matched the
+ filter.
+*/
+QList<QLandmarkId> QLandmarkIdFetchRequest::landmarkIds() const
+{
+ Q_D(const QLandmarkIdFetchRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarkIds;
+}
+
+#include "moc_qlandmarkidfetchrequest.cpp"
+
+QTM_END_NAMESPACE
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/location/landmarks/qlandmarkidfetchrequest.h b/src/location/landmarks/qlandmarkidfetchrequest.h
new file mode 100644
index 00000000..6d1ed48a
--- /dev/null
+++ b/src/location/landmarks/qlandmarkidfetchrequest.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKIDFETCHREQUEST_H
+#define QLANDMARKIDFETCHREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdFetchRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkIdFetchRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+
+public:
+ QLandmarkIdFetchRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkIdFetchRequest();
+
+ QLandmarkFilter filter() const;
+ void setFilter(const QLandmarkFilter &filter);
+
+ QList<QLandmarkSortOrder> sorting() const;
+ void setSorting(const QList<QLandmarkSortOrder> &sorting);
+ void setSorting(const QLandmarkSortOrder &sorting);
+
+ int limit() const;
+ void setLimit(int limit);
+
+ int offset() const;
+ void setOffset(int offset);
+
+ QList<QLandmarkId> landmarkIds() const;
+private:
+ Q_DISABLE_COPY(QLandmarkIdFetchRequest)
+ Q_DECLARE_PRIVATE(QLandmarkIdFetchRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkidfilter.cpp b/src/location/landmarks/qlandmarkidfilter.cpp
new file mode 100644
index 00000000..35f9d203
--- /dev/null
+++ b/src/location/landmarks/qlandmarkidfilter.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkidfilter.h"
+#include "qlandmarkidfilter_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkIdFilter
+ \brief The QLandmarkIdFilter class is used to search for landmarks based
+ on a list of landmark identifiers.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkIdFilter)
+
+/*!
+ Creates a filter that selects landmarks using a list of landmark \a ids.
+*/
+QLandmarkIdFilter::QLandmarkIdFilter(const QList<QLandmarkId> &ids)
+ : QLandmarkFilter(new QLandmarkIdFilterPrivate(ids)) {}
+
+/*!
+ \fn QLandmarkIdFilter::QLandmarkIdFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new id filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkIdFilter::~QLandmarkIdFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Returns the list of landmark identifiers that the filter will use to determine matches.
+*/
+QList<QLandmarkId> QLandmarkIdFilter::landmarkIds() const
+{
+ Q_D(const QLandmarkIdFilter);
+ return d->landmarkIds;
+}
+
+/*!
+ Sets the \a ids that the filter will use to determine matches.
+*/
+void QLandmarkIdFilter::setLandmarkIds(const QList<QLandmarkId> &ids)
+{
+ Q_D(QLandmarkIdFilter);
+ d->landmarkIds = ids;
+}
+
+/*!
+ Adds \a id to the list of landmark ids this filter searches for.
+*/
+void QLandmarkIdFilter::append(const QLandmarkId &id)
+{
+ Q_D(QLandmarkIdFilter);
+ d->landmarkIds.append(id);
+}
+
+/*!
+ Removes \a id to the list of landmark ids this filter searches for.
+*/
+void QLandmarkIdFilter::remove(const QLandmarkId &id)
+{
+ Q_D(QLandmarkIdFilter);
+ d->landmarkIds.removeAll(id);
+}
+
+/*!
+ Removes all identifiers from the filter.
+*/
+void QLandmarkIdFilter::clear()
+{
+ Q_D(QLandmarkIdFilter);
+ d->landmarkIds.clear();
+}
+
+/*!
+ Appends the given \a id to the list of landmark identifiers
+ this filter searches for.
+*/
+QLandmarkIdFilter &QLandmarkIdFilter::operator<<(const QLandmarkId &id)
+{
+ Q_D(QLandmarkIdFilter);
+ d->landmarkIds.append(id);
+ return *this;
+}
+
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkIdFilterPrivate::QLandmarkIdFilterPrivate(const QList<QLandmarkId> &ids)
+ : landmarkIds(ids)
+{
+ type = QLandmarkFilter::LandmarkIdFilter;
+}
+
+QLandmarkIdFilterPrivate::QLandmarkIdFilterPrivate(const QLandmarkIdFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ landmarkIds(other.landmarkIds)
+{
+}
+
+QLandmarkIdFilterPrivate::~QLandmarkIdFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkidfilter.h b/src/location/landmarks/qlandmarkidfilter.h
new file mode 100644
index 00000000..ea10bbf9
--- /dev/null
+++ b/src/location/landmarks/qlandmarkidfilter.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKIDFILTER_H
+#define QLANDMARKIDFILTER_H
+
+#include "qlandmarkid.h"
+#include "qlandmarkfilter.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkIdFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkIdFilter(const QList<QLandmarkId> &ids = QList<QLandmarkId>());
+ QLandmarkIdFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkIdFilter();
+
+ QList<QLandmarkId> landmarkIds() const;
+ void setLandmarkIds(const QList<QLandmarkId> &ids);
+ void append(const QLandmarkId &id);
+ void remove(const QLandmarkId &id);
+ void clear();
+
+ QLandmarkIdFilter &operator<<(const QLandmarkId &);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkIdFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkidfilter_p.h b/src/location/landmarks/qlandmarkidfilter_p.h
new file mode 100644
index 00000000..98ab9700
--- /dev/null
+++ b/src/location/landmarks/qlandmarkidfilter_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKIDFILTER_P_H
+#define QLANDMARKIDFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+#include "qlandmarkid.h"
+#include "qlandmarkidfilter.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkIdFilterPrivate(const QList<QLandmarkId> &ids =QList<QLandmarkId>());
+ QLandmarkIdFilterPrivate(const QLandmarkIdFilterPrivate &other);
+ virtual ~QLandmarkIdFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate *other) const
+ {
+ const QLandmarkIdFilterPrivate *od = static_cast<const QLandmarkIdFilterPrivate*>(other);
+ return landmarkIds == od->landmarkIds;
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkIdFilter, QLandmarkFilter::LandmarkIdFilter)
+
+ QList<QLandmarkId> landmarkIds;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkimportrequest.cpp b/src/location/landmarks/qlandmarkimportrequest.cpp
new file mode 100644
index 00000000..39d7efe3
--- /dev/null
+++ b/src/location/landmarks/qlandmarkimportrequest.cpp
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkimportrequest.h"
+#include "qlandmarkrequests_p.h"
+#include <QFile>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkImportRequest
+ \brief The QLandmarkImportRequest class allows a client to asynchronously
+ request that a landmark manager import a set of landmarks.
+
+ For a QLandmarkImportRequest, the resultsAvailable() signal will be emitted
+ when landmarks have been successfully imported by the manager. The list
+ of added landmarks may be retrieved by the landmarkIds() function. The resultsAvailable()
+ signal may also be emitted if an overall operational error occurs.
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ Note that for S60 and Symbian platforms, the waitForFinished() function is not
+ supported for import requests and will always return false.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-request
+*/
+
+/*!
+ Constructs a landmark import request with the given \a manager \a parent.
+*/
+QLandmarkImportRequest::QLandmarkImportRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkImportRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkImportRequest::~QLandmarkImportRequest()
+{
+}
+
+/*!
+ Returns the device from which landmarks are read.
+*/
+QIODevice *QLandmarkImportRequest::device() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->device;
+}
+
+/*!
+ Sets the \a device from which landmarks are read.
+*/
+void QLandmarkImportRequest::setDevice(QIODevice *device)
+{
+ Q_D(QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->device = device;
+}
+
+/*!
+ If the currently assigned device is a QFile, or if setFileName() has
+ been called, this function returns the name of the file to be
+ read from. In all other cases, it returns an empty string.
+
+ \sa setFileName(), setDevice()
+*/
+QString QLandmarkImportRequest::fileName() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ QFile *file = qobject_cast<QFile *>(d->device);
+ return file ? file->fileName() : QString();
+}
+
+/*!
+ Sets the name of the file to be read from to \a fileName. Internally,
+ QLandmarkImportRequest will create a QFile and use this as the
+ device to import from.
+
+ \sa fileName(), setDevice()
+*/
+void QLandmarkImportRequest::setFileName(const QString &fileName)
+{
+ Q_D(QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->device = new QFile(fileName);
+}
+
+/*!
+ Returns the expected data format for the import operation.
+ By default no format is set, indicating that the manager
+ will try to automatically detect the format of the import file.
+*/
+QString QLandmarkImportRequest::format() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->format;
+}
+
+/*!
+ Sets the expected data \a format for the import operation.
+ If an empty string is set, then during the import,
+ an attempt is made to auto detect the format.
+*/
+void QLandmarkImportRequest::setFormat(const QString &format)
+{
+ Q_D(QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->format = format;
+}
+
+/*!
+ Returns the transfer option of the import request.
+ The transfer option defines how categories are treated
+ during the import operation. The default option is
+ QLandmarkManager::IncludeCategoryData.
+
+*/
+QLandmarkManager::TransferOption QLandmarkImportRequest::transferOption() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->option;
+}
+
+/*!
+ Sets the transfer \a option of the import request.
+ The transfer \a option defines how categories are treated
+ during the import operation.
+*/
+void QLandmarkImportRequest::setTransferOption(QLandmarkManager::TransferOption option)
+{
+ Q_D(QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->option = option;
+}
+
+/*!
+ Returns identifier of the category which all landmarks are assigned to if
+ QLandmarkManager::AttachSingleCategory is used
+ as the import option.
+*/
+QLandmarkCategoryId QLandmarkImportRequest::categoryId() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->categoryId;
+}
+
+/*!
+ Sets the identifier of the category to which all landmarks are assigned to,
+ if QLandmarkManager::AttachSingleCategory is used as the import option, to
+ \a categoryId.
+*/
+void QLandmarkImportRequest::setCategoryId(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ d->categoryId = categoryId;
+}
+
+/*!
+ Returns a list of identifiers of landmarks that have been imported.
+*/
+QList<QLandmarkId> QLandmarkImportRequest::landmarkIds() const
+{
+ Q_D(const QLandmarkImportRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarkIds;
+}
+
+#include "moc_qlandmarkimportrequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkimportrequest.h b/src/location/landmarks/qlandmarkimportrequest.h
new file mode 100644
index 00000000..a5018b0e
--- /dev/null
+++ b/src/location/landmarks/qlandmarkimportrequest.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKIMPORTREQUEST_H
+#define QLANDMARKIMPORTREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+class QIODevice;
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkImportRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkImportRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkImportRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkImportRequest();
+
+ QIODevice *device() const;
+ void setDevice(QIODevice *device);
+
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ QString format() const;
+ void setFormat(const QString &format);
+
+ QLandmarkManager::TransferOption transferOption() const;
+ void setTransferOption(QLandmarkManager::TransferOption option);
+
+ QLandmarkCategoryId categoryId() const;
+ void setCategoryId(const QLandmarkCategoryId &categoryId);
+
+ QList<QLandmarkId> landmarkIds() const;
+private:
+ Q_DISABLE_COPY(QLandmarkImportRequest)
+ Q_DECLARE_PRIVATE(QLandmarkImportRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkintersectionfilter.cpp b/src/location/landmarks/qlandmarkintersectionfilter.cpp
new file mode 100644
index 00000000..faeffb72
--- /dev/null
+++ b/src/location/landmarks/qlandmarkintersectionfilter.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkintersectionfilter.h"
+#include "qlandmarkintersectionfilter_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkIntersectionFilter
+ \brief The QLandmarkIntersectionFilter class provides a filter which intersects the results
+ of its constituent filters.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ Conceptually it performs an AND operation and thus may be used to
+ select landmarks which match all of it's constituent filters.
+ If the intersection filter contains a proximity filter at the top level (i.e. which is not nested
+ inside another filter) then the landmarks will be sorted by distance according to that filter.
+ Note that a using sort order other than QLandmarkSortOrder (i.e. no sort) will override the
+ sorting by distance).
+
+ Whether an intersection filter can be comprised of
+ compound filters (i.e. union or intersection filters) is backend specific.
+ Even if this is supported the performance of such a filter is likely to be poor.
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkIntersectionFilter);
+
+/*!
+ Constructs an intersection filter.
+*/
+QLandmarkIntersectionFilter::QLandmarkIntersectionFilter()
+ : QLandmarkFilter(new QLandmarkIntersectionFilterPrivate())
+{
+}
+
+/*!
+ \fn QLandmarkIntersectionFilter::QLandmarkIntersectionFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new intersection filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkIntersectionFilter::~QLandmarkIntersectionFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Sets the \a filters whose criteria will be intersected.
+ \sa filters()
+ */
+void QLandmarkIntersectionFilter::setFilters(const QList<QLandmarkFilter> &filters)
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters = filters;
+}
+
+/*!
+ Prepends the given \a filter to the list of intersected filters
+ \sa append(), filters()
+*/
+void QLandmarkIntersectionFilter::prepend(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters.prepend(filter);
+}
+
+/*!
+ Appends the given \a filter to the list of intersected filters
+ \sa operator<<(), prepend(), filters()
+*/
+void QLandmarkIntersectionFilter::append(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters.append(filter);
+}
+
+/*!
+ Removes the given \a filter from the list of intersected filters.
+ \sa filters(), append(), prepend()
+*/
+void QLandmarkIntersectionFilter::remove(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters.removeAll(filter);
+}
+
+/*!
+ Removes all filters from the list of intersected filters.
+*/
+void QLandmarkIntersectionFilter::clear()
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters.clear();
+}
+
+/*!
+ Appends the given \a filter to the list of intersected filters
+ \sa append()
+ */
+QLandmarkIntersectionFilter& QLandmarkIntersectionFilter::operator<<(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkIntersectionFilter);
+ d->filters.append(filter);
+ return *this;
+}
+
+/*!
+ Returns the list of filters which form the intersection filter
+ \sa setFilters(), prepend(), append(), remove()
+ */
+QList<QLandmarkFilter> QLandmarkIntersectionFilter::filters() const
+{
+ Q_D(const QLandmarkIntersectionFilter);
+ return d->filters;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkIntersectionFilterPrivate::QLandmarkIntersectionFilterPrivate()
+{
+ type = QLandmarkFilter::IntersectionFilter;
+}
+
+QLandmarkIntersectionFilterPrivate::QLandmarkIntersectionFilterPrivate(const QLandmarkIntersectionFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ filters(other.filters) {}
+
+QLandmarkIntersectionFilterPrivate::~QLandmarkIntersectionFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkintersectionfilter.h b/src/location/landmarks/qlandmarkintersectionfilter.h
new file mode 100644
index 00000000..750775e8
--- /dev/null
+++ b/src/location/landmarks/qlandmarkintersectionfilter.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKINTERSECTIONFILTER_H
+#define QLANDMARKINTERSECTIONFILTER_H
+
+#include "qlandmarkfilter.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIntersectionFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkIntersectionFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkIntersectionFilter();
+ QLandmarkIntersectionFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkIntersectionFilter();
+
+ void setFilters(const QList<QLandmarkFilter>& filters);
+
+ void prepend(const QLandmarkFilter &filter);
+ void append(const QLandmarkFilter &filter);
+ void remove(const QLandmarkFilter &filter);
+ void clear();
+
+ QLandmarkIntersectionFilter& operator<<(const QLandmarkFilter& filter);
+ QList<QLandmarkFilter> filters() const;
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkIntersectionFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkintersectionfilter_p.h b/src/location/landmarks/qlandmarkintersectionfilter_p.h
new file mode 100644
index 00000000..3920f3e6
--- /dev/null
+++ b/src/location/landmarks/qlandmarkintersectionfilter_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKINTERSECTIONFILTER_P_H
+#define QLANDMARKINTERSECTIONFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIntersectionFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkIntersectionFilterPrivate();
+ QLandmarkIntersectionFilterPrivate(const QLandmarkIntersectionFilterPrivate &other);
+ virtual ~QLandmarkIntersectionFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate* other) const
+ {
+ const QLandmarkIntersectionFilterPrivate *od = static_cast<const QLandmarkIntersectionFilterPrivate*>(other);
+ return filters == od->filters;
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkIntersectionFilter, QLandmarkFilter::IntersectionFilter)
+
+ QList<QLandmarkFilter> filters;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkmanager.cpp b/src/location/landmarks/qlandmarkmanager.cpp
new file mode 100644
index 00000000..1a2f21db
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanager.cpp
@@ -0,0 +1,1473 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkmanager.h"
+#include "qlandmarkmanager_p.h"
+
+#include <QStringList>
+#include <QString>
+#include <QIODevice>
+#include <QFile>
+#include <QUrl>
+#include <QPluginLoader>
+#include <QDebug>
+#include "qlandmarkcategoryid.h"
+#include "qlandmarkcategory.h"
+#include "qlandmark.h"
+#include "qlandmarkmanagerengine.h"
+#include "qlandmarkmanagerenginefactory.h"
+#include "qlandmarkidfilter.h"
+
+QTM_USE_NAMESPACE
+
+/*!
+ \variable QLandmarkManager::Gpx
+ The format constant to define using the gpx format in the import and export functions.
+ \sa importLandmarks(), exportLandmarks()
+*/
+Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Gpx, "Gpx");
+
+/*!
+ \variable QLandmarkManager::Lmx
+ The format constant to define using the lmx format in the import and export functions.
+ \sa importLandmarks(), exportLandmarks()
+*/
+Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Lmx, "Lmx");
+
+/*!
+ \variable QLandmarkManager::Kml
+ The format constant to define using the kml format in the import and export functions.
+ \sa importLandmarks(), exportLandmarks()
+*/
+Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Kml, "Kml");
+
+/*!
+ \variable QLandmarkManager::Kmz
+ The format constant to define using the kmz format in the import and export functions.
+ \sa importLandmarks(), exportLandmarks()
+*/
+Q_DEFINE_LATIN1_CONSTANT(QLandmarkManager::Kmz, "Kmz");
+
+/*!
+ \class QLandmarkManager
+ \brief The QLandmarkManager class provides an interface for storage
+ and retrieval of landmarks from a landmark store.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-main
+
+ The QLandmarkManager is the starting class to use when working with landmarks.
+ It effectively represents a landmark datastore and it provides the synchronous operations for the
+ creation, retrieval, updating and deletion of both landmarks and categories. For asynchronous operations
+ use the \l {Asynchronous Landmark Requests} {request classes} which use the manager as a parameter.
+ The manager provides notifications whenever landmarks or categories are added, updated or removed.
+
+ Each manager is identified by a manager name which typically takes the form of a reverse domain string
+ such as \c com.nokia.qt.landmarks.engines.sqlite. However every supported platform provides a default
+ manager which may be instantiated without having to provide a name like so:
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Instantiate default QLandmarkManager
+
+ \section1 Retrieval Operations
+
+ To retrieve a set of landmarks we provide may provide a QLandmarkFilter, QLandmarkSortOrder and limit and offset as necessary.
+ The QLandmarkFilter defines the criteria for selecting landmarks; for example, a QLandmarkCategoryFilter may be used
+ to choose landmarks that belong to a certain category. A QLandmarkSortOrder order defines how the results should
+ be sorted. (Note that if you wish to sort by distance, you should use a proxmity filter, see QLandmarkProximityFilter).
+ The limit allows specification of the maximum number of items to
+ return and the offset defines the index of the first item. The following demonstrates how to search for the first 100
+ landmarks belonging to a given category, sorted by name.
+
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks by category synchronously
+
+ The set of parameters described above are not always necessary as defaults are provided, if we wanted to retrieve
+ all landmarks, then the appropriate call is:
+
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve all landmarks synchronously
+ \note Landmark retrieval is potentially a long operation, the synchronous API provided by the manager
+ is subject to blocking. It is generally recommended that the QLandmarkFetchRequest be used because
+ it behaves asynchronously.
+
+ Categories may be retrieved in a similar manner:
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories synchronously simple
+
+ \section1 Saving and Deleting
+
+ Saving and deleting landmarks and categories are fairly straightforward. To add a new landmark or category
+ simply instantiate a QLandmark or QLandmarkCategory, set its data fields (e.g., name, coordinate, etc.) and pass
+ a pointer to the appropriate save operation. For example:
+
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add landmark synchronously simple
+
+ We pass the landmark by pointer bcause it will be assigned a new QLandmarkId when the function call is done.
+ Saving a landmark with a valid id already set will update the existing landmark.
+
+ Removal of landmark may be done as follows:
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove landmark synchronously simple
+
+ \section1 Importing and Exporting
+
+ Import and export are potentially long operations, to perform these operations asynchronously
+ see QLandmarkImportRequest and QLandmarkExportRequest. The simplest way to perform an import
+ is to supply a file name while an export will need both a file name and format.
+
+ \snippet doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp ImportExport landmark simple
+
+ The formats supported for import and export can be found by calling the
+ supportedFormats() function with the type of operation to be performed,
+ either ImportOperation or ExportOperation.
+*/
+
+/*!
+ \enum QLandmarkManager::Error
+ Defines the possible errors for the landmark manager.
+ \value NoError No error occurred
+ \value DoesNotExistError The most recent operation failed due to an item not being found, usually an import file.
+ \value LandmarkDoesNotExistError The most recent operation failed due to a specified landmark not being found.
+ \value CategoryDoesNotExistError The most recent operation faied due to a specified category not being found.
+ \value AlreadyExistsError The most recent operation failed because the specified landmark or category already exists.
+ \value LockedError The most recent operation failed because the datastore specified is currently locked.
+ \value PermissionsError The most recent operation failed because the caller does not have permission to perform the operation.
+ \value OutOfMemoryError The most recent operation failed due to running out of memory.
+ \value VersionMismatchError The most recent operation failed because the backend of the manager is not of the required version.
+ \value NotSupportedError The most recent operation failed because the requested operation is not supported by the manager.
+ \value BadArgumentError The most recent operation failed because one or more of the parameters to the operation were invalid.
+ \value InvalidManagerError The most recent operation failed because the manager failed to initialize correctly and is invalid.
+ This could be due using a manager name that is not recognised/available. A landmark request object will return this error if
+ if is assigned a null manager pointer.
+ \value ParsingError The most recent operation failed because the imported file could not be parsed.
+ \value CancelError The most recent operation failed to complete due to user cancelation.
+ \value UnknownError The most recent operation failed for an unknown reason.
+*/
+
+/*!
+ \enum QLandmarkManager::TransferOption
+ Defines the possible options when transferring landmarks during import or export.
+ \value IncludeCategoryData During an import, category data is included. If an imported category doesn't exist
+ the category is created. If the imported category name matches an existing
+ category name, then the landmark is added to that category. For exports, categories
+ are included in the exported file if the file format allows it.
+ \value ExcludeCategoryData Landmarks are imported or exported without any categories assigned to the landmarks.
+ \value AttachSingleCategory Only relevant for import operations. When landmarks are imported they are
+ all assigned to a given category.
+*/
+
+/*!
+ \enum QLandmarkManager::ManagerFeature
+ Defines the possible features the landmark manager can support.
+ \value ImportExportFeature The manager supports import and/or export operations
+ \value NotificationsFeature The manager will emit notification signals when landmarks/categories have
+ been added/modified/removed from the datastore it manages.
+*/
+
+/*!
+ \enum QLandmarkManager::SupportLevel
+ Defines the possible support levels the manager can provide for a given filter or sort order list.
+ \value NativeSupport The manager natively supports the filter or sort order list.
+ \value EmulatedSupport The manager emulates the behaviour of the filter or sort order list.
+ Emulated behaviour will inherently be slower than a natively supported implementation.
+ \value NoSupport The manager does not support the filter or sort order list at all.
+*/
+
+/*!
+ \enum QLandmarkManager::TransferOperation
+ Defines the type of transfer.
+ \value ImportOperation Landmarks are being copied from a file to the device.
+ \value ExportOperation Landmarks are being copied from the device to a file.
+*/
+
+/*!
+ Constructs a QLandmarkManager. The default manager implementation for the platform will be used.
+
+ The \a parent QObject will be used as the parent of this QLandmarkManager.
+*/
+QLandmarkManager::QLandmarkManager(QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLandmarkManagerPrivate())
+{
+ Q_D(QLandmarkManager);
+ d->q_ptr = this;
+ QString managerName;
+
+#ifdef Q_OS_SYMBIAN
+ managerName = "com.nokia.qt.landmarks.engines.symbian";
+#elif defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
+ managerName = "com.nokia.qt.landmarks.engines.qsparql";
+#else
+ managerName = "com.nokia.qt.landmarks.engines.sqlite";
+#endif
+
+ d->createEngine(managerName);
+}
+
+/*!
+ Constructs a QLandmarkManager whose implementation is identified by \a managerName with the given
+ \a parameters.
+
+ The \a parent QObject will be used as the parent of this QLandmarkManager.
+
+ If an empty \a managerName is specified, the default manager implementation for the platform will be used.
+*/
+QLandmarkManager::QLandmarkManager(const QString &managerName, const QMap<QString, QString> &parameters, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLandmarkManagerPrivate())
+{
+ Q_D(QLandmarkManager);
+ d->q_ptr = this;
+ d->createEngine(managerName, parameters);
+}
+
+/*!
+ Frees the memory used by the QLandmarkManager
+*/
+QLandmarkManager::~QLandmarkManager()
+{
+ Q_D(QLandmarkManager);
+
+ if (d->engine)
+ delete d->engine;
+
+ delete d;
+}
+
+/*!
+ Adds the given \a landmark to the database if \a landmark has a
+ default-constructed identifer, or an identifier with the manager
+ URI set to the URI of this manager and an empty id.
+
+ If the manager URI of the identifier of the \a landmark is neither
+ empty nor equal to the URI of this manager, or the id member of the
+ identifier is not empty, but does not exist in the manager,
+ the operation will fail and calling error() will return
+ \c QLandmarkManager::LandmarkDoesNotExistError.
+
+ Alternatively, the function will update the existing landmark in the
+ database if \a landmark has a non-empty id and currently exists
+ within the database.
+
+ Returns false on failure or true on success. On successful save
+ of a landmark with an empty id, it will be assigned a valid
+ id and have its manager URI set to the URI of this manager.
+*/
+bool QLandmarkManager::saveLandmark(QLandmark *landmark)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->saveLandmark(landmark,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Adds the list of \a landmarks to the database.
+ Returns true if the landmarks were saved successfully, otherwise returns
+ false.
+
+ This function will set per-input errors in the QLandmarkManager::errorMap().
+
+ The QLandmarkManager::error() function will only return \c
+ QLandmarkManager::NoError if all landmarks were saved successfully.
+
+ For each new landmark that was successfully saved, a landmark identifier
+ is assigned to that landmark.
+*/
+bool QLandmarkManager::saveLandmarks(QList<QLandmark> *landmarks)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->saveLandmarks(landmarks,
+ &(d->errorMap),
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Remove the landmark identified by \a landmarkId from the database.
+
+ Returns true if the landmark was removed successfully, otherwise
+ returnse false.
+*/
+bool QLandmarkManager::removeLandmark(const QLandmarkId &landmarkId)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->removeLandmark(landmarkId,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+
+/*!
+ Removes the \a landmark from the database.
+
+ Returns true if the landmark was removed successfully,
+ otherwise returns false.
+*/
+bool QLandmarkManager::removeLandmark(const QLandmark &landmark)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->removeLandmark(landmark.landmarkId(),
+ &(d->errorCode),
+ &(d->errorString));
+
+}
+
+/*!
+ Removes every landmark whose identifier is contained in the list
+ of \a landmarkIds. Returns true if all landmarks were removed
+ successfully, otherwise false.
+
+ This batch function will set per-input errors in the QLandmarkManager::errorMap().
+
+ The QLandmarkManager::error() function will only return
+ \c QLandmarkManager::NoError if all landmarks were removed successfully.
+
+ \sa QLandmarkManager::removeLandmark()
+*/
+bool QLandmarkManager::removeLandmarks(const QList<QLandmarkId> &landmarkIds)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+
+ return d->engine->removeLandmarks(landmarkIds,
+ &(d->errorMap),
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Convenience function to remove the given \a landmarks from the database.
+ Returns true if all landmarks were removed
+ successfully, otherwise false.
+
+ This batch function will set per input errors in the QLandmarkManager::errorMap().
+
+ The QLandmarkManager::error() function will only return
+ \c QLandmarkManager::NoError if all landmarks were removed successfully.
+
+
+
+ \sa QLandmarkManager::removeLandmark()
+*/
+bool QLandmarkManager::removeLandmarks(const QList<QLandmark> &landmarks)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkId> landmarkIds;
+ for (int i=0; i < landmarks.count(); ++i) {
+ landmarkIds << landmarks.at(i).landmarkId();
+ }
+
+ return d->engine->removeLandmarks(landmarkIds,
+ &(d->errorMap),
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+
+
+/*!
+ Adds the given \a category to the database if \a category has a
+ default-constructed identifier, or an identifier with the manager
+ URI set to the URI of this manager and an empty id.
+
+ If the manager URI of the identifier of the \a category is neither
+ empty nor equal to the URI of this manager, or the id member of the
+ identifier is not empty, but does not exist in the manager,
+ the operation will fail and calling error() will return
+ \c QLandmarkManager::CategoryDoesNotExistError.
+
+ Alternatively, the function will update the existing category in the
+ database if \a category has a non-empty id and currently exists
+ within the database.
+
+ Returns false on failure or true on success. On successful save
+ of a category with an invalid id, it will be assigned a valid
+ id and have its manager URI set to the URI of this manager.
+*/
+bool QLandmarkManager::saveCategory(QLandmarkCategory *category)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->saveCategory(category,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Remove the category identified by \a categoryId from the database.
+
+ Returns true if the category was removed successfully, otherwise
+ returnse false.
+*/
+bool QLandmarkManager::removeCategory(const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->removeCategory(categoryId,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Remove the given \a category from the database
+
+ Returns true if the category was removed successfully, otherwise
+ returnse false.
+*/
+bool QLandmarkManager::removeCategory(const QLandmarkCategory &category)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->removeCategory(category.categoryId(),
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Returns the cateory in the database identified by \a categoryId.
+*/
+QLandmarkCategory QLandmarkManager::category(const QLandmarkCategoryId &categoryId) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QLandmarkCategory();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QLandmarkCategory cat = d->engine->category(categoryId,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QLandmarkCategory();
+
+ return cat;
+}
+
+/*!
+ Returns a list of categories which match the given \a categoryIds.
+
+ This batch function will set per-input errors in the QLandmarkManager::errorMap();
+
+ The QLandmarkManager::error() function will only return \c QLandmarkManager::NoError if
+ all categories were successfully retrieved.
+ */
+QList<QLandmarkCategory> QLandmarkManager::categories(const QList<QLandmarkCategoryId> &categoryIds) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmarkCategory>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkCategory> cats = d->engine->categories(categoryIds,
+ &(d->errorMap),
+ &(d->errorCode),
+ &(d->errorString));
+
+ return cats;
+}
+
+/*!
+ Returns a list of categories.The \a limit defines the maximum number of categories
+ to return and the \a offset defines the index offset of the first category.
+ A \a limit of -1 means all categories should be returned(a limit of 0 means zero
+ categories are returned). The categories
+ are returned in the order as designated by \a nameSort.
+*/
+QList<QLandmarkCategory> QLandmarkManager::categories(int limit, int offset, const QLandmarkNameSort &nameSort) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmarkCategory>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkCategory> cats = d->engine->categories(limit, offset, nameSort,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmarkCategory>();
+
+ return cats;
+}
+
+/*!
+ Returns a list of category identifiers.
+ The \a limit defines the maximum number of ids to return and the \a offset defines the index offset
+ of the first id. A \a limit of -1 means ids for all categories should be returned.
+ The identifiers are returned in order as designed by \a nameSort. Note that a limit
+ of 0 will return zero category ids.
+*/
+QList<QLandmarkCategoryId> QLandmarkManager::categoryIds(int limit, int offset, const QLandmarkNameSort &nameSort) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmarkCategoryId>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkCategoryId> ids = d->engine->categoryIds(limit, offset, nameSort,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmarkCategoryId>();
+
+ return ids;
+}
+
+/*!
+ Returns the landmark in the database identified by \a landmarkId
+*/
+QLandmark QLandmarkManager::landmark(const QLandmarkId &landmarkId) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QLandmark();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QLandmark lm = d->engine->landmark(landmarkId,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QLandmark();
+
+ return lm;
+}
+
+/*!
+ Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrders.
+ The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset
+ of the first landmark. A \a limit of -1 means all matching landmarks should be returned.
+*/
+QList<QLandmark> QLandmarkManager::landmarks(const QLandmarkFilter &filter, int limit, int offset,
+ const QList<QLandmarkSortOrder> &sortOrders) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmark>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmark> lms = d->engine->landmarks(filter,
+ limit,
+ offset,
+ sortOrders,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmark>();
+
+ return lms;
+}
+
+/*!
+ Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrder.
+ The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset
+ of the first landmark. A \a limit of -1 means all matching landmarks should be returned and that
+ a limit of 0 will return zero landmarks.
+*/
+QList<QLandmark> QLandmarkManager::landmarks(const QLandmarkFilter &filter, int limit, int offset,
+ const QLandmarkSortOrder &sortOrder) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmark>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkSortOrder> sortOrders;
+ if (sortOrder.type() != QLandmarkSortOrder::NoSort)
+ sortOrders.append(sortOrder);
+
+ QList<QLandmark> lms = d->engine->landmarks(filter,
+ limit,
+ offset,
+ sortOrders,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmark>();
+
+ return lms;
+}
+
+/*!
+ Returns a list of landmarks which match the given \a landmarkIds.
+
+ This batch function will set per-input errors in the QLandmarkManager::errorMap().
+
+ The QLandmarkManager::error() function will only return \c QLandmarkManager::NoError if
+ all landmarks were successfully retrieved.
+
+*/
+QList<QLandmark> QLandmarkManager::landmarks(const QList<QLandmarkId> &landmarkIds) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmark>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmark> lms = d->engine->landmarks(landmarkIds,
+ &(d->errorMap),
+ &(d->errorCode),
+ &(d->errorString));
+ return lms;
+}
+
+/*!
+ Returns a list of landmark identifiers which match the given \a filter and are sorted according to
+ the given \a sortOrders. The \a limit defines the maximum number of landmark ids to return and the
+ \a offset defines the index offset of the first landmark id.
+ A \a limit of -1 means that ids of all matching landmarks should be returned. Note that
+ a limit of 0 will return zero landmark ids.
+*/
+QList<QLandmarkId> QLandmarkManager::landmarkIds(const QLandmarkFilter &filter,
+ int limit, int offset,
+ const QList<QLandmarkSortOrder> &sortOrders) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmarkId>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkId> ids = d->engine->landmarkIds(filter,
+ limit,
+ offset,
+ sortOrders,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmarkId>();
+
+ return ids;
+}
+
+/*!
+ Convenience function to returns a list of landmark identifiers which match the given \a filter and are sorted according to
+ the given \a sortOrder. The \a limit defines the maximum number of landmark ids to return and the
+ \a offset defines the index offset of the first landmark id.
+ A \a limit of -1 means that ids of all matching landmarks should be returned. Note
+ that a limit of 0 will return zero landmark ids.
+
+
+*/
+QList<QLandmarkId> QLandmarkManager::landmarkIds(const QLandmarkFilter &filter,
+ int limit, int offset,
+ const QLandmarkSortOrder &sortOrder) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QList<QLandmarkId>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ QList<QLandmarkSortOrder> sortOrders;
+ sortOrders.append(sortOrder);
+
+ QList<QLandmarkId> ids = d->engine->landmarkIds(filter,
+ limit,
+ offset,
+ sortOrders,
+ &(d->errorCode),
+ &(d->errorString));
+
+ if (d->errorCode != NoError)
+ return QList<QLandmarkId>();
+
+ return ids;
+}
+
+/*!
+ Reads landmarks from the given \a device and saves them. The data from the \a device
+ is expected to adhere to the provided \a format. If no \a format is provided,
+ the manager tries to auto detect the \a format.
+
+ The \a option can be used to control whether categories in the imported
+ file will be added during the import. If the \c AttachSingleCategory option is used, then
+ all the landmarks in the import file are assigned to the category identified by
+ \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId
+ doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExistError is set. Note that
+ some file formats may not support categories at all.
+
+ Returns true if all landmarks could be imported, otherwise
+ returns false.
+
+*/
+bool QLandmarkManager::importLandmarks(QIODevice *device, const QString &format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId &categoryId)
+{
+ Q_D(QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->importLandmarks(device,
+ format,
+ option,
+ categoryId,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Convenience function that will read landmarks from \a fileName in
+ the expected \a format. If no \a format is provided, the manager tries
+ to auto detect the \a format. Internally a QFile is opened with
+ QIODevice::ReadOnly permissions.
+
+ The \a option can be used to control whether categories in the imported
+ file will be added during the import. If the \c AttachSingleCategory option is used, then
+ all the landmarks in the import file are assigned to the category identified by
+ \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId
+ doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExistError is set. Note that
+ some file formats may not support categories at all.
+
+ Returns true if all landmarks could be imported, otherwise
+ returns false.
+*/
+bool QLandmarkManager::importLandmarks(const QString &fileName, const QString &format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId &categoryId)
+{
+ QFile file(fileName);
+ return importLandmarks(&file, format,option,categoryId);
+}
+
+/*!
+ Writes landmarks to the given \a device. The landmarks will be written
+ according to the specified \a format. If \a landmarkIds is empty, then
+ all landmarks will be exported, otherwise only those landmarks that
+ match \a landmarkIds will be exported.
+
+ The \a option can be used to control whether categories will be exported or not.
+ Note that the \c AttachSingleCategory option has no meaning during
+ export and the manager will export as if \a option was \c IncludeCategoryData.
+ Also, be aware that some file formats may not support categories at all and for
+ these formats, the \a option is always treated as if it was \c ExcludeCategoryData.
+
+ Returns true if all specified landmarks were successfully exported,
+ otherwise returns false. It may be possible that only a subset
+ of landmarks are exported.
+*/
+bool QLandmarkManager::exportLandmarks(QIODevice *device, const QString &format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->exportLandmarks(device,
+ format,
+ landmarkIds,
+ option,
+ &(d->errorCode),
+ &(d->errorString));
+}
+
+/*!
+ Convenience function that will write landmarks to \a fileName in the expected
+ \a format. Internally a QFile is opened with QIODevice::WriteOnly permissions.
+ If \a landmarkIds is empty, then all landmarks will be exported, otherwise
+ only those landmarks that match \a landmarkIds will be exported.
+
+ The \a option can be used to control whether categories will be exported or not.
+ Note that the \c AttachSingleCategory option has no meaning during
+ export and the manager will export as if \a option was \c IncludeCategoryData.
+ Also, be aware that some file formats may not support categories at all and for
+ these formats, the \a option is always treated as if it was \c ExcludeCategoryData.
+
+ Returns true if all specified landmarks were successfully exported,
+ otherwise returns false. It may be possible that only a subset
+ of landmarks are exported.
+*/
+bool QLandmarkManager::exportLandmarks(const QString &fileName, const QString &format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option) const
+{
+ QFile file(fileName);
+
+ return exportLandmarks(&file, format,landmarkIds, option);
+}
+
+/*!
+ Returns the file formats supported for the given transfer \a operation. ie import or export.
+*/
+QStringList QLandmarkManager::supportedFormats(QLandmarkManager::TransferOperation operation) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QStringList();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->supportedFormats(operation, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns the error code of the most recent operation. All functions will modify the error based on whether the
+ operation successfully or not.
+*/
+QLandmarkManager::Error QLandmarkManager::error() const
+{
+ Q_D(const QLandmarkManager);
+ return d->errorCode;
+}
+
+/*!
+ Returns a short human-readable description of the error that occurred
+ in the most recent operation. The error string is intended to be used
+ by developers and is not suitable for showing to end users.
+*/
+QString QLandmarkManager::errorString() const
+{
+ Q_D(const QLandmarkManager);
+ return d->errorString;
+}
+
+/*!
+Returns per-input error codes for the most recent operation. This function only
+returns meaningful information if the most recent operation was a batch
+operation. The keys in the map correspond to the index of the input list.
+The error map is only populated for indexes at which an error occurred.
+Eg If we saved 5 landmarks and an error occurred at index 3, the error map
+will have only a single key for index 3.
+
+\sa error(), categories(), landmarks(), saveLandmarks(), removeCategory(), removeLandmarks()
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkManager::errorMap() const
+{
+ Q_D(const QLandmarkManager);
+ return d->errorMap;
+}
+
+/*!
+ Returns whether the manager supports the given \a feature.
+*/
+bool QLandmarkManager::isFeatureSupported(QLandmarkManager::ManagerFeature feature) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return false;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->isFeatureSupported(feature, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns the support level the manager provides for the given \a filter. For the case
+ of intersection and union filters, whether the elements will be individually processed
+ is dependent on the particular manager implementation.
+*/
+QLandmarkManager::SupportLevel QLandmarkManager::filterSupportLevel(const QLandmarkFilter &filter) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QLandmarkManager::NoSupport;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->filterSupportLevel(filter, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns the support level the manager provides for the given \a sortOrder.
+*/
+QLandmarkManager::SupportLevel QLandmarkManager::sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder) const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QLandmarkManager::NoSupport;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->sortOrderSupportLevel(sortOrder, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns true if the manager is entirely read-only. Meaning
+ landmarks and categories cannot be added, modified or removed.
+*/
+bool QLandmarkManager::isReadOnly() const
+{
+ Q_D(const QLandmarkManager);
+ if (!d->engine) {
+ return true;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->isReadOnly(&(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns true if the landmark identified by \a landmarkId
+ considered read-only by the manager.
+
+ If the \a landmarkId does not refer to an existing landmark,
+ it is considered writable unless the manager is exclusively read-only.
+*/
+bool QLandmarkManager::isReadOnly(const QLandmarkId &landmarkId) const
+{
+ Q_D(const QLandmarkManager);
+ if (!d->engine) {
+ return true;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->isReadOnly(landmarkId, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns true if the category identified by \a categoryId is
+ considered read-only by the manager.
+
+ If \a categoryId does not refer to an existing category,
+ it is considered writable unless the manager is exclusively read-only.
+*/
+bool QLandmarkManager::isReadOnly(const QLandmarkCategoryId &categoryId) const
+{
+ Q_D(const QLandmarkManager);
+ if (!d->engine) {
+ return true;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->isReadOnly(categoryId, &(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns a list of landmark attribute keys that may be used in a
+ QLandmarkAttributeFilter.
+*/
+QStringList QLandmarkManager::searchableLandmarkAttributeKeys() const
+{
+ Q_D(const QLandmarkManager);
+ if (!d->engine) {
+ return QStringList();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+
+ return d->engine->searchableLandmarkAttributeKeys(&(d->errorCode), &(d->errorString));
+}
+
+/*!
+ Returns the manager name for this QLandmarkManager.
+
+ The manager name usually takes the format of a reverse domain string. An example
+ of a manager name is \c com.nokia.qt.landmarks.engines.sqlite
+*/
+QString QLandmarkManager::managerName() const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QString();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+ return d->engine->managerName();
+}
+
+/*!
+ Return the parameters relevant to the creation of this QLandmarkManager.
+
+ The parameters may be viewed as a set of key-value pairs. Each manager
+ may have a different set of parameters depending upon its backend implementation.
+*/
+QMap<QString, QString> QLandmarkManager::managerParameters() const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QMap<QString, QString>();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+ return d->engine->managerParameters();
+}
+
+/*!
+ Return the uri describing this QLandmarkManager, consisting of the manager name and any parameters.
+ */
+QString QLandmarkManager::managerUri() const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return QString();
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+ return d->engine->managerUri();
+}
+
+/*!
+ Returns the engine backend implementation version number.
+*/
+int QLandmarkManager::managerVersion() const
+{
+ Q_D(const QLandmarkManager);
+
+ if (!d->engine) {
+ return 0;
+ }
+
+ d->errorCode = QLandmarkManager::NoError;
+ d->errorString = "";
+ d->errorMap.clear();
+ return d->engine->managerVersion();
+}
+
+/*!
+ Returns a list of available manager names that can
+ be used when constructing a QLandmarkManager
+*/
+QStringList QLandmarkManager::availableManagers()
+{
+ return QLandmarkManagerPrivate::factories().keys();
+}
+
+/*! Returns a URI that completely describes a manager implementation/datastore,
+ and the parameters with which to instantiate the manager,
+ from the given \a managerName, \a params and an optional \a implementationVersion */
+QString QLandmarkManager::buildUri(const QString& managerName, const QMap<QString, QString>& params, int implementationVersion)
+{
+ QString ret(QLatin1String("qtlandmarks:%1:%2"));
+ // we have to escape each param
+ QStringList escapedParams;
+ QStringList keys = params.keys();
+ for (int i=0; i < keys.size(); i++) {
+ QString key = keys.at(i);
+ QString arg = params.value(key);
+ arg = arg.replace(QLatin1Char('&'), QLatin1String("&amp;"));
+ arg = arg.replace(QLatin1Char('='), QLatin1String("&equ;"));
+ key = key.replace(QLatin1Char('&'), QLatin1String("&amp;"));
+ key = key.replace(QLatin1Char('='), QLatin1String("&equ;"));
+ key = key + QLatin1Char('=') + arg;
+ escapedParams.append(key);
+ }
+
+ if (implementationVersion != -1) {
+ QString versionString = QString(QLatin1String(QTLANDMARKS_IMPLEMENTATION_VERSION_NAME));
+ versionString += QString::fromAscii("=");
+ versionString += QString::number(implementationVersion);
+ escapedParams.append(versionString);
+ }
+
+ return ret.arg(managerName, escapedParams.join(QLatin1String("&")));
+}
+
+/*!
+ Constructs a QLandmarkManager whose implementation, store and parameters are specified in the given \a storeUri,
+ and whose parent object is \a parent.
+ */
+QLandmarkManager* QLandmarkManager::fromUri(const QString& storeUri, QObject* parent)
+{
+ if (storeUri.isEmpty()) {
+ return new QLandmarkManager(QString(), QMap<QString, QString>(), parent);
+ } else {
+ QString id;
+ QMap<QString, QString> parameters;
+ if (parseUri(storeUri, &id, &parameters)) {
+ return new QLandmarkManager(id, parameters, parent);
+ } else {
+ // invalid
+ return NULL;
+ }
+ }
+}
+
+/*!
+ Splits the given \a uri into the manager name and parameters that it describes, and places the information
+ into the memory addressed by \a pManagerName and \a pParams respectively. Returns true if \a uri could be split successfully,
+ otherwise returns false
+ */
+bool QLandmarkManager::parseUri(const QString& uri, QString* pManagerName, QMap<QString, QString>* pParams)
+{
+ // Format: qtlandmarks:<managerid>:<key>=<value>&<key>=<value>
+ // - it is assumed the prefix(qtlandmarks) and managerid cannot contain ':'
+ // - it is assumed keys and values do not contain '=' or '&'
+ // but can contain &amp; and &equ;
+ QStringList colonSplit = uri.split(QLatin1Char(':'));
+ QString prefix = colonSplit.value(0);
+
+ if (prefix != QLatin1String("qtlandmarks"))
+ return false;
+
+ QString managerName = colonSplit.value(1);
+
+ if (managerName.trimmed().isEmpty())
+ return false;
+
+ QString firstParts = prefix + QLatin1Char(':') + managerName + QLatin1Char(':');
+ QString paramString = uri.mid(firstParts.length());
+
+ QMap<QString, QString> outParams;
+
+ // Now we have to decode each parameter
+ if (!paramString.isEmpty()) {
+ QStringList params = paramString.split(QRegExp(QLatin1String("&(?!(amp;|equ;))")), QString::KeepEmptyParts);
+ // If we have an empty string for paramstring, we get one entry in params,
+ // so skip that case.
+ for(int i = 0; i < params.count(); i++) {
+ /* This should be something like "foo&amp;bar&equ;=grob&amp;" */
+ QStringList paramChunk = params.value(i).split(QLatin1String("="), QString::KeepEmptyParts);
+
+ if (paramChunk.count() != 2)
+ return false;
+
+ QString arg = paramChunk.value(0);
+ QString param = paramChunk.value(1);
+ arg.replace(QLatin1String("&equ;"), QLatin1String("="));
+ arg.replace(QLatin1String("&amp;"), QLatin1String("&"));
+ param.replace(QLatin1String("&equ;"), QLatin1String("="));
+ param.replace(QLatin1String("&amp;"), QLatin1String("&"));
+ if (arg.isEmpty())
+ return false;
+ outParams.insert(arg, param);
+ }
+ }
+
+ if (pParams)
+ *pParams = outParams;
+ if (pManagerName)
+ *pManagerName = managerName;
+ return true;
+}
+
+/*!
+ \internal
+*/
+void QLandmarkManager::connectNotify(const char *signal)
+{
+
+ if (!d_ptr->isConnected) {
+ if (d_ptr->engine) {
+ if (QLatin1String(signal) == SIGNAL(landmarksAdded(QList<QLandmarkId>))
+ || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(landmarksRemoved(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(dataChanged()))) {
+ connect(d_ptr->engine,SIGNAL(landmarksAdded(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksAdded(QList<QLandmarkId>)));
+ connect(d_ptr->engine,SIGNAL(landmarksChanged(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksChanged(QList<QLandmarkId>)));
+ connect(d_ptr->engine,SIGNAL(landmarksRemoved(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksRemoved(QList<QLandmarkId>)));
+ connect(d_ptr->engine,SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)));
+ connect(d_ptr->engine,SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)));
+ connect(d_ptr->engine,SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)));
+ connect(d_ptr->engine,SIGNAL(dataChanged()),
+ this, SIGNAL(dataChanged()));
+ d_ptr->isConnected = true;
+ }
+ }
+ }
+ QObject::connectNotify(signal);
+}
+
+/*!
+ \internal
+*/
+void QLandmarkManager::disconnectNotify(const char *signal)
+{
+ if (d_ptr->isConnected) {
+ if (d_ptr->engine) {
+ if ((QLatin1String(signal) == SIGNAL(landmarksAdded(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(landmarksRemoved(QList<QLandmarkId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)))
+ || (QLatin1String(signal) == SIGNAL(dataChanged()))) {
+ disconnect(d_ptr->engine,SIGNAL(landmarksAdded(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksAdded(QList<QLandmarkId>)));
+ disconnect(d_ptr->engine,SIGNAL(landmarksChanged(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksChanged(QList<QLandmarkId>)));
+ disconnect(d_ptr->engine,SIGNAL(landmarksRemoved(QList<QLandmarkId>)),
+ this, SIGNAL(landmarksRemoved(QList<QLandmarkId>)));
+ disconnect(d_ptr->engine,SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)));
+ disconnect(d_ptr->engine,SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)));
+ disconnect(d_ptr->engine,SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)),
+ this, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)));
+ disconnect(d_ptr->engine,SIGNAL(dataChanged()),
+ this, SIGNAL(dataChanged()));
+ d_ptr->isConnected = false;
+ }
+ }
+ }
+ QObject::disconnectNotify(signal);
+}
+
+QLandmarkManagerEngine *QLandmarkManager::engine()
+{
+ return d_ptr->engine;
+}
+
+/*!
+ \fn QLandmarkManager::dataChanged()
+ This signal is emitted by the manager if its internal state changes and it is unable to precisely determine
+ the changes which occurred, or if the manager considers the changes to be radical enough to require clients to reload
+ all data. If the signal is emitted, no other signals will be emitted for the associated changes.
+*/
+
+/*!
+ \fn void QLandmarkManager::landmarksAdded(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted when landmarks (identified by \a landmarkIds) have been added to the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes.
+ \sa landmarksChanged(), landmarksRemoved()
+*/
+
+/*!
+ \fn void QLandmarkManager::landmarksChanged(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted when landmarks (identified by \a landmarkIds) have been modified in the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes. Note that removal
+ of a category will not trigger a \c landmarksChanged signal for landmarks belonging to that category.
+
+ \sa landmarksAdded(), landmarksRemoved()
+*/
+
+/*!
+ \fn void QLandmarkManager::landmarksRemoved(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted when landmarks (identified by \a landmarkIds) have been removed from the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes.
+ \sa landmarksAdded(), landmarksChanged()
+*/
+
+/*!
+ \fn void QLandmarkManager::categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted when categories (identified by \a categoryIds) have been added to the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes.
+ \sa categoriesChanged(), categoriesRemoved()
+*/
+
+/*!
+ \fn void QLandmarkManager::categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted when categories (identified by \a categoryIds) have been modified in the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes.
+ \sa categoriesAdded(), categoriesRemoved()
+*/
+
+/*!
+ \fn void QLandmarkManager::categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted when categories (identified by \a categoryIds) have been removed from the datastore managed by this manager.
+ This signal is not emitted if the dataChanged() signal was previously emitted for these changes.
+ \sa categoriesAdded(), categoriesChanged()
+*/
+
+#include "moc_qlandmarkmanager.cpp"
diff --git a/src/location/landmarks/qlandmarkmanager.h b/src/location/landmarks/qlandmarkmanager.h
new file mode 100644
index 00000000..13a9f08f
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanager.h
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKMANAGER_H
+#define QLANDMARKMANAGER_H
+
+#include "qmobilityglobal.h"
+#include "qlandmarkid.h"
+#include "qlandmarkfilter.h"
+#include "qlandmarksortorder.h"
+#include "qlandmarkcategoryid.h"
+#include "qlandmarknamesort.h"
+#include "qlandmarkfilter.h"
+#include "qlandmarkcategory.h"
+#include "qlandmark.h"
+
+#include <qlatin1constant.h>
+#include <QObject>
+#include <QMap>
+class QIODevice;
+class QStringList;
+
+QTM_BEGIN_NAMESPACE
+class QLandmarkManagerPrivate;
+class QLandmarkManagerEngine;
+
+class Q_LOCATION_EXPORT QLandmarkManager: public QObject
+{
+ Q_OBJECT
+public:
+ enum Error {
+ NoError = 0,
+ DoesNotExistError,
+ LandmarkDoesNotExistError,
+ CategoryDoesNotExistError,
+ AlreadyExistsError,
+ LockedError,
+ PermissionsError,
+ OutOfMemoryError,
+ VersionMismatchError,
+ NotSupportedError,
+ BadArgumentError,
+ InvalidManagerError,
+ ParsingError,
+ CancelError,
+ UnknownError,
+ };
+
+ enum SupportLevel {
+ NativeSupport,
+ EmulatedSupport,
+ NoSupport
+ };
+
+ enum ManagerFeature {
+ ImportExportFeature,
+ NotificationsFeature
+ };
+
+
+ enum TransferOption {
+ IncludeCategoryData,
+ ExcludeCategoryData,
+ AttachSingleCategory
+ };
+
+ enum TransferOperation {
+ ImportOperation,
+ ExportOperation
+ };
+
+#ifdef Q_QDOC
+ static const QLatin1Constant Gpx;
+ static const QLatin1Constant Lmx;
+ static const QLatin1Constant Kml;
+ static const QLatin1Constant Kmz;
+#else
+ Q_DECLARE_LATIN1_CONSTANT(Gpx, "Gpx");
+ Q_DECLARE_LATIN1_CONSTANT(Lmx, "Lmx");
+ Q_DECLARE_LATIN1_CONSTANT(Kml, "Kml");
+ Q_DECLARE_LATIN1_CONSTANT(Kmz, "Kmz");
+#endif
+
+#ifdef Q_QDOC
+ QLandmarkManager(QObject *parent = 0);
+ QLandmarkManager(const QString &managerName, const QMap<QString, QString> &parameters = 0, QObject *parent = 0);
+#else
+ QLandmarkManager(QObject *parent = 0);
+ QLandmarkManager(const QString &managerName, const QMap<QString, QString>& parameters = (QMap<QString, QString>()), QObject *parent = 0);
+#endif
+ virtual ~QLandmarkManager();
+
+ bool saveLandmark(QLandmark *landmark);
+ bool saveLandmarks(QList<QLandmark> *landmarks);
+
+ bool removeLandmark(const QLandmarkId &landmarkId);
+ bool removeLandmark(const QLandmark &landmark);
+
+ bool removeLandmarks(const QList<QLandmarkId> &landmarksIds);
+ bool removeLandmarks(const QList<QLandmark> &landmarks);
+
+ bool saveCategory(QLandmarkCategory *category);
+ bool removeCategory(const QLandmarkCategoryId &categoryId);
+ bool removeCategory(const QLandmarkCategory &category);
+
+ QLandmarkCategory category(const QLandmarkCategoryId &categoryId) const;
+ QList<QLandmarkCategory> categories(const QList<QLandmarkCategoryId> &categoryIds) const;
+
+ QList<QLandmarkCategory> categories( int limit=-1, int offset=0, const QLandmarkNameSort &nameSort = QLandmarkNameSort()) const;
+ QList<QLandmarkCategoryId> categoryIds(int limit =-1, int offset=0, const QLandmarkNameSort &nameSort = QLandmarkNameSort()) const;
+
+ QLandmark landmark(const QLandmarkId &landmarkId) const;
+ QList<QLandmark> landmarks(const QLandmarkFilter &filter,
+ int limit, int offset,
+ const QList<QLandmarkSortOrder>& sortOrders) const;
+ QList<QLandmark> landmarks(const QLandmarkFilter &filter = QLandmarkFilter(),
+ int limit=-1, int offset=0,
+ const QLandmarkSortOrder &sortOrder = QLandmarkSortOrder()) const;
+
+ QList<QLandmark> landmarks(const QList<QLandmarkId> &landmarkIds) const;
+ QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter,
+ int limit, int offset,
+ const QList<QLandmarkSortOrder> &sortOrders)const;
+ QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter = QLandmarkFilter(),
+ int limit=-1, int offset =0,
+ const QLandmarkSortOrder &sortOrder = QLandmarkSortOrder()) const;
+
+ bool importLandmarks(QIODevice *device, const QString &format= QString() ,QLandmarkManager::TransferOption option = IncludeCategoryData, const QLandmarkCategoryId& = QLandmarkCategoryId());
+ bool importLandmarks(const QString &fileName, const QString &format = QString(),QLandmarkManager::TransferOption option = IncludeCategoryData, const QLandmarkCategoryId& = QLandmarkCategoryId());
+ bool exportLandmarks(QIODevice *device, const QString &format, const QList<QLandmarkId> &landmarkIds = QList<QLandmarkId>(), QLandmarkManager::TransferOption option = IncludeCategoryData) const;
+ bool exportLandmarks(const QString &, const QString &format, const QList<QLandmarkId> &landmarkIds = QList<QLandmarkId>(), QLandmarkManager::TransferOption option = IncludeCategoryData) const;
+
+ QStringList supportedFormats(TransferOperation operation) const;
+
+ Error error() const;
+ QString errorString() const;
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+
+ bool isFeatureSupported(ManagerFeature feature) const;
+ SupportLevel filterSupportLevel(const QLandmarkFilter &filter) const;
+ SupportLevel sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder) const;
+
+ bool isReadOnly() const;
+ bool isReadOnly(const QLandmarkId &id) const;
+ bool isReadOnly(const QLandmarkCategoryId &id) const;
+
+ QStringList searchableLandmarkAttributeKeys() const;
+
+ QString managerName() const;
+ QMap<QString, QString> managerParameters() const;
+ QString managerUri() const;
+ int managerVersion() const;
+
+ static QStringList availableManagers();
+ static QString buildUri(const QString& managerName, const QMap<QString, QString>& params,int implementationVersion = -1);
+ static QLandmarkManager* fromUri(const QString& uri, QObject* parent = 0);
+ static bool parseUri(const QString& uri, QString* managerName, QMap<QString, QString>* params);
+
+Q_SIGNALS:
+ void dataChanged();
+ void landmarksAdded(const QList<QLandmarkId> &landmarkIds);
+ void landmarksChanged(const QList<QLandmarkId> &landmarkIds);
+ void landmarksRemoved(const QList<QLandmarkId> &landmarkIds);
+
+ void categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds);
+ void categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds);
+ void categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+
+private:
+ QLandmarkManagerPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QLandmarkManager)
+ friend class QLandmarkAbstractRequest;
+ QLandmarkManagerEngine *engine();
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkmanager_p.cpp b/src/location/landmarks/qlandmarkmanager_p.cpp
new file mode 100644
index 00000000..1b9bb613
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanager_p.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkmanager_p.h"
+#include "qlandmarkmanagerengine.h"
+#include "qlandmarkmanagerenginefactory.h"
+#include <QPluginLoader>
+#include <QDebug>
+#include <QStringList>
+#include <QCoreApplication>
+#include <QObject>
+#include <QProcess>
+#include <QEventLoop>
+
+#include "qmobilitypluginsearch.h"
+
+QTM_USE_NAMESPACE
+
+QLandmarkManagerPrivate::QLandmarkManagerPrivate()
+ : engine(0),
+ errorCode(QLandmarkManager::NoError),
+ isConnected(false),
+ q_ptr(0)
+{
+}
+
+void QLandmarkManagerPrivate::createEngine(const QString &managerName, const QMap<QString,QString> &parameters)
+{
+ Q_Q(QLandmarkManager);
+
+ if (!q->availableManagers().contains(managerName)) {
+ errorCode = QLandmarkManager::InvalidManagerError;
+ errorString = QString("The landmark manager, %1, was not found").arg(managerName);
+ qWarning() << errorString;
+ engine = 0;
+ return;
+ }
+
+ QList<QLandmarkManagerEngineFactory *> factories = QLandmarkManagerPrivate::factories().values(managerName);
+
+ bool ok;
+ int implementationVersion = parameters.value(QTLANDMARKS_IMPLEMENTATION_VERSION_NAME).toInt(&ok);
+ if (!ok)
+ implementationVersion = -1;
+
+ foreach(QLandmarkManagerEngineFactory *f, factories)
+ {
+ QList<int> versions = f->supportedImplementationVersions();
+ if (implementationVersion == -1 //no given implementation version required
+ || versions.isEmpty() //manager engine factory does not report any versions
+ || versions.contains(implementationVersion)) {
+ engine = f->engine(parameters, &errorCode, &errorString);
+ break;
+ }
+ }
+
+ if (!engine) {
+ if (errorCode == QLandmarkManager::NoError) {
+ errorCode = QLandmarkManager::InvalidManagerError;
+ errorString = "The landmark manager could not return the requested engine instance";
+ }
+ }
+}
+
+QLandmarkManagerEngine* QLandmarkManagerPrivate::getEngine(const QLandmarkManager* manager)
+{
+ if (manager)
+ return manager->d_ptr->engine;
+ return 0;
+}
+
+ QHash<QString, QLandmarkManagerEngineFactory*> QLandmarkManagerPrivate::factories(bool reload)
+ {
+ static QHash<QString, QLandmarkManagerEngineFactory*> factories;
+ static bool alreadyDiscovered = false;
+
+ if (reload == true)
+ alreadyDiscovered = false;
+
+ if (!alreadyDiscovered) {
+ loadStaticFactories(&factories);
+ loadDynamicFactories(&factories);
+ alreadyDiscovered = true;
+ }
+ return factories;
+ }
+
+void QLandmarkManagerPrivate::loadDynamicFactories(QHash<QString, QLandmarkManagerEngineFactory*> *factories)
+{
+ QStringList paths;
+ paths << mobilityPlugins(QLatin1String("landmarks"));
+
+ QPluginLoader qpl;
+ for (int i=0;i < paths.count(); ++i) {
+ qpl.setFileName(paths.at(i));
+
+ QLandmarkManagerEngineFactory *f = qobject_cast<QLandmarkManagerEngineFactory*>(qpl.instance());
+ if (f) {
+ QString name = f->managerName();
+
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+ if (showDebug)
+ qDebug() << "Dynamic: found an engine plugin with name" << name;
+#endif
+ factories->insertMulti(name,f);
+ }
+ }
+}
+
+void QLandmarkManagerPrivate::loadStaticFactories(QHash<QString, QLandmarkManagerEngineFactory*> *factories)
+{
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+#endif
+
+ QObjectList staticPlugins = QPluginLoader::staticInstances();
+ for(int i=0; i < staticPlugins.count(); ++i) {
+ QLandmarkManagerEngineFactory *f = qobject_cast<QLandmarkManagerEngineFactory*>(staticPlugins.at(i));
+ if (f){
+ QString name = f->managerName();
+
+#if !defined QT_NO_DEBUG
+ if (showDebug)
+ qDebug() << "Static: found an engine plugin with name" << name;
+#endif
+ if(!name.isEmpty()) {
+ factories->insertMulti(name, f);
+ }
+ }
+
+ }
+}
diff --git a/src/location/landmarks/qlandmarkmanager_p.h b/src/location/landmarks/qlandmarkmanager_p.h
new file mode 100644
index 00000000..8d4b3d01
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanager_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKMANAGER_P_H
+#define QLANDMARKMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include "qlandmarkmanager.h"
+#include <QHash>
+#include <QString>
+#include <QMap>
+
+#define QTLANDMARKS_IMPLEMENTATION_VERSION_NAME "com.nokia.qtmobility.landmarks.implementation.version"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManagerEngine;
+class QLandmarkManagerEngineFactory;
+
+class QLandmarkManagerPrivate
+{
+public:
+ QLandmarkManagerPrivate();
+ void createEngine(const QString &managerName, const QMap<QString,QString> &parameters = (QMap<QString, QString>()));
+
+ QLandmarkManagerEngine *engine;
+ mutable QLandmarkManager::Error errorCode;
+ mutable QString errorString;
+ mutable QMap<int, QLandmarkManager::Error> errorMap;
+ static QLandmarkManagerEngine *getEngine(const QLandmarkManager* manager);
+ static void loadFactories();
+ static QHash<QString, QLandmarkManagerEngineFactory*> factories(bool reload = false);
+ static void loadDynamicFactories (QHash<QString, QLandmarkManagerEngineFactory*> *factories);
+ static void loadStaticFactories (QHash<QString, QLandmarkManagerEngineFactory*> *factories);
+ bool isConnected;//identifies whether connections have been made to the notification signals
+
+ QLandmarkManager *q_ptr;
+ Q_DECLARE_PUBLIC(QLandmarkManager)
+};
+
+QTM_END_NAMESPACE
+
+#endif // QLANDMARKMANAGER_P_H
diff --git a/src/location/landmarks/qlandmarkmanagerengine.cpp b/src/location/landmarks/qlandmarkmanagerengine.cpp
new file mode 100644
index 00000000..41bb7dbe
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanagerengine.cpp
@@ -0,0 +1,1389 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkmanagerengine.h"
+#include "qlandmark.h"
+#include "qlandmarkcategory.h"
+#include "qlandmarkid.h"
+#include "qlandmarkcategoryid.h"
+
+#include "qlandmarkrequests_p.h"
+#include "qlandmark_p.h"
+#include "qlandmarkcategory_p.h"
+
+#include "qlandmarkabstractrequest.h"
+#include "qlandmarkidfetchrequest.h"
+#include "qlandmarkfetchrequest.h"
+#include "qlandmarkfetchbyidrequest.h"
+#include "qlandmarkremoverequest.h"
+#include "qlandmarksaverequest.h"
+#include "qlandmarkcategoryidfetchrequest.h"
+#include "qlandmarkcategoryfetchrequest.h"
+#include "qlandmarkcategoryfetchbyidrequest.h"
+#include "qlandmarkcategoryremoverequest.h"
+#include "qlandmarkcategorysaverequest.h"
+#include "qlandmarkimportrequest.h"
+#include "qlandmarkexportrequest.h"
+
+#include "qlandmarknamesort.h"
+
+#include "qlandmarkattributefilter.h"
+#include "qlandmarkboxfilter.h"
+#include "qlandmarkcategoryfilter.h"
+#include "qlandmarkintersectionfilter.h"
+#include "qlandmarkidfilter.h"
+#include "qlandmarknamefilter.h"
+#include "qlandmarkproximityfilter.h"
+#include "qlandmarkunionfilter.h"
+
+#include "qgeocoordinate.h"
+
+#include <QWeakPointer>
+
+QTM_BEGIN_NAMESPACE
+
+bool matchString(const QString &sourceString, const QString &matchString, QLandmarkFilter::MatchFlags matchFlags )
+{
+ Qt::CaseSensitivity cs;
+ if (matchFlags & QLandmarkFilter::MatchCaseSensitive)
+ cs = Qt::CaseSensitive;
+ else
+ cs = Qt::CaseInsensitive;
+ if ((matchFlags & 3) == QLandmarkFilter::MatchEndsWith) {
+ return sourceString.endsWith(matchString, cs);
+ } else if ((matchFlags & 3) == QLandmarkFilter::MatchStartsWith) {
+ return sourceString.startsWith(matchString, cs);
+ } else if ((matchFlags & 3) == QLandmarkFilter::MatchContains) {
+ return sourceString.contains(matchString,cs);
+ } else if (matchFlags & QLandmarkFilter::MatchFixedString) {
+ return sourceString.compare(matchString,cs) == 0;
+ } else {
+ return QVariant(sourceString) == QVariant(matchString);
+ }
+}
+
+QVariant getLandmarkAttribute(const QString key, const QLandmark &landmark)
+{
+ if (key == "name") {
+ return landmark.name();
+ } else if (key == "description") {
+ return landmark.description();
+ } else if (key == "countryCode") {
+ return landmark.address().countryCode();
+ } else if (key == "country") {
+ return landmark.address().country();
+ } else if (key == "state") {
+ return landmark.address().state();
+ } else if (key == "city") {
+ return landmark.address().city();
+ } else if (key == "district") {
+ return landmark.address().district();
+ } else if (key == "district") {
+ return landmark.address().district();
+ } else if (key == "street") {
+ return landmark.address().street();
+ } else if (key == "postcode") {
+ return landmark.address().postcode();
+ } else if (key == "phoneNumber") {
+ return landmark.phoneNumber();
+ } else {
+ return QVariant(); // shouldn't be possible
+ }
+}
+
+QStringList commonLandmarkKeys = QStringList() << "name"
+ << "description"
+ << "countryCode"
+ << "country"
+ << "state"
+ << "county"
+ << "city"
+ << "district"
+ << "street"
+ << "postcode"
+ << "phoneNumber";
+
+/*!
+ \class QLandmarkManagerEngine
+ \brief The QLandmarkManagerEngine class provides the interface for all implementations
+ of the landmark manager backend functionality.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-backend
+
+ Instances of this class are usually provided by \l QLandmarkManagerEngineFactory, which is loaded
+ from a plugin.
+*/
+
+/*!
+ Constructs a landmark manager engine.
+*/
+QLandmarkManagerEngine::QLandmarkManagerEngine()
+{
+}
+
+/*!
+ Destructor.
+*/
+QLandmarkManagerEngine::~QLandmarkManagerEngine()
+{
+}
+
+/*! Returns the manager name for this QLandmarkManagerEngine */
+QString QLandmarkManagerEngine::managerName() const
+{
+ return QString(QLatin1String("base"));
+}
+
+/*!
+ Returns the parameters with which this engine was constructed. Note that
+ the engine may have discarded unused or invalid parameters at the time of
+ construction, and these will not be returned.
+ */
+QMap<QString, QString> QLandmarkManagerEngine::managerParameters() const
+{
+ return QMap<QString, QString>(); // default implementation requires no parameters.
+}
+
+/*!
+ Returns the unique URI of this manager, which is built from the manager name and the parameters
+ used to construct it.
+ */
+QString QLandmarkManagerEngine::managerUri() const
+{
+ return QLandmarkManager::buildUri(managerName(), managerParameters(), managerVersion());
+}
+
+/*!
+ Returns the engine backend implementation version number
+ */
+int QLandmarkManagerEngine::managerVersion() const
+{
+ return 0;
+}
+
+/*!
+ Returns a list of landmark identifiers which match the given \a filter and are sorted according to
+ the given \a sortOrders. The \a limit defines the maximum number of landmark IDs to return and the
+ \a offset defines the index offset of the first landmark ID.
+ A \a limit of -1 means that IDs of all matching landmarks should be returned.
+
+ Any error which occurs will be saved in \a error and \a errorString.
+ */
+QList<QLandmarkId> QLandmarkManagerEngine::landmarkIds(const QLandmarkFilter& /*filter*/,
+ int /*limit*/, int /*offset*/, const QList<QLandmarkSortOrder>& /*sortOrders*/, QLandmarkManager::Error* /*error*/,
+ QString */* errorString */) const
+{
+ return QList<QLandmarkId>();
+}
+
+/*!
+ Returns a list of category identifiers
+ The \a limit defines the maximum number of IDs to return and the \a offset defines the index offset
+ of the first ID. A \a limit of -1 means IDs for all categories should be returned.
+ Any error which occurs will be saved in \a error and \a errorString.
+ The identifiers are returned in order according to the given \a nameSort.
+*/
+QList<QLandmarkCategoryId> QLandmarkManagerEngine::categoryIds(int /*limit*/, int /*offset*/, const QLandmarkNameSort& /*nameSort*/, QLandmarkManager::Error* /*error*/,
+ QString* /*errorString*/) const
+{
+ return QList<QLandmarkCategoryId>();
+}
+
+/*!
+ Returns the landmark in the datastore identified by \a landmarkId.
+
+ Any errors encountered are:stored in \a error and \a errorString.
+ The \a error is set to QLandmarkManager::LandmarkDoesNotExistError if the landmark could not be found.
+*/
+QLandmark QLandmarkManagerEngine::landmark(const QLandmarkId &/*landmarkId*/, QLandmarkManager::Error * /*error*/,
+ QString* /*errorString*/) const
+{
+ return QLandmark();
+}
+
+/*!
+ Returns a list of landmarks which match the given \a landmarkIds. The engine will populate \a errorMap
+ (the map of indices of the \a landmarkIds list to errors) for the indexes where the landmark could not
+ be retrieved.
+
+ Overall operation errors are stored in \a error and
+ \a errorString. \a error is set to QLandmarkManager::NoError,
+ all landmarks were successfully retrieved.
+*/
+QList<QLandmark> QLandmarkManagerEngine::landmarks(const QList<QLandmarkId>& /*landmarkIds*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const
+{
+ return QList<QLandmark>();
+}
+
+/*!
+ Returns a list of landmarks which match the given \a filter and are sorted according to the \a sortOrders.
+ The \a limit defines the maximum number of landmarks to return and the \a offset defines the index offset
+ of the first landmark. A \a limit of -1 means all matching landmarks should be returned.
+
+ Overall operation errors are stored in \a error and \a errorString.
+*/
+QList<QLandmark> QLandmarkManagerEngine::landmarks(const QLandmarkFilter& /*filter*/, int /*limit*/, int /*offset*/,
+ const QList<QLandmarkSortOrder>& /*sortOrders*/, QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const
+{
+ return QList<QLandmark>();
+}
+
+/*!
+ Returns the category in the datastore identified by \a categoryId.
+
+ Any errors encountered are stored in \a error and \a errorString.
+ A QLandmarkManager::CategoryDoesNotExist error is set if the category could not be found.
+*/
+QLandmarkCategory QLandmarkManagerEngine::category(const QLandmarkCategoryId& /*categoryId*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const
+{
+ return QLandmarkCategory();
+}
+
+/*!
+ Returns a list of categories which match the given \a categoryIds. The engine will populate \a errorMap
+ (the map of indices of the \a categoryIds list to errors) for the indexes where the category could not
+ be retrieved.
+
+ Overall operation errors are stored in \a error and
+ \a errorString. \a error is set to QLandmarkManager::NoError, if
+ all categories were successfully retrieved.
+*/
+QList<QLandmarkCategory> QLandmarkManagerEngine::categories(const QList<QLandmarkCategoryId>& /*categoryIds*/,
+ QMap<int, QLandmarkManager::Error>* /*errorMap*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const
+{
+ return QList<QLandmarkCategory>();
+}
+
+/*!
+ Returns a list of categories.
+ The \a limit defines the maximum number of categories to return and the \a offset defines the index offset
+ of the first category. A \a limit of -1 means all categories should be returned.
+ The returned categories ordered according to the gien \a nameSort.
+*/
+QList<QLandmarkCategory> QLandmarkManagerEngine::categories(int /*limit*/, int /*offset*/, const QLandmarkNameSort& /*nameSort*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/) const
+{
+ return QList<QLandmarkCategory>();
+}
+
+/*!
+ Adds the given \a landmark to the datastore if \a landmark has a
+ default-constructed identifer, or an identifier with the manager
+ URI set to the URI of this manager and an empty id.
+
+ If the manager URI of the identifier of the \a landmark is neither
+ empty nor equal to the URI of this manager, or the id member of the
+ identifier is not empty, but does not exist in the manager,
+ the operation will fail and and \a error will be set to
+ \c QLandmarkManager::LandmarkDoesNotExistError.
+
+ Alternatively, the function will update the existing landmark in the
+ datastore if \a landmark has a non-empty id and currently exists
+ within the datastore.
+
+ Returns false on failure or true on success. On successful save
+ of a landmark with an empty id, it will be assigned a valid
+ id and have its manager URI set to the URI of this manager.
+
+ The engine must emit the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation.
+
+ Any errors encountered during this operation should be stored in
+ \a error and \a errorString.
+*/
+bool QLandmarkManagerEngine::saveLandmark(QLandmark* /*landmark*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Adds the list of \a landmarks to the datastore.
+ Returns true if the landmarks were saved successfully, otherwise returns
+ false.
+
+ The engine will populate \a errorMap (the map of indices of the
+ \a landmarks list to errors) for every index for which the landmark could not be
+ saved.
+
+
+ For each newly saved landmark that was successful, the identifier
+ of the landmark will be updated with a new value.
+
+ The engine emits the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation.
+
+ Overall operation errors are stored in \a error and
+ \a errorString. \a error is set to QLandmarkManager::NoError,
+ if all \a landmarks were successfully saved.
+
+ \sa QLandmarkManagerEngine::saveLandmark()
+*/
+bool QLandmarkManagerEngine::saveLandmarks(QList<QLandmark> * /*landmarks*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Remove the landmark identified by \a landmarkId from the datastore.
+
+ Returns true if the landmark was removed successfully, otherwise
+ returnse false.
+
+ The engine emits the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation.
+
+ Any errors encountered during this operation should be stored to
+ \a error and \a errorString.
+*/
+bool QLandmarkManagerEngine::removeLandmark(const QLandmarkId& /*landmarkId*/, QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Removes every landmark whose identifier is contained in the list
+ of \a landmarkIds. Returns true if all landmarks were removed
+ successfully, otherwise false.
+
+ The engine populates \a errorMap (the map of indices of the
+ \a landmarkIds list to errors) for every index for which the landmark could not be
+ removed.
+
+ The engine also emits the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation.
+
+ Overall operation errors are stored in \a error and
+ \a errorString. \a error is set to QLandmarkManager::NoError, if
+ all landmarks were successfully removed.
+
+ \sa QLandmarkManagerEngine::removeLandmark()
+*/
+bool QLandmarkManagerEngine::removeLandmarks(const QList<QLandmarkId>& /*landmarkIds*/, QMap<int, QLandmarkManager::Error>* /*errorMap*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Adds the given \a category to the datastore if \a category has a
+ default-constructed identifier, or an identifier with the manager
+ URI set to the URI of this manager and an empty id.
+
+ If the manager URI of the identifier of the \a category is neither
+ empty nor equal to the URI of this manager, or the id member of the
+ identifier is not empty, but does not exist in the manager,
+ the operation should fail and \a error should be set to
+ \c QLandmarkManager::CategoryDoesNotExistError.
+
+ Alternatively, the function should update the existing category in the
+ datastore if \a category has a non-empty id and currently exists
+ within the datastore.
+
+ Returns false on failure or true on success. On successful save
+ of a category with an invalid id, it should be assigned a valid
+ id and have its manager URI set to the URI of this manager.
+
+ The engine returns the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation.
+
+ Overall operations errors should be stored in \a error and
+ \a errorString.
+*/
+bool QLandmarkManagerEngine::saveCategory(QLandmarkCategory* /*category*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Removes the category identified by \a categoryId from the datastore.
+
+ Returns true if the category was removed successfully, otherwise
+ returnse false.
+
+ The engine emits the appropriate signals to inform clients of changes
+ to the datastore resulting from this operation
+
+ Overall operational errors are stored in \a error and
+ \a errorString.
+*/
+bool QLandmarkManagerEngine::removeCategory(const QLandmarkCategoryId& /*categoryId*/,
+ QLandmarkManager::Error* /*error*/, QString* /*errorString*/)
+{
+ return false;
+}
+
+/*!
+ Reads landmarks from the given \a device and saves them. The data from the \a device
+ is expected to adhere to the provided \a format. If no \a format is provided,
+ the manager engine tries to autodetect the \a format.
+
+ The \a option can be used to control whether categories in the imported
+ file will be added during the import. If the \c AttachSingleCategory option is used, then
+ all the landmarks in the import file are assigned to the category identified by
+ \a categoryId, in all other circumstances \a categoryId is ignored. If \a categoryId
+ doesn't exist when using \c AttachSingleCategory, QLandmarkManager::CategoryDoesNotExist error is returned. Note that
+ some file formats may not support categories at all.
+
+ Returns true if all landmarks could be imported, otherwise returns false.
+
+ Overall operational errors are stored in \a error and
+ \a errorString.
+*/
+bool QLandmarkManagerEngine::importLandmarks(QIODevice* /*device*/, const QString& /*format*/, QLandmarkManager::TransferOption /*option*/, const QLandmarkCategoryId& /*categoryId*/,
+ QLandmarkManager::Error *error, QString *errorString)
+{
+ Q_ASSERT(error);
+ Q_ASSERT(errorString);
+ *error = QLandmarkManager::NotSupportedError;
+ *errorString ="Not supported";
+ return false;
+}
+
+/*!
+ Writes landmarks to the given \a device. The landmarks will be written
+ according to the specified \a format. If \a landmarkIds is empty, then
+ all landmarks will be exported, otherwise only those landmarks that
+ match \a landmarkIds will be exported.
+
+ The \a option can be used to control whether categories will be exported or not.
+ Note that the \c AttachSingleCategory option has no meaning during
+ export and the manager will export as if \a option was \c IncludeCategoryData.
+ Also, be aware that some file formats may not support categories at all and for
+ these formats, the \a option is always treated as if it was \c ExcludeCategoryData.
+
+ Returns true if all specified landmarks were successfully exported,
+ otherwise returns false.
+
+ Overall operation errors are stored in \a error and
+ \a errorString.
+*/
+bool QLandmarkManagerEngine::exportLandmarks(QIODevice * /*device*/, const QString& /*format*/, const QList<QLandmarkId> &/*landmarkIds*/, QLandmarkManager::TransferOption /*option*/,
+ QLandmarkManager::Error *error, QString *errorString) const
+{
+ Q_ASSERT(error);
+ Q_ASSERT(errorString);
+ *error = QLandmarkManager::NotSupportedError;
+ *errorString = "Not supported";
+ return false;
+}
+
+/*!
+ Returns the supported file formats for the given transfer \a operation, i.e. import or export.
+ Errors are stored in \a error and \a errorString.
+*/
+QStringList QLandmarkManagerEngine::supportedFormats(QLandmarkManager::TransferOperation /*operation*/ , QLandmarkManager::Error *error, QString *errorString) const
+{
+ Q_ASSERT(error);
+ Q_ASSERT(errorString);
+ *error = QLandmarkManager::NoError;
+ *errorString = "";
+ return QStringList();
+}
+
+/*!
+ \fn QLandmarkManager::SupportLevel QLandmarkManagerEngine::filterSupportLevel(const QLandmarkFilter &filter,
+ QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns the support level the manager engine provides for the given \a filter. Errors are stored in \a error
+ and \a errorString.
+*/
+
+/*!
+ \fn QLandmarkManager::SupportLevel QLandmarkManagerEngine::sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder,
+ QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns the support level the manager engine provides for the given \a sortOrder. Errors are stored in \a error
+ and \a errorString.
+*/
+
+/*!
+ \fn bool QLandmarkManagerEngine::isFeatureSupported(QLandmarkManager::ManagerFeature feature, QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns true if the manager engine supports the given \a feature, otherwise returns false; Errors are stored in
+ \a error and \a errorString.
+*/
+
+/*!
+ \fn bool QLandmarkManagerEngine::isReadOnly(QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns true if the manager engine is exclusively read only. Meaning
+ landmarks and categories cannot be added, modified or removed. Errors are stored in \a error and \a errorString.
+*/
+
+/*!
+ \fn bool QLandmarkManagerEngine::isReadOnly(const QLandmarkId &landmarkId,
+ QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns true if the landmark identified by \a landmarkId
+ considered read-only by the manager engine.
+
+ If the \a landmarkId does not refer to an existing landmark,
+ it is considered writable unless the manager engine is exclusively read-only.
+ Errors are stored in \a error and \a errorString.
+ */
+
+ /*!
+ \fn bool QLandmarkManagerEngine::isReadOnly(const QLandmarkCategoryId &categoryId,
+ QLandmarkManager::Error *error, QString *errorString) const
+
+ Returns true if the category identified by \a categoryId is
+ considered read-only by the manager engine.
+
+ If \a categoryId does not refer to an existing category,
+ it is considered writable unless the manager engine is exclusively read-only.
+ Errors are stored in \a error and \a errorString.
+*/
+
+/*!
+ \fn QStringList QLandmarkManagerEngine::searchableLandmarkAttributeKeys(QLandmarkManager::Error *error, QString *errorString) const
+ Returns the list of landmark attribute keys that may be used in a QLandmarkAttributeFilter.
+ Errors are stored in \a error and \a errorString.
+*/
+
+/*!
+ Notifies the manager engine that the given \a request has been destroyed.
+*/
+void QLandmarkManagerEngine::requestDestroyed(QLandmarkAbstractRequest* request)
+{
+ Q_UNUSED(request);
+}
+
+/*!
+ Asks the manager engine to begin the given \a request
+ which is currently in a re(startable) state.
+
+ Returns true if the request was started successfully,
+ else returns false.
+
+ \sa QLandmarkAbstractRequest::start()
+*/
+bool QLandmarkManagerEngine::startRequest(QLandmarkAbstractRequest* request)
+{
+ Q_UNUSED(request);
+ return false;
+}
+
+/*!
+ Asks the manager engine to cancel the given \a request which was
+ previously started and is currently in a cancellable state.
+ Returns true if cancelation of the request was started successfully,
+ otherwise returns false.
+
+ \sa startRequest(), QLandmarkAbstractRequest::cancel()
+ */
+bool QLandmarkManagerEngine::cancelRequest(QLandmarkAbstractRequest* request)
+{
+ Q_UNUSED(request);
+ return false;
+}
+
+/*!
+ Blocks until the manager engine has completed the given \a request
+ which was previously started, or until \a msecs milliseconds have passed.
+ Returns true if the request was completed, and false if the request was not in the
+ \c QLandmarkAbstractRequest::Active state, no progress could be reported or
+ if the engine does not support waitForFinished functionality.
+
+ \sa startRequest()
+ */
+bool QLandmarkManagerEngine::waitForRequestFinished(QLandmarkAbstractRequest* request, int msecs)
+{
+ Q_UNUSED(request);
+ Q_UNUSED(msecs);
+ return false;
+}
+
+/*!
+ \fn QLandmarkManagerEngine::dataChanged()
+
+ This signal is emitted some time after changes occur to the datastore managed by this
+ engine, and the engine is unable to precisely determine which changes occurred, or if the
+ engine considers the changes to be radical enough to require clients to reload all data.
+
+ If this signal is emitted, no other signals may be emitted for the associated changes.
+
+ As it is possible that other processes (or other devices) may have caused the
+ changes, the timing can not be determined.
+
+ \sa landmarksAdded(), landmarksChanged(), landmarksRemoved(), categoriesAdded(),
+ categoriesChanged(), categoriesRemoved()
+*/
+
+/*!
+ \fn QLandmarkManagerEngine::landmarksAdded(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted some time after a set of landmarks has been added to
+ the datastore managed by the engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may
+ have added the landmarks, the exact timing cannot be determined.
+
+ There may be one or more landmark identifiers in the \a landmarkIds list.
+
+ \sa dataChanged(), landmarksChanged(), landmarksRemoved()
+*/
+
+/*!
+ \fn QLandmarkManagerEngine::landmarksChanged(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted some time after a set of landmarks have been modified in
+ the datastore managed by this engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may have modified the landmarks,
+ the timing cannot be determined.
+
+ Note that removal of a category will not trigger a \c landmarksChanged signal for landmarks belonging to that category.
+
+ There may be one ore more landmark identifiers in the \a landmarkIds list.
+ \sa dataChanged(), landmarksAdded(), landmarksRemoved()
+*/
+
+
+/*!
+ \fn QLandmarkManagerEngine::landmarksRemoved(const QList<QLandmarkId> &landmarkIds)
+
+ This signal is emitted some time after a set of landmarks have been removed from the
+ datastore managed by this engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may have removed the landmarks,
+ the timing cannot be determined.
+
+ There may be one ore more landmark identifiers in the \a landmarkIds list.
+ \sa dataChanged(), landmarksAdded(), landmarksChanged()
+*/
+
+/*!
+ \fn QLandmarkManagerEngine::categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted some time after a set of categories has been added to the datastore
+ managed by this engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may
+ have added the landmarks, the exact timing cannot be determined.
+
+ There may be one or more category identifiers in the \a categoryIds list.
+
+ \sa dataChanged(), categoriesChanged(), categoriesRemoved()
+*/
+
+/*!
+ \fn QLandmarkManagerEngine::categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted some time after a set of categories have been modified in the datastore
+ managed by the engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may have modified the categories,
+ the timing cannot be determined.
+
+ There may be one ore more category identifiers in the \a categoryIds list.
+
+ \sa dataChanged(), categoriesAdded(), categoriesRemoved()
+*/
+
+/*!
+ \fn QLandmarkManagerEngine::categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds)
+
+ This signal is emitted some time after a set of categories have been removed from the datastore
+ managed by this engine and where the \l dataChanged() signal was not emitted for those changes.
+ As it is possible that other processes(or other devices) may have removed the categories,
+ the timing cannot be determined.
+
+ There may be one ore more category identifiers in the \a categoryIds list.
+
+ \sa dataChanged(), categoriesAdded(), categoriesChanged()
+*/
+
+/*!
+ Updates the given asynchronous request \a req by setting the new \a state
+ of the request. If the new state is different, the stateChanged() signal will be emitted
+ by the request.
+
+*/
+void QLandmarkManagerEngine::updateRequestState(QLandmarkAbstractRequest *req, QLandmarkAbstractRequest::State state)
+{
+ if (req) {
+ QMutexLocker ml(&req->d_ptr->mutex);
+ if (req->d_ptr->state != state) {
+ req->d_ptr->state = state;
+ ml.unlock();
+ emit req->stateChanged(state);
+ }
+ }
+}
+
+/*!
+ Updates the given QLandmarkIdFetchRequest \a req with the latest \a result,
+ and operation \a error and \a errorString. In addition, the state of the request
+ will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkIdFetchRequest(QLandmarkIdFetchRequest* req, const QList<QLandmarkId>& result,
+ QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkIdFetchRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkIdFetchRequestPrivate * rd = static_cast<QLandmarkIdFetchRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->landmarkIds = result;
+ bool emitState = rd->state != newState;
+ rd->state =newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit ireq.data()->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkFetchRequest \a req with the latest \a result,
+ and operation \a error and \a errorString. In addition, the state of the request
+ will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkFetchRequest(QLandmarkFetchRequest* req, const QList<QLandmark>& result,
+ QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkFetchRequest> ireq(req); //Take this incase the first emit deletes us.
+ QLandmarkFetchRequestPrivate * rd = static_cast<QLandmarkFetchRequestPrivate*>(ireq.data()->d_ptr);
+
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->landmarks = result;
+ bool emitState = rd->state != newState;
+ rd->state =newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkFetchByIdRequest \a req with the latest \a result,
+ operation \a error and \a errorString and map of input index to individual errors, \a errorMap.
+ In addition, the state of the request
+ will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkFetchByIdRequest(QLandmarkFetchByIdRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkFetchByIdRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkFetchByIdRequestPrivate* rd = static_cast<QLandmarkFetchByIdRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ rd->landmarks = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && req)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkRemoveRequest \a req with the operation \a error and
+ \a errorString and map of input index to individual errors, \a errorMap. In addition,
+ the state of the request will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkRemoveRequest(QLandmarkRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString,
+ const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkRemoveRequest>ireq(req);//Take this in case the first emit delete us
+ QLandmarkRemoveRequestPrivate* rd = static_cast<QLandmarkRemoveRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+
+}
+
+/*!
+ Updates the given QLandmarkSaveRequest \a req with the latest \a result, operation \a error
+ and \a errorString, and map of input index to individual errors, \a errorMap.
+ In addition, the state of the request will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkSaveRequest(QLandmarkSaveRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkSaveRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkSaveRequestPrivate* rd = static_cast<QLandmarkSaveRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ rd->landmarks = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkCategoryIdFetchRequest \a req with the latest \a result,
+ and operation \a error and \a errorString. In addition, the state of the request
+ will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkCategoryIdFetchRequest(QLandmarkCategoryIdFetchRequest* req, const QList<QLandmarkCategoryId>& result,
+ QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+
+{
+ if (req) {
+ QWeakPointer<QLandmarkCategoryIdFetchRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkCategoryIdFetchRequestPrivate* rd = static_cast<QLandmarkCategoryIdFetchRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->categoryIds = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkCategoryFetchRequest \a req with the latest \a result,
+ and operation \a error and \a errorString. In addition, the state of the request
+ will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkCategoryFetchRequest(QLandmarkCategoryFetchRequest* req, const QList<QLandmarkCategory>& result,
+ QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+
+{
+ if (req) {
+ QWeakPointer<QLandmarkCategoryFetchRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkCategoryFetchRequestPrivate* rd = static_cast<QLandmarkCategoryFetchRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->categories = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkCategoryFetchByIdRequest \a req with the latest \a result,
+ and operation \a error and \a errorString, and map of input index to individual errors, \a errorMap.
+ In addition, the state of the request will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the
+ request progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkCategoryFetchByIdRequest(QLandmarkCategoryFetchByIdRequest* req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkCategoryFetchByIdRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkCategoryFetchByIdRequestPrivate* rd = static_cast<QLandmarkCategoryFetchByIdRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ rd->categories = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkCategoryRemoveRequest \a req with the operation \a error and
+ \a errorString and map of input index to individual errors, \a errorMap. In addition,
+ the state of the request will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkCategoryRemoveRequest(QLandmarkCategoryRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString,
+ const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkCategoryRemoveRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkRemoveRequestPrivate* rd = static_cast<QLandmarkRemoveRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkSaveCategoryRequest \a req with the latest \a result, operation error \a error
+ and \a errorString, and map of input index to individual errors, \a errorMap.
+ In addition, the state of the request will be changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+ */
+void QLandmarkManagerEngine::updateLandmarkCategorySaveRequest(QLandmarkCategorySaveRequest* req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkCategorySaveRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkCategorySaveRequestPrivate* rd = static_cast<QLandmarkCategorySaveRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->errorMap = errorMap;
+ rd->categories = result;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkImportRequest \a req with the operation \a error and \a errorString.
+ In addition the state of the request is changed to \a newState. This function may also be used
+ to update the \a ids of the landmarks which have been imported.
+
+ It then causes the request to emit its resultsAvailable() signal to notify the clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+*/
+void QLandmarkManagerEngine::updateLandmarkImportRequest(QLandmarkImportRequest *req, const QList<QLandmarkId> &ids, QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkImportRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkImportRequestPrivate* rd = static_cast<QLandmarkImportRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ rd->landmarkIds = ids;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && ireq)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Updates the given QLandmarkExportRequest \a req with the operation \a error and \a errorString.
+ In addition the state of the request is changed to \a newState.
+
+ It then causes the request to emit its resultsAvailable() signal to notify the clients of the request
+ progress.
+
+ If the new request state is different from the previous state, the stateChanged() signal will
+ also be emitted from the request.
+*/
+void QLandmarkManagerEngine::updateLandmarkExportRequest(QLandmarkExportRequest *req, QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState)
+{
+ if (req) {
+ QWeakPointer<QLandmarkExportRequest> ireq(req); //Take this in case the first emit delete us
+ QLandmarkExportRequestPrivate* rd = static_cast<QLandmarkExportRequestPrivate*>(ireq.data()->d_ptr);
+ QMutexLocker ml(&rd->mutex);
+ rd->error = error;
+ rd->errorString = errorString;
+ bool emitState = rd->state != newState;
+ rd->state = newState;
+ ml.unlock();
+ emit req->resultsAvailable();
+ if (emitState && req)
+ emit req->stateChanged(newState);
+ }
+}
+
+/*!
+ Compares two landmarks (\a a and \a b) using the given list of \a sortOrders. Returns a negative number if \a a should appear
+ before \a b according to the sort order, a positive number if \a a should appear after \a b according to the sort order,
+ and zero if the two are unable to be sorted.
+ */
+int QLandmarkManagerEngine::compareLandmark(const QLandmark& a, const QLandmark& b, const QList<QLandmarkSortOrder>& sortOrders)
+{
+ int comparison = 0;
+ for(int i=0; i < sortOrders.count(); ++i) {
+
+ switch (sortOrders.at(i).type())
+ {
+ case (QLandmarkSortOrder::NameSort):
+ {
+ const QLandmarkNameSort nameSort = sortOrders.at(i);
+ comparison = compareName(a, b, nameSort);
+ break;
+ }
+ default:
+ comparison =0;
+ }
+
+ if (comparison != 0)
+ break;
+ }
+ return comparison;
+}
+
+
+/*!
+ Compares two landmarks (\a a and \a b) by name.
+
+ Returns a negative number if \a a should appear before \a b according to the \a nameSort,
+ a positive number if \a a should appear after \a b according to the \a nameSort,
+ and zero if the two are unable to be sorted.
+
+ Assuming an ascending order sort, an integer less than, equal to, or greater than zero
+ is returned if \a a is less than, equal to or greater than \a b.
+
+ \a nameSort specifies whether an ascending or descending order is used and whether
+ the sort is case sensitive or not.
+ */
+int QLandmarkManagerEngine::compareName(const QLandmark &a, const QLandmark &b, const QLandmarkNameSort &nameSort)
+{
+ int result = QString::compare(a.name(), b.name(), nameSort.caseSensitivity());
+
+ if (nameSort.direction() == Qt::DescendingOrder)
+ result *= -1;
+
+ return result;
+}
+
+/*!
+ Performs an insertion sort \a landmark into the \a sorted list, according to the provided \a sortOrders list.
+ The first QLandmarkSortOrder in the list has the highest priority; if the \a landmark is deemed equal to another
+ in the \a sorted list, the second QLandmarkSortOrder in the list is used (and so on until either the landmark is inserted
+ or there are no more sort order objects in the list).
+ */
+void QLandmarkManagerEngine::addSorted(QList<QLandmark>* sorted, const QLandmark& landmark, const QList<QLandmarkSortOrder>& sortOrders)
+{
+ if (sortOrders.count() > 0) {
+ for (int i = 0; i < sorted->size(); i++) {
+ // check to see if the new landmark should be inserted here
+ int comparison = compareLandmark(sorted->at(i), landmark, sortOrders);
+ if (comparison > 0) {
+ sorted->insert(i, landmark);
+ return;
+ }
+ }
+ }
+
+ // hasn't been inserted yet? append to the list.
+ sorted->append(landmark);
+}
+
+/*!
+ Returns true if the supplied \a landmark matches the supplied \a filter.
+ */
+bool QLandmarkManagerEngine::testFilter(const QLandmarkFilter& filter, const QLandmark& landmark)
+{
+ switch(filter.type()) {
+ case QLandmarkFilter::DefaultFilter:
+ return true;
+
+ case QLandmarkFilter::AttributeFilter:
+ {
+ const QLandmarkAttributeFilter attribFilter(filter);
+ QStringList filterKeys = attribFilter.attributeKeys();
+
+ if (attribFilter.operationType() == QLandmarkAttributeFilter::AndOperation) {
+ QVariant lmAttributeValue;
+ foreach(const QString filterKey, filterKeys)
+ {
+ if (commonLandmarkKeys.contains(filterKey)) {
+ lmAttributeValue = getLandmarkAttribute(filterKey, landmark);
+
+ if (lmAttributeValue.type() == QVariant::String) {
+ QString lmString = lmAttributeValue.toString();
+ QString attribString = attribFilter.attribute(filterKey).toString();
+ if (matchString(lmString, attribString, attribFilter.matchFlags(filterKey)))
+ continue;
+ } else if (attribFilter.attribute(filterKey) == lmAttributeValue) {
+ continue;
+ }
+
+ return false;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ } else {//must be OR operation
+ QVariant lmAttributeValue;
+ foreach(const QString filterKey, filterKeys) {
+ if (commonLandmarkKeys.contains(filterKey)) {
+
+ lmAttributeValue = getLandmarkAttribute(filterKey, landmark);
+
+ if (lmAttributeValue.type() == QVariant::String) {
+ QString lmString = lmAttributeValue.toString();
+ QString attribString = attribFilter.attribute(filterKey).toString();
+ if (matchString(lmString, attribString, attribFilter.matchFlags(filterKey)))
+ return true;
+ }
+
+ if (attribFilter.attribute(filterKey) == lmAttributeValue) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+ case QLandmarkFilter::BoxFilter:
+ {
+ const QLandmarkBoxFilter boxFilter(filter);
+
+ if (!boxFilter.boundingBox().isValid())
+ return false;
+
+ double tly = boxFilter.boundingBox().topLeft().latitude();
+ double bry = boxFilter.boundingBox().bottomRight().latitude();
+ double tlx = boxFilter.boundingBox().topLeft().longitude();
+ double brx = boxFilter.boundingBox().bottomRight().longitude();
+
+ bool latWrap = (tly < bry);
+ bool longWrap = (tlx > brx);
+
+ if (latWrap)
+ return false;
+
+ //check if landmark is outside the box's latitudes
+ if ( landmark.coordinate().latitude() < bry && landmark.coordinate().latitude() > tly)
+ return false;
+
+ double lmx = landmark.coordinate().longitude();
+ if (longWrap) {
+ //if (landmark.coordinate().longitude() <= tlx || landmark.coordinate().longitude() >= brx)
+ if ( ((lmx > 0.0) && (lmx<= tlx)) || ((lmx < 0.0) && (lmx >= brx)))
+ return false;
+ } else {
+ if (lmx < tlx || lmx > brx)
+ return false;
+ }
+
+ //landmark must be within the bounds to reach here.
+ return true;
+ }
+ case QLandmarkFilter::CategoryFilter:
+ {
+ const QLandmarkCategoryFilter categoryFilter(filter);
+ QList<QLandmarkCategoryId> categories = landmark.categoryIds();
+ foreach(const QLandmarkCategoryId id, categories)
+ {
+ if (id == categoryFilter.categoryId())
+ return true;
+ }
+ return false;
+ }
+ case QLandmarkFilter::IntersectionFilter:
+ {
+ const QLandmarkIntersectionFilter andFilter(filter);
+ const QList<QLandmarkFilter>& terms = andFilter.filters();
+ if (terms.count() ==0)
+ return false;
+
+ for(int i=0; i < terms.count();i++) {
+ if (!testFilter(terms.at(i), landmark))
+ return false;
+ }
+ return true;
+ }
+ case QLandmarkFilter::LandmarkIdFilter:
+ {
+ QLandmarkIdFilter idFilter(filter);
+ const QList<QLandmarkId> &ids = idFilter.landmarkIds();
+ foreach(const QLandmarkId id, ids) {
+ if (id == landmark.landmarkId())
+ return true;
+ }
+ return false;
+ }
+ case QLandmarkFilter::InvalidFilter:
+ {
+ return false;
+ }
+ case QLandmarkFilter::NameFilter:
+ {
+ QLandmarkNameFilter nameFilter(filter);
+ return matchString(landmark.name(), nameFilter.name(), nameFilter.matchFlags());
+ }
+ case QLandmarkFilter::ProximityFilter:
+ {
+ QLandmarkProximityFilter proximityFilter(filter);
+
+ qreal distance = proximityFilter.center().distanceTo(landmark.coordinate());
+ if (distance < proximityFilter.radius() || qFuzzyCompare(distance, proximityFilter.radius()))
+ return true;
+ else
+ return false;
+ }
+ case QLandmarkFilter::UnionFilter:
+ {
+ const QLandmarkUnionFilter orFilter(filter);
+ const QList<QLandmarkFilter>& terms = orFilter.filters();
+ if (terms.count() == 0)
+ return false;
+ else {
+ for (int i=0; i < terms.count(); i++) {
+ if (testFilter(terms.at(i), landmark))
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+ return false;
+}
+
+/*! Sorts the given list of \a landmarks according to the provided \a sortOrders */
+QList<QLandmarkId> QLandmarkManagerEngine::sortLandmarks(const QList<QLandmark>& landmarks, const QList<QLandmarkSortOrder>& sortOrders)
+{
+ QList<QLandmarkId> landmarkIds;
+ QList<QLandmark> sortedLandmarks;
+ if(!sortOrders.isEmpty()) {
+ foreach (const QLandmark& landmark, landmarks) {
+ QLandmarkManagerEngine::addSorted(&sortedLandmarks, landmark, sortOrders);
+ }
+
+ foreach (const QLandmark& landmark, sortedLandmarks) {
+ landmarkIds.append(landmark.landmarkId());
+ }
+ } else {
+ foreach(const QLandmark& landmark, landmarks) {
+ landmarkIds.append(landmark.landmarkId());
+ }
+ }
+ return landmarkIds;
+}
+
+#include "moc_qlandmarkmanagerengine.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkmanagerengine.h b/src/location/landmarks/qlandmarkmanagerengine.h
new file mode 100644
index 00000000..e4d1e4bc
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanagerengine.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q_LANDMARKMANAGERENGINE_H
+#define Q_LANDMARKMANAGERENGINE_H
+#include <QObject>
+#include <QMap>
+#include "qmobilityglobal.h"
+
+#include "qlandmarkmanager.h"
+#include "qlandmarkabstractrequest.h"
+
+
+class QIODevice;
+
+QTM_BEGIN_NAMESPACE
+class QLandmarkCategory;
+class QLandmarkCategoryId;
+class QLandmark;
+class QLandmarkId;
+class QLandmarkSortOrder;
+class QLandmarkIdFetchRequest;
+class QLandmarkFetchRequest;
+class QLandmarkFetchByIdRequest;
+class QLandmarkRemoveRequest;
+class QLandmarkSaveRequest;
+class QLandmarkCategoryIdFetchRequest;
+class QLandmarkCategoryFetchRequest;
+class QLandmarkCategoryFetchByIdRequest;
+class QLandmarkCategoryRemoveRequest;
+class QLandmarkCategorySaveRequest;
+class QLandmarkImportRequest;
+class QLandmarkExportRequest;
+
+class QLandmarkFilter;
+class QLandmarkNameFilter;
+class QLandmarkProximityFilter;
+class QLandmarkCategoryFilter;
+class QLandmarkBoxFilter;
+class QLandmarkUnionFilter;
+class QLandmarkIntersectionFilter;
+class QLandmarkAttributeFilter;
+
+class QLandmarkNameSort;
+class QLandmarkDistanceSort;
+
+class Q_LOCATION_EXPORT QLandmarkManagerEngine : public QObject
+{
+ Q_OBJECT
+public:
+ QLandmarkManagerEngine();
+ virtual ~QLandmarkManagerEngine();
+
+ /* URI reporting */
+ virtual QString managerName() const = 0; // e.g. "com.nokia.qt.landmarks.engines.s60"
+ virtual QMap<QString, QString> managerParameters() const = 0; // e.g. "filename=private.db"
+ virtual int managerVersion() const = 0;
+
+ QString managerUri() const;
+
+ /* Filtering */
+ virtual QList<QLandmarkId> landmarkIds(const QLandmarkFilter &filter, int limit, int offset, const QList<QLandmarkSortOrder>& sortOrders,
+ QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QList<QLandmarkCategoryId> categoryIds(int limit, int offset, const QLandmarkNameSort &nameSort, QLandmarkManager::Error *error,
+ QString *errorString) const = 0;
+
+ /* Retrieval */
+ virtual QLandmark landmark(const QLandmarkId &landmarkId, QLandmarkManager::Error *error,
+ QString *errorString) const =0;
+ virtual QList<QLandmark> landmarks(const QList<QLandmarkId> &landmarkIds,QMap<int, QLandmarkManager::Error> *errorMap,
+ QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QList<QLandmark> landmarks(const QLandmarkFilter &filter, int limit, int offset, const QList<QLandmarkSortOrder>& sortOrders,
+ QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QLandmarkCategory category(const QLandmarkCategoryId &landmarkCategoryId, QLandmarkManager::Error *error,
+ QString *errorString) const = 0;
+ virtual QList<QLandmarkCategory> categories(const QList<QLandmarkCategoryId> &landmarkCategoryIds, QMap<int, QLandmarkManager::Error> *errorMap,
+ QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QList<QLandmarkCategory> categories(int limit, int offset, const QLandmarkNameSort &nameSort, QLandmarkManager::Error *error,
+ QString *errorString) const = 0;
+
+ /*saving and removing*/
+ virtual bool saveLandmark(QLandmark* landmark, QLandmarkManager::Error *error, QString *errorString) = 0;
+ virtual bool saveLandmarks(QList<QLandmark> * landmark, QMap<int, QLandmarkManager::Error> *errorMap,
+ QLandmarkManager::Error *error, QString *errorString) = 0;
+ virtual bool removeLandmark(const QLandmarkId &landmarkId, QLandmarkManager::Error *error, QString *errorString) = 0;
+ virtual bool removeLandmarks(const QList<QLandmarkId> &landmarkId, QMap<int, QLandmarkManager::Error> *errorMap, QLandmarkManager::Error *error,
+ QString *errorString) = 0;
+
+ virtual bool saveCategory(QLandmarkCategory* category, QLandmarkManager::Error *error, QString *errorString) = 0;
+ virtual bool removeCategory(const QLandmarkCategoryId &categoryId, QLandmarkManager::Error *error, QString *errorString) = 0;
+
+ virtual bool importLandmarks(QIODevice *device, const QString& format, QLandmarkManager::TransferOption option, const QLandmarkCategoryId& id,
+ QLandmarkManager::Error *error, QString *errorString) = 0;
+ virtual bool exportLandmarks(QIODevice *device, const QString& format, const QList<QLandmarkId> &landmarkIds, QLandmarkManager::TransferOption option,
+ QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QStringList supportedFormats(QLandmarkManager::TransferOperation operation, QLandmarkManager::Error *error, QString *errorString) const;
+
+ virtual QLandmarkManager::SupportLevel filterSupportLevel(const QLandmarkFilter &filter, QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual QLandmarkManager::SupportLevel sortOrderSupportLevel(const QLandmarkSortOrder &sortOrder, QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual bool isFeatureSupported(QLandmarkManager::ManagerFeature feature, QLandmarkManager::Error *error, QString *errorString) const = 0;
+
+ virtual bool isReadOnly(QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual bool isReadOnly(const QLandmarkId &landmarkId, QLandmarkManager::Error *error, QString *errorString) const = 0;
+ virtual bool isReadOnly(const QLandmarkCategoryId &categoryId, QLandmarkManager::Error *error, QString *errorString) const = 0;
+
+ virtual QStringList searchableLandmarkAttributeKeys(QLandmarkManager::Error *error, QString *errorString) const = 0;
+
+ /* Asynchronous Request Support */
+ virtual void requestDestroyed(QLandmarkAbstractRequest* request) = 0;
+ virtual bool startRequest(QLandmarkAbstractRequest* request) = 0;
+ virtual bool cancelRequest(QLandmarkAbstractRequest* request) = 0;
+ virtual bool waitForRequestFinished(QLandmarkAbstractRequest* request, int msecs) = 0;
+
+Q_SIGNALS:
+ void dataChanged();
+ void landmarksAdded(const QList<QLandmarkId> &landmarkIds);
+ void landmarksChanged(const QList<QLandmarkId> &landmarkIds);
+ void landmarksRemoved(const QList<QLandmarkId> &landmarkIds);
+
+ void categoriesAdded(const QList<QLandmarkCategoryId> &categoryIds);
+ void categoriesChanged(const QList<QLandmarkCategoryId> &categoryIds);
+ void categoriesRemoved(const QList<QLandmarkCategoryId> &categoryIds);
+
+public:
+ static void updateRequestState(QLandmarkAbstractRequest *req, QLandmarkAbstractRequest::State state);
+ static void updateLandmarkIdFetchRequest(QLandmarkIdFetchRequest* req, const QList<QLandmarkId>& result,
+ QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkFetchRequest(QLandmarkFetchRequest* req, const QList<QLandmark>& result,
+ QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkFetchByIdRequest(QLandmarkFetchByIdRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkRemoveRequest(QLandmarkRemoveRequest* req, QLandmarkManager::Error error, const QString &errorString,
+ const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkSaveRequest(QLandmarkSaveRequest* req, const QList<QLandmark>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkCategoryIdFetchRequest(QLandmarkCategoryIdFetchRequest *req, const QList<QLandmarkCategoryId>& result,
+ QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkCategoryFetchRequest(QLandmarkCategoryFetchRequest *req, const QList<QLandmarkCategory>& result,
+ QLandmarkManager::Error error, const QString &errorString, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkCategoryFetchByIdRequest(QLandmarkCategoryFetchByIdRequest *req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkCategoryRemoveRequest(QLandmarkCategoryRemoveRequest *req, QLandmarkManager::Error error, const QString &errorString,
+ const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkCategorySaveRequest(QLandmarkCategorySaveRequest *req, const QList<QLandmarkCategory>& result, QLandmarkManager::Error error,
+ const QString &errorString, const QMap<int, QLandmarkManager::Error>& errorMap, QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkImportRequest(QLandmarkImportRequest *req, const QList<QLandmarkId> &ids, QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState);
+ static void updateLandmarkExportRequest(QLandmarkExportRequest *req, QLandmarkManager::Error error, const QString &errorString,
+ QLandmarkAbstractRequest::State newState);
+
+ static int compareLandmark(const QLandmark& a, const QLandmark& b, const QList<QLandmarkSortOrder>& sortOrders);
+ static int compareName(const QLandmark &a, const QLandmark &b, const QLandmarkNameSort &nameSort);
+
+ static void addSorted(QList<QLandmark>* sorted, const QLandmark& landmark, const QList<QLandmarkSortOrder>& sortOrders);
+ static bool testFilter(const QLandmarkFilter& filter, const QLandmark& landmark);
+ static QList<QLandmarkId> sortLandmarks(const QList<QLandmark>& landmarks, const QList<QLandmarkSortOrder>& sortOrders);
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkmanagerenginefactory.cpp b/src/location/landmarks/qlandmarkmanagerenginefactory.cpp
new file mode 100644
index 00000000..e4d2a402
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanagerenginefactory.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkmanagerenginefactory.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkManagerEngineFactory
+ \brief The QLandmarkManagerEngineFactory class provides the interface for
+ plugins that implement QLandmarkManagerEngine functionality.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-backend
+
+ This class provides a simple interface for the creation of
+ landmark manager engine instances. Each factory has a specific id
+ associated with it, which forms the \c managerName parameter
+ when creating \l QLandmarkManager objects.
+
+ \sa QLandmarkManager, QLandmarkManagerEngine
+ */
+
+/*!
+ Destroys the engine factory.
+ */
+QLandmarkManagerEngineFactory::~QLandmarkManagerEngineFactory()
+{
+}
+
+/*!
+ This function returns a list of versions of the engine which this factory can instantiate.
+ */
+QList<int> QLandmarkManagerEngineFactory::supportedImplementationVersions() const
+{
+ return QList<int>();
+}
+
+/*!
+ \fn QLandmarkManagerEngineFactory::managerName() const
+
+ This function returns a unique string that identifies
+ the engine provided by this factory.
+
+ Typically this would be of the form "com.nokia.qt.landmarks.engines.sqlite", with
+ the appropriate domain and engine name substituted.
+ */
+
+/*!
+ \fn QLandmarkManagerEngineFactory::engine(const QMap<QString, QString>& parameters, QLandmarkManager::Error *error,
+ QString *errorString)
+
+ This function is called by the QLandmarkManager implementation to
+ create an instance of the engine provided by this factory.
+
+ The \a parameters supplied can be ignored or interpreted as desired.
+
+ If a supplied parameter results in an unfulfillable request, or some other error
+ occurs, this function may return a null pointer, and the client developer will get an
+ invalid QLandmarkManager in return. Errors are stored in \a error and \a errorString.
+ */
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkmanagerenginefactory.h b/src/location/landmarks/qlandmarkmanagerenginefactory.h
new file mode 100644
index 00000000..e5419a9b
--- /dev/null
+++ b/src/location/landmarks/qlandmarkmanagerenginefactory.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKMANAGERENGINEFACTORY_H
+#define QLANDMARKMANAGERENGINEFACTORY_H
+
+#include "qmobilityglobal.h"
+#include "qlandmarkmanager.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManagerEngine;
+class Q_LOCATION_EXPORT QLandmarkManagerEngineFactory
+{
+public:
+ virtual QList<int> supportedImplementationVersions() const;
+ virtual ~QLandmarkManagerEngineFactory();
+ virtual QLandmarkManagerEngine *engine(const QMap<QString, QString> &parameters,
+ QLandmarkManager::Error *error,
+ QString *errorString) = 0;
+ virtual QString managerName() const = 0;
+};
+
+QTM_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+#define QT_LANDMARKS_BACKEND_INTERFACE "com.nokia.qt.mobility.landmarks.enginefactory/1.0"
+Q_DECLARE_INTERFACE(QtMobility::QLandmarkManagerEngineFactory, QT_LANDMARKS_BACKEND_INTERFACE);
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarknamefilter.cpp b/src/location/landmarks/qlandmarknamefilter.cpp
new file mode 100644
index 00000000..4c16a716
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamefilter.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarknamefilter.h"
+#include "qlandmarknamefilter_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkNameFilter
+ \brief The QLandmarkNameFilter class is used to search for landmarks by name.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-filter
+
+ Please note that different platforms support different capabilities with the attribute filter.
+ \list
+ \o The S60 3.1, 3.2 and 5.0 platforms do not support the MatchContains flag while the Symbian
+ platform does.
+ \o Note also that MatchContains is supported using the sparql and sqlite \l {Landmark Managers and Plugins} {managers}.
+ \endlist
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkNameFilter)
+
+/*!
+ Creates a filter that selects landmarks by \a name.
+*/
+QLandmarkNameFilter::QLandmarkNameFilter(const QString &name)
+ : QLandmarkFilter(new QLandmarkNameFilterPrivate(name)) {}
+
+/*!
+ \fn QLandmarkNameFilter::QLandmarkNameFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new name filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkNameFilter::~QLandmarkNameFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Returns the name that the filter will use to determine matches.
+*/
+QString QLandmarkNameFilter::name() const
+{
+ Q_D(const QLandmarkNameFilter);
+ return d->name;
+}
+
+/*!
+ Sets the \a name that the filter will use to determine matches.
+*/
+void QLandmarkNameFilter::setName(const QString &name)
+{
+ Q_D(QLandmarkNameFilter);
+ d->name = name;
+}
+
+/*!
+ Returns the matching criteria of the filter.
+*/
+QLandmarkFilter::MatchFlags QLandmarkNameFilter::matchFlags() const
+{
+ Q_D(const QLandmarkNameFilter);
+ return d->flags;
+}
+
+/*!
+ Sets the matching criteria to those defined in \a flags.
+*/
+void QLandmarkNameFilter::setMatchFlags(QLandmarkFilter::MatchFlags flags)
+{
+ Q_D(QLandmarkNameFilter);
+ d->flags = flags;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkNameFilterPrivate::QLandmarkNameFilterPrivate(const QString &name)
+ : name(name),
+ flags(0)
+{
+ type = QLandmarkFilter::NameFilter;
+}
+
+QLandmarkNameFilterPrivate::QLandmarkNameFilterPrivate(const QLandmarkNameFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ name(other.name),
+ flags(other.flags) {}
+
+QLandmarkNameFilterPrivate::~QLandmarkNameFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarknamefilter.h b/src/location/landmarks/qlandmarknamefilter.h
new file mode 100644
index 00000000..1fa03f68
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamefilter.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKNAMEFILTER_H
+#define QLANDMARKNAMEFILTER_H
+
+#include "qlandmarkfilter.h"
+#include "qnamespace.h"
+
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkNameFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkNameFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkNameFilter(const QString &name = QString());
+ QLandmarkNameFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkNameFilter();
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QLandmarkFilter::MatchFlags matchFlags() const;
+ void setMatchFlags(QLandmarkFilter::MatchFlags flags);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkNameFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarknamefilter_p.h b/src/location/landmarks/qlandmarknamefilter_p.h
new file mode 100644
index 00000000..b10c4daa
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamefilter_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKNAMEFILTER_P_H
+#define QLANDMARKNAMEFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+
+#include "qnamespace.h"
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkNameFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkNameFilterPrivate(const QString &name = QString());
+ QLandmarkNameFilterPrivate(const QLandmarkNameFilterPrivate &other);
+ virtual ~QLandmarkNameFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate *other) const
+ {
+ const QLandmarkNameFilterPrivate *od = static_cast<const QLandmarkNameFilterPrivate*>(other);
+ return (name == od->name)
+ && (flags == od->flags);
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkNameFilter, QLandmarkFilter::NameFilter)
+
+ QString name;
+ QLandmarkFilter::MatchFlags flags;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarknamesort.cpp b/src/location/landmarks/qlandmarknamesort.cpp
new file mode 100644
index 00000000..29ef3209
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamesort.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarknamesort.h"
+#include "qlandmarknamesort_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkNameSort
+ \brief The QLandmarkNameSort class is used to sort landmarks by name.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-sort
+ \since 1.1
+
+ Note that some manager's may not support case sensitive sorting.
+*/
+
+Q_IMPLEMENT_LANDMARKSORTORDER_PRIVATE(QLandmarkNameSort)
+
+/*!
+ Creates a sort order that sorts by name according to the given \a direction and
+ case \a sensitivity.
+*/
+QLandmarkNameSort::QLandmarkNameSort(Qt::SortOrder direction, Qt::CaseSensitivity sensitivity)
+ : QLandmarkSortOrder(new QLandmarkNameSortPrivate())
+{
+ Q_D(QLandmarkNameSort);
+ d->order = direction;
+ d->sensitivity = sensitivity;
+}
+
+/*!
+ \fn QLandmarkNameSort::QLandmarkNameSort(const QLandmarkSortOrder &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new name sort order.
+*/
+
+/*!
+ Destroys the sort order.
+*/
+QLandmarkNameSort::~QLandmarkNameSort()
+{
+}
+
+/*!
+ Returns the case sensitivity of the sort order.
+*/
+Qt::CaseSensitivity QLandmarkNameSort::caseSensitivity() const
+{
+ Q_D(const QLandmarkNameSort);
+ return d->sensitivity;
+}
+
+/*!
+ Sets the the \a caseSensitivity of the sort order.
+*/
+void QLandmarkNameSort::setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
+{
+ Q_D(QLandmarkNameSort);
+ d->sensitivity = caseSensitivity;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+QLandmarkNameSortPrivate::QLandmarkNameSortPrivate()
+ : QLandmarkSortOrderPrivate(),
+ sensitivity(Qt::CaseInsensitive)
+{
+ type = QLandmarkSortOrder::NameSort;
+}
+
+QLandmarkNameSortPrivate::QLandmarkNameSortPrivate(const QLandmarkNameSortPrivate &other)
+ : QLandmarkSortOrderPrivate(other),
+ sensitivity(other.sensitivity) {}
+
+QLandmarkNameSortPrivate::~QLandmarkNameSortPrivate() {}
+
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarknamesort.h b/src/location/landmarks/qlandmarknamesort.h
new file mode 100644
index 00000000..0b2a1d69
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamesort.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKNAMESORT_H
+#define QLANDMARKNAMESORT_H
+
+#include "qlandmarksortorder.h"
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkNameSortPrivate;
+class Q_LOCATION_EXPORT QLandmarkNameSort : public QLandmarkSortOrder
+{
+public:
+ QLandmarkNameSort(Qt::SortOrder direction = Qt::AscendingOrder, Qt::CaseSensitivity = Qt::CaseInsensitive);
+ QLandmarkNameSort(const QLandmarkSortOrder &other);
+ virtual ~QLandmarkNameSort();
+
+ Qt::CaseSensitivity caseSensitivity() const;
+ void setCaseSensitivity(Qt::CaseSensitivity sensitivity);
+private:
+ Q_DECLARE_LANDMARKSORTORDER_PRIVATE(QLandmarkNameSort)
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarknamesort_p.h b/src/location/landmarks/qlandmarknamesort_p.h
new file mode 100644
index 00000000..84638fb8
--- /dev/null
+++ b/src/location/landmarks/qlandmarknamesort_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKNAMESORT_P_H
+#define QLANDMARKNAMESORT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarksortorder_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkNameSortPrivate : public QLandmarkSortOrderPrivate
+{
+public:
+ QLandmarkNameSortPrivate();
+ QLandmarkNameSortPrivate(const QLandmarkNameSortPrivate &other);
+ virtual ~QLandmarkNameSortPrivate();
+
+ virtual bool compare(const QLandmarkSortOrderPrivate *other) const
+ {
+ //it is assumed that the types and superclass member variables already match
+ const QLandmarkNameSortPrivate *od = static_cast<const QLandmarkNameSortPrivate*>(other);
+ return sensitivity == od->sensitivity;
+ }
+
+ Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(QLandmarkNameSort, QLandmarkSortOrder::NameSort)
+
+ Qt::CaseSensitivity sensitivity;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkproximityfilter.cpp b/src/location/landmarks/qlandmarkproximityfilter.cpp
new file mode 100644
index 00000000..cfe32e29
--- /dev/null
+++ b/src/location/landmarks/qlandmarkproximityfilter.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkproximityfilter.h"
+#include "qlandmarkproximityfilter_p.h"
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkProximityFilter
+ \brief The QLandmarkProximityFilter class is used to search for landmarks based on the radius
+ around a given coordinate and perform sorting by distance.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ In order to be a valid filter, the region covered by the proximity filter must not cover one of the poles.
+ The landmarks are returned in ascending order of distance. A proximity filter may
+ be used inside an intersection filter to sort landmarks by distance in combination with other
+ criteria such as categories. (Note that a using sort order other than QLandmarkSortOrder (i.e. no sort)
+ will override the sorting by distance).
+
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkProximityFilter)
+
+/*!
+ Creates a filter that will select landmarks within a given \a radius around
+ a \a center coordinate.
+*/
+QLandmarkProximityFilter::QLandmarkProximityFilter(const QGeoCoordinate &center, qreal radius)
+ : QLandmarkFilter(new QLandmarkProximityFilterPrivate(QGeoBoundingCircle(center, radius)))
+{
+}
+
+/*!
+ Creates a filter that will select landmarks withiin a given bounding \a circle.
+ */
+QLandmarkProximityFilter::QLandmarkProximityFilter(const QGeoBoundingCircle &circle)
+ : QLandmarkFilter(new QLandmarkProximityFilterPrivate(circle))
+{
+}
+
+/*!
+ \fn QLandmarkProximityFilter::QLandmarkProximityFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new proximity filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkProximityFilter::~QLandmarkProximityFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Returns the center coordinate of the filter.
+*/
+QGeoCoordinate QLandmarkProximityFilter::center() const
+{
+ Q_D(const QLandmarkProximityFilter);
+ return d->circle.center();
+}
+
+/*!
+ Sets the \a center coordinate of the filter.
+*/
+void QLandmarkProximityFilter::setCenter(const QGeoCoordinate &center)
+{
+ Q_D(QLandmarkProximityFilter);
+ d->circle.setCenter(center);
+}
+
+/*!
+ Returns the radius of the filter. The unit of the radius is meters.
+*/
+qreal QLandmarkProximityFilter::radius() const
+{
+ Q_D(const QLandmarkProximityFilter);
+ return d->circle.radius();
+}
+
+/*!
+ Sets the \a radius of the filter. The unit of the radius is meters.
+*/
+void QLandmarkProximityFilter::setRadius(qreal radius)
+{
+ Q_D(QLandmarkProximityFilter);
+ d->circle.setRadius(radius);
+}
+
+/*!
+ Sets the bounding circle for the proximity filter.
+*/
+QGeoBoundingCircle QLandmarkProximityFilter::boundingCircle()
+{
+ Q_D(const QLandmarkProximityFilter);
+ return d->circle;
+}
+
+/*!
+ Sets the bounding \a circle for the proximity filter
+*/
+void QLandmarkProximityFilter::setBoundingCircle(const QGeoBoundingCircle &circle)
+{
+ Q_D(QLandmarkProximityFilter);
+ d->circle = circle;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkProximityFilterPrivate::QLandmarkProximityFilterPrivate(const QGeoBoundingCircle &circle)
+ : QLandmarkFilterPrivate(),
+ circle(circle)
+{
+ type = QLandmarkFilter::ProximityFilter;
+}
+
+QLandmarkProximityFilterPrivate::QLandmarkProximityFilterPrivate(const QLandmarkProximityFilterPrivate &other)
+ : QLandmarkFilterPrivate(other)
+{
+ circle.setCenter(other.circle.center());
+ circle.setRadius(other.circle.radius());
+}
+
+QLandmarkProximityFilterPrivate::~QLandmarkProximityFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkproximityfilter.h b/src/location/landmarks/qlandmarkproximityfilter.h
new file mode 100644
index 00000000..ed59558f
--- /dev/null
+++ b/src/location/landmarks/qlandmarkproximityfilter.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKPROXIMITY_H
+#define QLANDMARKPROXIMITY_H
+
+#include "qlandmarkfilter.h"
+#include "qgeocoordinate.h"
+#include "qgeoboundingcircle.h"
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkProximityFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkProximityFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkProximityFilter(const QGeoCoordinate &center = QGeoCoordinate(), qreal radius = -1);
+ QLandmarkProximityFilter(const QGeoBoundingCircle &circle);
+ QLandmarkProximityFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkProximityFilter();
+
+ QGeoCoordinate center() const;
+ void setCenter(const QGeoCoordinate &center);
+
+ qreal radius() const;
+ void setRadius(qreal radius);
+
+ QGeoBoundingCircle boundingCircle();
+ void setBoundingCircle(const QGeoBoundingCircle &circle);
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkProximityFilter)
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarkproximityfilter_p.h b/src/location/landmarks/qlandmarkproximityfilter_p.h
new file mode 100644
index 00000000..7b77e1f7
--- /dev/null
+++ b/src/location/landmarks/qlandmarkproximityfilter_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKPROXIMITYFILTER_P_H
+#define QLANDMARKPROXIMITYFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+#include "qlandmarkproximityfilter.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class QLandmarkProximityFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkProximityFilterPrivate(const QGeoBoundingCircle &circle = QGeoBoundingCircle());
+ QLandmarkProximityFilterPrivate(const QLandmarkProximityFilterPrivate &other);
+ virtual ~QLandmarkProximityFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate *other) const
+ {
+ //it is assumed that the types and superclass member variables already match
+ const QLandmarkProximityFilterPrivate *od = static_cast<const QLandmarkProximityFilterPrivate*>(other);
+ return (circle == od->circle);
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkProximityFilter, QLandmarkFilter::ProximityFilter)
+
+ QGeoBoundingCircle circle;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkremoverequest.cpp b/src/location/landmarks/qlandmarkremoverequest.cpp
new file mode 100644
index 00000000..6ef90ecf
--- /dev/null
+++ b/src/location/landmarks/qlandmarkremoverequest.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkremoverequest.h"
+#include "qlandmarkrequests_p.h"
+#include <QMap>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkRemoveRequest
+ \brief The QLandmarkRemoveRequest class allows a client to asynchronously
+ request that certain landmarks be removed from a landmark manager.
+
+ For a QLandmarkRemoveRequest, the resultsAvailable() signal will be emitted
+ when either an individual items error out (individaul errors may be retrieved
+ by calling errorMap()), or when an overall operation error occurs(which may be
+ retrieved by calling error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+*/
+
+/*!
+ Constructs a landmark remove request with the given \a manager and \a parent.
+*/
+QLandmarkRemoveRequest::QLandmarkRemoveRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkRemoveRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkRemoveRequest::~QLandmarkRemoveRequest()
+{
+}
+
+/*!
+ Returns the list of identifiers of landmarks which will be removed.
+*/
+QList<QLandmarkId> QLandmarkRemoveRequest::landmarkIds() const
+{
+ Q_D(const QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarkIds;
+}
+
+/*!
+ Sets the list of \a landmarkIds of landmarks which will be removed.
+
+ \sa setLandmarkId()
+*/
+void QLandmarkRemoveRequest::setLandmarkIds(const QList<QLandmarkId> &landmarkIds)
+{
+ Q_D(QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds = landmarkIds;
+}
+
+/*!
+ Convenience function to set the \a landmarkId of a single landmark to be removed.
+ It is the equivalent of calling setLandmarkIds() with a single \a landmarkId
+ in the ID list.
+
+ \sa setLandmarkIds()
+*/
+void QLandmarkRemoveRequest::setLandmarkId(const QLandmarkId &landmarkId)
+{
+ Q_D(QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds.clear();
+ d->landmarkIds.append((landmarkId));
+}
+
+/*!
+ Convenience function to set the list of \a landmarks which will be removed.
+ This function is the equivalent of calling setLandmarkIds() with the IDs of
+ the \a landmarks.
+
+ \sa setLandmarkIds()
+*/
+void QLandmarkRemoveRequest::setLandmarks(const QList<QLandmark> &landmarks)
+{
+ Q_D(QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds.clear();
+ for (int i=0; i < landmarks.count(); ++i)
+ d->landmarkIds.append(landmarks.at(i).landmarkId());
+}
+
+/*!
+ Convenience function that sets a single \a landmark to be removed.
+ This function is the equivalent of calling setLandmarkIds()
+ with the ID of \a landmark.
+*/
+void QLandmarkRemoveRequest::setLandmark(const QLandmark &landmark)
+{
+ Q_D(QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarkIds.clear();
+ d->landmarkIds.append(landmark.landmarkId());
+}
+
+/*!
+ Returns the mapping of input landmark ID list indices
+ to the errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkRemoveRequest::errorMap() const
+{
+ Q_D(const QLandmarkRemoveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarkremoverequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarkremoverequest.h b/src/location/landmarks/qlandmarkremoverequest.h
new file mode 100644
index 00000000..12ba70bc
--- /dev/null
+++ b/src/location/landmarks/qlandmarkremoverequest.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKREMOVEREQUEST_H
+#define QLANDMARKREMOVEREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkRemoveRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkRemoveRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkRemoveRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkRemoveRequest();
+
+ QList<QLandmarkId> landmarkIds() const;
+ void setLandmarkIds(const QList<QLandmarkId> &landmarkIds);
+ void setLandmarkId(const QLandmarkId &landmarkId);
+
+ void setLandmarks(const QList<QLandmark> &landmark);
+ void setLandmark(const QLandmark &landmark);
+
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+private:
+ Q_DISABLE_COPY(QLandmarkRemoveRequest)
+ Q_DECLARE_PRIVATE(QLandmarkRemoveRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkrequests_p.h b/src/location/landmarks/qlandmarkrequests_p.h
new file mode 100644
index 00000000..99c1fdd9
--- /dev/null
+++ b/src/location/landmarks/qlandmarkrequests_p.h
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKREQUESTS_P_H
+#define QLANDMARKREQUESTS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkabstractrequest_p.h"
+#include "qlandmark.h"
+#include "qlandmarkcategory.h"
+#include "qlandmarkcategoryfetchrequest.h"
+#include "qlandmarknamesort.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkIdFetchRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkIdFetchRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr),
+ limit(-1), offset(0)
+ {
+ type = QLandmarkAbstractRequest::LandmarkIdFetchRequest;
+ }
+
+ QLandmarkFilter filter;
+ QList<QLandmarkSortOrder>sorting;
+ int limit;
+ int offset;
+ QList<QLandmarkId> landmarkIds;
+};
+
+class QLandmarkFetchRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkFetchRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr),
+ limit(-1), offset(0)
+ {
+ type = QLandmarkAbstractRequest::LandmarkFetchRequest;
+ }
+ QLandmarkFilter filter;
+ QList<QLandmarkSortOrder> sorting;
+ int limit;
+ int offset;
+ QList<QLandmark> landmarks;
+};
+
+class QLandmarkFetchByIdRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkFetchByIdRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr)
+ {
+ type = QLandmarkAbstractRequest::LandmarkFetchByIdRequest;
+ }
+
+ QList<QLandmarkId> landmarkIds;
+ QList<QLandmark> landmarks;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+class QLandmarkRemoveRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkRemoveRequestPrivate(QLandmarkManager *manager)
+ : QLandmarkAbstractRequestPrivate(manager)
+ {
+ type = QLandmarkAbstractRequest::LandmarkRemoveRequest;
+ }
+
+ QList<QLandmarkId> landmarkIds;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+
+class QLandmarkSaveRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkSaveRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr)
+ {
+ type = QLandmarkAbstractRequest::LandmarkSaveRequest;
+ }
+
+ QList<QLandmark> landmarks;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+class QLandmarkCategoryIdFetchRequestPrivate: public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkCategoryIdFetchRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr),
+ limit(-1), offset(0)
+ {
+ type = QLandmarkAbstractRequest::CategoryIdFetchRequest;
+ }
+
+ QList<QLandmarkCategoryId> categoryIds;
+ QLandmarkNameSort sorting;
+ int limit;
+ int offset;
+};
+
+class QLandmarkCategoryFetchRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkCategoryFetchRequestPrivate(QLandmarkManager *mgr)
+ :QLandmarkAbstractRequestPrivate(mgr),
+ limit(-1), offset(0)
+ {
+ type = QLandmarkAbstractRequest::CategoryFetchRequest;
+ }
+
+ QList<QLandmarkCategory> categories;
+ QLandmarkNameSort sorting;
+ int limit;
+ int offset;
+};
+
+class QLandmarkCategoryFetchByIdRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkCategoryFetchByIdRequestPrivate(QLandmarkManager *mgr)
+ :QLandmarkAbstractRequestPrivate(mgr)
+ {
+ type = QLandmarkAbstractRequest::CategoryFetchByIdRequest;
+ }
+
+ QList<QLandmarkCategoryId> categoryIds;
+ QList<QLandmarkCategory> categories;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+class QLandmarkCategoryRemoveRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkCategoryRemoveRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr)
+ {
+ type = QLandmarkAbstractRequest::CategoryRemoveRequest;
+ }
+
+
+ QList<QLandmarkCategoryId> categoryIds;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+class QLandmarkCategorySaveRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkCategorySaveRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr)
+ {
+ type = QLandmarkAbstractRequest::CategorySaveRequest;
+ }
+
+ QList<QLandmarkCategory> categories;
+ QMap<int, QLandmarkManager::Error> errorMap;
+};
+
+class QLandmarkImportRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkImportRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr),
+ device(0),
+ fileName(QString()),
+ format(QString()),
+ option(QLandmarkManager::IncludeCategoryData),
+ categoryId(QLandmarkCategoryId()),
+ landmarkIds(QList<QLandmarkId>())
+ {
+ type = QLandmarkAbstractRequest::ImportRequest;
+ }
+
+ QIODevice *device;
+ QString fileName;
+ QString format;
+ QLandmarkManager::TransferOption option;
+ QLandmarkCategoryId categoryId;
+ QList<QLandmarkId> landmarkIds;
+};
+
+class QLandmarkExportRequestPrivate : public QLandmarkAbstractRequestPrivate
+{
+public:
+ QLandmarkExportRequestPrivate(QLandmarkManager *mgr)
+ : QLandmarkAbstractRequestPrivate(mgr),
+ device(0),
+ fileName(QString()),
+ format(QString()),
+ option(QLandmarkManager::IncludeCategoryData),
+ landmarkIds(QList<QLandmarkId>())
+ {
+ type = QLandmarkAbstractRequest::ExportRequest;
+ }
+
+ QIODevice *device;
+ QString fileName;
+ QString format;
+ QLandmarkManager::TransferOption option;
+ QList<QLandmarkId> landmarkIds;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarksaverequest.cpp b/src/location/landmarks/qlandmarksaverequest.cpp
new file mode 100644
index 00000000..8c521495
--- /dev/null
+++ b/src/location/landmarks/qlandmarksaverequest.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarksaverequest.h"
+#include "qlandmarkrequests_p.h"
+#include "qlandmark.h"
+
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkSaveRequest
+ \brief The QLandmarkSaveRequest class allows a client to asynchronously
+ request that certain landmarks be saved by a landmark manager.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-request
+ \since 1.1
+
+ For a QLandmarkSaveRequest, the resultsAvailable() signal will be emitted
+ when either an individual items error out (individaul errors may be retrieved
+ by calling errorMap()), or when an overall operation error occurs(which may be
+ retrieved by calling error()).
+
+ Please see the class documentation for QLandmarkAbstractRequest for more information about
+ the usage of request classes and ownership semantics.
+*/
+
+/*!
+ Constructs a landmark save request with the given \a manager and \a parent.
+*/
+QLandmarkSaveRequest::QLandmarkSaveRequest(QLandmarkManager *manager, QObject *parent)
+ : QLandmarkAbstractRequest(new QLandmarkSaveRequestPrivate(manager), parent)
+{
+}
+
+/*!
+ Destroys the request object.
+*/
+QLandmarkSaveRequest::~QLandmarkSaveRequest()
+{
+}
+
+/*!
+ Returns the list of landmarks to be saved. If called after the save operation has
+ finished, any new landmarks will have had their QLandmarkId set.
+ (Landmarks which were updated or failed to save will remain unchanged, use the
+ errorMap() function to determine which particular landmarks failed to save.)
+*/
+QList<QLandmark> QLandmarkSaveRequest::landmarks() const
+{
+ Q_D(const QLandmarkSaveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->landmarks;
+}
+
+/*!
+ Sets the list of \a landmarks to be saved.
+
+ \sa setLandmark()
+*/
+void QLandmarkSaveRequest::setLandmarks(const QList<QLandmark> &landmarks)
+{
+ Q_D(QLandmarkSaveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarks = landmarks;
+}
+
+/*!
+ Convenience function to set a single \a landmark to be saved. This
+ function is the equivalent of calling setLandmarks() with a single
+ \a landmark.
+
+ \sa setLandmarks()
+*/
+void QLandmarkSaveRequest::setLandmark(const QLandmark &landmark)
+{
+ Q_D(QLandmarkSaveRequest);
+ QMutexLocker ml(&d->mutex);
+ d->landmarks.clear();
+ d->landmarks.append(landmark);
+}
+
+/*!
+ Returns the mapping of input landmark list indices to errors which occurred.
+*/
+QMap<int, QLandmarkManager::Error> QLandmarkSaveRequest::errorMap() const
+{
+ Q_D(const QLandmarkSaveRequest);
+ QMutexLocker ml(&d->mutex);
+ return d->errorMap;
+}
+
+#include "moc_qlandmarksaverequest.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/landmarks/qlandmarksaverequest.h b/src/location/landmarks/qlandmarksaverequest.h
new file mode 100644
index 00000000..db672b86
--- /dev/null
+++ b/src/location/landmarks/qlandmarksaverequest.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKSAVEREQUEST_H
+#define QLANDMARKSAVEREQUEST_H
+
+#include "qlandmarkabstractrequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkSaveRequestPrivate;
+class Q_LOCATION_EXPORT QLandmarkSaveRequest : public QLandmarkAbstractRequest
+{
+ Q_OBJECT
+public:
+ QLandmarkSaveRequest(QLandmarkManager *manager, QObject *parent = 0);
+ ~QLandmarkSaveRequest();
+
+ QList<QLandmark> landmarks() const;
+ void setLandmarks(const QList<QLandmark> &landmarks);
+ void setLandmark(const QLandmark &landmark);
+
+ QMap<int, QLandmarkManager::Error> errorMap() const;
+private:
+ Q_DISABLE_COPY(QLandmarkSaveRequest)
+ Q_DECLARE_PRIVATE(QLandmarkSaveRequest)
+ friend class QLandmarkManagerEngine;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarksortorder.cpp b/src/location/landmarks/qlandmarksortorder.cpp
new file mode 100644
index 00000000..74901d57
--- /dev/null
+++ b/src/location/landmarks/qlandmarksortorder.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarksortorder.h"
+#include "qlandmarksortorder_p.h"
+#include "qlandmarkid.h"
+
+#if !defined(Q_CC_MWERKS)
+template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone()
+{
+ return d->clone();
+}
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkSortOrder
+ \brief The QLandmarkSortOrder class serves as a base class
+ for the different sort order types and by itself represents
+ no sorting.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup landmarks-sort
+
+ The sort orders define how a list of landmarks should be ordered
+ when they searched using a QLandmarkManager or one of the
+ landmark request classes. (For sorting by distance
+ see the QLandmarkProximityFilter).
+*/
+
+/*!
+ \enum QLandmarkSortOrder::SortType
+ Defines the type of sort order.
+ \value NoSort No sorting is applied
+ \value NameSort Sorts landmarks by name.
+*/
+
+/*!
+ Constructs a landmark sort order.
+
+ The type of the sort order is NoSort.
+*/
+QLandmarkSortOrder::QLandmarkSortOrder()
+ : d_ptr(new QLandmarkSortOrderPrivate())
+{
+}
+
+/*!
+ \internal
+*/
+QLandmarkSortOrder::QLandmarkSortOrder(QLandmarkSortOrderPrivate *d_ptr)
+ : d_ptr(d_ptr)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QLandmarkSortOrder::QLandmarkSortOrder(const QLandmarkSortOrder &other)
+ : d_ptr(other.d_ptr)
+{
+}
+
+/*!
+ Assigns \a other to this sort order and returns a reference to this
+ sort order.
+*/
+QLandmarkSortOrder &QLandmarkSortOrder::operator=(const QLandmarkSortOrder & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Destroys the sort order
+*/
+QLandmarkSortOrder::~QLandmarkSortOrder()
+{
+}
+
+/*!
+ Returns the type of sort.
+*/
+QLandmarkSortOrder::SortType QLandmarkSortOrder::type() const
+{
+ return d_ptr->type;
+}
+
+/*!
+ Returns the direction of the sort order.
+*/
+Qt::SortOrder QLandmarkSortOrder::direction() const
+{
+ return d_ptr->order;
+}
+
+/*!
+ Sets the \a direction of the sort order.
+*/
+void QLandmarkSortOrder::setDirection(Qt::SortOrder direction)
+{
+ d_ptr->order = direction;
+}
+
+/*!
+ \fn QLandmarkSortOrder::operator==(const QLandmarkSortOrder& other) const
+ Returns true if this sort order is identical to \a other.
+ \sa operator!=()
+*/
+bool QLandmarkSortOrder::operator==(const QLandmarkSortOrder& other) const
+{
+
+ if(!d_ptr->QLandmarkSortOrderPrivate::compare(other.d_ptr))
+ return false;
+
+ /* Different types can't be equal */
+ if (other.type() != type())
+ return false;
+
+ /* Otherwise, use the virtual op == */
+ return d_ptr->compare(other.d_ptr);
+}
+
+/*!
+ \fn QLandmarkSortOrder::operator!=(const QLandmarkSortOrder &other) const
+ Returns true if this sort order is not identical to \a other.
+
+ \sa operator==()
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkSortOrderPrivate::QLandmarkSortOrderPrivate()
+ : QSharedData(),
+ type(QLandmarkSortOrder::NoSort),
+ order(Qt::AscendingOrder)
+{
+}
+
+QLandmarkSortOrderPrivate::QLandmarkSortOrderPrivate(const QLandmarkSortOrderPrivate &other)
+ : QSharedData(),
+ type(other.type),
+ order(other.order)
+{
+}
+
+QLandmarkSortOrderPrivate::~QLandmarkSortOrderPrivate()
+{
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarksortorder.h b/src/location/landmarks/qlandmarksortorder.h
new file mode 100644
index 00000000..bb7d0f46
--- /dev/null
+++ b/src/location/landmarks/qlandmarksortorder.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKSORTORDER_H
+#define QLANDMARKSORTORDER_H
+
+#include "qmobilityglobal.h"
+#include "qnamespace.h"
+
+#include <QSharedDataPointer>
+#include <QList>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+#define Q_DECLARE_LANDMARKSORTORDER_PRIVATE(Class) \
+ inline Class##Private* d_func(); \
+ inline const Class##Private* d_func() const; \
+ friend class Class##Private;
+
+class QLandmarkId;
+class QLandmark;
+
+class QLandmarkSortOrderPrivate;
+class Q_LOCATION_EXPORT QLandmarkSortOrder
+{
+
+friend class QLandmarkSortOrderPrivate;
+
+public:
+ enum SortType {NoSort, NameSort};
+
+ QLandmarkSortOrder();
+ QLandmarkSortOrder(const QLandmarkSortOrder &other);
+ QLandmarkSortOrder& operator = (const QLandmarkSortOrder &other);
+ virtual ~QLandmarkSortOrder();
+
+ SortType type() const;
+ Qt::SortOrder direction() const;
+ void setDirection(Qt::SortOrder direction);
+
+ bool operator==(const QLandmarkSortOrder &other) const;
+ bool operator!=(const QLandmarkSortOrder &other) const {
+ return !(*this == other);
+ }
+protected:
+ QLandmarkSortOrder(QLandmarkSortOrderPrivate *dd);
+ QSharedDataPointer<QLandmarkSortOrderPrivate> d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/landmarks/qlandmarksortorder_p.h b/src/location/landmarks/qlandmarksortorder_p.h
new file mode 100644
index 00000000..0deb04c7
--- /dev/null
+++ b/src/location/landmarks/qlandmarksortorder_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKSORTORDER_P_H
+#define QLANDMARKSORTORDER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarksortorder.h"
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+#define Q_IMPLEMENT_LANDMARKSORTORDER_PRIVATE(Class) \
+ Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
+ const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \
+ Class::Class(const QLandmarkSortOrder& other) : QLandmarkSortOrder() { Class##Private::copyIfPossible(d_ptr, other); }
+
+#define Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(Class, Type) \
+ virtual QLandmarkSortOrderPrivate* clone() const { return new Class##Private(*this); } \
+ static void copyIfPossible(QSharedDataPointer<QLandmarkSortOrderPrivate>& d_ptr, const QLandmarkSortOrder& other) \
+ { \
+ if (other.type() == Type) \
+ d_ptr = extract_d(other); \
+ else \
+ d_ptr = new Class##Private(); \
+ }
+
+class QLandmarkSortOrderPrivate : public QSharedData
+{
+public:
+ QLandmarkSortOrderPrivate();
+ QLandmarkSortOrderPrivate(const QLandmarkSortOrderPrivate &);
+ virtual ~QLandmarkSortOrderPrivate();
+
+ virtual bool compare(const QLandmarkSortOrderPrivate *other) const {
+ return order == other->order;
+ }
+
+ /* Helper functions for C++ protection rules */
+ static const QSharedDataPointer<QLandmarkSortOrderPrivate>& extract_d(const QLandmarkSortOrder& other) {return other.d_ptr;}
+
+ Q_IMPLEMENT_LANDMARKSORTORDER_VIRTUALCTORS(QLandmarkSortOrder, QLandmarkSortOrder::NoSort)
+
+ QLandmarkSortOrder::SortType type;
+ Qt::SortOrder order;
+};
+
+QTM_END_NAMESPACE
+
+#if defined(Q_CC_MWERKS)
+// This results in multiple symbol definition errors on all other compilers
+// but not having a definition here results in an attempt to use the unspecialized
+// clone (which fails because of the pure virtuals above)
+template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone()
+{
+ return d->clone();
+}
+#else
+template<> QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QLandmarkSortOrderPrivate)>::clone();
+#endif
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/landmarks/qlandmarkunionfilter.cpp b/src/location/landmarks/qlandmarkunionfilter.cpp
new file mode 100644
index 00000000..8d792e4a
--- /dev/null
+++ b/src/location/landmarks/qlandmarkunionfilter.cpp
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlandmarkunionfilter.h"
+#include "qlandmarkunionfilter_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QLandmarkUnionFilter
+ \brief The QLandmarkUnionFilter class provides a filter which unions the results
+ of its constituent filters.
+
+ \inmodule QtLocation
+
+ \ingroup landmarks-filter
+ \since 1.1
+
+ Conceptually it performs an OR operation and may thus be used
+ to select landmarks which match any one of it's constituent filters.
+
+ Whether a union filter can be comprised of
+ compound filters (i.e. union or intersection filters) is backend specific.
+ Even if this is supported the performance of such a filter is likely to be poor.
+*/
+
+Q_IMPLEMENT_LANDMARKFILTER_PRIVATE(QLandmarkUnionFilter);
+
+/*!
+ Constructs a new union filter.
+*/
+QLandmarkUnionFilter::QLandmarkUnionFilter()
+ : QLandmarkFilter(new QLandmarkUnionFilterPrivate)
+{
+}
+
+/*!
+ \fn QLandmarkUnionFilter::QLandmarkUnionFilter(const QLandmarkFilter &other)
+ Constructs a copy of \a other if possible, otherwise constructs a new union filter.
+*/
+
+/*!
+ Destroys the filter.
+*/
+QLandmarkUnionFilter::~QLandmarkUnionFilter()
+{
+ // pointer deleted in superclass destructor
+}
+
+/*!
+ Sets the \a filters whose criteria will be unioned.
+ \sa filters()
+*/
+void QLandmarkUnionFilter::setFilters(const QList<QLandmarkFilter>& filters)
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters = filters;
+}
+
+/*!
+ Prepends the given \a filter to the list of unioned filters.
+
+ \sa append(), filters()
+*/
+void QLandmarkUnionFilter::prepend(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters.prepend(filter);
+}
+
+/*!
+ Appends the given \a filter to the list of unioned filters.
+
+ \sa operator<<(), prepend(), filters()
+*/
+void QLandmarkUnionFilter::append(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters.append(filter);
+}
+
+/*!
+ Removes the given \a filter from the union list.
+ \sa filters(), append(), prepend()
+*/
+void QLandmarkUnionFilter::remove(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters.removeAll(filter);
+}
+
+/*!
+ Removes all filters from the union list.
+ \sa remove()
+*/
+void QLandmarkUnionFilter::clear()
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters.clear();
+}
+
+/*!
+ Appends the given \a filter to the list of unioned filters.
+
+ \sa append()
+ */
+QLandmarkUnionFilter& QLandmarkUnionFilter::operator<<(const QLandmarkFilter &filter)
+{
+ Q_D(QLandmarkUnionFilter);
+ d->filters.append(filter);
+ return *this;
+}
+
+/*!
+ Returns the list of filters which form the union filter.
+
+ \sa setFilters(), prepend(), append(), remove()
+ */
+QList<QLandmarkFilter> QLandmarkUnionFilter::filters() const
+{
+ Q_D(const QLandmarkUnionFilter);
+ return d->filters;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QLandmarkUnionFilterPrivate::QLandmarkUnionFilterPrivate()
+ : QLandmarkFilterPrivate()
+{
+ type = QLandmarkFilter::UnionFilter;
+}
+
+QLandmarkUnionFilterPrivate::QLandmarkUnionFilterPrivate(const QLandmarkUnionFilterPrivate &other)
+ : QLandmarkFilterPrivate(other),
+ filters(other.filters) {}
+
+QLandmarkUnionFilterPrivate::~QLandmarkUnionFilterPrivate() {}
+
+QTM_END_NAMESPACE
diff --git a/src/location/landmarks/qlandmarkunionfilter.h b/src/location/landmarks/qlandmarkunionfilter.h
new file mode 100644
index 00000000..9ba8abb8
--- /dev/null
+++ b/src/location/landmarks/qlandmarkunionfilter.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKUNIONFILTER_H
+#define QLANDMARKUNIONFILTER_H
+
+#include "qlandmarkfilter.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkUnionFilterPrivate;
+class Q_LOCATION_EXPORT QLandmarkUnionFilter : public QLandmarkFilter
+{
+public:
+ QLandmarkUnionFilter();
+ QLandmarkUnionFilter(const QLandmarkFilter &other);
+ virtual ~QLandmarkUnionFilter();
+
+ void setFilters(const QList<QLandmarkFilter> &filters);
+
+ void prepend(const QLandmarkFilter &filter);
+ void append(const QLandmarkFilter &filter);
+ void remove(const QLandmarkFilter &filter);
+ void clear();
+
+ QLandmarkUnionFilter& operator<<(const QLandmarkFilter &filter);
+ QList<QLandmarkFilter> filters() const;
+
+private:
+ Q_DECLARE_LANDMARKFILTER_PRIVATE(QLandmarkUnionFilter)
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/landmarks/qlandmarkunionfilter_p.h b/src/location/landmarks/qlandmarkunionfilter_p.h
new file mode 100644
index 00000000..93563e35
--- /dev/null
+++ b/src/location/landmarks/qlandmarkunionfilter_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLANDMARKUNIONFILTER_P_H
+#define QLANDMARKUNIONFILTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qlandmarkfilter_p.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkUnionFilterPrivate : public QLandmarkFilterPrivate
+{
+public:
+ QLandmarkUnionFilterPrivate();
+ QLandmarkUnionFilterPrivate(const QLandmarkUnionFilterPrivate &other);
+ virtual ~QLandmarkUnionFilterPrivate();
+
+ virtual bool compare(const QLandmarkFilterPrivate* other) const
+ {
+ //it is assumed that the types and superclass member variables already match
+ const QLandmarkUnionFilterPrivate *od = static_cast<const QLandmarkUnionFilterPrivate*>(other);
+ return filters == od->filters;
+ }
+
+ Q_IMPLEMENT_LANDMARKFILTER_VIRTUALCTORS(QLandmarkUnionFilter, QLandmarkFilter::UnionFilter)
+
+ QList<QLandmarkFilter> filters;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/liblocationwrapper.cpp b/src/location/liblocationwrapper.cpp
new file mode 100644
index 00000000..fbb4f9fc
--- /dev/null
+++ b/src/location/liblocationwrapper.cpp
@@ -0,0 +1,377 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "liblocationwrapper_p.h"
+
+#include <QDateTime>
+
+using namespace std;
+
+QTM_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(LiblocationWrapper, LocationEngine)
+
+LiblocationWrapper *LiblocationWrapper::instance()
+{
+ return LocationEngine();
+}
+
+LiblocationWrapper::LiblocationWrapper()
+ : file(NULL),
+ locationControl(NULL),
+ locationDevice(NULL),
+ errorHandlerId(0),
+ posChangedId(0),
+ origUpdateInterval(0),
+ startcounter(0),
+ validLastUpdate(false),
+ validLastSatUpdate(false),
+ locationState(LiblocationWrapper::Undefined) {}
+
+LiblocationWrapper::~LiblocationWrapper()
+{
+ if (locationDevice)
+ g_object_unref(locationDevice);
+ if (locationControl)
+ g_object_unref(locationControl);
+}
+
+bool LiblocationWrapper::inited()
+{
+ int retval = false;
+ if (!(locationState & LiblocationWrapper::Inited)) {
+ g_type_init();
+
+ locationControl = location_gpsd_control_get_default();
+
+ if (locationControl) {
+ g_object_set(G_OBJECT(locationControl),
+ "preferred-method", LOCATION_METHOD_USER_SELECTED,
+ "preferred-interval", LOCATION_INTERVAL_1S,
+ NULL);
+ locationDevice =
+ (LocationGPSDevice*)g_object_new(LOCATION_TYPE_GPS_DEVICE,
+ NULL);
+
+ if (locationDevice) {
+ errorHandlerId =
+ g_signal_connect(G_OBJECT(locationControl), "error-verbose",
+ G_CALLBACK(&locationError),
+ static_cast<void*>(this));
+ posChangedId =
+ g_signal_connect(G_OBJECT(locationDevice), "changed",
+ G_CALLBACK(&locationChanged),
+ static_cast<void*>(this));
+ locationState = LiblocationWrapper::Inited;
+ retval = true;
+ startcounter = 0;
+ }
+ }
+ } else {
+ retval = true;
+ }
+ return retval;
+}
+
+void LiblocationWrapper::locationError(LocationGPSDevice *device,
+ gint errorCode, gpointer data)
+{
+ Q_UNUSED(device);
+ QString locationError;
+
+ switch (errorCode) {
+ case LOCATION_ERROR_USER_REJECTED_DIALOG:
+ locationError = "User didn't enable requested methods";
+ break;
+ case LOCATION_ERROR_USER_REJECTED_SETTINGS:
+ locationError = "User changed settings, which disabled location.";
+ break;
+ case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
+ locationError = "Problems with BT GPS";
+ break;
+ case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
+ locationError = "Requested method is not allowed in offline mode";
+ break;
+ case LOCATION_ERROR_SYSTEM:
+ locationError = "System error.";
+ break;
+ default:
+ locationError = "Unknown error.";
+ }
+
+ qDebug() << "Location error:" << locationError;
+
+ LiblocationWrapper *object;
+ object = (LiblocationWrapper *)data;
+ emit object->error();
+}
+
+void LiblocationWrapper::locationChanged(LocationGPSDevice *device,
+ gpointer data)
+{
+ QGeoPositionInfo posInfo;
+ QGeoCoordinate coordinate;
+ QGeoSatelliteInfo satInfo;
+ int satellitesInUseCount = 0;
+ LiblocationWrapper *object;
+
+ if (!data || !device) {
+ return;
+ }
+
+ object = (LiblocationWrapper *)data;
+
+ if (device) {
+ if (device->fix) {
+ if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
+ posInfo.setTimestamp(QDateTime::fromTime_t(device->fix->time));
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
+ coordinate.setLatitude(device->fix->latitude);
+ coordinate.setLongitude(device->fix->longitude);
+ posInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy,
+ device->fix->eph / 100.0);
+ posInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy,
+ device->fix->epv);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) {
+ coordinate.setAltitude(device->fix->altitude);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
+ posInfo.setAttribute(QGeoPositionInfo::GroundSpeed,
+ device->fix->speed / 3.6);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET) {
+ posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed,
+ device->fix->climb);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
+ posInfo.setAttribute(QGeoPositionInfo::Direction,
+ device->fix->track);
+ }
+ }
+
+ if (device->satellites_in_view) {
+ QList<QGeoSatelliteInfo> satsInView;
+ QList<QGeoSatelliteInfo> satsInUse;
+ unsigned int i;
+ for (i = 0;i < device->satellites->len;i++) {
+ LocationGPSDeviceSatellite *satData =
+ (LocationGPSDeviceSatellite *)g_ptr_array_index(device->satellites,
+ i);
+ satInfo.setSignalStrength(satData->signal_strength);
+ satInfo.setPrnNumber(satData->prn);
+ satInfo.setAttribute(QGeoSatelliteInfo::Elevation,
+ satData->elevation);
+ satInfo.setAttribute(QGeoSatelliteInfo::Azimuth,
+ satData->azimuth);
+
+ satsInView.append(satInfo);
+ if (satData->in_use) {
+ satellitesInUseCount++;
+ satsInUse.append(satInfo);
+ }
+ }
+
+ if (!satsInView.isEmpty())
+ object->satellitesInViewUpdated(satsInView);
+
+ if (!satsInUse.isEmpty())
+ object->satellitesInUseUpdated(satsInUse);
+ }
+ }
+
+ posInfo.setCoordinate(coordinate);
+
+ emit object->positionUpdated(posInfo);
+}
+
+QGeoPositionInfo LiblocationWrapper::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ QGeoPositionInfo posInfo;
+ QGeoCoordinate coordinate;
+ double time;
+ double latitude;
+ double longitude;
+ double altitude;
+ double speed;
+ double track;
+ double climb;
+
+ GConfItem lastKnownPositionTime("/system/nokia/location/lastknown/time");
+ GConfItem lastKnownPositionLatitude("/system/nokia/location/lastknown/latitude");
+ GConfItem lastKnownPositionLongitude("/system/nokia/location/lastknown/longitude");
+ GConfItem lastKnownPositionAltitude("/system/nokia/location/lastknown/altitude");
+ GConfItem lastKnownPositionSpeed("/system/nokia/location/lastknown/speed");
+ GConfItem lastKnownPositionTrack("/system/nokia/location/lastknown/track");
+ GConfItem lastKnownPositionClimb("/system/nokia/location/lastknown/climb");
+
+ if (validLastSatUpdate)
+ return lastSatUpdate;
+
+ if (!fromSatellitePositioningMethodsOnly)
+ if (validLastUpdate)
+ return lastUpdate;
+
+ time = lastKnownPositionTime.value().toDouble();
+ latitude = lastKnownPositionLatitude.value().toDouble();
+ longitude = lastKnownPositionLongitude.value().toDouble();
+ altitude = lastKnownPositionAltitude.value().toDouble();
+ speed = lastKnownPositionSpeed.value().toDouble();
+ track = lastKnownPositionTrack.value().toDouble();
+ climb = lastKnownPositionClimb.value().toDouble();
+
+ if (longitude && latitude) {
+ coordinate.setLongitude(longitude);
+ coordinate.setLatitude(latitude);
+ if (altitude) {
+ coordinate.setAltitude(altitude);
+ }
+ posInfo.setCoordinate(coordinate);
+ }
+
+ if (speed) {
+ posInfo.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
+ }
+
+ if (track) {
+ posInfo.setAttribute(QGeoPositionInfo::Direction, track);
+ }
+
+ if (climb) {
+ posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, climb);
+ }
+
+ // Only positions with time (3D) are provided.
+ if (time) {
+ posInfo.setTimestamp(QDateTime::fromTime_t(time));
+ return posInfo;
+ }
+
+ return QGeoPositionInfo();
+}
+
+void LiblocationWrapper::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+ satsInView = satellites;
+}
+
+void LiblocationWrapper::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
+{
+ satsInUse = satellites;
+}
+
+QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInView()
+{
+ return satsInView;
+}
+
+QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInUse()
+{
+ return satsInUse;
+}
+
+void LiblocationWrapper::start() {
+ startcounter++;
+
+ if ((locationState & LiblocationWrapper::Inited) &&
+ !(locationState & LiblocationWrapper::Started)) {
+ if (!errorHandlerId) {
+ errorHandlerId =
+ g_signal_connect(G_OBJECT(locationControl), "error-verbose",
+ G_CALLBACK(&locationError),
+ static_cast<void*>(this));
+ }
+
+ if (!posChangedId) {
+ posChangedId =
+ g_signal_connect(G_OBJECT(locationDevice), "changed",
+ G_CALLBACK(&locationChanged),
+ static_cast<void*>(this));
+ }
+
+ location_gpsd_control_start(locationControl);
+
+ locationState |= LiblocationWrapper::Started;
+ locationState &= ~LiblocationWrapper::Stopped;
+ }
+}
+
+void LiblocationWrapper::stop() {
+ startcounter--;
+
+ if (startcounter > 0)
+ return;
+
+ if ((locationState & (LiblocationWrapper::Started |
+ LiblocationWrapper::Inited)) &&
+ !(locationState & LiblocationWrapper::Stopped)) {
+ if (errorHandlerId)
+ g_signal_handler_disconnect(G_OBJECT(locationControl),
+ errorHandlerId);
+ if (posChangedId)
+ g_signal_handler_disconnect(G_OBJECT(locationDevice),
+ posChangedId);
+ errorHandlerId = 0;
+ posChangedId = 0;
+ startcounter = 0;
+ location_gpsd_control_stop(locationControl);
+
+ locationState &= ~LiblocationWrapper::Started;
+ locationState |= LiblocationWrapper::Stopped;
+ }
+}
+
+bool LiblocationWrapper::isActive() {
+ if (locationState & LiblocationWrapper::Started)
+ return true;
+ else
+ return false;
+}
+
+#include "moc_liblocationwrapper_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/liblocationwrapper_p.h b/src/location/liblocationwrapper_p.h
new file mode 100644
index 00000000..e5d5d9c2
--- /dev/null
+++ b/src/location/liblocationwrapper_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIBLOCATIONWRAPPER_H
+#define LIBLOCATINWRAPPER_H
+
+// INCLUDES
+#include <QDebug>
+#include <QFile>
+
+#include "qgeocoordinate.h"
+#include "qgeopositioninfo.h"
+#include "qgeosatelliteinfo.h"
+
+#include "gconfitem_p.h"
+
+extern "C" {
+ #include <glib.h>
+ #include <location/location-gpsd-control.h>
+ #include <location/location-gps-device.h>
+ #include <location/location-misc.h>
+ #include <location/location-distance-utils.h>
+}
+
+QTM_BEGIN_NAMESPACE
+
+class LiblocationWrapper : public QObject
+{
+ Q_OBJECT
+
+public:
+ static LiblocationWrapper *instance();
+ LiblocationWrapper();
+ ~LiblocationWrapper();
+
+ void start();
+ void stop();
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ bool inited();
+ bool isActive();
+ QList<QGeoSatelliteInfo> satellitesInView();
+ QList<QGeoSatelliteInfo> satellitesInUse();
+
+private:
+ QFile *file;
+ LocationGPSDControl *locationControl;
+ LocationGPSDevice *locationDevice;
+
+ static void locationError(LocationGPSDevice *device, gint code, gpointer data);
+ static void locationChanged(LocationGPSDevice *device, gpointer data);
+
+ int errorHandlerId;
+ int posChangedId;
+ int origUpdateInterval;
+ int startcounter;
+ QGeoPositionInfo lastUpdate;
+ QGeoPositionInfo lastSatUpdate;
+ bool validLastUpdate;
+ bool validLastSatUpdate;
+ bool fromSatellite;
+
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ QList<QGeoSatelliteInfo> satsInView;
+ QList<QGeoSatelliteInfo> satsInUse;
+
+ enum LocationState {
+ Undefined = 0,
+ Inited = 1,
+ Started = 2,
+ Stopped = 4,
+ RequestActive = 8,
+ RequestSingleShot = 16
+ };
+ int locationState;
+
+signals:
+ void positionUpdated(const QGeoPositionInfo &position);
+ void error();
+};
+
+QTM_END_NAMESPACE
+#endif // LIBLOCATIONWRAPPER_H
diff --git a/src/location/location.pro b/src/location/location.pro
new file mode 100644
index 00000000..55abe286
--- /dev/null
+++ b/src/location/location.pro
@@ -0,0 +1,197 @@
+TEMPLATE = lib
+TARGET = QtLocation
+QT = core gui network sql
+
+include(../../common.pri)
+
+DEFINES += QT_BUILD_LOCATION_LIB QT_MAKEDLL
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+INCLUDEPATH += .
+DEPENDPATH += .
+
+include(landmarks/landmarks.pri)
+include(maps/maps.pri)
+
+contains(proj_enabled, yes) {
+ LIBS += -lproj
+} else {
+ include($$PWD/../3rdparty/proj.pri)
+}
+
+PUBLIC_HEADERS += \
+ qgeoaddress.h \
+ qgeoareamonitor.h \
+ qgeoboundingarea.h \
+ qgeoboundingbox.h \
+ qgeoboundingcircle.h \
+ qgeocoordinate.h \
+ qgeoplace.h \
+ qgeopositioninfo.h \
+ qgeopositioninfosource.h \
+ qgeosatelliteinfo.h \
+ qgeosatelliteinfosource.h \
+ qnmeapositioninfosource.h \
+ qgeopositioninfosourcefactory.h
+
+PRIVATE_HEADERS += \
+ qgeoaddress_p.h \
+ qgeoboundingbox_p.h \
+ qgeoboundingcircle_p.h \
+ qgeoplace_p.h \
+ qlocationutils_p.h \
+ qnmeapositioninfosource_p.h \
+ qgeoareamonitor_polling_p.h \
+ projwrapper_p.h \
+ qgeocoordinate_p.h
+
+symbian {
+ PRIVATE_HEADERS += qgeopositioninfosource_s60_p.h \
+ qmlbackendao_s60_p.h \
+ qgeosatelliteinfosource_s60_p.h \
+ notificationcallback_s60_p.h \
+ notificationsatellitecallback_s60_p.h
+
+ contains(lbt_enabled, yes) {
+ PRIVATE_HEADERS += \
+ qgeoareamonitor_s60_p.h \
+ qmlbackendmonitorao_s60_p.h \
+ qmlbackendmonitorcreatetriggerao_s60_p.h \
+ qmlbackendmonitorinfo_s60_p.h \
+ qmlbackendtriggerchangeao_s60_p.h \
+ notificationmonitorcallback_s60_p.h
+ }
+
+ SOURCES += qgeopositioninfosource_s60.cpp \
+ qgeosatelliteinfosource_s60.cpp \
+ qmlbackendao_s60.cpp
+
+ contains(lbt_enabled, yes) {
+ SOURCES += \
+ qgeoareamonitor_s60.cpp \
+ qmlbackendmonitorao_s60.cpp \
+ qmlbackendmonitorcreatetriggerao_s60.cpp \
+ qmlbackendmonitorinfo_s60.cpp \
+ qmlbackendtriggerchangeao_s60.cpp
+ }
+}
+
+wince* {
+ PRIVATE_HEADERS += qgeopositioninfosource_wince_p.h \
+ qgeosatelliteinfosource_wince_p.h \
+ qgeoinfothread_wince_p.h
+ SOURCES += qgeopositioninfosource_wince.cpp \
+ qgeosatelliteinfosource_wince.cpp \
+ qgeoinfothread_wince.cpp
+ LIBS += -lgpsapi
+}
+
+maemo6|meego {
+ CONFIG += qdbus link_pkgconfig
+ SOURCES += qgeopositioninfosource_maemo.cpp \
+ qgeosatelliteinfosource_maemo.cpp \
+ dbuscomm_maemo.cpp \
+ dbusserver_maemo.cpp
+ PRIVATE_HEADERS += qgeopositioninfosource_maemo_p.h \
+ qgeosatelliteinfosource_maemo_p.h \
+ dbuscomm_maemo_p.h \
+ dbusserver_maemo_p.h
+}
+
+maemo5 {
+ CONFIG += qdbus link_pkgconfig
+ SOURCES += gconfitem.cpp \
+ liblocationwrapper.cpp \
+ qgeopositioninfosource_maemo5.cpp \
+ qgeosatelliteinfosource_maemo5.cpp
+ HEADERS += gconfitem_p.h \
+ liblocationwrapper_p.h \
+ qgeopositioninfosource_maemo5_p.h \
+ qgeosatelliteinfosource_maemo5_p.h
+ PKGCONFIG += glib-2.0 gconf-2.0
+ LIBS += -llocation
+ QMAKE_PKGCONFIG_REQUIRES = glib-2.0 gconf-2.0
+}
+
+meego {
+ contains (geoclue-master_enabled, yes) {
+ message("Building location with GeoClue master support.")
+ SOURCES += qgeopositioninfosource_geocluemaster.cpp
+ PRIVATE_HEADERS += qgeopositioninfosource_geocluemaster_p.h
+ DEFINES += GEOCLUE_MASTER_AVAILABLE=1
+ PKGCONFIG += geoclue
+ QMAKE_PKGCONFIG_REQUIRES += geoclue
+ } else {
+ message("Building location without GeoClue master support.")
+ }
+ contains (gypsy_enabled, yes) {
+ message("Building location with Gypsy support.")
+ SOURCES += qgeosatelliteinfosource_gypsy.cpp
+ PRIVATE_HEADERS += qgeosatelliteinfosource_gypsy_p.h
+ DEFINES += GYPSY_AVAILABLE=1
+ PKGCONFIG += gypsy
+ QMAKE_PKGCONFIG_REQUIRES += gypsy
+ } else {
+ message("Building location without Gypsy support.")
+ }
+ if (contains(gypsy_enabled, yes) || contains (geoclue-master_enabled, yes)) {
+ CONFIG += qdbus link_pkgconfig
+ PKGCONFIG += gconf-2.0 glib-2.0
+ QMAKE_PKGCONFIG_REQUIRES += glib-2.0 gconf-2.0
+ }
+}
+
+HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
+
+SOURCES += \
+ qgeoaddress.cpp \
+ qgeoareamonitor.cpp \
+ qgeoboundingarea.cpp \
+ qgeoboundingbox.cpp \
+ qgeoboundingcircle.cpp \
+ qgeocoordinate.cpp \
+ qgeoplace.cpp \
+ qgeopositioninfo.cpp \
+ qgeopositioninfosource.cpp \
+ qgeosatelliteinfo.cpp \
+ qgeosatelliteinfosource.cpp \
+ qlocationutils.cpp \
+ qnmeapositioninfosource.cpp \
+ qgeoareamonitor_polling.cpp \
+ projwrapper_p.cpp \
+ qgeopositioninfosourcefactory.cpp
+
+symbian {
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0x2002AC83
+
+ INCLUDEPATH += $${EPOCROOT}epoc32/include/osextensions \
+ $${EPOCROOT}epoc32/include/LBTHeaders \
+ $${EPOCROOT}epoc32/include/platform
+ LIBS += -llbs
+ LIBS += -lefsrv
+ contains(lbt_enabled, yes) {
+ LIBS += -llbt
+ }
+
+ QtLocationDeployment.sources = QtLocation.dll
+ QtLocationDeployment.path = /sys/bin
+ DEPLOYMENT += QtLocationDeployment
+}
+
+simulator {
+ QT += gui
+ SOURCES += qgeopositioninfosource_simulator.cpp \
+ qlocationdata_simulator.cpp \
+ qgeosatelliteinfosource_simulator.cpp \
+ qlocationconnection_simulator.cpp
+ HEADERS += qgeopositioninfosource_simulator_p.h \
+ qlocationdata_simulator_p.h \
+ qgeosatelliteinfosource_simulator_p.h \
+ qlocationconnection_simulator_p.h
+ INCLUDEPATH += ../mobilitysimulator
+ qtAddLibrary(QtMobilitySimulator)
+}
+
+CONFIG += middleware
+include(../../features/deploy.pri)
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri
new file mode 100644
index 00000000..6a5e8f1b
--- /dev/null
+++ b/src/location/maps/maps.pri
@@ -0,0 +1,95 @@
+
+INCLUDEPATH += maps
+
+include(tiled/tiled.pri)
+
+PUBLIC_HEADERS += \
+ maps/qgeomaneuver.h \
+ maps/qgeomapcircleobject.h \
+ maps/qgeomapcustomobject.h \
+ maps/qgeomapdata.h \
+ maps/qgeomapgroupobject.h \
+ maps/qgeomapobject.h \
+ maps/qgeomapobjectinfo.h \
+ maps/qgeomapoverlay.h \
+ maps/qgeomappingmanager.h \
+ maps/qgeomappingmanagerengine.h \
+ maps/qgeomappixmapobject.h \
+ maps/qgeomappolygonobject.h \
+ maps/qgeomappolylineobject.h \
+ maps/qgeomaprectangleobject.h \
+ maps/qgeomaprouteobject.h \
+ maps/qgeomaptextobject.h \
+ maps/qgeoroute.h \
+ maps/qgeoroutereply.h \
+ maps/qgeorouterequest.h \
+ maps/qgeoroutesegment.h \
+ maps/qgeoroutingmanager.h \
+ maps/qgeoroutingmanagerengine.h \
+ maps/qgeosearchmanager.h \
+ maps/qgeosearchmanagerengine.h \
+ maps/qgeosearchreply.h \
+ maps/qgeoserviceprovider.h \
+ maps/qgeoserviceproviderfactory.h \
+ maps/qgraphicsgeomap.h
+
+PRIVATE_HEADERS += \
+ maps/qgeomaneuver_p.h \
+ maps/qgeomapcircleobject_p.h \
+ maps/qgeomapcustomobject_p.h \
+ maps/qgeomapdata_p.h \
+ maps/qgeomapgroupobject_p.h \
+ maps/qgeomapobject_p.h \
+ maps/qgeomapobjectinfo_p.h \
+ maps/qgeomapoverlay_p.h \
+ maps/qgeomappingmanager_p.h \
+ maps/qgeomappingmanagerengine_p.h \
+ maps/qgeomappixmapobject_p.h \
+ maps/qgeomappolygonobject_p.h \
+ maps/qgeomappolylineobject_p.h \
+ maps/qgeomaprectangleobject_p.h \
+ maps/qgeomaprouteobject_p.h \
+ maps/qgeomaptextobject_p.h \
+ maps/qgeoroute_p.h \
+ maps/qgeoroutereply_p.h \
+ maps/qgeorouterequest_p.h \
+ maps/qgeoroutesegment_p.h \
+ maps/qgeoroutingmanager_p.h \
+ maps/qgeoroutingmanagerengine_p.h \
+ maps/qgeosearchmanager_p.h \
+ maps/qgeosearchmanagerengine_p.h \
+ maps/qgeosearchreply_p.h \
+ maps/qgeoserviceprovider_p.h \
+ maps/qgraphicsgeomap_p.h \
+ maps/qgeomapobjectengine_p.h
+
+SOURCES += \
+ maps/qgeomaneuver.cpp \
+ maps/qgeomapcircleobject.cpp \
+ maps/qgeomapcustomobject.cpp \
+ maps/qgeomapdata.cpp \
+ maps/qgeomapgroupobject.cpp \
+ maps/qgeomapobject.cpp \
+ maps/qgeomapoverlay.cpp \
+ maps/qgeomappingmanager.cpp \
+ maps/qgeomappingmanagerengine.cpp \
+ maps/qgeomappixmapobject.cpp \
+ maps/qgeomappolygonobject.cpp \
+ maps/qgeomappolylineobject.cpp \
+ maps/qgeomaprectangleobject.cpp \
+ maps/qgeomaprouteobject.cpp \
+ maps/qgeomaptextobject.cpp \
+ maps/qgeoroute.cpp \
+ maps/qgeoroutereply.cpp \
+ maps/qgeorouterequest.cpp \
+ maps/qgeoroutesegment.cpp \
+ maps/qgeoroutingmanager.cpp \
+ maps/qgeoroutingmanagerengine.cpp \
+ maps/qgeosearchmanager.cpp \
+ maps/qgeosearchmanagerengine.cpp \
+ maps/qgeosearchreply.cpp \
+ maps/qgeoserviceprovider.cpp \
+ maps/qgeoserviceproviderfactory.cpp \
+ maps/qgraphicsgeomap.cpp \
+ maps/qgeomapobjectinfo.cpp \
+ maps/qgeomapobjectengine_p.cpp
diff --git a/src/location/maps/qgeomaneuver.cpp b/src/location/maps/qgeomaneuver.cpp
new file mode 100644
index 00000000..92a2ac26
--- /dev/null
+++ b/src/location/maps/qgeomaneuver.cpp
@@ -0,0 +1,321 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomaneuver.h"
+#include "qgeomaneuver_p.h"
+
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoManeuver
+ \brief The QGeoManeuver class represents the information relevant to the
+ point at which two QGeoRouteSegments meet.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ QGeoRouteSegment instances can be thought of as edges on a routing
+ graph, with QGeoManeuver instances as optional labels attached to the
+ vertices of the graph.
+
+ The most interesting information help in a QGeoManeuver instance is
+ normally the textual navigation to provide and the position at which to
+ provide it, accessible by instructionText() and position() respectively.
+
+ It is also possible to determine if a routing waypoint has been passed by
+ checking if waypoint() returns a valid QGeoCoordinate.
+*/
+
+/*!
+\enum QGeoManeuver::InstructionDirection
+
+Describes the change in direction associated with the instruction text
+that is associated with a QGeoManaeuver.
+
+\value NoDirection
+There is no direction associated with the instruction text.
+
+\value DirectionForward
+The instruction indicates that the direction of travel does not need to change.
+
+\value DirectionBearRight
+The instruction indicates that the direction of travel should bear to the right.
+
+\value DirectionLightRight
+The instruction indicates that a light turn to the right is required.
+
+\value DirectionRight
+The instruction indicates that a turn to the right is required.
+
+\value DirectionHardRight
+The instruction indicates that a hard turn to the right is required.
+
+\value DirectionUTurnRight
+The instruction indicates that a u-turn to the right is required.
+
+\value DirectionUTurnLeft
+The instruction indicates that a u-turn to the left is required.
+
+\value DirectionHardLeft
+The instruction indicates that a hard turn to the left is required.
+
+\value DirectionLeft
+The instruction indicates that a turn to the left is required.
+
+\value DirectionLightLeft
+The instruction indicates that a light turn to the left is required.
+
+\value DirectionBearLeft
+The instruction indicates that the direction of travel should bear to the left.
+
+*/
+
+/*!
+ Constructs a invalid maneuver object.
+
+ The maneuver will remain invalid until one of
+ setPosition(), setInstructionText(), setDirection(),
+ setTimeToNextInstruction(), setDistanceToNextInstruction() or
+ setWaypoint() is called.
+*/
+QGeoManeuver::QGeoManeuver()
+ : d_ptr(new QGeoManeuverPrivate()) {}
+
+/*!
+ Constructs a maneuver object from the contents of \a other.
+*/
+QGeoManeuver::QGeoManeuver(const QGeoManeuver &other)
+ : d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys this manevuer object.
+*/
+QGeoManeuver::~QGeoManeuver() {}
+
+/*!
+ Assigns \a other to this maneuver object and then returns
+ a reference to this maneuver object.
+*/
+QGeoManeuver& QGeoManeuver::operator= (const QGeoManeuver & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this maneuver is equal to \a other.
+*/
+bool QGeoManeuver::operator== (const QGeoManeuver &other) const
+{
+ return (*(d_ptr.constData()) == *(other.d_ptr.constData()));
+}
+
+/*!
+ Returns whether this maneuver is not equal to \a other.
+*/
+bool QGeoManeuver::operator!= (const QGeoManeuver &other) const
+{
+ return !(operator==(other));
+}
+
+/*!
+ Returns whether this maneuver is valid or not.
+
+ Invalid maneuvers are used when there is no information
+ that needs to be attached to the endpoint of a QGeoRouteSegment instance.
+*/
+bool QGeoManeuver::isValid() const
+{
+ return d_ptr->valid;
+}
+
+/*!
+ Sets the position where instructionText() should be displayed to \a
+ position.
+*/
+void QGeoManeuver::setPosition(const QGeoCoordinate &position)
+{
+ d_ptr->valid = true;
+ d_ptr->position = position;
+}
+
+/*!
+ Returns the position where instructionText() should be displayed.
+*/
+QGeoCoordinate QGeoManeuver::position() const
+{
+ return d_ptr->position;
+}
+
+/*!
+ Sets the textual navigation instructions to \a instructionText.
+*/
+void QGeoManeuver::setInstructionText(const QString &instructionText)
+{
+ d_ptr->valid = true;
+ d_ptr->text = instructionText;
+}
+
+/*!
+ Returns the textual navigation instructions.
+*/
+QString QGeoManeuver::instructionText() const
+{
+ return d_ptr->text;
+}
+
+/*!
+ Sets the direction associated with the associated instruction to \a
+ direction.
+*/
+void QGeoManeuver::setDirection(QGeoManeuver::InstructionDirection direction)
+{
+ d_ptr->valid = true;
+ d_ptr->direction = direction;
+}
+
+/*!
+ Returns the direction associated with the associated instruction.
+*/
+QGeoManeuver::InstructionDirection QGeoManeuver::direction() const
+{
+ return d_ptr->direction;
+}
+
+/*!
+ Sets the estimated time it will take to travel from the point at which the
+ associated instruction was issued and the point that the next instruction
+ should be issued, in seconds, to \a secs.
+*/
+void QGeoManeuver::setTimeToNextInstruction(int secs)
+{
+ d_ptr->valid = true;
+ d_ptr->timeToNextInstruction = secs;
+}
+
+/*!
+ Returns the estimated time it will take to travel from the point at which
+ the associated instruction was issued and the point that the next
+ instruction should be issued, in seconds.
+*/
+int QGeoManeuver::timeToNextInstruction() const
+{
+ return d_ptr->timeToNextInstruction;
+}
+
+/*!
+ Sets the distance, in metres, between the point at which the associated
+ instruction was issued and the point that the next instruction should be
+ issued to \a distance.
+*/
+void QGeoManeuver::setDistanceToNextInstruction(qreal distance)
+{
+ d_ptr->valid = true;
+ d_ptr->distanceToNextInstruction = distance;
+}
+
+/*!
+ Returns the distance, in metres, between the point at which the associated
+ instruction was issued and the point that the next instruction should be
+ issued.
+*/
+qreal QGeoManeuver::distanceToNextInstruction() const
+{
+ return d_ptr->distanceToNextInstruction;
+}
+
+/*!
+ Sets the waypoint associated with this maneuver to \a coordinate.
+*/
+void QGeoManeuver::setWaypoint(const QGeoCoordinate &coordinate)
+{
+ d_ptr->valid = true;
+ d_ptr->waypoint = coordinate;
+}
+
+/*!
+ Returns the waypoint associated with this maneuver.
+
+ If there is not waypoint associated with this maneuver an invalid
+ QGeoCoordinate will be returned.
+*/
+QGeoCoordinate QGeoManeuver::waypoint() const
+{
+ return d_ptr->waypoint;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoManeuverPrivate::QGeoManeuverPrivate()
+ : valid(false),
+ direction(QGeoManeuver::NoDirection),
+ timeToNextInstruction(0),
+ distanceToNextInstruction(0.0) {}
+
+QGeoManeuverPrivate::QGeoManeuverPrivate(const QGeoManeuverPrivate &other)
+ : QSharedData(other),
+ valid(other.valid),
+ position(other.position),
+ text(other.text),
+ direction(other.direction),
+ timeToNextInstruction(other.timeToNextInstruction),
+ distanceToNextInstruction(other.distanceToNextInstruction),
+ waypoint(other.waypoint) {}
+
+QGeoManeuverPrivate::~QGeoManeuverPrivate() {}
+
+bool QGeoManeuverPrivate::operator ==(const QGeoManeuverPrivate &other) const
+{
+ return ((valid == other.valid)
+ && (position == other.position)
+ && (text == other.text)
+ && (direction == other.direction)
+ && (timeToNextInstruction == other.timeToNextInstruction)
+ && (distanceToNextInstruction == other.distanceToNextInstruction)
+ && (waypoint == other.waypoint));
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomaneuver.h b/src/location/maps/qgeomaneuver.h
new file mode 100644
index 00000000..e88b60ba
--- /dev/null
+++ b/src/location/maps/qgeomaneuver.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMANEUVER_H
+#define QGEOMANEUVER_H
+
+#include "qmobilityglobal.h"
+
+#include <QExplicitlySharedDataPointer>
+
+class QString;
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoManeuverPrivate;
+
+class Q_LOCATION_EXPORT QGeoManeuver
+{
+
+public:
+ enum InstructionDirection {
+ NoDirection,
+ DirectionForward,
+ DirectionBearRight,
+ DirectionLightRight,
+ DirectionRight,
+ DirectionHardRight,
+ DirectionUTurnRight,
+ DirectionUTurnLeft,
+ DirectionHardLeft,
+ DirectionLeft,
+ DirectionLightLeft,
+ DirectionBearLeft
+ };
+
+ QGeoManeuver();
+ QGeoManeuver(const QGeoManeuver &other);
+ ~QGeoManeuver();
+
+ QGeoManeuver& operator= (const QGeoManeuver &other);
+
+ bool operator== (const QGeoManeuver &other) const;
+ bool operator!= (const QGeoManeuver &other) const;
+
+ bool isValid() const;
+
+ void setPosition(const QGeoCoordinate &position);
+ QGeoCoordinate position() const;
+
+ void setInstructionText(const QString &instructionText);
+ QString instructionText() const;
+
+ void setDirection(InstructionDirection direction);
+ InstructionDirection direction() const;
+
+ void setTimeToNextInstruction(int secs);
+ int timeToNextInstruction() const;
+
+ void setDistanceToNextInstruction(qreal distance);
+ qreal distanceToNextInstruction() const;
+
+ void setWaypoint(const QGeoCoordinate &coordinate);
+ QGeoCoordinate waypoint() const;
+
+private:
+ QExplicitlySharedDataPointer<QGeoManeuverPrivate> d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeomaneuver_p.h b/src/location/maps/qgeomaneuver_p.h
new file mode 100644
index 00000000..3a66c737
--- /dev/null
+++ b/src/location/maps/qgeomaneuver_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMANEUVER_P_H
+#define QGEOMANEUVER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomaneuver.h"
+#include "qgeocoordinate.h"
+
+#include <QSharedData>
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoManeuverPrivate : public QSharedData
+{
+public:
+ QGeoManeuverPrivate();
+ QGeoManeuverPrivate(const QGeoManeuverPrivate &other);
+ ~QGeoManeuverPrivate();
+
+ bool operator== (const QGeoManeuverPrivate &other) const;
+
+ bool valid;
+ QString id;
+ QGeoCoordinate position;
+ QString text;
+ QGeoManeuver::InstructionDirection direction;
+ int timeToNextInstruction;
+ qreal distanceToNextInstruction;
+ QGeoCoordinate waypoint;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapcircleobject.cpp b/src/location/maps/qgeomapcircleobject.cpp
new file mode 100644
index 00000000..35ff7747
--- /dev/null
+++ b/src/location/maps/qgeomapcircleobject.cpp
@@ -0,0 +1,340 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapcircleobject.h"
+#include "qgeomapcircleobject_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapCircleObject
+ \brief The QGeoMapCircleObject class is a QGeoMapObject used to draw the region
+ within a given distance of a coordinate.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The circle is specified by either a valid QGeoBoundingCircle instance or a
+ valid QGeoCoordinate instance and a qreal with value greater than 0.0,
+ which represent the center of the circle and the radius of the circle in
+ metres respectively.
+
+ The circle may appear as an ellipse on maps which use the Mercator
+ projection. This is done so that the circle accurately covers all points at
+ a distance of the radius or less from the center.
+*/
+
+/*!
+ Constructs a new circle object.
+*/
+QGeoMapCircleObject::QGeoMapCircleObject()
+ : d_ptr(new QGeoMapCircleObjectPrivate())
+{
+ setUnits(QGeoMapObject::MeterUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Constructs a new circle object based on the circle \a circle.
+*/
+QGeoMapCircleObject::QGeoMapCircleObject(const QGeoBoundingCircle &circle)
+ : d_ptr(new QGeoMapCircleObjectPrivate())
+{
+ d_ptr->circle = circle;
+ setUnits(QGeoMapObject::MeterUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Constructs a new circle object with a center at coordinate \a center
+ and a radius in meters of \a radius.
+*/
+QGeoMapCircleObject::QGeoMapCircleObject(const QGeoCoordinate &center, qreal radius)
+ : d_ptr(new QGeoMapCircleObjectPrivate())
+{
+ d_ptr->circle = QGeoBoundingCircle(center, radius);
+ setUnits(QGeoMapObject::MeterUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+ setOrigin(center);
+}
+
+/*!
+ Destroys this circle object.
+*/
+QGeoMapCircleObject::~QGeoMapCircleObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapCircleObject::type() const
+{
+ return QGeoMapObject::CircleType;
+}
+
+/*!
+ \property QGeoMapCircleObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw an outline around the circle. The circle is
+ filled using the QGeoMapCircleObject::brush property.
+
+ The pen will be treated as a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+void QGeoMapCircleObject::setPen(const QPen &pen)
+{
+ QPen newPen = pen;
+ newPen.setCosmetic(true);
+ const QPen oldPen = d_ptr->pen;
+
+ if (oldPen == newPen)
+ return;
+
+ d_ptr->pen = newPen;
+ emit penChanged(newPen);
+}
+
+QPen QGeoMapCircleObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+/*!
+ \reimp
+ */
+bool QGeoMapCircleObject::contains(const QGeoCoordinate &coordinate) const
+{
+ return d_ptr->circle.contains(coordinate);
+}
+
+/*!
+ \property QGeoMapCircleObject::brush
+ \brief This property holds the brush that will be used to draw this object.
+
+ The brush is used to fill in circle.
+
+ The outline around the perimeter of the circle is drawn using the
+ QGeoMapCircleObject::pen property.
+*/
+void QGeoMapCircleObject::setBrush(const QBrush &brush)
+{
+ if (d_ptr->brush != brush) {
+ d_ptr->brush = brush;
+ emit brushChanged(brush);
+ }
+}
+
+QBrush QGeoMapCircleObject::brush() const
+{
+ return d_ptr->brush;
+}
+
+/*!
+ \property QGeoMapCircleObject::pointCount
+ \brief This property holds the number of vertices used in an approximate polygon.
+
+ \since 1.2
+
+ For a circle using ExactTransform, this property describes the number
+ of sides that should be used to generate a polygonal approximation which
+ is then transformed vertex-by-vertex into screen coordinates.
+*/
+quint32 QGeoMapCircleObject::pointCount() const
+{
+ return d_ptr->pointCount;
+}
+
+void QGeoMapCircleObject::setPointCount(quint32 pointCount)
+{
+ d_ptr->pointCount = pointCount;
+}
+
+/*!
+ Returns a QGeoBoundingCircle instance which corresponds to the circle that
+ will be drawn by this object.
+
+ This is equivalent to
+ \code
+ QGeoMapCircleObject *object;
+ // setup object
+ QGeoBoundingCircle(object->center(), object->radius());
+ \endcode
+*/
+QGeoBoundingCircle QGeoMapCircleObject::circle() const
+{
+ return d_ptr->circle;
+}
+
+/*!
+ Sets the circle that will be drawn by this object to \a circle.
+
+ This is equivalent to
+ \code
+ QGeoMapCircleObject *object;
+ // setup object
+ object->setCenter(circle.center());
+ object->setRadius(circle.radius());
+ \endcode
+*/
+void QGeoMapCircleObject::setCircle(const QGeoBoundingCircle &circle)
+{
+ QGeoBoundingCircle oldCircle = d_ptr->circle;
+
+ if (oldCircle == circle)
+ return;
+
+ d_ptr->circle = circle;
+ setOrigin(circle.center());
+ setRadius(circle.radius());
+
+ if (oldCircle.center() != d_ptr->circle.center())
+ emit centerChanged(d_ptr->circle.center());
+
+ if (oldCircle.radius() != d_ptr->circle.radius())
+ emit radiusChanged(d_ptr->circle.radius());
+}
+
+/*!
+ \property QGeoMapCircleObject::center
+
+ \brief This property holds the coordinate of the center of the circle to be
+ drawn by this circle object.
+
+ The default value of this property is an invalid coordinate. While the
+ value of this property is invalid the circle object will not be displayed.
+*/
+void QGeoMapCircleObject::setCenter(const QGeoCoordinate &center)
+{
+ if (d_ptr->circle.center() != center) {
+ d_ptr->circle.setCenter(center);
+ setOrigin(center);
+ emit centerChanged(center);
+ }
+}
+
+QGeoCoordinate QGeoMapCircleObject::center() const
+{
+ return d_ptr->circle.center();
+}
+
+/*!
+ \property QGeoMapCircleObject::radius
+ \brief This property holds the radius in metres of the circle that will be
+ drawn by this circle object.
+
+ The default value of this property is -1.0. While the value of this
+ property is not greater than 0 the circle object will not be displayed.
+*/
+void QGeoMapCircleObject::setRadius(qreal radius)
+{
+ if (d_ptr->circle.radius() != radius) {
+ d_ptr->circle.setRadius(radius);
+ emit radiusChanged(radius);
+ }
+}
+
+qreal QGeoMapCircleObject::radius() const
+{
+ return d_ptr->circle.radius();
+}
+
+/*!
+\fn void QGeoMapCircleObject::centerChanged(const QGeoCoordinate &center)
+
+ This signal is emitted when the center of the circle object has
+ changed.
+
+ The new value is \a center.
+*/
+
+/*!
+\fn void QGeoMapCircleObject::radiusChanged(qreal radius)
+
+ This signal is emitted when the radius of the circle object has
+ changed.
+
+ The new value is \a radius.
+*/
+
+/*!
+\fn void QGeoMapCircleObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw the edge of
+ the circle object has changed.
+
+ The new value is \a pen.
+*/
+
+/*!
+\fn void QGeoMapCircleObject::brushChanged(const QBrush &brush)
+
+ This signal is emitted when the brush used to fill the inside of
+ the circle object has changed.
+
+ The new value is \a brush.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapCircleObjectPrivate::QGeoMapCircleObjectPrivate() :
+ pointCount(120)
+{
+ pen.setCosmetic(true);
+}
+
+QGeoMapCircleObjectPrivate::~QGeoMapCircleObjectPrivate()
+{
+}
+
+#include "moc_qgeomapcircleobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomapcircleobject.h b/src/location/maps/qgeomapcircleobject.h
new file mode 100644
index 00000000..2d70b0e2
--- /dev/null
+++ b/src/location/maps/qgeomapcircleobject.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPCIRCLEOBJECT_H
+#define QGEOMAPCIRCLEOBJECT_H
+
+#include "qgeomapobject.h"
+
+#include <QMetaType>
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingCircle;
+class QGeoMapCircleObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapCircleObject : public QGeoMapObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
+ Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
+ Q_PROPERTY(quint32 pointCount READ pointCount WRITE setPointCount)
+
+ QGeoMapCircleObject();
+ QGeoMapCircleObject(const QGeoBoundingCircle &circle);
+ QGeoMapCircleObject(const QGeoCoordinate &center, qreal radius);
+ ~QGeoMapCircleObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoBoundingCircle circle() const;
+ void setCircle(const QGeoBoundingCircle &circle);
+
+ bool contains(const QGeoCoordinate &coordinate) const;
+
+ QGeoCoordinate center() const;
+ void setCenter(const QGeoCoordinate &center);
+
+ qreal radius() const;
+ void setRadius(qreal radius);
+
+ QPen pen() const;
+ void setPen(const QPen &pen);
+
+ QBrush brush() const;
+ void setBrush(const QBrush &brush);
+
+ quint32 pointCount() const;
+ void setPointCount(quint32 pointCount);
+
+Q_SIGNALS:
+ void centerChanged(const QGeoCoordinate &center);
+ void radiusChanged(qreal radius);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+
+private:
+ QGeoMapCircleObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapCircleObject)
+ Q_DISABLE_COPY(QGeoMapCircleObject)
+};
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_METATYPE(qreal)
+
+#endif
diff --git a/src/location/maps/qgeomapcircleobject_p.h b/src/location/maps/qgeomapcircleobject_p.h
new file mode 100644
index 00000000..9c7f5bb2
--- /dev/null
+++ b/src/location/maps/qgeomapcircleobject_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPCIRCLEOBJECT_P_H
+#define QGEOMAPCIRCLEOBJECT_P_H
+
+#include <QPen>
+#include <QBrush>
+
+#include "qgeoboundingcircle.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapCircleObjectPrivate
+{
+public:
+ QGeoMapCircleObjectPrivate();
+ ~QGeoMapCircleObjectPrivate();
+
+ QGeoBoundingCircle circle;
+ QPen pen;
+ QBrush brush;
+ quint32 pointCount;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapcustomobject.cpp b/src/location/maps/qgeomapcustomobject.cpp
new file mode 100644
index 00000000..d873a428
--- /dev/null
+++ b/src/location/maps/qgeomapcustomobject.cpp
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapcustomobject.h"
+#include "qgeomapcustomobject_p.h"
+#include "qgeoboundingbox.h"
+
+#include <QGraphicsItem>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapCustomObject
+ \brief The QGeoMapCustomObject class is a QGeoMapObject used to draw
+ a pixmap on a map.
+
+ \inmodule QtLocation
+
+ \ingroup maps-mapping-objects
+ \since 1.2
+
+ Any arbitrary QGraphicsItem can be associated with a QGeoMapCustomObject, and to
+ this end it contains support for interpreting the coordinates of the
+ QGraphicsItem in a variety of different ways.
+
+ For example, the following code creates a QGraphicsEllipseItem and a
+ QGeoMapCustomObject to display it. The EllipseItem extends from the origin point,
+ out 20 meters to the east and 30 metres south.
+
+ \code
+ QGraphicsEllipseItem *ellipseItem = new QGraphicsEllipseItem;
+ ellipseItem->setRect(0, 0, 20, 30);
+
+ QGeoMapCustomObject *mapObject = new QGeoMapCustomObject;
+ mapObject->setGraphicsItem(ellipseItem);
+ mapObject->setUnits(QGeoMapObject::MeterUnit);
+ mapObject->setOrigin(QGeoCoordinate(-27.5796, 153.1));
+ \endcode
+
+ \section2 Units and coordinates
+
+ The local units and coordinates of the QGraphicsItem are transformed
+ onto the map based on the \a units, \a origin, \a transformType and
+ \a transform properties. Several systems are available, including
+ pixels, meters and seconds of arc.
+
+ It should be noted that both pixel and meter coordinate systems are south-
+ oriented (ie, positive Y axis faces south on the map). However, the
+ RelativeArcSeconds unit system faces north to align with the standard
+ latitude grid. The Y axis can be flipped if necessary by making use of the
+ GraphicsItem's \a transform property
+
+ \code
+ QTransform northFlip;
+ northFlip.scale(0, -1);
+
+ ellipseItem->setTransform(northFlip);
+ \endcode
+
+ \section2 Transform methods
+
+ Normally, the GraphicsItem will be transformed into map coordinates using
+ a bilinear interpolation. Another option is the ExactTransform, which
+ converts the GraphicsItem exactly into map coordinates, but is only available
+ for certain subclasses of QGraphicsItem. Other interpolation methods may
+ be provided in future for greater accuracy near poles and in different
+ map projections, without the limitations of ExactTransform.
+
+ Calling setUnits() or setting the units property will result in the
+ default value of transformType being restored. See QGeoMapObject::transformType
+ for more details.
+
+ \section2 Caveats
+
+ Other than the coordinate system features, there are a few differences
+ with using QGraphicsItems on a map compared to using them on a standard
+ QGraphicsScene. One of the most important of these is the use of the
+ \a update() function. When an application changes anything that has an
+ effect upon the appearance, size, shape etc of the QGraphicsItem, it
+ must call \a QGeoMapCustomObject::update() to ensure that the map is updated.
+
+ Another is the use of child items of a QGraphicsItem. These are supported
+ in more or less the same manner as in QGraphicsScene, with the exception
+ of use in concert with \a ExactTransform -- any object with transformType
+ set to \a ExactTransform will not have children of its QGraphicsItem drawn
+ on the map.
+*/
+
+/*!
+ Constructs a new custom object.
+*/
+QGeoMapCustomObject::QGeoMapCustomObject()
+ : d_ptr(new QGeoMapCustomObjectPrivate())
+{
+}
+
+/*!
+ Constructs a new custom object which will draw a QGraphicsItem at an
+ offset of \a offset pixels from the coordinate \a coordinate.
+*/
+QGeoMapCustomObject::QGeoMapCustomObject(const QGeoCoordinate &coordinate, const QPoint &offset)
+ : d_ptr(new QGeoMapCustomObjectPrivate())
+{
+ setOrigin(coordinate);
+ d_ptr->offset = offset;
+}
+
+/*!
+ Destroys this custom object.
+*/
+QGeoMapCustomObject::~QGeoMapCustomObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapCustomObject::type() const
+{
+ return QGeoMapObject::CustomType;
+}
+
+/*!
+*/
+void QGeoMapCustomObject::update()
+{
+ emit triggerUpdate();
+}
+
+/*!
+\fn void QGeoMapCustomObject::triggerUpdate()
+*/
+
+/*!
+ \property QGeoMapCustomObject::graphicsItem
+ \brief This property holds the graphics item which will
+ be drawn by this custom object.
+
+ If the graphics item is 0 then nothing will be drawn.
+*/
+
+QGraphicsItem* QGeoMapCustomObject::graphicsItem() const
+{
+ return d_ptr->graphicsItem;
+}
+
+void QGeoMapCustomObject::setGraphicsItem(QGraphicsItem *graphicsItem)
+{
+ if (d_ptr->graphicsItem == graphicsItem)
+ return;
+
+ d_ptr->graphicsItem = graphicsItem;
+
+ emit graphicsItemChanged(graphicsItem);
+}
+
+/*!
+\fn void QGeoMapCustomObject::graphicsItemChanged(QGraphicsItem *graphicsItem)
+
+ This signal is emitted when the graphics item which this custom object
+ draws is changed.
+
+ The new value will be \a graphicsItem.
+*/
+
+/*!
+ \property QGeoMapCustomObject::offset
+ \brief This property holds the offset in pixels at which the graphics
+ item will be drawn by this custom object.
+
+ The default value of this property is QPoint(0, 0). If this value is not
+ changed the upper left coordinate of the graphics item will be drawn at the
+ coordinate specified by QGeoMapCustomObject::coordinate.
+
+ The offset is in pixels and is independent of the zoom level of the map.
+*/
+QPoint QGeoMapCustomObject::offset() const
+{
+ return d_ptr->offset;
+// QPointF pt = d_ptr->offset;
+//
+// QPoint rounded;
+// rounded.setX(int(pt.x() > 0 ? pt.x() + 0.5 : pt.x() - 0.5));
+// rounded.setY(int(pt.y() > 0 ? pt.y() + 0.5 : pt.y() - 0.5));
+//
+// return rounded;
+}
+
+void QGeoMapCustomObject::setOffset(const QPoint &offset)
+{
+ if (d_ptr->offset != offset) {
+ d_ptr->offset = offset;
+ emit offsetChanged(offset);
+ }
+}
+
+/*!
+\fn void QGeoMapCustomObject::offsetChanged(const QPoint &offset)
+
+ This signal is emitted when the on-screen offset from the coordinate
+ at which this custom object should be drawn has changed.
+
+ The new value will be \a offset.
+*/
+
+/*!
+ Sets the origin of the object to \a origin.
+*/
+void QGeoMapCustomObject::setOrigin(const QGeoCoordinate &origin)
+{
+ QGeoMapObject::setOrigin(origin);
+}
+
+/*!
+ Sets the coordinate units of the object to \a unit.
+
+ Note that setting this property will reset the transformType property to
+ the default for the units given. For PixelUnit, this is ExactTransform,
+ and for all others, BilinearTransform.
+*/
+void QGeoMapCustomObject::setUnits(const CoordinateUnit &unit)
+{
+ QGeoMapObject::setUnits(unit);
+}
+
+/*!
+ Sets the transform type of the object to \a type.
+*/
+void QGeoMapCustomObject::setTransformType(const TransformType &type)
+{
+ QGeoMapObject::setTransformType(type);
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapCustomObjectPrivate::QGeoMapCustomObjectPrivate()
+ : graphicsItem(0) {}
+
+QGeoMapCustomObjectPrivate::~QGeoMapCustomObjectPrivate()
+{
+}
+
+#include "moc_qgeomapcustomobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomapcustomobject.h b/src/location/maps/qgeomapcustomobject.h
new file mode 100644
index 00000000..f2ef6d71
--- /dev/null
+++ b/src/location/maps/qgeomapcustomobject.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPCUSTOMOBJECT_H
+#define QGEOMAPCUSTOMOBJECT_H
+
+#include "qgeomapobject.h"
+#include "qgeocoordinate.h"
+
+#include <QPoint>
+
+#include <QGraphicsItem>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapCustomObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapCustomObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGraphicsItem* graphicsItem READ graphicsItem WRITE setGraphicsItem NOTIFY graphicsItemChanged)
+ Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
+
+public:
+ QGeoMapCustomObject();
+ QGeoMapCustomObject(const QGeoCoordinate &coordinate, const QPoint &offset = QPoint(0, 0));
+ ~QGeoMapCustomObject();
+
+ QGeoMapObject::Type type() const;
+
+ void update();
+
+ QGraphicsItem* graphicsItem() const;
+ void setGraphicsItem(QGraphicsItem *graphicsItem);
+
+ QPoint offset() const;
+ void setOffset(const QPoint &offset);
+
+ void setOrigin(const QGeoCoordinate &origin);
+ void setUnits(const CoordinateUnit &unit);
+ void setTransformType(const TransformType &type);
+
+Q_SIGNALS:
+ void triggerUpdate();
+ void graphicsItemChanged(QGraphicsItem *graphicsItem);
+ void offsetChanged(const QPoint &offset);
+
+private:
+ QGeoMapCustomObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapCustomObject)
+ Q_DISABLE_COPY(QGeoMapCustomObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapcustomobject_p.h b/src/location/maps/qgeomapcustomobject_p.h
new file mode 100644
index 00000000..c7db4542
--- /dev/null
+++ b/src/location/maps/qgeomapcustomobject_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPCUSTOMOBJECT_P_H
+#define QGEOMAPCUSTOMOBJECT_P_H
+
+#include "qgeocoordinate.h"
+
+#include <QPoint>
+
+class QGraphicsItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapCustomObjectPrivate
+{
+public:
+ QGeoMapCustomObjectPrivate();
+ ~QGeoMapCustomObjectPrivate();
+
+ QGraphicsItem *graphicsItem;
+ QPoint offset;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapdata.cpp b/src/location/maps/qgeomapdata.cpp
new file mode 100644
index 00000000..d6716d02
--- /dev/null
+++ b/src/location/maps/qgeomapdata.cpp
@@ -0,0 +1,836 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapdata.h"
+#include "qgeomapdata_p.h"
+
+#include <QGraphicsScene>
+#include <QGraphicsItem>
+#include <QGraphicsPolygonItem>
+#include <QGraphicsLineItem>
+#include <QGraphicsEllipseItem>
+#include <QGraphicsPathItem>
+
+#include "qgeoboundingbox.h"
+#include "qgeocoordinate.h"
+#include "qgraphicsgeomap.h"
+#include "qgeomapobject.h"
+#include "qgeomappixmapobject.h"
+#include "qgeomapgroupobject.h"
+#include "qgeomaptextobject.h"
+#include "qgeomappingmanagerengine.h"
+#include "qgeomapoverlay.h"
+
+#include "qgeomapobjectengine_p.h"
+#include "qgeomapobject_p.h"
+#include "projwrapper_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapData
+
+ \brief The QGeoMapData class are used as a bridge between QGraphicsGeoMap and
+ QGeoMappingManager.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ Instances of QGeoMapData are created with
+ QGeoMappingManager::createMapData(), and are used internally by
+ QGraphicsGeoMap to manage the state of the map and the associated
+ QGeoMapObject instances.
+
+ Plugin implementers will need to provide implementations of
+ coordinateToScreenPosition(const QGeoCoordinate &coordinate) and
+ QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition).
+
+ The other virtual functions can be overridden. If the screen position to
+ coordinate tranformations are expensive then overriding these functions may
+ allow optimizations based on caching parts of the geometry information.
+
+ Subclasses should override createMapObjectInfo() so that QGeoMapObjectInfo
+ instances will be created for each QGeoMapObject type in order to provide
+ the QGeoMapData subclass specific behaviours for the map objects.
+ */
+
+/*!
+ Constructs a new map data object, which makes use of the functionality provided by \a engine.
+*/
+QGeoMapData::QGeoMapData(QGeoMappingManagerEngine *engine)
+ : d_ptr(new QGeoMapDataPrivate(this, engine))
+{
+ if (engine->supportedConnectivityModes().length() > 0)
+ setConnectivityMode(engine->supportedConnectivityModes().at(0));
+ else
+ setConnectivityMode(QGraphicsGeoMap::NoConnectivity);
+}
+
+/*!
+ \internal
+*/
+QGeoMapData::QGeoMapData(QGeoMapDataPrivate *dd) : d_ptr(dd) {}
+
+/*!
+ Destroys this map data object.
+*/
+QGeoMapData::~QGeoMapData()
+{
+ Q_D(QGeoMapData);
+ delete d;
+}
+
+/*!
+ This function is run after the QGeoMapData instance has been
+ constructed.
+
+ Any subclasses which override this function should make sure that
+ QGeoMapData::init() is called within the body of the overriding function.
+*/
+void QGeoMapData::init()
+{
+ d_ptr->containerObject = new QGeoMapGroupObject();
+ d_ptr->containerObject->setMapData(this);
+}
+
+/*!
+ Returns the mapping engine that this map data object is associated with.
+*/
+QGeoMappingManagerEngine* QGeoMapData::engine() const
+{
+ return d_ptr->engine;
+}
+
+/*!
+ Returns the QGeoMapObject which acts as the parent to all QGeoMapObject
+ instances which are added to the map by the user.
+*/
+QGeoMapObject* QGeoMapData::containerObject()
+{
+ return d_ptr->containerObject;
+}
+
+/*!
+ Sets the size of the map viewport to \a size.
+
+ The size will be adjusted by the associated QGraphicsGeoMap as it resizes.
+*/
+void QGeoMapData::setWindowSize(const QSizeF &size)
+{
+ if (d_ptr->windowSize == size)
+ return;
+
+ d_ptr->windowSize = size;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit windowSizeChanged(d_ptr->windowSize);
+}
+
+/*!
+ \property QGeoMapData::windowSize
+ Returns the size of the map viewport.
+
+ The size will be adjusted by the associated QGraphicsGeoMap as it resizes.
+*/
+QSizeF QGeoMapData::windowSize() const
+{
+ return d_ptr->windowSize;
+}
+
+/*!
+ Sets the zoom level of the map to \a zoomLevel.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+
+ If \a zoomLevel is less than minimumZoomLevel() then minimumZoomLevel()
+ will be used, and if \a zoomLevel is larger than
+ maximumZoomLevel() then maximumZoomLevel() will be used.
+*/
+void QGeoMapData::setZoomLevel(qreal zoomLevel)
+{
+ zoomLevel = qMin(zoomLevel, d_ptr->engine->maximumZoomLevel());
+ zoomLevel = qMax(zoomLevel, d_ptr->engine->minimumZoomLevel());
+
+ if (d_ptr->zoomLevel == zoomLevel)
+ return;
+
+ d_ptr->zoomLevel = zoomLevel;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit zoomLevelChanged(d_ptr->zoomLevel);
+}
+
+/*!
+ \property QGeoMapData::zoomLevel
+
+ Returns the zoom level of the map.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGeoMapData::zoomLevel() const
+{
+ return d_ptr->zoomLevel;
+}
+
+/*!
+ \property QGeoMapData::supportsBearing
+
+ Returns whether bearing is supported by this engine.
+*/
+bool QGeoMapData::supportsBearing() const
+{
+ return d_ptr->engine->supportsBearing();
+}
+
+/*!
+ Sets the bearing of the map to \a bearing.
+
+ Value in degrees in the range of 0-360. 0 being equivalent to 0 degrees from
+ north.
+*/
+void QGeoMapData::setBearing(qreal bearing)
+{
+ if (!supportsBearing())
+ return;
+
+ bearing = qMin(bearing, qreal(360.0));
+ bearing = qMax(bearing, qreal(0.0));
+
+ if (d_ptr->bearing == bearing)
+ return;
+
+ d_ptr->bearing = bearing;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit bearingChanged(d_ptr->bearing);
+}
+
+/*!
+ \property QGeoMapData::bearing
+
+ Returns the current bearing of the map.
+
+ Value in degrees in the range of 0-360. 0 being equivalent to 0 degrees from
+ north.
+*/
+qreal QGeoMapData::bearing() const
+{
+ return d_ptr->bearing;
+}
+
+/*!
+ \property QGeoMapData::supportsTilting
+
+ Returns whether tilting is supported by this engine.
+*/
+bool QGeoMapData::supportsTilting() const
+{
+ return d_ptr->engine->supportsTilting();
+}
+
+/*!
+ \property QGeoMapData::minimumTilt
+
+ Returns minimum tilt supported by this engine.
+*/
+qreal QGeoMapData::minimumTilt() const
+{
+ return d_ptr->engine->minimumTilt();
+}
+
+/*!
+ \property QGeoMapData::maximumTilt
+
+ Returns maximum tilt supported by this engine.
+*/
+qreal QGeoMapData::maximumTilt() const
+{
+ return d_ptr->engine->maximumTilt();
+}
+
+/*!
+ Sets the tilt of the map to \a tilt.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+
+ If \a tilt is less than minimumTilt() then minimumTilt()
+ will be used, and if \a tilt is larger than
+ maximumTilt() then maximumTilt() will be used.
+*/
+void QGeoMapData::setTilt(qreal tilt)
+{
+ if (!supportsTilting())
+ return;
+
+ tilt = qMin(tilt, d_ptr->engine->maximumTilt());
+ tilt = qMax(tilt, d_ptr->engine->minimumTilt());
+
+ if (d_ptr->tilt == tilt)
+ return;
+
+ d_ptr->tilt = tilt;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit tiltChanged(d_ptr->tilt);
+}
+
+/*!
+ \property QGeoMapData::tilt
+
+ Returns the current tilt of the map.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGeoMapData::tilt() const
+{
+ return d_ptr->tilt;
+}
+
+/*!
+ Pans the map view \a dx pixels in the x direction and \a dy pixels
+ in the y direction.
+
+ The x and y axes are specified in Graphics View Framework coordinates.
+ By default this will mean that positive values of \a dx move the
+ viewed area to the right and that positive values of \a dy move the
+ viewed area down.
+
+ Subclasses should call QGeoMapData::setCenter() when the pan has completed.
+*/
+void QGeoMapData::pan(int dx, int dy)
+{
+ QPointF pos = coordinateToScreenPosition(center());
+ setCenter(screenPositionToCoordinate(QPointF(pos.x() + dx, pos.y() + dy)));
+}
+
+/*!
+ Centers the map viewport on the coordinate \a center.
+*/
+void QGeoMapData::setCenter(const QGeoCoordinate &center)
+{
+ if (d_ptr->center == center)
+ return;
+
+ d_ptr->center = center;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit centerChanged(d_ptr->center);
+}
+
+/*!
+ \property QGeoMapData::center
+
+ Returns the coordinate of the point in the center of the map viewport.
+*/
+QGeoCoordinate QGeoMapData::center() const
+{
+ return d_ptr->center;
+}
+
+/*!
+ Changes the type of map data to display to \a mapType.
+*/
+void QGeoMapData::setMapType(QGraphicsGeoMap::MapType mapType)
+{
+ if (d_ptr->mapType == mapType)
+ return;
+
+ d_ptr->mapType = mapType;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit mapTypeChanged(mapType);
+}
+
+/*!
+ \property QGeoMapData::mapType
+
+ Returns the type of map data which is being displayed.
+*/
+QGraphicsGeoMap::MapType QGeoMapData::mapType() const
+{
+ return d_ptr->mapType;
+}
+
+/*!
+ Changes the connectivity mode of this map to \a connectivityMode
+*/
+void QGeoMapData::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
+{
+ if (d_ptr->connectivityMode == connectivityMode)
+ return;
+
+ d_ptr->connectivityMode = connectivityMode;
+
+ if (!d_ptr->blockPropertyChangeSignals)
+ emit connectivityModeChanged(connectivityMode);
+}
+
+/*!
+ \property QGeoMapData::connectivityMode
+
+ Returns the connectivity mode for this map.
+*/
+QGraphicsGeoMap::ConnectivityMode QGeoMapData::connectivityMode() const
+{
+ return d_ptr->connectivityMode;
+}
+
+/*!
+ Returns the map objects associated with this map.
+*/
+QList<QGeoMapObject*> QGeoMapData::mapObjects() const
+{
+ return d_ptr->containerObject->childObjects();
+}
+
+/*!
+ Adds \a mapObject to the list of map objects managed by this map.
+
+ The children objects are drawn in order of the QGeoMapObject::zValue()
+ value. Children objects having the same z value will be drawn
+ in the order they were added.
+
+ The map will take ownership of the \a mapObject.
+*/
+void QGeoMapData::addMapObject(QGeoMapObject *mapObject)
+{
+ d_ptr->addObject(mapObject);
+}
+
+/*!
+ Removes \a mapObject from the list of map objects managed by this map.
+ The map will release ownership of the \a mapObject.
+*/
+void QGeoMapData::removeMapObject(QGeoMapObject *mapObject)
+{
+ d_ptr->removeObject(mapObject);
+}
+
+/*!
+ Clears the map objects associated with this map.
+
+ The map objects will be deleted.
+*/
+void QGeoMapData::clearMapObjects()
+{
+ d_ptr->clearObjects();
+}
+
+/*!
+ \fn QGeoBoundingBox QGeoMapData::viewport() const
+ Returns a bounding box corresponding to the physical area displayed
+ in the viewport of the map.
+
+ The bounding box which is returned is defined by the upper left and
+ lower right corners of the visible area of the map.
+*/
+
+/*!
+ \fn void QGeoMapData::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
+
+ Attempts to fit the bounding box \a bounds into the viewport of the map.
+
+ This method will change the zoom level to the maximum zoom level such
+ that all of \a bounds is visible within the resulting viewport.
+
+ If \a preserveViewportCenter is false the map will be centered on the
+ bounding box \a bounds before the zoom level is changed, otherwise the
+ center of the map will not be changed.
+*/
+
+/*!
+ Returns the list of visible map objects managed by this map which
+ contain the point \a screenPosition within their boundaries.
+*/
+QList<QGeoMapObject*> QGeoMapData::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
+{
+ QList<QGeoMapObject*> results;
+
+ QGeoCoordinate coord = screenPositionToCoordinate(screenPosition);
+ int childObjectCount = d_ptr->containerObject->childObjects().count();
+ for (int i = 0; i < childObjectCount; ++i) {
+ QGeoMapObject *object = d_ptr->containerObject->childObjects().at(i);
+ if (object->contains(coord) && object->isVisible())
+ results.append(object);
+ }
+
+ return results;
+}
+
+/*!
+ Returns the list of visible map objects managed by this map which are displayed at
+ least partially within the on screen rectangle \a screenRect.
+*/
+QList<QGeoMapObject*> QGeoMapData::mapObjectsInScreenRect(const QRectF &screenRect) const
+{
+ QList<QGeoMapObject*> results;
+
+ QGeoCoordinate topLeft = screenPositionToCoordinate(screenRect.topLeft());
+ QGeoCoordinate bottomRight = screenPositionToCoordinate(screenRect.bottomRight());
+
+ QGeoBoundingBox bounds(topLeft, bottomRight);
+
+ int childObjectCount = d_ptr->containerObject->childObjects().count();
+ for (int i = 0; i < childObjectCount; ++i) {
+ QGeoMapObject *object = d_ptr->containerObject->childObjects().at(i);
+ if (bounds.intersects(object->boundingBox()) && object->isVisible())
+ results.append(object);
+ }
+
+ return results;
+}
+
+/*!
+ Returns the list of visible map objects manager by this widget which
+ are displayed at least partially within the viewport of the map.
+*/
+QList<QGeoMapObject*> QGeoMapData::mapObjectsInViewport() const
+{
+ return this->mapObjectsInScreenRect(QRectF(0.0,
+ 0.0,
+ d_ptr->windowSize.width(),
+ d_ptr->windowSize.height()));
+}
+
+/*!
+\fn QPointF QGeoMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+
+ Returns the position on the screen at which \a coordinate is displayed.
+
+ An invalid QPointF will be returned if \a coordinate is invalid or is not
+ within the current viewport.
+*/
+
+/*!
+\fn QGeoCoordinate QGeoMapData::screenPositionToCoordinate(const QPointF &screenPosition) const
+
+ Returns the coordinate corresponding to the point in the viewport at \a
+ screenPosition.
+
+ An invalid QGeoCoordinate will be returned if \a screenPosition is invalid
+ or is not within the current viewport.
+*/
+
+/*!
+ Paints the map and everything associated with it on \a painter, using the
+ options \a option.
+
+ This will paint the map with paintMap(), then the map overlays with
+ QGeoMapOverlay::paint(), then the map objects with paintObjects(), and
+ finally paintProviderNotices().
+*/
+void QGeoMapData::paint(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ paintMap(painter, option);
+
+ for (int i = 0; i < d_ptr->overlays.size(); ++i)
+ d_ptr->overlays[i]->paint(painter, option);
+
+ paintObjects(painter, option);
+
+ paintProviderNotices(painter, option);
+}
+
+/*!
+ Paints the map on \a painter, using the options \a option.
+
+ The map overlays, map objects and the provider notices (such as copyright
+ and powered by notices) are painted in separate methods, which are combined
+ in the paint() method.
+
+ The default implementation does not paint anything.
+*/
+void QGeoMapData::paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ Q_UNUSED(painter)
+ Q_UNUSED(option)
+}
+
+/*!
+ Paints the map objects on \a painter, using the options \a option.
+
+ The default implementation makes use of the coordinateToScreenPosition
+ implemented by the subclass to perform object positioning and rendering.
+
+ This implementation should suffice for most common use cases, and supports
+ the full range of coordinate systems and transforms available to a
+ QGeoMapObject.
+*/
+void QGeoMapData::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ Q_UNUSED(painter)
+ Q_UNUSED(option)
+}
+
+/*!
+ Paints the provider notices on \a painter, using the options \a option.
+
+ The provider notices are things like the copyright and powered by notices.
+
+ The provider may not want the client developers to be able to move the
+ notices from their standard positions and so we have not provided API
+ support for specifying the position of the notices at this time.
+
+ If support for hinting at the position of the notices is to be provided by
+ plugin parameters, the suggested parameter keys are
+ "mapping.notices.copyright.alignment" and
+ "mapping.notices.poweredby.alignment", with type Qt::Alignment.
+
+ The default implementation does not paint anything.
+*/
+void QGeoMapData::paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ Q_UNUSED(painter)
+ Q_UNUSED(option)
+}
+
+/*!
+ Creates a QGeoMapObjectInfo instance which implements the behaviours o
+ the map object \a object which are specific to this QGeoMapData.
+
+ The default implementation returns 0.
+*/
+QGeoMapObjectInfo *QGeoMapData::createMapObjectInfo(QGeoMapObject *object)
+{
+ Q_UNUSED(object);
+ return 0;
+}
+
+/*!
+ Returns the map overlays associated with this map.
+*/
+QList<QGeoMapOverlay*> QGeoMapData::mapOverlays() const
+{
+ return d_ptr->overlays;
+}
+
+/*!
+ Adds \a overlay to the list of map overlays associated with this map.
+
+ The overlays will be drawn in the order in which they were added.
+
+ The map will take ownership of \a overlay.
+*/
+void QGeoMapData::addMapOverlay(QGeoMapOverlay *overlay)
+{
+ if (!overlay)
+ return;
+
+ overlay->setMapData(this);
+ d_ptr->overlays.append(overlay);
+}
+
+/*!
+ Removes \a overlay from the list of map overlays associated with this map.
+
+ The map will release ownership of \a overlay.
+*/
+void QGeoMapData::removeMapOverlay(QGeoMapOverlay *overlay)
+{
+ if (!overlay)
+ return;
+
+ d_ptr->overlays.removeAll(overlay);
+}
+
+/*!
+ Clears the map overlays associated with this map.
+
+ The map overlays will be deleted.
+*/
+void QGeoMapData::clearMapOverlays()
+{
+ qDeleteAll(d_ptr->overlays);
+ d_ptr->overlays.clear();
+}
+
+
+/*!
+ Sets whether changes to properties will trigger their corresponding signals to \a block.
+
+ By default the QGeoMapData implementations of the property functions are used
+ which cause the property notification signals to be emitted immediately.
+
+ Calling this function with \a block set to true will prevent these
+ signals from being called, which will allow a subclass to defer the
+ emission of the signal until a later time.
+
+ If this function needs to be called it should be used as soon as possible,
+ preferably in the constructor of the QGeoMapData subclass.
+*/
+void QGeoMapData::setBlockPropertyChangeSignals(bool block)
+{
+ d_ptr->blockPropertyChangeSignals = block;
+}
+
+/*!
+\fn void QGeoMapData::windowSizeChanged(const QSizeF &windowSize)
+
+ This signal is emitted when the size of the window which contains
+ the map has changed.
+
+ The new value is \a windowSize.
+*/
+
+/*!
+\fn void QGeoMapData::zoomLevelChanged(qreal zoomLevel)
+
+ This signal is emitted when the zoom level of the map has changed.
+
+ The new value is \a zoomLevel.
+*/
+
+/*!
+\fn void QGeoMapData::bearingChanged(qreal bearing)
+
+ This signal is emitted when the bearing of the map has changed.
+
+ The new value is \a bearing.
+*/
+
+/*!
+\fn void QGeoMapData::tiltChanged(qreal tilt)
+
+ This signal is emitted when the tilt of the map has changed.
+
+ The new value is \a tilt.
+*/
+
+/*!
+\fn void QGeoMapData::centerChanged(const QGeoCoordinate &coordinate)
+
+ This signal is emitted when the center of the map has changed.
+
+ The new value is \a coordinate.
+*/
+
+/*!
+\fn void QGeoMapData::mapTypeChanged(QGraphicsGeoMap::MapType mapType)
+
+ This signal is emitted when the type of the map has changes.
+
+ The value is \a mapType.
+*/
+
+/*!
+\fn void QGeoMapData::connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode)
+
+ This signal is emitted when the connectivity mode used to fetch the
+ map data has changed.
+
+ The new value is \a connectivityMode.
+*/
+
+/*!
+\fn void QGeoMapData::updateMapDisplay(const QRectF &target)
+
+ This signal is emitted when the region \a target of the window which
+ contains the map needs to be updated.
+
+
+ If \a target is empty then the entire map will be updated.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapDataPrivate::QGeoMapDataPrivate(QGeoMapData *parent, QGeoMappingManagerEngine *engine)
+ : QObject(0),
+ engine(engine),
+ containerObject(0),
+ zoomLevel(-1.0),
+ shiftSinceLastInval(0, 0),
+ windowSize(0, 0),
+ bearing(0.0),
+ tilt(0.0),
+ blockPropertyChangeSignals(false),
+ q_ptr(parent)
+{}
+
+QGeoMapDataPrivate::~QGeoMapDataPrivate()
+{
+ if (containerObject)
+ delete containerObject;
+ qDeleteAll(overlays);
+}
+
+void QGeoMapDataPrivate::addObject(QGeoMapObject *object)
+{
+ containerObject->addChildObject(object);
+ //emit q_ptr->updateMapDisplay();
+}
+
+void QGeoMapDataPrivate::removeObject(QGeoMapObject *object)
+{
+ containerObject->removeChildObject(object);
+}
+
+void QGeoMapDataPrivate::clearObjects()
+{
+ foreach (QGeoMapObject *obj, containerObject->childObjects()) {
+ this->removeObject(obj);
+ delete obj;
+ }
+}
+
+QPointF QGeoMapDataPrivate::coordinateToScreenPosition(double lon, double lat) const
+{
+ QGeoCoordinate c(lon, lat);
+ return q_ptr->coordinateToScreenPosition(c);
+}
+
+void QGeoMapDataPrivate::emitUpdateMapDisplay(const QRectF &target)
+{
+ emit q_ptr->updateMapDisplay(target);
+}
+
+
+#include "moc_qgeomapdata.cpp"
+#include "moc_qgeomapdata_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomapdata.h b/src/location/maps/qgeomapdata.h
new file mode 100644
index 00000000..39f3fbe0
--- /dev/null
+++ b/src/location/maps/qgeomapdata.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPDATA_H
+#define QGEOMAPDATA_H
+
+#include "qgraphicsgeomap.h"
+
+#include <QObject>
+#include <QSize>
+#include <QRectF>
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBox;
+class QGeoMappingManagerEngine;
+class QGeoMapObject;
+class QGeoMapGroupObject;
+class QGeoMapDataPrivate;
+class QGeoMapOverlay;
+class QGeoMapObjectInfo;
+
+class Q_LOCATION_EXPORT QGeoMapData : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QSizeF windowSize READ windowSize WRITE setWindowSize NOTIFY windowSizeChanged)
+ Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
+ Q_PROPERTY(QGraphicsGeoMap::MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
+ Q_PROPERTY(QGraphicsGeoMap::ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
+ Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
+ Q_PROPERTY(qreal minimumTilt READ minimumTilt CONSTANT)
+ Q_PROPERTY(qreal maximumTilt READ maximumTilt CONSTANT)
+ Q_PROPERTY(bool supportsTilting READ supportsTilting CONSTANT)
+ Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
+ Q_PROPERTY(bool supportsBearing READ supportsBearing CONSTANT)
+
+public:
+ QGeoMapData(QGeoMappingManagerEngine *engine);
+ virtual ~QGeoMapData();
+
+ virtual void init();
+
+ virtual void setWindowSize(const QSizeF &size);
+ virtual QSizeF windowSize() const;
+
+ virtual void setZoomLevel(qreal zoomLevel);
+ virtual qreal zoomLevel() const;
+
+ bool supportsBearing() const;
+ void setBearing(qreal bearing);
+ qreal bearing() const;
+
+ bool supportsTilting() const;
+ void setTilt(qreal tilt);
+ qreal tilt() const;
+ qreal minimumTilt() const;
+ qreal maximumTilt() const;
+
+ virtual void pan(int dx, int dy);
+
+ virtual void setCenter(const QGeoCoordinate &center);
+ virtual QGeoCoordinate center() const;
+
+ virtual void setMapType(QGraphicsGeoMap::MapType mapType);
+ virtual QGraphicsGeoMap::MapType mapType() const;
+
+ virtual void setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode);
+ virtual QGraphicsGeoMap::ConnectivityMode connectivityMode() const;
+
+ QList<QGeoMapObject*> mapObjects() const;
+ void addMapObject(QGeoMapObject *mapObject);
+ void removeMapObject(QGeoMapObject *mapObject);
+ void clearMapObjects();
+
+ virtual QGeoBoundingBox viewport() const = 0;
+ virtual void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false) = 0;
+
+ virtual QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
+ virtual QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
+ virtual QList<QGeoMapObject*> mapObjectsInViewport() const;
+
+ QList<QGeoMapOverlay*> mapOverlays() const;
+ void addMapOverlay(QGeoMapOverlay *overlay);
+ void removeMapOverlay(QGeoMapOverlay *overlay);
+ void clearMapOverlays();
+
+ virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const = 0;
+ virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition) const = 0;
+
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option);
+
+protected:
+ QGeoMapData(QGeoMapDataPrivate *dd);
+
+ QGeoMappingManagerEngine* engine() const;
+ QGeoMapObject* containerObject();
+
+ void setBlockPropertyChangeSignals(bool block);
+
+ virtual void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
+ virtual void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
+ virtual void paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option);
+
+ virtual QGeoMapObjectInfo* createMapObjectInfo(QGeoMapObject *object);
+
+ QGeoMapDataPrivate* d_ptr;
+
+Q_SIGNALS:
+ void windowSizeChanged(const QSizeF &windowSize);
+ void zoomLevelChanged(qreal zoomLevel);
+ void centerChanged(const QGeoCoordinate &coordinate);
+ void mapTypeChanged(QGraphicsGeoMap::MapType mapType);
+ void connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode);
+ void updateMapDisplay(const QRectF &target = QRectF());
+ void bearingChanged(qreal bearing);
+ void tiltChanged(qreal tilt);
+
+private:
+ Q_DECLARE_PRIVATE(QGeoMapData)
+ Q_DISABLE_COPY(QGeoMapData)
+
+ friend class QGeoMapObject;
+ friend class QGeoMapObjectInfo;
+ friend class QGeoMapGroupObject;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/maps/qgeomapdata_p.h
new file mode 100644
index 00000000..742715ab
--- /dev/null
+++ b/src/location/maps/qgeomapdata_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPDATA_P_H
+#define QGEOMAPDATA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomapgroupobject.h"
+
+#include <QGraphicsScene>
+#include <QGraphicsItem>
+#include "qgeocoordinate.h"
+#include "qgraphicsgeomap.h"
+#include "projwrapper_p.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMappingManagerEngine;
+class QGeoMapObjectEngine;
+class QGeoMapOverlay;
+
+class QGeoMapDataPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoMapDataPrivate(QGeoMapData *parent, QGeoMappingManagerEngine *engine);
+ virtual ~QGeoMapDataPrivate();
+
+ QGeoMappingManagerEngine *engine;
+ QGeoMapGroupObject* containerObject;
+
+ qreal zoomLevel;
+ QPointF shiftSinceLastInval;
+ qreal bearing;
+ qreal tilt;
+ QGeoCoordinate center;
+ QSizeF windowSize;
+ QGraphicsGeoMap::MapType mapType;
+ QGraphicsGeoMap::ConnectivityMode connectivityMode;
+
+ QList<QGeoMapOverlay*> overlays;
+
+ bool blockPropertyChangeSignals;
+
+ virtual void addObject(QGeoMapObject *object);
+ virtual void removeObject(QGeoMapObject *object);
+ void clearObjects();
+
+ virtual QPointF coordinateToScreenPosition(double lon, double lat) const;
+
+ void emitUpdateMapDisplay(const QRectF &target = QRectF());
+
+ QGeoMapData *q_ptr;
+ Q_DECLARE_PUBLIC(QGeoMapData)
+private:
+ Q_DISABLE_COPY(QGeoMapDataPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapgroupobject.cpp b/src/location/maps/qgeomapgroupobject.cpp
new file mode 100644
index 00000000..dcd953a2
--- /dev/null
+++ b/src/location/maps/qgeomapgroupobject.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapgroupobject.h"
+#include "qgeomapgroupobject_p.h"
+
+#include "qgeomapobject_p.h"
+#include "qgeomapobjectengine_p.h"
+
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+
+#include "qgeomapdata.h"
+#include "qgeomapdata_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapGroupObject
+ \brief The QGeoMapGroupObject class is a QGeoMapObject used to
+ manager a group of other map objects.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The QGeoMapGroupObject class can be used to quickly add and remove
+ groups of objects to a map.
+
+ The map objects contained in the group will be ordered relative to
+ one another in the usual manner, such that objects with higher z-values
+ will be drawn over objects with lower z-values and objects with
+ equal z-values will be drawn in insertion order.
+
+ This ordering of the objects will be independent of the other
+ objects that are added to the map, since the z-value and insertion
+ order of the QGeoMapGroupObject is used to determine where the
+ group is placed in the scene.
+*/
+
+/*!
+ Constructs a new group object.
+*/
+QGeoMapGroupObject::QGeoMapGroupObject()
+ : d_ptr(new QGeoMapGroupObjectPrivate(this)) {}
+
+/*!
+ Destroys this group object.
+*/
+QGeoMapGroupObject::~QGeoMapGroupObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapGroupObject::type() const
+{
+ return QGeoMapObject::GroupType;
+}
+
+/*!
+ Returns a bounding box which contains this map object.
+
+ If this map object has children, the bounding box will be large
+ enough to contain both this map object and all of its children.
+*/
+QGeoBoundingBox QGeoMapGroupObject::boundingBox() const
+{
+ QGeoBoundingBox bounds;
+
+ if (d_ptr->children.size() == 0)
+ return bounds;
+
+ bounds = d_ptr->children.at(0)->boundingBox();
+
+ for (int i = 1; i < d_ptr->children.size(); ++i)
+ bounds = bounds.united(d_ptr->children.at(i)->boundingBox());
+
+ return bounds;
+}
+
+/*!
+ Returns whether \a coordinate is contained with the boundary of this
+ map object.
+
+ If this map object has children, this function will return whether
+ \a coordinate is contained within the boundary of this map object or
+ within the boundary of any of its children.
+*/
+bool QGeoMapGroupObject::contains(const QGeoCoordinate &coordinate) const
+{
+ for (int i = 0; i < d_ptr->children.size(); ++i)
+ if (d_ptr->children.at(i)->contains(coordinate))
+ return true;
+
+ return false;
+}
+
+bool mapObjectLessThan(const QGeoMapObject* op1, const QGeoMapObject* op2)
+{
+ return op1->operator <(*op2);
+}
+
+/*!
+ Adds \a childObject to the list of children of this map object.
+
+ The children objects are drawn in order of the QGeoMapObject::zValue()
+ value. Children objects having the same z value will be drawn
+ in the order they were added.
+
+ The map object will take ownership of \a childObject.
+*/
+void QGeoMapGroupObject::addChildObject(QGeoMapObject *childObject)
+{
+ if (!childObject || d_ptr->children.contains(childObject))
+ return;
+
+ childObject->setMapData(mapData());
+ childObject->d_func()->serial = d_func()->serial++;
+
+ //binary search
+ QList<QGeoMapObject*>::iterator i = qUpperBound(d_ptr->children.begin(),
+ d_ptr->children.end(),
+ childObject,
+ mapObjectLessThan);
+ d_ptr->children.insert(i, childObject);
+
+ connect(childObject, SIGNAL(zValueChanged(int)),
+ d_ptr, SLOT(childChangedZValue(int)));
+
+ emit childAdded(childObject);
+}
+
+/*!
+ Removes \a childObject from the list of children of this map object.
+
+ The map object will release ownership of \a childObject.
+*/
+void QGeoMapGroupObject::removeChildObject(QGeoMapObject *childObject)
+{
+ if (!childObject)
+ return;
+
+ if (d_ptr->children.removeAll(childObject) > 0) {
+
+ disconnect(childObject, SIGNAL(zValueChanged(int)),
+ d_ptr, SLOT(childChangedZValue(int)));
+
+ emit childRemoved(childObject);
+ childObject->setMapData(0);
+
+// if (this->mapData()) {
+// QGeoMapObjectEngine *oe = this->mapData()->d_ptr->oe;
+// if (oe)
+// oe->removeObject(childObject);
+// }
+ }
+
+// update();
+}
+
+/*!
+ Returns the children of this object.
+*/
+QList<QGeoMapObject*> QGeoMapGroupObject::childObjects() const
+{
+ return d_ptr->children;
+}
+
+/*!
+ Clears the children of this object.
+
+ The child objects will be deleted.
+*/
+void QGeoMapGroupObject::clearChildObjects()
+{
+ for (int i = d_ptr->children.size() - 1; i >=0; --i) {
+ QGeoMapObject* child = d_ptr->children[i];
+ removeChildObject(child);
+ delete child;
+ }
+
+ d_ptr->children.clear();
+}
+
+/*!
+ Sets whether this group of objects is visible to \a visible.
+*/
+void QGeoMapGroupObject::setVisible(bool visible)
+{
+ for (int i = 0; i < d_ptr->children.size(); ++i)
+ d_ptr->children[i]->setVisible(visible);
+
+ QGeoMapObject::setVisible(visible);
+}
+
+/*!
+ \reimp
+*/
+void QGeoMapGroupObject::setMapData(QGeoMapData *mapData)
+{
+
+ for (int i = 0; i < d_ptr->children.size(); ++i) {
+ d_ptr->children[i]->setMapData(mapData);
+ if (mapData)
+ emit childAdded(d_ptr->children[i]);
+ }
+
+ QGeoMapObject::setMapData(mapData);
+}
+
+/*!
+\fn void QGeoMapGroupObject::childAdded(QGeoMapObject *childObject)
+
+ This signal will be emitted when the map object \a childObject
+ is added to the group.
+*/
+
+/*!
+\fn void QGeoMapGroupObject::childUpdated(QGeoMapObject *childObject)
+
+ This signal will be emitted when the map object \a childObject
+ belonging to the group is updated.
+*/
+
+/*!
+\fn void QGeoMapGroupObject::childRemoved(QGeoMapObject *childObject)
+
+ This signal will be emitted when the map object \a childObject
+ is removed from the group.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapGroupObjectPrivate::QGeoMapGroupObjectPrivate(QGeoMapGroupObject *p) :
+ QObject(p),
+ serial(1),
+ q_ptr(p)
+{}
+
+QGeoMapGroupObjectPrivate::~QGeoMapGroupObjectPrivate()
+{
+ qDeleteAll(children);
+}
+
+void QGeoMapGroupObjectPrivate::childChangedZValue(int zValue)
+{
+ Q_UNUSED(zValue);
+ QGeoMapObject *child = qobject_cast<QGeoMapObject*>(sender());
+ if (!child)
+ return;
+
+ if (children.removeAll(child) > 0) {
+ QList<QGeoMapObject*>::iterator i = qUpperBound(children.begin(),
+ children.end(),
+ child,
+ mapObjectLessThan);
+ children.insert(i, child);
+ emit q_ptr->childUpdated(child);
+ }
+}
+
+#include "moc_qgeomapgroupobject.cpp"
+#include "moc_qgeomapgroupobject_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomapgroupobject.h b/src/location/maps/qgeomapgroupobject.h
new file mode 100644
index 00000000..7d485d10
--- /dev/null
+++ b/src/location/maps/qgeomapgroupobject.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPGROUPOBJECT_H
+#define QGEOMAPGROUPOBJECT_H
+
+#include "qgeomapobject.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBox;
+class QGeoMapGroupObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapGroupObject : public QGeoMapObject
+{
+ Q_OBJECT
+public:
+ QGeoMapGroupObject();
+ ~QGeoMapGroupObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoBoundingBox boundingBox() const;
+ bool contains(const QGeoCoordinate &coordinate) const;
+
+ QList<QGeoMapObject*> childObjects() const;
+ void addChildObject(QGeoMapObject *childObject);
+ void removeChildObject(QGeoMapObject *childObject);
+ void clearChildObjects();
+
+ void setVisible(bool visible);
+
+ void setMapData(QGeoMapData *mapData);
+
+Q_SIGNALS:
+ void childAdded(QGeoMapObject *childObject);
+ void childUpdated(QGeoMapObject *childObject);
+ void childRemoved(QGeoMapObject *childObject);
+
+private:
+ QGeoMapGroupObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapGroupObject)
+ Q_DISABLE_COPY(QGeoMapGroupObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapgroupobject_p.h b/src/location/maps/qgeomapgroupobject_p.h
new file mode 100644
index 00000000..01d7f391
--- /dev/null
+++ b/src/location/maps/qgeomapgroupobject_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPGROUPOBJECT_P_H
+#define QGEOMAPGROUPOBJECT_P_H
+
+#include "qgeomapobject.h"
+
+#include <QObject>
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapGroupObject;
+
+class QGeoMapGroupObjectPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoMapGroupObjectPrivate(QGeoMapGroupObject *p);
+ ~QGeoMapGroupObjectPrivate();
+
+ QList<QGeoMapObject *> children;
+ quint32 serial;
+
+public slots:
+ void childChangedZValue(int zValue);
+
+private:
+ QGeoMapGroupObject *q_ptr;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapobject.cpp b/src/location/maps/qgeomapobject.cpp
new file mode 100644
index 00000000..3c42fc45
--- /dev/null
+++ b/src/location/maps/qgeomapobject.cpp
@@ -0,0 +1,534 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapobject.h"
+#include "qgeomapobject_p.h"
+#include "qgeomapobjectengine_p.h"
+#include "qgeomapobjectinfo.h"
+#include "qgeomapdata.h"
+#include "qgeomapdata_p.h"
+#include "qgeoboundingbox.h"
+#include "qgeocoordinate.h"
+#include "projwrapper_p.h"
+
+#include <QtAlgorithms>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapObject
+ \brief The QGeoMapObject class is a graphical item to be displayed on a map.
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ QGeoMapObject is the base class used to display graphical items on a map.
+
+ Subclasses of QGeoMapObject exist in order to simplify the task of
+ creating and managing map objects of various kinds.
+
+ QGeoMapCustomObject is the most generic of these objects in that it
+ allows QGraphicsItems to be added to a map, however as not all mapping
+ plugins use the Qt Graphics View framework so clients should use
+ QGraphicsGeoMap::supportsCustomMapObjects() before using
+ QGeoMapCustomObject.
+
+ QGeoMapObject instances can also be grouped into heirarchies in order to
+ simplify the process of creating compound objects and managing groups of
+ objects (see QGeoMapGroupObject)
+*/
+
+/*!
+ \enum QGeoMapObject::Type
+
+ Describes the type of a map object.
+
+ \value NullType
+ An empty QGeoMapObject.
+ \value GroupType
+ A QGeoMapObject used to organize other map objects into groups.
+ \value RectangleType
+ A QGeoMapObject used to display a rectangular region.
+ \value CircleType
+ A QGeoMapObject used to display a circular region.
+ \value PolylineType
+ A QGeoMapObject used to display a multi-segment line.
+ \value PolygonType
+ A QGeoMapObject used to display a polygonal region.
+ \value PixmapType
+ A QGeoMapObject used to display a pixmap on a map.
+ \value TextType
+ A QGeoMapObject used to display text on a map
+ \value RouteType
+ A QGeoMapObject used to display a route.
+ \value CustomType
+ A QGeoMapObject displaying a custom GraphicsItem.
+*/
+
+/*!
+ \enum QGeoMapObject::CoordinateUnit
+
+ \since 1.2
+
+ Describes the units of measurement used for a map object's
+ graphics item.
+
+ \value PixelUnit
+ Units are in pixels on the screen. Pixel coordinate (0,0) is
+ translated to the origin coordinate.
+ \value MeterUnit
+ Units are in meters on the ground -- a local Transverse Mercator
+ coordinate system (on the WGS84 ellipsoid) is used for translation,
+ centered on the origin coordinate.
+ \value RelativeArcSecondUnit
+ Units are in arc seconds relative to the origin coordinate (along the
+ WGS84 ellipsoid).
+ \value AbsoluteArcSecondUnit
+ Units are in arc seconds on WGS84, origin ignored.
+*/
+
+/*!
+ \enum QGeoMapObject::TransformType
+
+ \since 1.2
+
+ Describes the type of transformation applied to change this object's
+ coordinate system into screen coordinates.
+
+ \value BilinearTransform
+ This object's bounding box is taken, and transformed at each of its
+ corners into screen coordinates. A bilinear interpolation is then used
+ to draw the rest of the object's GraphicsItem.
+ \value ExactTransform
+ Individual key points on the object are transformed and the GraphicsItem
+ is constructed in direct pixel coordinates. This is only available for
+ certain subclasses, depending on the implementation of QGeoMapData used.
+*/
+
+/*!
+ Constructs a new map object associated with \a mapData.
+
+ The object will be in pixel coordinates, with exact transform.
+*/
+QGeoMapObject::QGeoMapObject(QGeoMapData *mapData)
+ : d_ptr(new QGeoMapObjectPrivate())
+{
+ setMapData(mapData);
+}
+
+/*!
+ Destroys this map object.
+*/
+QGeoMapObject::~QGeoMapObject()
+{
+ setMapData(0);
+ delete d_ptr;
+}
+
+/*!
+ Returns the type of this map object.
+*/
+QGeoMapObject::Type QGeoMapObject::type() const
+{
+// if (d_ptr->graphicsItem)
+// return QGeoMapObject::CustomType;
+// else
+ return QGeoMapObject::NullType;
+}
+
+/*!
+ \property QGeoMapObject::zValue
+ \brief This property holds the z-value of the map object.
+
+ The z-value determines the order in which the objects are drawn on the
+ screen. Objects with the same value will be drawn in the order that
+ they were added to the map or map object.
+
+ This is the same behaviour as QGraphicsItem.
+*/
+void QGeoMapObject::setZValue(int zValue)
+{
+ if (d_ptr->zValue != zValue) {
+ d_ptr->zValue = zValue;
+ emit zValueChanged(d_ptr->zValue);
+ }
+}
+
+int QGeoMapObject::zValue() const
+{
+ return d_ptr->zValue;
+}
+
+/*!
+ \property QGeoMapObject::visible
+ \brief This property holds whether the map object is visible.
+*/
+void QGeoMapObject::setVisible(bool visible)
+{
+ if (d_ptr->isVisible != visible) {
+ d_ptr->isVisible = visible;
+ emit visibleChanged(d_ptr->isVisible);
+ }
+}
+
+bool QGeoMapObject::isVisible() const
+{
+ return d_ptr->isVisible;
+}
+
+/*!
+ \property QGeoMapObject::selected
+ \brief This property holds whether the map object is selected.
+*/
+void QGeoMapObject::setSelected(bool selected)
+{
+ if (d_ptr->isSelected != selected) {
+ d_ptr->isSelected = selected;
+ emit selectedChanged(d_ptr->isSelected);
+ }
+}
+
+bool QGeoMapObject::isSelected() const
+{
+ return d_ptr->isSelected;
+}
+
+/*!
+ Returns a bounding box which contains this map object.
+
+ The default implementation requires the object to be added to a map
+ before this function returns a valid bounding box.
+*/
+QGeoBoundingBox QGeoMapObject::boundingBox() const
+{
+ if (!d_ptr->info)
+ return QGeoBoundingBox();
+
+ return d_ptr->info->boundingBox();
+}
+
+/*!
+ Returns whether \a coordinate is contained with the boundary of this
+ map object.
+
+ The default implementation requires the object to be added to a map
+ before this function is able to return true.
+*/
+bool QGeoMapObject::contains(const QGeoCoordinate &coordinate) const
+{
+ if (!d_ptr->info)
+ return false;
+
+ return d_ptr->info->contains(coordinate);
+}
+
+/*!
+ \internal
+*/
+bool QGeoMapObject::operator<(const QGeoMapObject &other) const
+{
+ return d_ptr->zValue < other.d_ptr->zValue ||
+ (d_ptr->zValue == other.d_ptr->zValue && d_ptr->serial < other.d_ptr->serial);
+}
+
+/*!
+ \internal
+*/
+bool QGeoMapObject::operator>(const QGeoMapObject &other) const
+{
+ return d_ptr->zValue > other.d_ptr->zValue ||
+ (d_ptr->zValue == other.d_ptr->zValue && d_ptr->serial > other.d_ptr->serial);
+}
+
+/*!
+ Associates the QGeoMapData instance \a mapData with this map object.
+
+ This will create an appropriate QGeoMapObjectInfo instance for
+ this QGeoMapObject and will connect the appropriate signals to it
+ so that it can be kept up to date.
+*/
+void QGeoMapObject::setMapData(QGeoMapData *mapData)
+{
+ if (d_ptr->mapData == mapData)
+ return;
+
+ if (d_ptr->info) {
+ delete d_ptr->info;
+ d_ptr->info = 0;
+ }
+
+ d_ptr->mapData = mapData;
+ if (!d_ptr->mapData)
+ return;
+
+ d_ptr->info = mapData->createMapObjectInfo(this);
+
+ if (!d_ptr->info)
+ return;
+
+ connect(d_ptr->mapData,
+ SIGNAL(windowSizeChanged(QSizeF)),
+ d_ptr->info,
+ SLOT(windowSizeChanged(QSizeF)));
+ connect(d_ptr->mapData,
+ SIGNAL(zoomLevelChanged(qreal)),
+ d_ptr->info,
+ SLOT(zoomLevelChanged(qreal)));
+ connect(d_ptr->mapData,
+ SIGNAL(centerChanged(QGeoCoordinate)),
+ d_ptr->info,
+ SLOT(centerChanged(QGeoCoordinate)));
+
+ connect(this,
+ SIGNAL(zValueChanged(int)),
+ d_ptr->info,
+ SLOT(zValueChanged(int)));
+ connect(this,
+ SIGNAL(visibleChanged(bool)),
+ d_ptr->info,
+ SLOT(visibleChanged(bool)));
+ connect(this,
+ SIGNAL(selectedChanged(bool)),
+ d_ptr->info,
+ SLOT(selectedChanged(bool)));
+ connect(this,
+ SIGNAL(originChanged(QGeoCoordinate)),
+ d_ptr->info,
+ SLOT(originChanged(QGeoCoordinate)));
+ connect(this,
+ SIGNAL(transformTypeChanged(QGeoMapObject::TransformType)),
+ d_ptr->info,
+ SLOT(transformTypeChanged(QGeoMapObject::TransformType)));
+ connect(this,
+ SIGNAL(unitsChanged(QGeoMapObject::CoordinateUnit)),
+ d_ptr->info,
+ SLOT(unitsChanged(QGeoMapObject::CoordinateUnit)));
+
+ d_ptr->info->init();
+}
+
+/*!
+ Returns the QGeoMapData instance associated with this object.
+
+ Will return 0 if not QGeoMapData instance has been set.
+*/
+QGeoMapData* QGeoMapObject::mapData() const
+{
+ return d_ptr->mapData;
+}
+
+/*!
+ Returns the QGeoMapObjectInfo instance which implements the
+ QGeoMapData specific behaviours of this map object.
+
+ This will mostly be useful when implementing custom QGeoMapData
+ subclasses.
+*/
+QGeoMapObjectInfo *QGeoMapObject::info() const
+{
+ return d_ptr->info;
+}
+
+/*!
+ \property QGeoMapObject::transformType
+ \brief This property holds the transformation type used to draw the object.
+
+ \since 1.2
+
+ \sa QGeoMapObject::TransformType
+*/
+QGeoMapObject::TransformType QGeoMapObject::transformType() const
+{
+ return d_ptr->transType;
+}
+
+/*!
+ Sets the transform type of the object to \a type.
+*/
+void QGeoMapObject::setTransformType(const TransformType &type)
+{
+ if (type == d_ptr->transType)
+ return;
+
+ d_ptr->transType = type;
+
+ emit transformTypeChanged(type);
+}
+
+/*!
+ \property QGeoMapObject::origin
+ \brief This property holds the origin of the object's coordinate system.
+
+ \since 1.2
+
+ How the origin coordinate is used depends on the selected coordinate
+ system, see QGeoMapObject::TransformType for more details.
+*/
+QGeoCoordinate QGeoMapObject::origin() const
+{
+ return d_ptr->origin;
+}
+
+/*!
+ Sets the origin of the object to \a origin.
+*/
+void QGeoMapObject::setOrigin(const QGeoCoordinate &origin)
+{
+ if (origin == d_ptr->origin)
+ return;
+
+ d_ptr->origin = origin;
+
+ emit originChanged(origin);
+}
+
+/*!
+ \property QGeoMapObject::units
+ \brief This property holds the units of measurement for the object.
+
+ \since 1.2
+
+ \sa QGeoMapObject::CoordinateUnit
+*/
+QGeoMapObject::CoordinateUnit QGeoMapObject::units() const
+{
+ return d_ptr->units;
+}
+
+/*!
+ Sets the coordinate units of the object to \a unit.
+
+ Note that setting this property will reset the transformType property to
+ the default for the units given. For PixelUnit, this is ExactTransform,
+ and for all others, BilinearTransform.
+*/
+void QGeoMapObject::setUnits(const CoordinateUnit &unit)
+{
+ if (unit == d_ptr->units)
+ return;
+
+ d_ptr->units = unit;
+
+ if (unit == QGeoMapObject::PixelUnit)
+ setTransformType(QGeoMapObject::ExactTransform);
+ else
+ setTransformType(QGeoMapObject::BilinearTransform);
+
+ emit unitsChanged(unit);
+}
+
+/*!
+\fn void QGeoMapObject::zValueChanged(int zValue)
+
+ This signal is emitted when the z value of the map object
+ has changed.
+
+ The new value is \a zValue.
+*/
+
+/*!
+\fn void QGeoMapObject::visibleChanged(bool visible)
+
+ This signal is emitted when the visible state of the map object
+ has changed.
+
+ The new value is \a visible.
+*/
+
+/*!
+\fn void QGeoMapObject::selectedChanged(bool selected)
+
+ This signal is emitted when the selected state of the map object
+ has changed.
+
+ The new vlaue is \a selected.
+*/
+
+/*!
+\fn void QGeoMapObject::originChanged(QGeoCoordinate origin)
+
+ This signal is emitted when the origin of the map object has changed.
+
+ The new value is \a origin.
+*/
+
+/*!
+\fn void QGeoMapObject::unitsChanged(QGeoMapObject::CoordinateUnit units)
+
+ This signal is emitted when the coordinate units of the map object have changed.
+
+ The new value is \a units.
+*/
+
+/*!
+\fn void QGeoMapObject::transformTypeChanged(QGeoMapObject::TransformType transformType)
+
+ This signal is emitted when the transform type of the map object has changed.
+
+ The new value is \a transformType.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapObjectPrivate::QGeoMapObjectPrivate()
+ : zValue(0),
+ serial(0),
+ isVisible(true),
+ isSelected(false),
+ mapData(0),
+ info(0),
+ units(QGeoMapObject::PixelUnit),
+ transType(QGeoMapObject::ExactTransform){}
+
+QGeoMapObjectPrivate::~QGeoMapObjectPrivate()
+{
+ if (info)
+ delete info;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+#include "moc_qgeomapobject.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomapobject.h b/src/location/maps/qgeomapobject.h
new file mode 100644
index 00000000..91fbb516
--- /dev/null
+++ b/src/location/maps/qgeomapobject.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECT_H
+#define QGEOMAPOBJECT_H
+
+#include "qmobilityglobal.h"
+
+#include <QList>
+#include <QObject>
+
+class QPainter;
+class QRectF;
+class QGraphicsItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBox;
+class QGeoMapObjectPrivate;
+class QGeoMapContainer;
+class QGeoMapObjectInfo;
+
+class QGeoMapData;
+
+class Q_LOCATION_EXPORT QGeoMapObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int zValue READ zValue WRITE setZValue NOTIFY zValueChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged)
+ Q_PROPERTY(QGeoCoordinate origin READ origin NOTIFY originChanged)
+ Q_PROPERTY(CoordinateUnit units READ units NOTIFY unitsChanged)
+ Q_PROPERTY(TransformType transformType READ transformType NOTIFY transformTypeChanged)
+
+public:
+ enum Type {
+ NullType,
+ GroupType,
+ RectangleType,
+ CircleType,
+ PolylineType,
+ PolygonType,
+ PixmapType,
+ TextType,
+ RouteType,
+ CustomType
+ };
+
+ enum CoordinateUnit {
+ PixelUnit,
+ MeterUnit,
+ RelativeArcSecondUnit,
+ AbsoluteArcSecondUnit
+ };
+
+ enum TransformType {
+ BilinearTransform,
+ ExactTransform
+ };
+
+ QGeoMapObject(QGeoMapData *mapData = 0);
+ virtual ~QGeoMapObject();
+
+ virtual Type type() const;
+
+ void setZValue(int zValue);
+ int zValue() const;
+
+ void setVisible(bool visible);
+ bool isVisible() const;
+
+ void setSelected(bool selected);
+ bool isSelected() const;
+
+ virtual QGeoBoundingBox boundingBox() const;
+ virtual bool contains(const QGeoCoordinate &coordinate) const;
+
+ bool operator<(const QGeoMapObject &other) const;
+ bool operator>(const QGeoMapObject &other) const;
+
+ virtual void setMapData(QGeoMapData *mapData);
+ virtual QGeoMapData* mapData() const;
+
+ QGeoMapObjectInfo *info() const;
+
+ QGeoCoordinate origin() const;
+ CoordinateUnit units() const;
+ TransformType transformType() const;
+
+protected:
+ void setOrigin(const QGeoCoordinate &origin);
+ void setUnits(const CoordinateUnit &unit);
+ void setTransformType(const TransformType &type);
+
+Q_SIGNALS:
+ void zValueChanged(int zValue);
+ void visibleChanged(bool visible);
+ void selectedChanged(bool selected);
+
+ void originChanged(QGeoCoordinate origin);
+ void unitsChanged(QGeoMapObject::CoordinateUnit units);
+ void transformTypeChanged(QGeoMapObject::TransformType transformType);
+
+private:
+ QGeoMapObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapObject)
+ Q_DISABLE_COPY(QGeoMapObject)
+
+ friend class QGeoMapDataPrivate;
+ friend class QGeoMapGroupObject;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapobject_p.h b/src/location/maps/qgeomapobject_p.h
new file mode 100644
index 00000000..8db71973
--- /dev/null
+++ b/src/location/maps/qgeomapobject_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECT_P_H
+#define QGEOMAPOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomapobject.h"
+#include "qgeomapobjectinfo.h"
+#include "qgeocoordinate.h"
+
+class QGraphicsItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapObject;
+class QGeoMapData;
+
+class QGeoMapObjectPrivate
+{
+public:
+ QGeoMapObjectPrivate();
+ virtual ~QGeoMapObjectPrivate();
+
+ int zValue;
+ quint32 serial;
+ bool isVisible;
+ bool isSelected;
+
+ QGeoMapData *mapData;
+ mutable QGeoMapObjectInfo *info;
+
+ QGeoMapObject::CoordinateUnit units;
+ QGeoMapObject::TransformType transType;
+ QGeoCoordinate origin;
+
+ Q_DISABLE_COPY(QGeoMapObjectPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapobjectengine_p.cpp b/src/location/maps/qgeomapobjectengine_p.cpp
new file mode 100644
index 00000000..868b8c8e
--- /dev/null
+++ b/src/location/maps/qgeomapobjectengine_p.cpp
@@ -0,0 +1,1179 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapobjectengine_p.h"
+#include "qgeomaprouteobject.h"
+#include "qgeomapcircleobject.h"
+#include "qgeocoordinate_p.h"
+#include "qgeoboundingbox.h"
+#include "projwrapper_p.h"
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include <QTransform>
+#include <QGraphicsItem>
+#include <QGraphicsScene>
+#include <QGraphicsPolygonItem>
+#include <QGraphicsPathItem>
+#include <QGraphicsEllipseItem>
+
+#include <cmath>
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+/*
+ A quick note about how the transforms are set up:
+
+ Each QGeoMapObject has its own "local" coordinate system, whether this
+ a pixel system or meters or whatever.
+
+ For local systems that are not in pixels, we do a two-stage transform --
+ first we transform the object to arc-seconds, then we transform from
+ arc-seconds to pixels on the screen. This is necessary as QGeoMapData
+ subclasses only provide a mapping from lat/lon coordinates to screen pixels
+ and no other source.
+
+ For local systems that are in pixels, we simply translate to the screen
+ coordinates. However, we still generate a transform to arc-seconds for these
+ objects, to speed up the drawing process.
+
+ QGeoMapDataPrivate has two sets of 3 fields that are used here:
+ - xxxTrans
+ - xxxScene
+ - xxxItems
+ (where xxx = [latLon, pixel])
+
+ xxxTrans = a multi-hash of transforms associated with each QGeoMapObject
+ (a given map object may appear at more than one coordinate if
+ it wraps over the dateline)
+ xxxScene = a QGraphicsScene filled with bounding boxes for each object, one
+ for each entry in xxxTrans
+ xxxItems = a hash taking the items in the xxxScene and giving back the original
+ QGeoMapObject they were created for
+
+ the "latLon" entries describe the transformations from local coordinates to
+ arc-seconds, and the "pixel" entries describe the transformations from local
+ coordinates to pixels on screen.
+
+ Items within latLonScene have their coordinates in arc-seconds, and items
+ within pixelScene have theirs in pixels.
+
+*/
+
+QGeoMapObjectEngine::QGeoMapObjectEngine(QGeoMapData *mapData, QGeoMapDataPrivate *mapDataP) :
+ md(mapData),
+ mdp(mapDataP),
+ exactMappingTolerance(1.0),
+ latLonScene(new QGraphicsScene),
+ pixelScene(new QGraphicsScene)
+{
+ pixelScene->setItemIndexMethod(QGraphicsScene::NoIndex);
+}
+
+QGeoMapObjectEngine::~QGeoMapObjectEngine()
+{
+ delete pixelScene;
+ delete latLonScene;
+
+ latLonTrans.clear();
+ latLonItems.clear();
+ latLonItemsRev.clear();
+ pixelTrans.clear();
+ pixelItems.clear();
+ pixelItemsRev.clear();
+
+ foreach (QGraphicsItem *i, latLonExact.values())
+ delete i;
+ latLonExact.clear();
+
+ foreach (QGraphicsItem *i, pixelExact.values())
+ delete i;
+ pixelExact.clear();
+}
+
+/*****************************************************************************
+ Object management
+ *****************************************************************************/
+
+void QGeoMapObjectEngine::addObject(QGeoMapObject *object)
+{
+ objectsForLatLonUpdate << object;
+ objectsForPixelUpdate << object;
+ updateTransforms();
+ rebuildScenes();
+}
+
+void QGeoMapObjectEngine::removeObject(QGeoMapObject *object)
+{
+ QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(object);
+ if (group) {
+ foreach (QGeoMapObject *child, group->childObjects())
+ removeObject(child);
+ } else {
+ QList<QRectF> rectsToUpdate;
+ foreach (QGraphicsItem *item, pixelItemsRev.values(object))
+ rectsToUpdate << item->boundingRect();
+
+ latLonTrans.remove(object);
+ foreach (QGraphicsItem *item, latLonItemsRev.values(object)) {
+ latLonItems.remove(item);
+ latLonScene->removeItem(item);
+ delete item;
+ }
+ latLonItemsRev.remove(object);
+
+ pixelTrans.remove(object);
+ foreach (QGraphicsItem *item, pixelItemsRev.values(object)) {
+ pixelItems.remove(item);
+ pixelScene->removeItem(item);
+ delete item;
+ }
+ pixelItemsRev.remove(object);
+
+ foreach (QRectF rect, rectsToUpdate)
+ mdp->emitUpdateMapDisplay(rect);
+ }
+}
+
+/*****************************************************************************
+ Transform support functions
+ *****************************************************************************/
+
+static QGraphicsPolygonItem *polyCopy(const QGraphicsPolygonItem *polyItem)
+{
+ QGraphicsPolygonItem *pi = new QGraphicsPolygonItem;
+ pi->setBrush(polyItem->brush());
+ pi->setPen(polyItem->pen());
+ pi->setVisible(polyItem->isVisible());
+ pi->setFillRule(polyItem->fillRule());
+ pi->setOpacity(polyItem->opacity());
+ pi->setGraphicsEffect(polyItem->graphicsEffect());
+ return pi;
+}
+
+static QGraphicsPolygonItem *polyCopy(const QGraphicsEllipseItem *elItem)
+{
+ QGraphicsPolygonItem *pi = new QGraphicsPolygonItem;
+ pi->setBrush(elItem->brush());
+ pi->setPen(elItem->pen());
+ pi->setVisible(elItem->isVisible());
+ pi->setOpacity(elItem->opacity());
+ pi->setGraphicsEffect(elItem->graphicsEffect());
+ return pi;
+}
+
+static QGraphicsPathItem *pathCopy(const QGraphicsPathItem *pathItem)
+{
+ QGraphicsPathItem *pi = new QGraphicsPathItem;
+ pi->setBrush(pathItem->brush());
+ pi->setPen(pathItem->pen());
+ pi->setVisible(pathItem->isVisible());
+ pi->setOpacity(pathItem->opacity());
+ pi->setGraphicsEffect(pathItem->graphicsEffect());
+ return pi;
+}
+
+static QPolygonF approximateCircle(QGraphicsEllipseItem *elItem,
+ QGeoMapObject *object,
+ const QGeoCoordinate &center,
+ const ProjCoordinate &projCenter)
+{
+ const QRectF rect = elItem->rect();
+
+ const double a = rect.height() / 2.0;
+ const double b = rect.width() / 2.0;
+
+ const double asq = a*a;
+ const double bsq = b*b;
+
+ QPolygonF secPoly;
+
+ quint32 detail = 150;
+ QGeoMapCircleObject *circObj = dynamic_cast<QGeoMapCircleObject*>(object);
+ if (circObj)
+ detail = circObj->pointCount();
+
+ const double Pi = 3.14159265358;
+ const double twopi = 6.283185307179;
+
+ const double dth = twopi / detail;
+
+ // TODO: make the semantics here the same as in normal graphicsview
+ double startAngle = elItem->startAngle();
+ startAngle /= 16.0;
+ startAngle *= twopi;
+ startAngle /= 360.0;
+
+ double stopAngle = elItem->startAngle() + elItem->spanAngle();
+ stopAngle /= 16.0;
+ stopAngle *= twopi;
+ stopAngle /= 360.0;
+
+ bool drawToCenter = (elItem->spanAngle() != 360 * 16);
+
+ for (double theta = startAngle; theta < stopAngle; theta += dth) {
+ const double top = b*sin(theta);
+ const double bottom = a*cos(theta);
+
+ double phi = atan(top / bottom);
+ if (bottom < 0)
+ phi = phi + Pi;
+
+ const double phiDeg = (360.0 * phi) / twopi;
+
+ const double costh = cos(theta);
+ const double sinth = sin(theta);
+
+ const double r = sqrt(asq*costh*costh + bsq*sinth*sinth);
+
+ double x, y;
+ QGeoCoordinatePrivate::atDistanceAndAzimuth(center, r, phiDeg,
+ &x, &y);
+ x *= 3600.0;
+ y *= 3600.0;
+
+ secPoly << QPointF(x,y);
+ }
+
+ if (drawToCenter)
+ secPoly << QPointF(projCenter.x() * 3600.0, projCenter.y() * 3600.0);
+
+ return secPoly;
+}
+
+bool QGeoMapObjectEngine::exactMetersToSeconds(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QGraphicsItem *item,
+ QList<QPolygonF> &polys)
+{
+ QString projStr = "+proj=tmerc +lat_0=%1 +lon_0=%2 +k=1.0 +x_0=0 +y_0=0 +ellps=WGS84";
+ projStr = projStr.arg(origin.latitude(), 0, 'f', 12)
+ .arg(origin.longitude(), 0, 'f', 12);
+
+ ProjCoordinateSystem localSys(projStr, false);
+ ProjCoordinateSystem wgs84("+proj=latlon +ellps=WGS84");
+
+ QTransform west;
+ west.translate(360.0 * 3600.0, 0.0);
+
+ QTransform east;
+ east.translate(-360.0 * 3600.0, 0.0);
+
+ foreach (QGraphicsItem *i, latLonExact.values(object))
+ delete i;
+ latLonExact.remove(object);
+
+ QGraphicsEllipseItem *elItem = dynamic_cast<QGraphicsEllipseItem*>(item);
+ if (elItem) {
+ QRectF rect = elItem->rect();
+
+ const QPointF cen = rect.center();
+ ProjCoordinate c(cen.x(), -1*cen.y(), 0.0, localSys);
+ c.convert(wgs84);
+ const QGeoCoordinate center = c.toGeoCoordinate();
+
+ QPolygonF wgs = approximateCircle(elItem, object, center, c);
+
+ QGraphicsPolygonItem *pi = polyCopy(elItem);
+ pi->setPolygon(wgs);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF westPoly = wgs * west;
+ pi = polyCopy(elItem);
+ pi->setPolygon(westPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF eastPoly = wgs * east;
+ pi = polyCopy(elItem);
+ pi->setPolygon(eastPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ return true;
+ }
+
+ QGraphicsPolygonItem *polyItem = dynamic_cast<QGraphicsPolygonItem*>(item);
+ if (polyItem) {
+ QPolygonF poly = polyItem->polygon() * polyItem->transform();
+
+ ProjPolygon p(poly, localSys);
+ p.scalarMultiply(1, -1, 1);
+ p.convert(wgs84);
+ QPolygonF wgs = p.toPolygonF(3600.0);
+
+ QGraphicsPolygonItem *pi = polyCopy(polyItem);
+ pi->setPolygon(wgs);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF westPoly = wgs * west;
+ pi = polyCopy(polyItem);
+ pi->setPolygon(westPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF eastPoly = wgs * east;
+ pi = polyCopy(polyItem);
+ pi->setPolygon(eastPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ return true;
+ }
+
+ QGraphicsPathItem *pathItem = dynamic_cast<QGraphicsPathItem*>(item);
+ if (pathItem) {
+ QPainterPath path = pathItem->path() * pathItem->transform();
+
+ for (int i = 0; i < path.elementCount(); ++i) {
+ QPainterPath::Element e = path.elementAt(i);
+
+ ProjCoordinate c(e.x, -1*e.y, 0.0, localSys);
+ Q_ASSERT(c.convert(wgs84));
+
+ path.setElementPositionAt(i, c.x() * 3600.0, c.y() * 3600.0);
+ }
+
+ QGraphicsPathItem *pi = pathCopy(pathItem);
+ pi->setPath(path);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPainterPath westPath = path * west;
+ pi = pathCopy(pathItem);
+ pi->setPath(westPath);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPainterPath eastPath = path * east;
+ pi = pathCopy(pathItem);
+ pi->setPath(eastPath);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ return true;
+ }
+
+ qWarning("QGeoMapData: did not recognize type of exact-transformed"
+ "object: type #%d (object not supported for exact transform)",
+ item->type());
+ return false;
+}
+
+bool QGeoMapObjectEngine::exactSecondsToSeconds(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QGraphicsItem *item,
+ QList<QPolygonF> &polys)
+{
+ QTransform west;
+ west.translate(360.0 * 3600.0, 0.0);
+
+ QTransform east;
+ east.translate(-360.0 * 3600.0, 0.0);
+
+ QTransform toAbs;
+ if (object->units() == QGeoMapObject::RelativeArcSecondUnit) {
+ double ox = origin.longitude() * 3600.0;
+ double oy = origin.latitude() * 3600.0;
+ toAbs.translate(ox, oy);
+ }
+
+ foreach (QGraphicsItem *i, latLonExact.values(object))
+ delete i;
+ latLonExact.remove(object);
+
+ QGraphicsPolygonItem *polyItem = dynamic_cast<QGraphicsPolygonItem*>(item);
+ if (polyItem) {
+ if (polyItem->polygon().isEmpty() || polyItem->polygon().size() < 3)
+ return false;
+
+ QPolygonF poly = polyItem->polygon() * polyItem->transform();
+ poly = poly * toAbs;
+
+ QGraphicsPolygonItem *pi = polyCopy(polyItem);
+ pi->setPolygon(poly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF westPoly = poly * west;
+ pi = polyCopy(polyItem);
+ pi->setPolygon(westPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ QPolygonF eastPoly = poly * east;
+ pi = polyCopy(polyItem);
+ pi->setPolygon(eastPoly);
+ latLonExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+
+ return true;
+ }
+
+ QGraphicsPathItem *pathItem = dynamic_cast<QGraphicsPathItem*>(item);
+ if (pathItem) {
+ if (pathItem->path().isEmpty() || pathItem->path().elementCount() < 2)
+ return false;
+
+ QPainterPath path = pathItem->path() * pathItem->transform();
+ path = path * toAbs;
+
+ QGraphicsPathItem *pi = pathCopy(pathItem);
+ pi->setPath(path);
+ latLonExact.insertMulti(object, pi);
+ const QPolygonF originalBounds = pi->boundingRect();
+ polys << originalBounds;
+
+ QPainterPath westPath = path * west;
+ pi = pathCopy(pathItem);
+ pi->setPath(westPath);
+ latLonExact.insertMulti(object, pi);
+ polys << originalBounds * west;
+
+ QPainterPath eastPath = path * east;
+ pi = pathCopy(pathItem);
+ pi->setPath(eastPath);
+ latLonExact.insertMulti(object, pi);
+ polys << originalBounds * east;
+
+ return true;
+ }
+
+ qWarning("QGeoMapData: did not recognize type of exact-transformed "
+ "object: type #%d (object not supported for exact transform)",
+ item->type());
+ return false;
+}
+
+void QGeoMapObjectEngine::bilinearMetersToSeconds(const QGeoCoordinate &origin,
+ QGraphicsItem *item,
+ QPolygonF &local,
+ QTransform &latLon)
+{
+ QString projStr = "+proj=tmerc +lat_0=%1 +lon_0=%2 +k=1.0 +x_0=0 +y_0=0 +ellps=WGS84";
+ projStr = projStr.arg(origin.latitude(), 0, 'f', 12)
+ .arg(origin.longitude(), 0, 'f', 12);
+
+ ProjCoordinateSystem localSys(projStr, false);
+ ProjCoordinateSystem wgs84("+proj=latlon +ellps=WGS84");
+
+ ProjPolygon p(local, localSys);
+ if (!p.convert(wgs84)) {
+ qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
+ "failed: projection is singular");
+ return;
+ }
+ QPolygonF wgs = p.toPolygonF(3600.0);
+
+ // QTransform expects the last vertex (closing vertex) to be dropped
+ local.remove(4);
+ wgs.remove(4);
+
+ // perform wrapping
+ if (wgs.at(2).x() < wgs.at(3).x()) {
+ QPointF topRight = wgs.at(1);
+ topRight.setX(topRight.x() + 360.0 * 3600.0);
+ wgs.replace(1, topRight);
+
+ QPointF bottomRight = wgs.at(2);
+ bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
+ wgs.replace(2, bottomRight);
+ }
+
+ bool ok = QTransform::quadToQuad(local, wgs, latLon);
+ if (!ok) {
+ qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
+ "failed: could not obtain a transformation matrix");
+ return;
+ }
+
+ QTransform flip;
+ flip.scale(1, -1);
+
+ latLon = flip * item->transform() * latLon;
+}
+
+void QGeoMapObjectEngine::bilinearPixelsToSeconds(const QGeoCoordinate &origin,
+ QGraphicsItem *item,
+ QPolygonF &local,
+ QTransform &latLon)
+{
+ QPointF pixelOrigin = mdp->coordinateToScreenPosition(origin.longitude(),
+ origin.latitude());
+
+ QPolygonF wgs;
+ foreach (const QPointF &pt, local) {
+ const QGeoCoordinate coord =
+ md->screenPositionToCoordinate(pt + pixelOrigin);
+ const QPointF lpt(coord.longitude() * 3600.0, coord.latitude() * 3600.0);
+ wgs.append(lpt);
+ }
+
+ // QTransform expects the last vertex (closing vertex) to be dropped
+ local.remove(4);
+ wgs.remove(4);
+
+ // perform wrapping
+ if (wgs.at(2).x() < wgs.at(3).x()) {
+ QPointF topRight = wgs.at(1);
+ topRight.setX(topRight.x() + 360.0 * 3600.0);
+ wgs.replace(1, topRight);
+
+ QPointF bottomRight = wgs.at(2);
+ bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
+ wgs.replace(2, bottomRight);
+ }
+
+ bool ok = QTransform::quadToQuad(local, wgs, latLon);
+ if (!ok) {
+ qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
+ "failed: could not obtain a transformation matrix");
+ return;
+ }
+
+ latLon = item->transform() * latLon;
+}
+
+void QGeoMapObjectEngine::bilinearSecondsToScreen(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys)
+{
+ Q_UNUSED(origin)
+
+ QList<QTransform> latLons = latLonTrans.values(object);
+
+ QGraphicsItem *item = graphicsItemFromMapObject(object);
+ if (!item)
+ return;
+
+ // compute the transform by linearising from the lat/lon space
+ foreach (QTransform latLon, latLons) {
+ QTransform pixel;
+
+
+ QPolygonF local = (item->boundingRect() | item->childrenBoundingRect());
+ QPolygonF latLonPoly = latLon.map(local);
+
+ QPolygonF pixelPoly = polyToScreen(latLonPoly);
+
+ // QTransform expects the last vertex (closing vertex) to be dropped
+ local.remove(4);
+ pixelPoly.remove(4);
+
+ bool ok = QTransform::quadToQuad(local, pixelPoly, pixel);
+ if (!ok) {
+ qWarning("QGeoMapData: bilinear transform to screen from arc-seconds "
+ "failed: could not compute transformation matrix");
+ return;
+ }
+
+ pixelTrans.insertMulti(object, pixel);
+
+ polys << pixelPoly;
+ }
+}
+
+struct PathStep
+{
+ bool tooClose;
+ QPointF pixel;
+ QPainterPath::Element e;
+};
+
+void QGeoMapObjectEngine::exactPixelMap(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys)
+{
+ Q_UNUSED(origin)
+
+ QList<QGraphicsItem*> latLonItems = latLonExact.values(object);
+
+ foreach (QGraphicsItem *i, pixelExact.values(object))
+ delete i;
+ pixelExact.remove(object);
+
+ double tolerance = exactMappingTolerance;
+ QGeoMapRouteObject *robj = qobject_cast<QGeoMapRouteObject*>(object);
+ if (robj)
+ tolerance = robj->detailLevel();
+ // square it
+ tolerance = tolerance * tolerance;
+
+ foreach (QGraphicsItem *latLonItem, latLonItems) {
+ QGraphicsPolygonItem *polyItem = qgraphicsitem_cast<QGraphicsPolygonItem*>(latLonItem);
+ if (polyItem) {
+ QPolygonF poly = polyItem->polygon();
+ QPolygonF pixelPoly = polyToScreen(poly);
+
+ QGraphicsPolygonItem *pi = polyCopy(polyItem);
+ pi->setPolygon(pixelPoly);
+ pixelExact.insertMulti(object, pi);
+ polys << pi->boundingRect();
+ }
+
+ QGraphicsPathItem *pathItem = qgraphicsitem_cast<QGraphicsPathItem*>(latLonItem);
+ if (pathItem) {
+ const QPainterPath path = pathItem->path();
+ const int pathSize = path.elementCount();
+ QPainterPath mpath;
+
+ const QRectF screen = latLonViewport().boundingRect();
+
+ QPointF lastPixelAdded;
+ bool lastOutside = true;
+
+ struct PathStep *steps = new struct PathStep[pathSize];
+
+ for (int i = 0; i < pathSize; ++i) {
+ const QPainterPath::Element e = path.elementAt(i);
+ steps[i].e = e;
+
+ double x = e.x; x /= 3600.0;
+ double y = e.y; y /= 3600.0;
+
+ const QPointF pixel = mdp->coordinateToScreenPosition(x, y);
+ const QPointF deltaP = (pixel - lastPixelAdded);
+ const double delta = deltaP.x() * deltaP.x() + deltaP.y() * deltaP.y();
+
+ steps[i].pixel = pixel;
+
+ if (!lastPixelAdded.isNull() && delta < tolerance) {
+ steps[i].tooClose = true;
+ } else {
+ steps[i].tooClose = false;
+ lastPixelAdded = pixel;
+ }
+ }
+
+ QPainterPath::Element em = steps[0].e;
+
+ for (int i = 0; i < pathSize; ++i) {
+ const QPainterPath::Element &e = steps[i].e;
+
+ if (steps[i].tooClose)
+ continue;
+
+ // guilty until proven innocent
+ bool outside = true;
+ if (screen.contains(e.x, e.y))
+ outside = false;
+ if (lastOutside) {
+ if (em.x < screen.left() && e.x > screen.right())
+ outside = false;
+ if (em.x > screen.right() && e.x < screen.left())
+ outside = false;
+ if (em.y < screen.bottom() && e.y > screen.top())
+ outside = false;
+ if (em.y > screen.top() && e.y < screen.bottom())
+ outside = false;
+ }
+
+ // skip points not inside the screen rect
+ // or attached to points inside it
+ if (outside && lastOutside)
+ continue;
+
+ // entering the screen rect
+ if (!outside && lastOutside && i > 0) {
+ const QPointF lastPixel = steps[i-1].pixel;
+ mpath.moveTo(lastPixel);
+ }
+ lastOutside = outside;
+
+ QPointF pixel = steps[i].pixel;
+
+ if (e.isMoveTo())
+ mpath.moveTo(pixel);
+ else
+ mpath.lineTo(pixel);
+
+ em = e;
+ }
+
+ delete[] steps;
+
+ QGraphicsPathItem *pi = pathCopy(pathItem);
+ pi->setPath(mpath);
+ pixelExact.insertMulti(object, pi);
+ polys << QPolygonF(pi->boundingRect());
+ }
+ }
+}
+
+void QGeoMapObjectEngine::pixelShiftToScreen(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys)
+{
+ QGraphicsItem *item = graphicsItemFromMapObject(object);
+ if (!item)
+ return;
+
+ const QRectF localRect = item->boundingRect()
+ | item->childrenBoundingRect();
+
+ // compute the transform as an origin shift
+ QList<QPointF> origins;
+ origins << QPointF(origin.longitude(), origin.latitude());
+ origins << QPointF(origin.longitude() + 360.0, origin.latitude());
+ origins << QPointF(origin.longitude() - 360.0, origin.latitude());
+
+ foreach (QPointF o, origins) {
+ QTransform pixel = item->transform();
+ QPointF pixelOrigin = mdp->coordinateToScreenPosition(o.x(), o.y());
+ pixel.translate(pixelOrigin.x(), pixelOrigin.y());
+ pixelTrans.insertMulti(object, pixel);
+ polys << pixel.map(localRect);
+ }
+}
+
+/*****************************************************************************
+ Update utility functions
+ *****************************************************************************/
+
+static void _zoomDepsRecurse(QGeoMapObjectEngine *eng, QGeoMapGroupObject *group)
+{
+ foreach (QGeoMapObject *obj, group->childObjects()) {
+ QGeoMapGroupObject *subgroup = qobject_cast<QGeoMapGroupObject*>(obj);
+ if (subgroup) {
+ _zoomDepsRecurse(eng, subgroup);
+ } else {
+ if (obj->units() == QGeoMapObject::PixelUnit) {
+ eng->objectsForLatLonUpdate << obj;
+ eng->objectsForPixelUpdate << obj;
+ }
+ }
+ }
+}
+
+void QGeoMapObjectEngine::invalidateZoomDependents()
+{
+ if (mdp->containerObject)
+ _zoomDepsRecurse(this, mdp->containerObject);
+}
+
+void QGeoMapObjectEngine::invalidatePixelsForViewport(bool updateNow)
+{
+ QPolygonF view = latLonViewport();
+
+ QList<QGraphicsItem*> itemsInView;
+ itemsInView = latLonScene->items(view, Qt::IntersectsItemShape,
+ Qt::AscendingOrder);
+
+ QSet<QGeoMapObject*> done = objectsForPixelUpdate.toSet();
+
+ foreach (QGraphicsItem *latLonItem, itemsInView) {
+ QGeoMapObject *object = latLonItems.value(latLonItem);
+ Q_ASSERT(object);
+ if (!done.contains(object)) {
+ objectsForPixelUpdate << object;
+ done.insert(object);
+ }
+ }
+
+ if (updateNow)
+ mdp->emitUpdateMapDisplay();
+}
+
+void QGeoMapObjectEngine::trimPixelTransforms()
+{
+ QPolygonF view = latLonViewport();
+
+ QList<QGraphicsItem*> itemsInView;
+ itemsInView = latLonScene->items(view, Qt::IntersectsItemShape,
+ Qt::AscendingOrder);
+
+ QSet<QGeoMapObject*> shouldBe;
+ foreach (QGraphicsItem *latLonItem, itemsInView) {
+ QGeoMapObject *object = latLonItems.value(latLonItem);
+ Q_ASSERT(object);
+ shouldBe.insert(object);
+ }
+
+ QList<QGraphicsItem*> itemsInPixels;
+ itemsInPixels = pixelScene->items();
+
+ QSet<QGeoMapObject*> currentlyAre;
+ foreach (QGraphicsItem *pixelItem, itemsInPixels) {
+ QGeoMapObject *object = pixelItems.value(pixelItem);
+ Q_ASSERT(object);
+ currentlyAre.insert(object);
+ }
+
+ QSet<QGeoMapObject*> excess = currentlyAre.subtract(shouldBe);
+ foreach (QGeoMapObject *object, excess) {
+ foreach (QGraphicsItem *item, pixelItemsRev.values(object)) {
+ pixelScene->removeItem(item);
+ pixelItems.remove(item);
+ delete item;
+ }
+ pixelTrans.remove(object);
+ pixelItemsRev.remove(object);
+ }
+
+ mdp->emitUpdateMapDisplay();
+}
+
+void QGeoMapObjectEngine::invalidateObject(QGeoMapObject *obj)
+{
+ // force the lat lon to update now
+ // otherwise we can't tell if it's supposed to be on screen
+ updateLatLonTransform(obj);
+
+ const QRectF view = latLonViewport().boundingRect();
+
+ bool needsPixelUpdate = false;
+ foreach (QGraphicsItem *item, latLonItemsRev.values(obj)) {
+ if (item->boundingRect().intersects(view)) {
+ needsPixelUpdate = true;
+ break;
+ }
+ }
+
+ if (needsPixelUpdate) {
+ objectsForPixelUpdate << obj;
+ mdp->emitUpdateMapDisplay();
+ }
+}
+
+// update the transform tables as necessary
+void QGeoMapObjectEngine::updateTransforms()
+{
+ bool groupUpdated = false;
+
+ foreach (QGeoMapObject *obj, objectsForLatLonUpdate) {
+ QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
+ if (group) {
+ updateLatLonsForGroup(group);
+ groupUpdated = true;
+ } else {
+ updateLatLonTransform(obj);
+ }
+ }
+
+ objectsForLatLonUpdate.clear();
+
+ foreach (QGeoMapObject *obj, objectsForPixelUpdate) {
+ QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
+ if (group) {
+ updatePixelsForGroup(group);
+ groupUpdated = true;
+ } else {
+ updatePixelTransform(obj);
+ }
+ }
+
+ objectsForPixelUpdate.clear();
+
+ if (groupUpdated)
+ rebuildScenes();
+}
+
+void QGeoMapObjectEngine::updatePixelsForGroup(QGeoMapGroupObject *group)
+{
+ foreach (QGeoMapObject *obj, group->childObjects()) {
+ QGeoMapGroupObject *subgroup = qobject_cast<QGeoMapGroupObject*>(obj);
+ if (subgroup) {
+ updatePixelsForGroup(subgroup);
+ } else {
+ updatePixelTransform(obj);
+ }
+ }
+}
+
+void QGeoMapObjectEngine::updateLatLonsForGroup(QGeoMapGroupObject *group)
+{
+ foreach (QGeoMapObject *object, group->childObjects()) {
+ QGeoMapGroupObject *subGroup = qobject_cast<QGeoMapGroupObject*>(object);
+ if (subGroup)
+ updateLatLonsForGroup(subGroup);
+ else
+ updateLatLonTransform(object);
+ }
+}
+
+static void addGroupToScene(QGeoMapObjectEngine *eng, QGeoMapGroupObject *group)
+{
+ foreach (QGeoMapObject *object, group->childObjects()) {
+ QGeoMapGroupObject *subGroup = qobject_cast<QGeoMapGroupObject*>(object);
+ if (subGroup) {
+ addGroupToScene(eng, subGroup);
+ } else {
+ foreach (QGraphicsItem *i, eng->latLonItemsRev.values(object))
+ eng->latLonScene->addItem(i);
+ foreach (QGraphicsItem *i, eng->pixelItemsRev.values(object))
+ eng->pixelScene->addItem(i);
+ }
+ }
+}
+
+void QGeoMapObjectEngine::rebuildScenes()
+{
+ foreach (QGraphicsItem *i, latLonScene->items())
+ latLonScene->removeItem(i);
+ foreach (QGraphicsItem *i, pixelScene->items())
+ pixelScene->removeItem(i);
+
+ delete latLonScene;
+ delete pixelScene;
+
+ latLonScene = new QGraphicsScene;
+ pixelScene = new QGraphicsScene;
+ pixelScene->setItemIndexMethod(QGraphicsScene::NoIndex);
+
+ addGroupToScene(this, mdp->containerObject);
+}
+
+/*****************************************************************************
+ Actual update functions
+ *****************************************************************************/
+
+void QGeoMapObjectEngine::updateLatLonTransform(QGeoMapObject *object)
+{
+ QGeoCoordinate origin = object->origin();
+
+ QGraphicsItem *item = graphicsItemFromMapObject(object);
+
+ // skip any objects without graphicsitems
+ if (!item)
+ return;
+
+ QRectF localRect = (item->boundingRect() | item->childrenBoundingRect());
+
+ // skip any objects with invalid bounds
+ if (!localRect.isValid() || localRect.isEmpty() || localRect.isNull())
+ return;
+
+ QPolygonF local = localRect * item->transform();
+ QList<QPolygonF> polys;
+
+ latLonTrans.remove(object);
+
+ if (object->transformType() == QGeoMapObject::BilinearTransform ||
+ object->units() == QGeoMapObject::PixelUnit) {
+ QTransform latLon;
+
+ if (object->units() == QGeoMapObject::MeterUnit) {
+ bilinearMetersToSeconds(origin, item, local, latLon);
+ } else if (object->units() == QGeoMapObject::RelativeArcSecondUnit) {
+ latLon.translate(origin.longitude() * 3600.0, origin.latitude() * 3600.0);
+ } else if (object->units() == QGeoMapObject::PixelUnit) {
+ bilinearPixelsToSeconds(origin, item, local, latLon);
+ }
+
+ polys << latLon.map(localRect);
+ latLonTrans.insertMulti(object, latLon);
+
+ QTransform latLonWest;
+ latLonWest.translate(360.0 * 3600.0, 0.0);
+ latLonWest = latLon * latLonWest;
+
+ polys << latLonWest.map(localRect);
+ latLonTrans.insertMulti(object, latLonWest);
+
+ QTransform latLonEast;
+ latLonEast.translate(-360.0 * 3600.0, 0.0);
+ latLonEast = latLon * latLonEast;
+
+ polys << latLonEast.map(localRect);
+ latLonTrans.insertMulti(object, latLonEast);
+
+ } else if (object->transformType() == QGeoMapObject::ExactTransform) {
+ if (object->units() == QGeoMapObject::MeterUnit) {
+ if (!exactMetersToSeconds(origin, object, item, polys))
+ return;
+ } else if (object->units() == QGeoMapObject::AbsoluteArcSecondUnit ||
+ object->units() == QGeoMapObject::RelativeArcSecondUnit) {
+ if (!exactSecondsToSeconds(origin, object, item, polys))
+ return;
+ } else {
+ qWarning("QGeoMapData: unknown units for map object");
+ return;
+ }
+ }
+
+ QList<QGraphicsItem*> items = latLonItemsRev.values(object);
+ if (items.size() != polys.size()) {
+ foreach (QGraphicsItem *item, items) {
+ latLonScene->removeItem(item);
+ latLonItems.remove(item);
+ delete item;
+ }
+ latLonItemsRev.remove(object);
+
+ foreach (QPolygonF poly, polys) {
+ QGraphicsItem *item = new QGraphicsPolygonItem(poly);
+ //item->setZValue(object->zValue());
+ item->setVisible(true);
+ latLonItems.insert(item, object);
+ latLonItemsRev.insertMulti(object, item);
+ latLonScene->addItem(item);
+ }
+ } else {
+ for (int i = 0; i < polys.size(); ++i) {
+ QGraphicsItem *item = items.at(i);
+
+ if (!item)
+ continue;
+
+ QGraphicsPolygonItem *pi = dynamic_cast<QGraphicsPolygonItem*>(item);
+ Q_ASSERT(pi);
+ pi->setPolygon(polys.at(i));
+ // pi->setZValue(object->zValue());
+ }
+ }
+}
+
+void QGeoMapObjectEngine::updatePixelTransform(QGeoMapObject *object)
+{
+ QGeoCoordinate origin = object->origin();
+ QGraphicsItem *item = graphicsItemFromMapObject(object);
+
+ // skip any objects without graphicsitems
+ if (!item)
+ return;
+
+ QRectF localRect = (item->boundingRect() | item->childrenBoundingRect());
+
+ // skip any objects with invalid bounds
+ if (!localRect.isValid() || localRect.isEmpty() || localRect.isNull())
+ return;
+
+ QList<QPolygonF> polys;
+
+ pixelTrans.remove(object);
+ if (object->transformType() == QGeoMapObject::BilinearTransform) {
+ bilinearSecondsToScreen(origin, object, polys);
+ } else if (object->transformType() == QGeoMapObject::ExactTransform) {
+ if (object->units() == QGeoMapObject::PixelUnit) {
+ pixelShiftToScreen(origin, object, polys);
+ } else {
+ exactPixelMap(origin, object, polys);
+ }
+ }
+
+ QList<QGraphicsItem*> items = pixelItemsRev.values(object);
+
+ if (items.size() != polys.size()) {
+ foreach (QGraphicsItem *item, items) {
+ pixelItems.remove(item);
+ pixelScene->removeItem(item);
+ delete item;
+ }
+ pixelItemsRev.remove(object);
+ foreach (QPolygonF poly, polys) {
+ QGraphicsPolygonItem *item = new QGraphicsPolygonItem(poly);
+ //item->setZValue(object->zValue());
+ item->setVisible(true);
+ pixelItems.insert(item, object);
+ pixelItemsRev.insertMulti(object, item);
+ pixelScene->addItem(item);
+ }
+ } else {
+ for (int i = 0; i < polys.size(); ++i) {
+ QGraphicsItem *item = items.at(i);
+
+ if (!item)
+ continue;
+
+ QGraphicsPolygonItem *pi = dynamic_cast<QGraphicsPolygonItem*>(item);
+ Q_ASSERT(pi);
+ pi->setPolygon(polys.at(i));
+ //pi->setZValue(object->zValue());
+ }
+ }
+}
+
+QPolygonF QGeoMapObjectEngine::latLonViewport()
+{
+ QPolygonF view;
+ QGeoBoundingBox viewport = md->viewport();
+ QGeoCoordinate c, c2;
+ double offset = 0.0;
+
+ c = viewport.bottomLeft();
+ view << QPointF(c.longitude() * 3600.0, c.latitude() * 3600.0);
+ c2 = viewport.bottomRight();
+ if (c2.longitude() < c.longitude())
+ offset = 360.0 * 3600.0;
+ view << QPointF(c2.longitude() * 3600.0 + offset, c2.latitude() * 3600.0);
+ c = viewport.topRight();
+ view << QPointF(c.longitude() * 3600.0 + offset, c.latitude() * 3600.0);
+ c = viewport.topLeft();
+ view << QPointF(c.longitude() * 3600.0, c.latitude() * 3600.0);
+
+ return view;
+}
+
+QPolygonF QGeoMapObjectEngine::polyToScreen(const QPolygonF &poly)
+{
+ QPolygonF r;
+#if QT_VERSION >= 0x040700
+ r.reserve(poly.size());
+#endif
+ foreach (QPointF pt, poly) {
+ const double x = pt.x() / 3600.0;
+ const double y = pt.y() / 3600.0;
+ const QPointF pixel = mdp->coordinateToScreenPosition(x, y);
+ r.append(pixel);
+ }
+ return r;
+}
+
+QGraphicsItem* QGeoMapObjectEngine::graphicsItemFromMapObject(QGeoMapObject *object)
+{
+ if (!object || !object->info())
+ return 0;
+
+ QGeoTiledMapObjectInfo *tiledInfo
+ = static_cast<QGeoTiledMapObjectInfo*>(object->info());
+
+ if (tiledInfo)
+ return tiledInfo->graphicsItem;
+
+ return 0;
+}
+
+#include "moc_qgeomapobjectengine_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomapobjectengine_p.h b/src/location/maps/qgeomapobjectengine_p.h
new file mode 100644
index 00000000..48cf03bd
--- /dev/null
+++ b/src/location/maps/qgeomapobjectengine_p.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTENGINE_P_H
+#define QGEOMAPOBJECTENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include "qgeomapdata_p.h"
+#include "qgeomapdata.h"
+#include "qgeomapobject_p.h"
+#include "qgeomapobject.h"
+
+#include <QHash>
+#include <QList>
+
+class QTransform;
+class QGraphicsItem;
+class QGraphicsScene;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapObjectEngine : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoMapObjectEngine(QGeoMapData *mapData, QGeoMapDataPrivate *mapDataP);
+ virtual ~QGeoMapObjectEngine();
+
+ QGeoMapData *md;
+ QGeoMapDataPrivate *mdp;
+
+ double exactMappingTolerance;
+
+ /*** Lookup hashes and scenes ***/
+
+ QHash<const QGeoMapObject*, QGraphicsItem*> latLonExact;
+ QHash<const QGeoMapObject*, QGraphicsItem*> pixelExact;
+
+ QHash<const QGeoMapObject*, QTransform> latLonTrans;
+ QGraphicsScene *latLonScene;
+ QHash<QGraphicsItem*, QGeoMapObject*> latLonItems;
+ QHash<QGeoMapObject*, QGraphicsItem*> latLonItemsRev;
+
+ QHash<const QGeoMapObject*, QTransform> pixelTrans;
+ QGraphicsScene *pixelScene;
+ QHash<QGraphicsItem*, QGeoMapObject*> pixelItems;
+ QHash<QGeoMapObject*, QGraphicsItem*> pixelItemsRev;
+
+ /*** Object management ***/
+
+ virtual void addObject(QGeoMapObject *object);
+ virtual void removeObject(QGeoMapObject *object);
+
+ /*** Updating and validity ***/
+
+ virtual void updateTransforms();
+
+ QList<QGeoMapObject*> objectsForPixelUpdate;
+ QList<QGeoMapObject*> objectsForLatLonUpdate;
+
+ virtual void updatePixelsForGroup(QGeoMapGroupObject *group);
+ virtual void updateLatLonsForGroup(QGeoMapGroupObject *group);
+
+ virtual void updateLatLonTransform(QGeoMapObject *object);
+ virtual void updatePixelTransform(QGeoMapObject *object);
+
+ virtual void rebuildScenes();
+
+ virtual void invalidateObject(QGeoMapObject *obj);
+ virtual void invalidateZoomDependents();
+ virtual void invalidatePixelsForViewport(bool updateNow=true);
+ virtual void trimPixelTransforms();
+
+public:
+
+ /*** Exact transform functions ***/
+
+ // these are virtual so subclasses can add new types
+ // of exact transform
+ virtual bool exactMetersToSeconds(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QGraphicsItem *item,
+ QList<QPolygonF> &polys);
+ virtual bool exactSecondsToSeconds(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QGraphicsItem *item,
+ QList<QPolygonF> &polys);
+
+ virtual void exactPixelMap(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys);
+
+ /*** Bilinear transforms ***/
+
+ void bilinearMetersToSeconds(const QGeoCoordinate &origin,
+ QGraphicsItem *item,
+ QPolygonF &local,
+ QTransform &latLon);
+ void bilinearPixelsToSeconds(const QGeoCoordinate &origin,
+ QGraphicsItem *item,
+ QPolygonF &local,
+ QTransform &latLon);
+ void bilinearSecondsToScreen(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys);
+
+ /*** Pixel shift transforms ***/
+
+ void pixelShiftToScreen(const QGeoCoordinate &origin,
+ QGeoMapObject *object,
+ QList<QPolygonF> &polys);
+
+ /*** Misc ***/
+ virtual QGraphicsItem* graphicsItemFromMapObject(QGeoMapObject *object);
+
+private:
+ /*** Internal helpers ***/
+ QPolygonF latLonViewport();
+ QPolygonF polyToScreen(const QPolygonF &poly);
+
+ Q_DISABLE_COPY(QGeoMapObjectEngine)
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOMAPOBJECTENGINE_P_H
diff --git a/src/location/maps/qgeomapobjectinfo.cpp b/src/location/maps/qgeomapobjectinfo.cpp
new file mode 100644
index 00000000..e399d472
--- /dev/null
+++ b/src/location/maps/qgeomapobjectinfo.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapobjectinfo.h"
+#include "qgeomapobjectinfo_p.h"
+
+#include "qgeomapdata.h"
+#include "qgeomapdata_p.h"
+#include "qgeomapobject.h"
+#include "qgeomapobject_p.h"
+#include "qgeoboundingbox.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapObjectInfo
+ \brief The QGeoMapObjectInfo class is the base class used to define the
+ parts of QGeoMapObject and its subclasses that are specific to a
+ particular QGeoMapData subclass.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ Most of the mapping functionality is provided by a QGeoMapData subclass,
+ including the rendering of the map itself.
+
+ This means that QGeoMapData subclasses need to be able to render each of
+ the QGeoMapObject instances and instances of the QGeoMapObject subclasses.
+
+ Furthermore, the need to be able to create and manipulate map objects
+ independently from the QGeoMapData instance precludes the use of a set of
+ factory methods for creating QGeoMapData specific map objects.
+
+ The QGeoMapObjectInfo class is used to provide the QGeoMapData subclass
+ specific behaviours for the map objects in a way which fulfils this need,
+ as the QGeoMapObjectInfo instances are only created at the point when a
+ map object becomes associated with a QGeoMapData subclass - which is most
+ commonly when the object is added to a QGraphicsGeoMap.
+*/
+
+/*!
+ Constructs a new object info instance which will provide the behaviours of
+ \a mapObject which are specific to \a mapData.
+*/
+QGeoMapObjectInfo::QGeoMapObjectInfo(QGeoMapData *mapData, QGeoMapObject *mapObject)
+ : QObject(mapObject),
+ d_ptr(new QGeoMapObjectInfoPrivate(mapData, mapObject)) {}
+
+/*!
+ Destroys this info object.
+*/
+QGeoMapObjectInfo::~QGeoMapObjectInfo()
+{
+ delete d_ptr;
+}
+
+/*!
+ This function is run after the constructor.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::init() {}
+
+/*!
+ This function is called when the window size of the map changes to
+ \a windowSize.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::windowSizeChanged(const QSizeF &windowSize)
+{
+ Q_UNUSED(windowSize)
+}
+
+/*!
+ This function is called when the zoom level of the map changes to
+ \a zoomLevel.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::zoomLevelChanged(qreal zoomLevel)
+{
+ Q_UNUSED(zoomLevel)
+}
+
+/*!
+ This function is called when the center of the map changes to
+ \a coordinate.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::centerChanged(const QGeoCoordinate &coordinate)
+{
+ Q_UNUSED(coordinate)
+}
+
+/*!
+ This function is run when the z value of the object changes to \a zValue.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::zValueChanged(int zValue)
+{
+ Q_UNUSED(zValue)
+}
+
+/*!
+ This function is run when the visible state of the object changes to
+ \a visible.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::visibleChanged(bool visible)
+{
+ Q_UNUSED(visible)
+}
+
+/*!
+ This function is run when the selected state of the object changes to
+ \a selected.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::selectedChanged(bool selected)
+{
+ Q_UNUSED(selected)
+}
+
+/*!
+ This function is run when the origin of the object changes to
+ \a origin.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::originChanged(const QGeoCoordinate &origin)
+{
+ Q_UNUSED(origin);
+}
+
+/*!
+ This function is run when the coordinate units of the object changes to
+ \a units.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::unitsChanged(QGeoMapObject::CoordinateUnit units)
+{
+ Q_UNUSED(units);
+}
+
+/*!
+ This function is run when the transform type of the object changes to
+ \a transformType.
+
+ The default implementation does nothing.
+*/
+void QGeoMapObjectInfo::transformTypeChanged(QGeoMapObject::TransformType transformType)
+{
+ Q_UNUSED(transformType);
+}
+
+/*!
+ Returns a bounding box which contains this map object.
+
+ The default implementation returns an invalid bounding box.
+*/
+QGeoBoundingBox QGeoMapObjectInfo::boundingBox() const
+{
+ return QGeoBoundingBox();
+}
+
+/*!
+ Returns whether \a coordinate is contained with the boundary of this
+ map object.
+
+ The default implementation returns false.
+*/
+bool QGeoMapObjectInfo::contains(const QGeoCoordinate &coordinate) const
+{
+ Q_UNUSED(coordinate)
+ return false;
+}
+
+/*!
+ Returns the QGeoMapData instance associated with this info object.
+*/
+QGeoMapData* QGeoMapObjectInfo::mapData()
+{
+ return d_ptr->mapData;
+}
+
+// Need to keep this for BC, otherwise would probably replace with const
+// version
+/*!
+ Returns the QGeoMapObject instance associated with this info object.
+*/
+QGeoMapObject* QGeoMapObjectInfo::mapObject()
+{
+ return d_ptr->mapObject;
+}
+
+/*!
+ Returns the QGeoMapObject instance associated with this info object.
+*/
+QGeoMapObject* QGeoMapObjectInfo::mapObject() const
+{
+ return d_ptr->mapObject;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapObjectInfoPrivate::QGeoMapObjectInfoPrivate(QGeoMapData *mapData, QGeoMapObject *mapObject)
+ : mapData(mapData),
+ mapObject(mapObject) {}
+
+QGeoMapObjectInfoPrivate::~QGeoMapObjectInfoPrivate() {}
+
+/*******************************************************************************
+*******************************************************************************/
+
+#include "moc_qgeomapobjectinfo.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomapobjectinfo.h b/src/location/maps/qgeomapobjectinfo.h
new file mode 100644
index 00000000..69b2b72c
--- /dev/null
+++ b/src/location/maps/qgeomapobjectinfo.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTINFO_H
+#define QGEOMAPOBJECTINFO_H
+
+#include "qmobilityglobal.h"
+#include "qgeomapobject.h"
+
+#include <QObject>
+#include <QSizeF>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBox;
+
+class QGeoMapData;
+class QGeoMapObject;
+class QGeoMapObjectInfoPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapObjectInfo : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoMapObjectInfo(QGeoMapData *mapData, QGeoMapObject *mapObject);
+ virtual ~QGeoMapObjectInfo();
+
+ virtual void init();
+
+ virtual QGeoBoundingBox boundingBox() const;
+ virtual bool contains(const QGeoCoordinate &coordinate) const;
+
+public slots:
+ virtual void windowSizeChanged(const QSizeF &windowSize);
+ virtual void zoomLevelChanged(qreal zoomLevel);
+ virtual void centerChanged(const QGeoCoordinate &coordinate);
+
+ virtual void zValueChanged(int zValue);
+ virtual void visibleChanged(bool visible);
+ virtual void selectedChanged(bool selected);
+
+ virtual void originChanged(const QGeoCoordinate &origin);
+ virtual void unitsChanged(QGeoMapObject::CoordinateUnit units);
+ virtual void transformTypeChanged(QGeoMapObject::TransformType transformType);
+
+protected:
+ QGeoMapData* mapData();
+ QGeoMapObject* mapObject();
+ QGeoMapObject* mapObject() const;
+
+private:
+ QGeoMapObjectInfoPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoMapObjectInfo)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapobjectinfo_p.h b/src/location/maps/qgeomapobjectinfo_p.h
new file mode 100644
index 00000000..483534b1
--- /dev/null
+++ b/src/location/maps/qgeomapobjectinfo_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTINFO_P_H
+#define QGEOMAPOBJECTINFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapObject;
+class QGeoMapData;
+
+class QGeoMapObjectInfoPrivate
+{
+public:
+ QGeoMapObjectInfoPrivate(QGeoMapData *mapData, QGeoMapObject *mapObject);
+ virtual ~QGeoMapObjectInfoPrivate();
+
+ QGeoMapData* mapData;
+ QGeoMapObject* mapObject;
+
+private:
+ Q_DISABLE_COPY(QGeoMapObjectInfoPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapoverlay.cpp b/src/location/maps/qgeomapoverlay.cpp
new file mode 100644
index 00000000..5d5fa582
--- /dev/null
+++ b/src/location/maps/qgeomapoverlay.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapoverlay.h"
+#include "qgeomapoverlay_p.h"
+
+#include "qgeomapdata.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapOverlay
+ \brief The QGeoMapOverlay class is used to draw overlays on the map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping
+
+ This allows for general drawing to occur in overlays above the map.
+*/
+
+/*!
+ Constructs a new map overlay object.
+*/
+QGeoMapOverlay::QGeoMapOverlay()
+ : d_ptr(new QGeoMapOverlayPrivate()) {}
+
+/*!
+ Destroys this map overlay object.
+*/
+QGeoMapOverlay::~QGeoMapOverlay()
+{
+ delete d_ptr;
+}
+
+/*!
+\fn void QGeoMapOverlay::paint(QPainter *painter, const QStyleOptionGraphicsItem *option)
+
+Paints the overlay on \a painter, using the options \a option.
+*/
+
+/*!
+ \internal
+*/
+void QGeoMapOverlay::setMapData(QGeoMapData * mapData)
+{
+ d_ptr->mapData = mapData;
+}
+
+/*!
+ Returns the QGeoMapData instance that this overlay is associated, or 0
+ if there is not such instance.
+
+ The QGeoMapData instance provides access to information such as the
+ zoom level and viewport position as well as methods to convert
+ screen positions to coordinates and vice-versa.
+*/
+QGeoMapData const * QGeoMapOverlay::mapData() const
+{
+ return d_ptr->mapData;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapOverlayPrivate::QGeoMapOverlayPrivate()
+ : mapData(0) {}
+
+
+QGeoMapOverlayPrivate::~QGeoMapOverlayPrivate() {}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomapoverlay.h b/src/location/maps/qgeomapoverlay.h
new file mode 100644
index 00000000..262e4c3c
--- /dev/null
+++ b/src/location/maps/qgeomapoverlay.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOVERLAY_H
+#define QGEOMAPOVERLAY_H
+
+#include "qmobilityglobal.h"
+
+#include <QList>
+#include <QObject>
+
+class QPainter;
+class QStyleOptionGraphicsItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapData;
+class QGeoMapOverlayPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapOverlay
+{
+public:
+ QGeoMapOverlay();
+ virtual ~QGeoMapOverlay();
+
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option) = 0;
+
+protected:
+ QGeoMapData const * mapData() const;
+
+private:
+ void setMapData(QGeoMapData * mapData);
+
+ QGeoMapOverlayPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapOverlay)
+ Q_DISABLE_COPY(QGeoMapOverlay)
+
+ friend class QGeoMapData;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomapoverlay_p.h b/src/location/maps/qgeomapoverlay_p.h
new file mode 100644
index 00000000..b8d4c901
--- /dev/null
+++ b/src/location/maps/qgeomapoverlay_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOVERLAY_P_H
+#define QGEOMAPOVERLAY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapData;
+
+class QGeoMapOverlayPrivate
+{
+public:
+ QGeoMapOverlayPrivate();
+ virtual ~QGeoMapOverlayPrivate();
+
+ QGeoMapData *mapData;
+
+private:
+ Q_DISABLE_COPY(QGeoMapOverlayPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappingmanager.cpp b/src/location/maps/qgeomappingmanager.cpp
new file mode 100644
index 00000000..3bac9036
--- /dev/null
+++ b/src/location/maps/qgeomappingmanager.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomappingmanager.h"
+#include "qgeomappingmanager_p.h"
+#include "qgeomappingmanagerengine.h"
+
+#include <QNetworkProxy>
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMappingManager
+ \brief The QGeoMappingManager class provides support for displaying
+ and interacting with maps.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping
+
+ A QGeoMappingManager instance can create QGeoMapData instances with
+ createMapData(). The QGeoMapData instances can be used to contain and
+ manage information concerning what a particular QGraphicsGeoMap is viewing.
+
+ The functions in this class will typically not be used by clients of this
+ API, as the most common uses will only need to obtain a QGeoMappingManager
+ instance and associate it with a QGraphicsGeoMap instance:
+ \code
+ QGeoServiceProvider serviceProvider("nokia");
+ QGeoMappingManager *manager = serviceProvider.mappingManager();
+ QGraphicsGeoMap *geoMap = new QGraphicsGeoMap(manager);
+ \endcode
+
+ This could have been simplified by having the plugin return a
+ QGraphicsGeoMap instance instead, but this approach allows users to
+ subclass QGraphicsGeoMap in order to override the standard event handlers
+ and implement custom map behaviours.
+*/
+
+/*!
+ Constructs a new manager with the specified \a parent and with the
+ implementation provided by \a engine.
+
+ This constructor is used internally by QGeoServiceProviderFactory. Regular
+ users should acquire instances of QGeoMappingManager with
+ QGeoServiceProvider::mappingManager()
+*/
+QGeoMappingManager::QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoMappingManagerPrivate)
+{
+ d_ptr->engine = engine;
+ if (d_ptr->engine) {
+ d_ptr->engine->setParent(this);
+ } else {
+ qFatal("The mapping manager engine that was set for this mapping manager was NULL.");
+ }
+}
+
+/*!
+ Destroys this mapping manager.
+*/
+QGeoMappingManager::~QGeoMappingManager()
+{
+ delete d_ptr;
+}
+
+/*!
+ Returns the name of the engine which implements the behaviour of this
+ mapping manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+QString QGeoMappingManager::managerName() const
+{
+ return d_ptr->engine->managerName();
+}
+
+/*!
+ Returns the version of the engine which implements the behaviour of this
+ mapping manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+int QGeoMappingManager::managerVersion() const
+{
+ return d_ptr->engine->managerVersion();
+}
+
+/*!
+ Returns a new QGeoMapData instance which will be managed by this manager.
+*/
+QGeoMapData* QGeoMappingManager::createMapData()
+{
+ return d_ptr->engine->createMapData();
+}
+
+/*!
+ Returns a list of the map types supported by this manager.
+*/
+QList<QGraphicsGeoMap::MapType> QGeoMappingManager::supportedMapTypes() const
+{
+ return d_ptr->engine->supportedMapTypes();
+}
+
+/*!
+ Returns a list of the connectivity modes supported by this manager.
+*/
+QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManager::supportedConnectivityModes() const
+{
+ return d_ptr->engine->supportedConnectivityModes();
+}
+
+/*!
+ Returns the minimum zoom level supported by this manager.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGeoMappingManager::minimumZoomLevel() const
+{
+ return d_ptr->engine->minimumZoomLevel();
+}
+
+/*!
+ Returns the maximum zoom level supported by this manager.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGeoMappingManager::maximumZoomLevel() const
+{
+ return d_ptr->engine->maximumZoomLevel();
+}
+
+/*!
+ Return whether bearing is supported by this manager.
+*/
+bool QGeoMappingManager::supportsBearing() const
+{
+ return d_ptr->engine->supportsBearing();
+}
+
+/*!
+ Return whether tilting is supported by this manager.
+*/
+bool QGeoMappingManager::supportsTilting() const
+{
+ return d_ptr->engine->supportsTilting();
+}
+
+/*!
+ Returns minimum tilt supported by this manager.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGeoMappingManager::minimumTilt() const
+{
+ return d_ptr->engine->minimumTilt();
+}
+
+/*!
+ Returns maximum tilt supported by this manager.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGeoMappingManager::maximumTilt() const
+{
+ return d_ptr->engine->maximumTilt();
+}
+
+/*!
+ Returns whether custom map objects are supported by this engine.
+
+ Custom map objects are map objects based on QGraphicsItem instances, which
+ are hard to support in cases where the map rendering is not being
+ performed by the Qt Graphics View framwork.
+*/
+bool QGeoMappingManager::supportsCustomMapObjects() const
+{
+ return d_ptr->engine->supportsCustomMapObjects();
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this mapping manager supports returning map labels
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoMappingManager::setLocale(const QLocale &locale)
+{
+ d_ptr->engine->setLocale(locale);
+}
+
+/*!
+ Returns the locale used to hint to this mapping manager about what
+ language to use for map labels.
+*/
+QLocale QGeoMappingManager::locale() const
+{
+ return d_ptr->engine->locale();
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMappingManagerPrivate::QGeoMappingManagerPrivate()
+ : engine(0) {}
+
+QGeoMappingManagerPrivate::~QGeoMappingManagerPrivate()
+{
+ if (engine)
+ delete engine;
+}
+
+#include "moc_qgeomappingmanager.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomappingmanager.h b/src/location/maps/qgeomappingmanager.h
new file mode 100644
index 00000000..192c32b1
--- /dev/null
+++ b/src/location/maps/qgeomappingmanager.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPINGMANAGER_H
+#define QGEOMAPPINGMANAGER_H
+
+#include "qgraphicsgeomap.h"
+
+#include <QObject>
+#include <QSize>
+#include <QPair>
+
+class QLocale;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoBoundingBox;
+class QGeoCoordinate;
+class QGeoMapData;
+class QGeoMappingManagerPrivate;
+class QGeoMapRequestOptions;
+
+class QGeoMappingManagerEngine;
+
+class Q_LOCATION_EXPORT QGeoMappingManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ ~QGeoMappingManager();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ QGeoMapData* createMapData();
+
+ QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
+ QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
+
+ qreal minimumZoomLevel() const;
+ qreal maximumZoomLevel() const;
+
+ bool supportsBearing() const;
+
+ bool supportsTilting() const;
+ qreal minimumTilt() const;
+ qreal maximumTilt() const;
+
+ bool supportsCustomMapObjects() const;
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+private:
+ QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject *parent = 0);
+
+ QGeoMappingManagerPrivate* d_ptr;
+ Q_DISABLE_COPY(QGeoMappingManager)
+
+ friend class QGeoServiceProvider;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappingmanager_p.h b/src/location/maps/qgeomappingmanager_p.h
new file mode 100644
index 00000000..4249786a
--- /dev/null
+++ b/src/location/maps/qgeomappingmanager_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPINGMANAGER_P_H
+#define QGEOMAPPINGMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgraphicsgeomap.h"
+
+#include <QSize>
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMappingManagerEngine;
+
+class QGeoMappingManagerPrivate
+{
+public:
+ QGeoMappingManagerPrivate();
+ ~QGeoMappingManagerPrivate();
+
+ QGeoMappingManagerEngine *engine;
+
+private:
+ Q_DISABLE_COPY(QGeoMappingManagerPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
new file mode 100644
index 00000000..72d3002b
--- /dev/null
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -0,0 +1,431 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomappingmanagerengine.h"
+#include "qgeomappingmanagerengine_p.h"
+
+#include <QNetworkProxy>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMappingManagerEngine
+ \brief The QGeoMappingManagerEngine class provides an interface and convenience methods
+ to implementors of QGeoServiceProvider plugins who want to provides support for displaying
+ and interacting with maps.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ Subclasses of QGeoMappingManagerEngine need to provide an implementations
+ of createMapData(). The QGeoMapData instances returned by createMapData()
+ can be used to contain and manage information concerning what a particular
+ QGraphicsGeoMap is viewing.
+
+ Most of the other functions configure the reported capabilities of the engine.
+ It is important that these functions are called before createMapData() or any of the
+ capability reporting functions are used to prevent incorrect or
+ inconsistent behaviour.
+*/
+
+/*!
+ Constructs a new engine with the specified \a parent, using \a parameters
+ to pass any implementation specific data to the engine.
+*/
+QGeoMappingManagerEngine::QGeoMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoMappingManagerEnginePrivate())
+{
+ Q_UNUSED(parameters)
+}
+
+/*!
+ \internal
+*/
+QGeoMappingManagerEngine::QGeoMappingManagerEngine(QGeoMappingManagerEnginePrivate *dd, QObject *parent)
+ : QObject(parent),
+ d_ptr(dd) {}
+
+/*!
+ Destroys this engine.
+*/
+QGeoMappingManagerEngine::~QGeoMappingManagerEngine()
+{
+ Q_D(QGeoMappingManagerEngine);
+ delete d;
+}
+
+/*!
+ Sets the name which this engine implementation uses to distinguish itself
+ from the implementations provided by other plugins to \a managerName.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoMappingManagerEngine::setManagerName(const QString &managerName)
+{
+ d_ptr->managerName = managerName;
+}
+
+/*!
+ Returns the name which this engine implementation uses to distinguish
+ itself from the implementations provided by other plugins.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+QString QGeoMappingManagerEngine::managerName() const
+{
+ return d_ptr->managerName;
+}
+
+/*!
+ Sets the version of this engine implementation to \a managerVersion.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoMappingManagerEngine::setManagerVersion(int managerVersion)
+{
+ d_ptr->managerVersion = managerVersion;
+}
+
+/*!
+ Returns the version of this engine implementation.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+int QGeoMappingManagerEngine::managerVersion() const
+{
+ return d_ptr->managerVersion;
+}
+
+/*!
+\fn QGeoMapData* QGeoMappingManagerEngine::createMapData()
+
+ Returns a new QGeoMapData instance which will be managed by
+ this manager.
+
+ A QGeoMapData instance contains and manages the information about
+ what a QGraphicsGeoMap is looking at. A single manager can be used by several
+ QGraphicsGeoMap instances since each instance has an associated QGeoMapData instance.
+
+ The QGeoMapData instance can be treated as a kind of session object, or
+ as a model in a model-view-controller architecture, with QGraphicsGeoMap
+ as the view and QGeoMappingManagerEngine as the controller.
+
+ Subclasses of QGeoMappingManagerEngine are free to override this function
+ to return subclasses of QGeoMapData in order to customize the
+ map.
+*/
+
+/*!
+ Returns a list of the map types supported by this engine.
+*/
+QList<QGraphicsGeoMap::MapType> QGeoMappingManagerEngine::supportedMapTypes() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->supportedMapTypes;
+}
+
+/*!
+ Returns a list of the connectivity modes supported by this engine.
+*/
+QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManagerEngine::supportedConnectivityModes() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->supportedConnectivityModes;
+}
+
+/*!
+ Returns the minimum zoom level supported by this engine.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGeoMappingManagerEngine::minimumZoomLevel() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->minimumZoomLevel;
+}
+
+/*!
+ Returns the maximum zoom level supported by this engine.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGeoMappingManagerEngine::maximumZoomLevel() const
+
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->maximumZoomLevel;
+}
+
+/*!
+ Sets the list of map types supported by this engine to \a mapTypes.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ that supportedMapTypes() provides accurate information.
+*/
+void QGeoMappingManagerEngine::setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->supportedMapTypes = mapTypes;
+}
+
+/*!
+ Sets the list of connectivity modes supported by this engine to \a connectivityModes.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ that supportedConnectivityModes() provides accurate information.
+
+ If createMapData does not specify a connectivity mode the first mode from
+ \a connectivityModes will be used, or QGraphicsGeoMap::NoConnectivity will
+ be used if \a connectivityModes is empty.
+*/
+void QGeoMappingManagerEngine::setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->supportedConnectivityModes = connectivityModes;
+}
+
+/*!
+ Sets the minimum zoom level supported by this engine to \a minimumZoom.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ minimumZoomLevel() provides accurate information.
+*/
+void QGeoMappingManagerEngine::setMinimumZoomLevel(qreal minimumZoom)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->minimumZoomLevel = minimumZoom;
+}
+
+/*!
+ Sets the maximum zoom level supported by this engine to \a maximumZoom.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ maximumZoomLevel() provides accurate information.
+*/
+void QGeoMappingManagerEngine::setMaximumZoomLevel(qreal maximumZoom)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->maximumZoomLevel = maximumZoom;
+}
+
+/*!
+ Return whether bearing is supported by this engine.
+*/
+bool QGeoMappingManagerEngine::supportsBearing() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->supportsBearing;
+}
+
+/*!
+ Return whether tilting is supported by this engine.
+*/
+bool QGeoMappingManagerEngine::supportsTilting() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->supportsTilting;
+}
+
+/*!
+ Returns the minimum tilt supported by this engine.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGeoMappingManagerEngine::minimumTilt() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->minimumTilt;
+}
+
+/*!
+ Returns the maximum tilt supported by this engine.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGeoMappingManagerEngine::maximumTilt() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->maximumTilt;
+}
+
+/*!
+ Sets the minimum tilt supported by this engine to \a minimumTilt.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ minimumTilt() provides accurate information. If no minimum value is set
+ by the subclass the value of 0 is used.
+*/
+void QGeoMappingManagerEngine::setMinimumTilt(qreal minimumTilt)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->minimumTilt = minimumTilt;
+}
+
+/*!
+ Sets the maximum tilt supported by this engine to \a maximumTilt.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ maximumTilt() provides accurate information. If no maximum value is set
+ by the subclass the value of 0 is used.
+*/
+void QGeoMappingManagerEngine::setMaximumTilt(qreal maximumTilt)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->maximumTilt = maximumTilt;
+}
+
+/*!
+ Sets whether bearing is supported by this engine to \a supportsBearing.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ supportsBearing() provides accurate information. If no value is set
+ by the subclass then bearing support is disabled and supportsBearing set
+ to false.
+*/
+void QGeoMappingManagerEngine::setSupportsBearing(bool supportsBearing)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->supportsBearing = supportsBearing;
+}
+
+/*!
+ Sets whether tilting is supported by this engine to \a supportsTilting.
+
+ Subclasses of QGeoMappingManagerEngine should use this function to ensure
+ supportsTilting() provides accurate information. If no value is set
+ by the subclass then tilting support is disabled and supportsTilting set
+ to false.
+*/
+void QGeoMappingManagerEngine::setSupportsTilting(bool supportsTilting)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->supportsTilting = supportsTilting;
+}
+
+/*!
+ Returns whether custom map objects are supported by this engine.
+
+ Custom map objects are map objects based on QGraphicsItem instances, which
+ are hard to support in cases where the map rendering is not being
+ performed by the Qt Graphics View framwork.
+*/
+bool QGeoMappingManagerEngine::supportsCustomMapObjects() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d_ptr->supportsCustomMapObjects;
+}
+
+/*!
+ Sets whether custom map objects are supported by this engine to \a supportsCustomMapObjects.
+
+ Custom map objects are map objects based on QGraphicsItem instances, which
+ are hard to support in cases where the map rendering is not being
+ performed by the Qt Graphics View framwork.
+*/
+void QGeoMappingManagerEngine::setSupportsCustomMapObjects(bool supportsCustomMapObjects)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d_ptr->supportsCustomMapObjects = supportsCustomMapObjects;
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this mapping manager supports returning map labels
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoMappingManagerEngine::setLocale(const QLocale &locale)
+{
+ d_ptr->locale = locale;
+}
+
+/*!
+ Returns the locale used to hint to this mapping manager about what
+ language to use for map labels.
+*/
+QLocale QGeoMappingManagerEngine::locale() const
+{
+ return d_ptr->locale;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMappingManagerEnginePrivate::QGeoMappingManagerEnginePrivate()
+ : managerVersion(-1),
+ minimumZoomLevel(0.0),
+ maximumZoomLevel(0.0),
+ supportsBearing(false),
+ supportsTilting(false),
+ minimumTilt(0.0),
+ maximumTilt(0.0),
+ supportsCustomMapObjects(false) {}
+
+QGeoMappingManagerEnginePrivate::~QGeoMappingManagerEnginePrivate() {}
+
+#include "moc_qgeomappingmanagerengine.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeomappingmanagerengine.h b/src/location/maps/qgeomappingmanagerengine.h
new file mode 100644
index 00000000..6a35a493
--- /dev/null
+++ b/src/location/maps/qgeomappingmanagerengine.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPINGMANAGERENGINE_H
+#define QGEOMAPPINGMANAGERENGINE_H
+
+#include "qgraphicsgeomap.h"
+
+#include <QObject>
+#include <QSize>
+#include <QPair>
+
+class QLocale;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoBoundingBox;
+class QGeoCoordinate;
+class QGeoMapData;
+class QGeoMappingManagerPrivate;
+class QGeoMapRequestOptions;
+
+class QGeoMappingManagerEnginePrivate;
+
+class Q_LOCATION_EXPORT QGeoMappingManagerEngine : public QObject
+{
+ Q_OBJECT
+
+public:
+ QGeoMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ virtual ~QGeoMappingManagerEngine();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ virtual QGeoMapData* createMapData() = 0;
+
+ QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
+ QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
+
+ qreal minimumZoomLevel() const;
+ qreal maximumZoomLevel() const;
+
+ bool supportsBearing() const;
+
+ bool supportsTilting() const;
+ qreal minimumTilt() const;
+ qreal maximumTilt() const;
+
+ bool supportsCustomMapObjects() const;
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+protected:
+ QGeoMappingManagerEngine(QGeoMappingManagerEnginePrivate *dd, QObject *parent = 0);
+
+ void setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes);
+ void setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes);
+
+ void setMinimumZoomLevel(qreal minimumZoom);
+ void setMaximumZoomLevel(qreal maximumZoom);
+
+ void setMaximumTilt(qreal maximumTilt);
+ void setMinimumTilt(qreal minimumTilt);
+
+ void setSupportsBearing(bool supportsBearing);
+ void setSupportsTilting(bool supportsTilting);
+
+ void setSupportsCustomMapObjects(bool supportsCustomMapObjects);
+
+ QGeoMappingManagerEnginePrivate* d_ptr;
+
+private:
+ void setManagerName(const QString &managerName);
+ void setManagerVersion(int managerVersion);
+
+ Q_DECLARE_PRIVATE(QGeoMappingManagerEngine)
+ Q_DISABLE_COPY(QGeoMappingManagerEngine)
+
+ friend class QGeoServiceProvider;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h
new file mode 100644
index 00000000..d0890ce0
--- /dev/null
+++ b/src/location/maps/qgeomappingmanagerengine_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPINGMANAGERENGINE_P_H
+#define QGEOMAPPINGMANAGERENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgraphicsgeomap.h"
+
+#include <QSize>
+#include <QList>
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMappingManagerEnginePrivate
+{
+public:
+ QGeoMappingManagerEnginePrivate();
+ virtual ~QGeoMappingManagerEnginePrivate();
+
+ QString managerName;
+ int managerVersion;
+
+ QList<QGraphicsGeoMap::MapType> supportedMapTypes;
+ QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes;
+ qreal minimumZoomLevel;
+ qreal maximumZoomLevel;
+ bool supportsBearing;
+ bool supportsTilting;
+ qreal minimumTilt;
+ qreal maximumTilt;
+ bool supportsCustomMapObjects;
+
+ QLocale locale;
+
+private:
+ Q_DISABLE_COPY(QGeoMappingManagerEnginePrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappixmapobject.cpp b/src/location/maps/qgeomappixmapobject.cpp
new file mode 100644
index 00000000..0109cea4
--- /dev/null
+++ b/src/location/maps/qgeomappixmapobject.cpp
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomappixmapobject.h"
+#include "qgeomappixmapobject_p.h"
+#include "qgeoboundingbox.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapPixmapObject
+ \brief The QGeoMapPixmapObject class is a QGeoMapObject used to draw
+ a pixmap on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The pixmap object is rendered such that the upper left corner of
+ QGeoMapPixmapObject::pixmap will be drawn QGeoMapPixmapObject::offset
+ pixels away from the position of QGeoMapPixmapObject::coordinate on the
+ map.
+*/
+
+/*!
+ Constructs a new pixmap object.
+*/
+QGeoMapPixmapObject::QGeoMapPixmapObject()
+ : d_ptr(new QGeoMapPixmapObjectPrivate())
+{
+}
+
+/*!
+ Constructs a new pixmap object which will draw the pixmap \a pixmap at an
+ offset of \a offset pixels from the coordinate \a coordinate.
+*/
+QGeoMapPixmapObject::QGeoMapPixmapObject(const QGeoCoordinate &coordinate, const QPoint &offset, const QPixmap &pixmap)
+ : d_ptr(new QGeoMapPixmapObjectPrivate())
+{
+ setOrigin(coordinate);
+ d_ptr->pixmap = pixmap;
+ d_ptr->offset = offset;
+}
+
+/*!
+ Destroys this pixmap object.
+*/
+QGeoMapPixmapObject::~QGeoMapPixmapObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapPixmapObject::type() const
+{
+ return QGeoMapObject::PixmapType;
+}
+
+/*!
+ \property QGeoMapPixmapObject::coordinate
+ \brief This property holds the coordinate that specifies where the pixmap
+ will be drawn by this pixmap object.
+
+ The default value of this property is an invalid coordinate. While the
+ value of this property is invalid the pixmap object will not be displayed.
+*/
+QGeoCoordinate QGeoMapPixmapObject::coordinate() const
+{
+ return origin();
+}
+
+void QGeoMapPixmapObject::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ if (origin() != coordinate) {
+ setOrigin(coordinate);
+ emit coordinateChanged(coordinate);
+ }
+}
+
+/*!
+ \property QGeoMapPixmapObject::pixmap
+ \brief This property holds the pixmap that will be drawn by this pixmap
+ object.
+
+ The default value of this property is a null pixmap. While the value of
+ this property is the null pixmap the pixmap object will not be displayed.
+
+ The pixmap will be drawn such that the upper left corner of the pixmap
+ will be drawn QGeoMapPixmapObject::offset pixels away from the position of
+ QGeoMapPixmapObject::coordinate on the map.
+*/
+QPixmap QGeoMapPixmapObject::pixmap() const
+{
+ return d_ptr->pixmap;
+}
+
+void QGeoMapPixmapObject::setPixmap(const QPixmap &pixmap)
+{
+ QPixmap curPixmap = d_ptr->pixmap;
+ if (curPixmap.isNull() && pixmap.isNull())
+ return;
+
+ if ((curPixmap.isNull() && !pixmap.isNull())
+ || (!curPixmap.isNull() && pixmap.isNull())
+ || (curPixmap.toImage() != pixmap.toImage())) {
+ d_ptr->pixmap = pixmap;
+ emit pixmapChanged(pixmap);
+ }
+}
+
+/*!
+ \property QGeoMapPixmapObject::offset
+ \brief This property holds the offset in pixels at which the pixmap will be
+ drawn by this pixmap object.
+
+ The default value of this property is QPoint(0, 0). If this value is not
+ changed the upper left coordinate of the pixmap will be drawn at the
+ coordinate specified by QGeoMapPixmapObject::coordinate.
+
+ The offset is in pixels and is independent of the zoom level of the map.
+ The offset property is provided so that pixmaps such as arrows can be drawn
+ with the point of the arrow placed exactly on the associated coordinate.
+*/
+QPoint QGeoMapPixmapObject::offset() const
+{
+ return d_ptr->offset;
+// QPointF pt = d_ptr->offset;
+//
+// QPoint rounded;
+// rounded.setX(int(pt.x() > 0 ? pt.x() + 0.5 : pt.x() - 0.5));
+// rounded.setY(int(pt.y() > 0 ? pt.y() + 0.5 : pt.y() - 0.5));
+//
+// return rounded;
+}
+
+void QGeoMapPixmapObject::setOffset(const QPoint &offset)
+{
+ if (d_ptr->offset != offset) {
+ d_ptr->offset = offset;
+ emit offsetChanged(offset);
+ }
+}
+
+/*!
+\fn void QGeoMapPixmapObject::coordinateChanged(const QGeoCoordinate &coordinate)
+
+ This signal is emitted when the coordinate at which the pixmap
+ should be drawn has changed.
+
+ The new value will be \a coordinate.
+*/
+
+/*!
+\fn void QGeoMapPixmapObject::pixmapChanged(const QPixmap &pixmap)
+
+ This signal is emitted when the pixmap associated with this
+ pixmap object has changed.
+
+ The new value will be \a pixmap.
+*/
+
+/*!
+\fn void QGeoMapPixmapObject::offsetChanged(const QPoint &offset)
+
+ This signal is emitted when the on-screen offset from the coordinate
+ at which this pixmap object should be drawn has changed.
+
+ The new value will be \a offset.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapPixmapObjectPrivate::QGeoMapPixmapObjectPrivate() {}
+
+QGeoMapPixmapObjectPrivate::~QGeoMapPixmapObjectPrivate() {}
+
+#include "moc_qgeomappixmapobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomappixmapobject.h b/src/location/maps/qgeomappixmapobject.h
new file mode 100644
index 00000000..31fbcceb
--- /dev/null
+++ b/src/location/maps/qgeomappixmapobject.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPIXMAPOBJECT_H
+#define QGEOMAPPIXMAPOBJECT_H
+
+#include "qgeomapobject.h"
+#include "qgeocoordinate.h"
+
+#include <QPixmap>
+#include <QPoint>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPixmapObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapPixmapObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
+ Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged)
+ Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
+
+public:
+ QGeoMapPixmapObject();
+ QGeoMapPixmapObject(const QGeoCoordinate &coordinate, const QPoint &offset = QPoint(0, 0), const QPixmap &pixmap = QPixmap());
+ ~QGeoMapPixmapObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoCoordinate coordinate() const;
+ void setCoordinate(const QGeoCoordinate &coordinate);
+
+ QPixmap pixmap() const;
+ void setPixmap(const QPixmap &pixmap);
+
+ QPoint offset() const;
+ void setOffset(const QPoint &offset);
+
+Q_SIGNALS:
+ void coordinateChanged(const QGeoCoordinate &coordinate);
+ void pixmapChanged(const QPixmap &pixmap);
+ void offsetChanged(const QPoint &offset);
+
+private:
+ QGeoMapPixmapObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapPixmapObject)
+ Q_DISABLE_COPY(QGeoMapPixmapObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappixmapobject_p.h b/src/location/maps/qgeomappixmapobject_p.h
new file mode 100644
index 00000000..ed4bcf08
--- /dev/null
+++ b/src/location/maps/qgeomappixmapobject_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPIXMAPOBJECT_P_H
+#define QGEOMAPPIXMAPOBJECT_P_H
+
+#include "qgeocoordinate.h"
+
+#include <QPixmap>
+#include <QPoint>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPixmapObjectPrivate
+{
+public:
+ QGeoMapPixmapObjectPrivate();
+ ~QGeoMapPixmapObjectPrivate();
+
+ QPixmap pixmap;
+ QPoint offset;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappolygonobject.cpp b/src/location/maps/qgeomappolygonobject.cpp
new file mode 100644
index 00000000..d7c5d6b7
--- /dev/null
+++ b/src/location/maps/qgeomappolygonobject.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomappolygonobject.h"
+#include "qgeomappolygonobject_p.h"
+
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapPolygonObject
+ \brief The QGeoMapPolygonObject class is a QGeoMapObject used to draw
+ a polygon on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The polygon is specified by a set of at least 3 valid QGeoCoordinate
+ instances listed in the same order in which the coordinates would be
+ traversed when traveling around the border of the polygon.
+*/
+
+/*!
+ Constructs a new polygon object.
+*/
+QGeoMapPolygonObject::QGeoMapPolygonObject()
+ : d_ptr(new QGeoMapPolygonObjectPrivate())
+{
+ setUnits(QGeoMapObject::RelativeArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Destroys this polygon object.
+*/
+QGeoMapPolygonObject::~QGeoMapPolygonObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapPolygonObject::type() const
+{
+ return QGeoMapObject::PolygonType;
+}
+
+/*!
+ \property QGeoMapPolygonObject::path
+ \brief This property holds the ordered list of coordinates which define the
+ polygon to be drawn by this polygon object.
+
+ The default value of this property is an empty list of coordinates.
+
+ The coordinates should be listed in the order in which they would be
+ traversed when traveling around the border of the polygon.
+
+ Invalid coordinates in the list will be ignored, and if the list of
+ coordinates contains less than 3 valid coordinates then the polygon object
+ will not be displayed.
+
+*/
+void QGeoMapPolygonObject::setPath(const QList<QGeoCoordinate> &path)
+{
+ if (d_ptr->path != path) {
+ d_ptr->path = path;
+ setOrigin(path.at(0));
+ emit pathChanged(emit d_ptr->path);
+ }
+}
+
+QList<QGeoCoordinate> QGeoMapPolygonObject::path() const
+{
+ return d_ptr->path;
+}
+
+/*!
+ \property QGeoMapPolygonObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw an outline around the polygon. The polygon is
+ filled using the QGeoMapPolygonObject::brush property.
+
+ The pen will be treated as a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+void QGeoMapPolygonObject::setPen(const QPen &pen)
+{
+
+ QPen newPen = pen;
+ newPen.setCosmetic(true);
+
+ if (d_ptr->pen == newPen)
+ return;
+
+ d_ptr->pen = pen;
+ emit penChanged(pen);
+}
+
+QPen QGeoMapPolygonObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+/*!
+ \property QGeoMapPolygonObject::brush
+ \brief This property holds the brush that will be used to draw this object.
+
+ The brush is used to fill in polygon.
+
+ The outline around the perimeter of the polygon is drawn using the
+ QGeoMapPolygonObject::pen property.
+*/
+void QGeoMapPolygonObject::setBrush(const QBrush &brush)
+{
+ if (d_ptr->brush != brush) {
+ d_ptr->brush = brush;
+ emit brushChanged(brush);
+ }
+}
+
+QBrush QGeoMapPolygonObject::brush() const
+{
+ return d_ptr->brush;
+}
+
+/*!
+\fn void QGeoMapPolygonObject::pathChanged(const QList<QGeoCoordinate> &path)
+
+ This signal is emitted when the ordered list of coordinates that define
+ the polygon to be drawn by this polygon object has changed.
+
+ The new value is \a path.
+*/
+
+/*!
+\fn void QGeoMapPolygonObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw the edge of this
+ polygon object has changed.
+
+ The new value is \a pen.
+*/
+
+/*!
+\fn void QGeoMapPolygonObject::brushChanged(const QBrush &brush)
+
+ This signal is emitted when the brush used to fill in the interior of
+ this polygon object has changed.
+
+ The new value is \a brush.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapPolygonObjectPrivate::QGeoMapPolygonObjectPrivate()
+{
+ pen.setCosmetic(true);
+}
+
+QGeoMapPolygonObjectPrivate::~QGeoMapPolygonObjectPrivate() {}
+
+#include "moc_qgeomappolygonobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomappolygonobject.h b/src/location/maps/qgeomappolygonobject.h
new file mode 100644
index 00000000..d2c185f2
--- /dev/null
+++ b/src/location/maps/qgeomappolygonobject.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPOLYGONOBJECT_H
+#define QGEOMAPPOLYGONOBJECT_H
+
+#include "qgeomapobject.h"
+
+#include <QList>
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPolygonObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapPolygonObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
+
+public:
+ QGeoMapPolygonObject();
+ ~QGeoMapPolygonObject();
+
+ QGeoMapObject::Type type() const;
+
+ void setPath(const QList<QGeoCoordinate> &path);
+ QList<QGeoCoordinate> path() const;
+
+ void setPen(const QPen &pen);
+ QPen pen() const;
+
+ void setBrush(const QBrush &brush);
+ QBrush brush() const;
+
+Q_SIGNALS:
+ void pathChanged(const QList<QGeoCoordinate> &path);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+
+private:
+ QGeoMapPolygonObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapPolygonObject)
+ Q_DISABLE_COPY(QGeoMapPolygonObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappolygonobject_p.h b/src/location/maps/qgeomappolygonobject_p.h
new file mode 100644
index 00000000..69bb09ae
--- /dev/null
+++ b/src/location/maps/qgeomappolygonobject_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPOLYGONOBJECT_P_H
+#define QGEOMAPPOLYGONOBJECT_P_H
+
+#include "qgeocoordinate.h"
+
+#include <QList>
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPolygonObjectPrivate
+{
+public:
+ QGeoMapPolygonObjectPrivate();
+ ~QGeoMapPolygonObjectPrivate();
+
+ QList<QGeoCoordinate> path;
+ QPen pen;
+ QBrush brush;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappolylineobject.cpp b/src/location/maps/qgeomappolylineobject.cpp
new file mode 100644
index 00000000..96f77bc7
--- /dev/null
+++ b/src/location/maps/qgeomappolylineobject.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomappolylineobject.h"
+#include "qgeomappolylineobject_p.h"
+
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapPolylineObject
+ \brief The QGeoMapPolylineObject class is a QGeoMapObject used to draw
+ a segmented line on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The polyline is specified by a list of at least 2 valid QGeoCoordinate
+ instances and a line will be drawn between every adjacent pairs of
+ coordinates in the list.
+*/
+
+/*!
+ Constructs a new polyline object.
+*/
+QGeoMapPolylineObject::QGeoMapPolylineObject()
+ : d_ptr(new QGeoMapPolylineObjectPrivate())
+{
+ setUnits(QGeoMapObject::RelativeArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Destroys this polyline object.
+*/
+QGeoMapPolylineObject::~QGeoMapPolylineObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapPolylineObject::type() const
+{
+ return QGeoMapObject::PolylineType;
+}
+
+/*!
+ \property QGeoMapPolylineObject::path
+ \brief This property holds the ordered list of coordinates which define the
+ segmented line to be drawn by this polyline object.
+
+ The default value of this property is an empty list of coordinates.
+
+ A line will be drawn between every pair of coordinates which are adjacent in
+ the list.
+
+ Invalid coordinates in the list will be ignored, and if the list of
+ coordinates contains less than 2 valid coordinates then the polyline object
+ will not be displayed.
+*/
+void QGeoMapPolylineObject::setPath(const QList<QGeoCoordinate> &path)
+{
+ if (d_ptr->path != path) {
+ d_ptr->path = path;
+ setOrigin(path.at(0));
+ emit pathChanged(d_ptr->path);
+ }
+}
+
+QList<QGeoCoordinate> QGeoMapPolylineObject::path() const
+{
+ return d_ptr->path;
+}
+
+/*!
+ \property QGeoMapPolylineObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw the polyline.
+
+ The pen will be treated as a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+void QGeoMapPolylineObject::setPen(const QPen &pen)
+{
+ QPen newPen = pen;
+ newPen.setCosmetic(false);
+
+ if (d_ptr->pen == newPen)
+ return;
+
+ d_ptr->pen = pen;
+ emit penChanged(pen);
+}
+
+QPen QGeoMapPolylineObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+/*!
+\fn void QGeoMapPolylineObject::pathChanged(const QList<QGeoCoordinate> &path)
+
+ This signal is emitted when the ordered list of coordinates that define
+ the polyline to be drawn by this polyline object has changed.
+
+ The new value is \a path.
+*/
+
+/*!
+\fn void QGeoMapPolylineObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw the edge of this
+ polyline object has changed.
+
+ The new value is \a pen.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapPolylineObjectPrivate::QGeoMapPolylineObjectPrivate()
+{
+ pen.setCosmetic(true);
+}
+
+QGeoMapPolylineObjectPrivate::~QGeoMapPolylineObjectPrivate() {}
+
+#include "moc_qgeomappolylineobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomappolylineobject.h b/src/location/maps/qgeomappolylineobject.h
new file mode 100644
index 00000000..9e4420d2
--- /dev/null
+++ b/src/location/maps/qgeomappolylineobject.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPOLYLINEOBJECT_H
+#define QGEOMAPPOLYLINEOBJECT_H
+
+#include "qgeomapobject.h"
+
+#include <QList>
+#include <QPen>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class QGeoMapPolylineObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapPolylineObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+
+public:
+ QGeoMapPolylineObject();
+ ~QGeoMapPolylineObject();
+
+ QGeoMapObject::Type type() const;
+
+ void setPath(const QList<QGeoCoordinate> &path);
+ QList<QGeoCoordinate> path() const;
+
+ void setPen(const QPen &pen);
+ QPen pen() const;
+
+Q_SIGNALS:
+ void pathChanged(const QList<QGeoCoordinate> &path);
+ void penChanged(const QPen &pen);
+
+private:
+ QGeoMapPolylineObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapPolylineObject)
+ Q_DISABLE_COPY(QGeoMapPolylineObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomappolylineobject_p.h b/src/location/maps/qgeomappolylineobject_p.h
new file mode 100644
index 00000000..28fd9b5e
--- /dev/null
+++ b/src/location/maps/qgeomappolylineobject_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPPOLYLINEOBJECT_P_H
+#define QGEOMAPPOLYLINEOBJECT_P_H
+
+#include "qgeocoordinate.h"
+
+#include <QList>
+#include <QPen>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPolylineObjectPrivate
+{
+public:
+ QGeoMapPolylineObjectPrivate();
+ ~QGeoMapPolylineObjectPrivate();
+
+ QList<QGeoCoordinate> path;
+ QPen pen;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaprectangleobject.cpp b/src/location/maps/qgeomaprectangleobject.cpp
new file mode 100644
index 00000000..ade4e564
--- /dev/null
+++ b/src/location/maps/qgeomaprectangleobject.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomaprectangleobject.h"
+#include "qgeomaprectangleobject_p.h"
+
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapRectangleObject
+ \brief The QGeoMapRectangleObject class is a QGeoMapObject used to draw
+ a rectangular region on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The rectangle is specified by either a valid QGeoBoundingBox instance or
+ a pair of valid QGeoCoordinate instances which represent the top left and
+ bottom right coordinates of the rectangle respectively.
+*/
+
+/*!
+ Constructs a new rectangle object.
+*/
+QGeoMapRectangleObject::QGeoMapRectangleObject()
+ : d_ptr(new QGeoMapRectangleObjectPrivate())
+{
+ setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Constructs a new rectangle object based on the bounding box \a boundingBox.
+*/
+QGeoMapRectangleObject::QGeoMapRectangleObject(const QGeoBoundingBox &boundingBox)
+ : d_ptr(new QGeoMapRectangleObjectPrivate())
+{
+ d_ptr->bounds = boundingBox;
+ setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Constructs a new rectangle object with the top left coordinate at \a
+ topLeft and the bottom right coordinate at \a bottomRight.
+*/
+QGeoMapRectangleObject::QGeoMapRectangleObject(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
+ : d_ptr(new QGeoMapRectangleObjectPrivate())
+{
+ d_ptr->bounds = QGeoBoundingBox(topLeft, bottomRight);
+ setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Destroys this rectangle object.
+*/
+QGeoMapRectangleObject::~QGeoMapRectangleObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapRectangleObject::type() const
+{
+ return QGeoMapObject::RectangleType;
+}
+
+/*!
+ Returns a QGeoBoundingBox instance which corresponds to the rectangle that
+ will be drawn by this object.
+
+ This is equivalent to
+ \code
+ QGeoMapRectangleObject *object;
+ // setup object
+ QGeoBoundingBox(object->topLeft(), object->bottomRight());
+ \endcode
+*/
+QGeoBoundingBox QGeoMapRectangleObject::bounds() const
+{
+ return d_ptr->bounds;
+}
+
+/*!
+ Sets the rectangle that will be drawn by this object to \a bounds.
+
+ This is equivalent to
+ \code
+ QGeoMapRectangleObject *object;
+ // setup object
+ object->setTopLeft(bounds.topLeft());
+ object->setBottomRight(bounds.bottomRight());
+ \endcode
+*/
+void QGeoMapRectangleObject::setBounds(const QGeoBoundingBox &bounds)
+{
+ QGeoBoundingBox oldBounds = d_ptr->bounds;
+
+ if (oldBounds == bounds)
+ return;
+
+ d_ptr->bounds = bounds;
+
+ if (d_ptr->bounds.topLeft() != oldBounds.topLeft())
+ emit topLeftChanged(d_ptr->bounds.topLeft());
+
+ if (d_ptr->bounds.bottomRight() != oldBounds.bottomRight())
+ emit bottomRightChanged(d_ptr->bounds.bottomRight());
+}
+
+/*!
+ \property QGeoMapRectangleObject::topLeft
+ \brief This property holds the top left coordinate of the rectangle to be
+ drawn by this rectangle object.
+
+ The default value of this property is an invalid coordinate. While
+ the value of this property is invalid the rectangle object will not be
+ displayed.
+*/
+QGeoCoordinate QGeoMapRectangleObject::topLeft() const
+{
+ return d_ptr->bounds.topLeft();
+}
+
+void QGeoMapRectangleObject::setTopLeft(const QGeoCoordinate &topLeft)
+{
+ if (d_ptr->bounds.topLeft() != topLeft) {
+ d_ptr->bounds.setTopLeft(topLeft);
+ emit topLeftChanged(d_ptr->bounds.topLeft());
+ }
+}
+
+/*!
+ \property QGeoMapRectangleObject::bottomRight
+ \brief This property holds the bottom right coordinate of the rectangle to
+ be drawn by this rectangle object.
+
+ The default value of this property is an invalid coordinate. While
+ the value of this property is invalid the rectangle object will not be
+ displayed.
+*/
+QGeoCoordinate QGeoMapRectangleObject::bottomRight() const
+{
+ return d_ptr->bounds.bottomRight();
+}
+
+void QGeoMapRectangleObject::setBottomRight(const QGeoCoordinate &bottomRight)
+{
+ if (d_ptr->bounds.bottomRight() != bottomRight) {
+ d_ptr->bounds.setBottomRight(bottomRight);
+ emit bottomRightChanged(d_ptr->bounds.bottomRight());
+ }
+}
+
+/*!
+ \property QGeoMapRectangleObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw an outline around the rectangle. The rectangle is
+ filled using the QGeoMapRectangleObject::brush property.
+
+ The pen will be treated as a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+QPen QGeoMapRectangleObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+void QGeoMapRectangleObject::setPen(const QPen &pen)
+{
+ QPen newPen = pen;
+ newPen.setCosmetic(true);
+
+ if (d_ptr->pen == newPen)
+ return;
+
+ d_ptr->pen = newPen;
+ emit penChanged(newPen);
+}
+
+/*!
+ \property QGeoMapRectangleObject::brush
+ \brief This property holds the brush that will be used to draw this object.
+
+ The brush is used to fill in rectangle.
+
+ The outline around the perimeter of the rectangle is drawn using the
+ QGeoMapRectangleObject::pen property.
+*/
+QBrush QGeoMapRectangleObject::brush() const
+{
+ return d_ptr->brush;
+}
+
+void QGeoMapRectangleObject::setBrush(const QBrush &brush)
+{
+ if (d_ptr->brush != brush) {
+ d_ptr->brush = brush;
+ emit brushChanged(d_ptr->brush);
+ }
+}
+
+/*!
+\fn void QGeoMapRectangleObject::topLeftChanged(const QGeoCoordinate &topLeft)
+
+ This signal is emitted when the top left coordinate of this rectangle
+ object has changed.
+
+ The new value is \a topLeft.
+*/
+
+/*!
+\fn void QGeoMapRectangleObject::bottomRightChanged(const QGeoCoordinate &bottomRight)
+
+ This signal is emitted when the bottom right coordinate of this rectangle
+ object has changed.
+
+ The new value is \a bottomRight.
+*/
+
+/*!
+\fn void QGeoMapRectangleObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw the perimeter of this
+ rectangle object has changed.
+
+ The new value is \a pen.
+*/
+
+/*!
+\fn void QGeoMapRectangleObject::brushChanged(const QBrush &brush)
+
+ This signal is emitted when the brush used to fill in the interior of
+ this rectangle object has changed.
+
+ The new value is \a brush.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapRectangleObjectPrivate::QGeoMapRectangleObjectPrivate()
+{
+ pen.setCosmetic(true);
+}
+
+QGeoMapRectangleObjectPrivate::~QGeoMapRectangleObjectPrivate() {}
+
+#include "moc_qgeomaprectangleobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomaprectangleobject.h b/src/location/maps/qgeomaprectangleobject.h
new file mode 100644
index 00000000..6bdd2968
--- /dev/null
+++ b/src/location/maps/qgeomaprectangleobject.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPRECTANGLEOBJECT_H
+#define QGEOMAPRECTANGLEOBJECT_H
+
+#include "qgeomapobject.h"
+
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRectangleObjectPrivate;
+class QGeoBoundingBox;
+class QGeoCoordinate;
+
+class Q_LOCATION_EXPORT QGeoMapRectangleObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft NOTIFY topLeftChanged)
+ Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight NOTIFY bottomRightChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
+
+public:
+ QGeoMapRectangleObject();
+ QGeoMapRectangleObject(const QGeoBoundingBox &boundingBox);
+ QGeoMapRectangleObject(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
+ ~QGeoMapRectangleObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoBoundingBox bounds() const;
+ void setBounds(const QGeoBoundingBox &bounds);
+
+ QGeoCoordinate topLeft() const;
+ void setTopLeft(const QGeoCoordinate &topLeft);
+
+ QGeoCoordinate bottomRight() const;
+ void setBottomRight(const QGeoCoordinate &bottomRight);
+
+ QPen pen() const;
+ void setPen(const QPen &pen);
+
+ QBrush brush() const;
+ void setBrush(const QBrush &brush);
+
+Q_SIGNALS:
+ void topLeftChanged(const QGeoCoordinate &topLeft);
+ void bottomRightChanged(const QGeoCoordinate &bottomRight);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+
+private:
+ QGeoMapRectangleObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapRectangleObject)
+ Q_DISABLE_COPY(QGeoMapRectangleObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaprectangleobject_p.h b/src/location/maps/qgeomaprectangleobject_p.h
new file mode 100644
index 00000000..c5303e67
--- /dev/null
+++ b/src/location/maps/qgeomaprectangleobject_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPRECTANGLEOBJECT_P_H
+#define QGEOMAPRECTANGLEOBJECT_P_H
+
+#include "qgeoboundingbox.h"
+
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRectangleObjectPrivate
+{
+public:
+ QGeoMapRectangleObjectPrivate();
+ ~QGeoMapRectangleObjectPrivate();
+
+ QGeoBoundingBox bounds;
+ QPen pen;
+ QBrush brush;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaprouteobject.cpp b/src/location/maps/qgeomaprouteobject.cpp
new file mode 100644
index 00000000..3822b874
--- /dev/null
+++ b/src/location/maps/qgeomaprouteobject.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomaprouteobject.h"
+#include "qgeomaprouteobject_p.h"
+#include "qgeocoordinate.h"
+#include "qgeoroutesegment.h"
+
+#define DEFAULT_ROUTE_DETAIL_LEVEL 6
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapRouteObject
+ \brief The QGeoMapRouteObject class is a QGeoMapObject used to draw
+ a route on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The route is specified by a QGeoRoute object.
+
+ The route might be quite detailed, and so to improve performance the
+ detail level can be set with QGeoMapRouteObject::detailLevel.
+
+ The route object draws the route as a series of lines with a minimum
+ on-screen harmattan length equal to the detail level. This is done so that
+ the small changes in direction of a road will be visible at high zoom
+ levels but will not slow down the rendering at the lower zoom levels.
+*/
+
+/*!
+ Constructs a new route object.
+*/
+QGeoMapRouteObject::QGeoMapRouteObject()
+ : d_ptr(new QGeoMapRouteObjectPrivate())
+{
+ setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Constructs a new route object for the route \a route.
+*/
+QGeoMapRouteObject::QGeoMapRouteObject(const QGeoRoute &route)
+ : d_ptr(new QGeoMapRouteObjectPrivate())
+{
+ d_ptr->route = route;
+ setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
+ setTransformType(QGeoMapObject::ExactTransform);
+}
+
+/*!
+ Destroys this route object
+*/
+QGeoMapRouteObject::~QGeoMapRouteObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapRouteObject::type() const
+{
+ return QGeoMapObject::RouteType;
+}
+
+/*!
+ \property QGeoMapRouteObject::route
+ \brief This property holds the which will be displayed.
+
+ The default value of this property is an empty route.
+
+ If QGeoRoute::path() returns a list of less than 2 valid QGeoCoordinates
+ then the route object will not be displayed.
+*/
+QGeoRoute QGeoMapRouteObject::route() const
+{
+ return d_ptr->route;
+}
+
+void QGeoMapRouteObject::setRoute(const QGeoRoute &route)
+{
+ d_ptr->route = route;
+ emit routeChanged(d_ptr->route);
+}
+
+/*!
+ \property QGeoMapRouteObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw the route.
+
+ The pen will be treated like a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+QPen QGeoMapRouteObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+void QGeoMapRouteObject::setPen(const QPen &pen)
+{
+ QPen newPen = pen;
+ newPen.setCosmetic(false);
+
+ if (d_ptr->pen == newPen)
+ return;
+
+ d_ptr->pen = newPen;
+ emit penChanged(newPen);
+}
+
+/*!
+ \property QGeoMapRouteObject::detailLevel
+ \brief This property holds the level of detail used to draw this object.
+
+ A QGeoRoute instance can contain a large amount of information about the
+ path taken by the route. This property is used as a hint to help reduce the
+ amount of information that needs to be drawn on the map.
+
+ The path taken by the route is represented as a list of QGeoCoordinate
+ instances. This route object will draw lines between these coordinates, but
+ will skip members of the list until the manhattan distance between the
+ start point and the end point of the line is at least \a detailLevel.
+
+ The default value of this property is 6.
+*/
+quint32 QGeoMapRouteObject::detailLevel() const
+{
+ return d_ptr->detailLevel;
+}
+
+void QGeoMapRouteObject::setDetailLevel(quint32 detailLevel)
+{
+ if (d_ptr->detailLevel != detailLevel) {
+ d_ptr->detailLevel = detailLevel;
+ emit detailLevelChanged(d_ptr->detailLevel);
+ }
+}
+
+/*!
+\fn void QGeoMapRouteObject::routeChanged(const QGeoRoute &route)
+
+ This signal is emitted when the route drawn by this route object
+ has changed.
+
+ The new value is \a route.
+*/
+
+/*!
+\fn void QGeoMapRouteObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw this route object has
+ changed.
+
+ The new value is \a pen.
+*/
+
+/*!
+\fn void QGeoMapRouteObject::detailLevelChanged(quint32 detailLevel)
+
+ This signal is emitted when the level of detail used to draw this
+ route object has changed.
+
+ The new value is \a detailLevel.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapRouteObjectPrivate::QGeoMapRouteObjectPrivate()
+{
+ detailLevel = DEFAULT_ROUTE_DETAIL_LEVEL;
+ pen.setCosmetic(true);
+}
+
+QGeoMapRouteObjectPrivate::~QGeoMapRouteObjectPrivate() {}
+
+#include "moc_qgeomaprouteobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomaprouteobject.h b/src/location/maps/qgeomaprouteobject.h
new file mode 100644
index 00000000..03af0e2c
--- /dev/null
+++ b/src/location/maps/qgeomaprouteobject.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPROUTEOBJECT_H
+#define QGEOMAPROUTEOBJECT_H
+
+#include "qgeomapobject.h"
+#include "qgeoroute.h"
+
+#include <QPen>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRouteObjectPrivate;
+class QGeoRoute;
+class QGeoCoordinate;
+
+class Q_LOCATION_EXPORT QGeoMapRouteObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoRoute route READ route WRITE setRoute NOTIFY routeChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ Q_PROPERTY(quint32 detailLevel READ detailLevel WRITE setDetailLevel NOTIFY detailLevelChanged)
+
+public:
+ QGeoMapRouteObject();
+ QGeoMapRouteObject(const QGeoRoute &route);
+ ~QGeoMapRouteObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoRoute route() const;
+ void setRoute(const QGeoRoute &route);
+
+ QPen pen() const;
+ void setPen(const QPen &pen);
+
+ quint32 detailLevel() const;
+ void setDetailLevel(quint32 detailLevel);
+
+Q_SIGNALS:
+ void routeChanged(const QGeoRoute &route);
+ void penChanged(const QPen &pen);
+ void detailLevelChanged(quint32 detailLevel);
+
+private:
+ QGeoMapRouteObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapRouteObject)
+ Q_DISABLE_COPY(QGeoMapRouteObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaprouteobject_p.h b/src/location/maps/qgeomaprouteobject_p.h
new file mode 100644
index 00000000..464f4359
--- /dev/null
+++ b/src/location/maps/qgeomaprouteobject_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPROUTEOBJECT_P_H
+#define QGEOMAPROUTEOBJECT_P_H
+
+#include "qgeoroute.h"
+
+#include <QPen>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRouteObjectPrivate
+{
+public:
+ QGeoMapRouteObjectPrivate();
+ ~QGeoMapRouteObjectPrivate();
+
+ QGeoRoute route;
+ QPen pen;
+ quint32 detailLevel;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaptextobject.cpp b/src/location/maps/qgeomaptextobject.cpp
new file mode 100644
index 00000000..8cc8d1ab
--- /dev/null
+++ b/src/location/maps/qgeomaptextobject.cpp
@@ -0,0 +1,375 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomaptextobject.h"
+#include "qgeomaptextobject_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoMapTextObject
+ \brief The QGeoMapTextObject class is a QGeoMapObject used to draw
+ text on a map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping-objects
+
+ The text is drawn at a given coordinate on the map.
+
+ The text object is drawn such that the rendered size of the text object is
+ independent of the zoom level of the map.
+*/
+
+/*!
+ Constructs a new text object.
+*/
+QGeoMapTextObject::QGeoMapTextObject()
+ : d_ptr(new QGeoMapTextObjectPrivate())
+{
+ setUnits(QGeoMapObject::PixelUnit);
+}
+
+/*!
+ Constructs a new text object which will display the text \a text with font
+ \a font at the coordinate \a coordinate on the map.
+
+ The text will be displayed at an on-screen offset from the coordinate of \a
+ offset pixels, and will be aligned according to \a alignment.
+*/
+QGeoMapTextObject::QGeoMapTextObject(const QGeoCoordinate &coordinate,
+ const QString &text,
+ const QFont &font,
+ const QPoint &offset,
+ Qt::Alignment alignment)
+ : d_ptr(new QGeoMapTextObjectPrivate())
+{
+ setOrigin(coordinate);
+ d_ptr->text = text;
+ d_ptr->font = font;
+ d_ptr->offset = offset;
+ d_ptr->alignment = alignment;
+ setUnits(QGeoMapObject::PixelUnit);
+}
+
+/*!
+ Destroys this text object.
+*/
+QGeoMapTextObject::~QGeoMapTextObject()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObject::Type QGeoMapTextObject::type() const
+{
+ return QGeoMapObject::TextType;
+}
+
+/*!
+ \property QGeoMapTextObject::coordinate
+ \brief This property holds the coordinate at which this text object
+ will be rendered.
+
+ The default value of this property is an invalid coordinate. While the
+ value of this property is invalid the text object will not be displayed.
+
+ If QGeoMapTextObject::offset and QGeoMapTextObject::alignment are not set
+ the text will be drawn so that it is centered both horizontally and
+ vertically around the position of QGeoMapTextObject::coordinate on the
+ screen.
+*/
+QGeoCoordinate QGeoMapTextObject::coordinate() const
+{
+ return origin();
+}
+
+void QGeoMapTextObject::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ if (origin() != coordinate) {
+ setOrigin(coordinate);
+ emit coordinateChanged(coordinate);
+ }
+}
+
+/*!
+ \property QGeoMapTextObject::text
+ \brief This property holds the text that will be displayed by this text
+ object.
+
+ The default value of this property is an empty string.
+*/
+QString QGeoMapTextObject::text() const
+{
+ return d_ptr->text;
+}
+
+void QGeoMapTextObject::setText(const QString &text)
+{
+ if (d_ptr->text != text) {
+ d_ptr->text = text;
+ emit textChanged(text);
+ }
+}
+
+/*!
+ \property QGeoMapTextObject::font
+ \brief This property holds the font that will be used to render the text
+ for this text object.
+
+ The default value of this property is the application's default font.
+
+ It is not necessary to account for the zoom level of the map, since text
+ objects are scaled such that they appear to be independent of the zoom
+ level.
+*/
+QFont QGeoMapTextObject::font() const
+{
+ return d_ptr->font;
+}
+
+void QGeoMapTextObject::setFont(const QFont &font)
+{
+ if (d_ptr->font != font) {
+ d_ptr->font = font;
+ emit fontChanged(font);
+ }
+}
+
+/*!
+ \property QGeoMapTextObject::pen
+ \brief This property holds the pen that will be used to draw this object.
+
+ The pen is used to draw an outline around the text. The text itself is
+ filled using the QGeoMapTextObject::brush property.
+
+ The pen will be treated as a cosmetic pen, which means that the width
+ of the pen will be independent of the zoom level of the map.
+*/
+QPen QGeoMapTextObject::pen() const
+{
+ return d_ptr->pen;
+}
+
+void QGeoMapTextObject::setPen(const QPen &pen)
+{
+ QPen newPen = pen;
+ newPen.setCosmetic(true);
+
+ if (d_ptr->pen == newPen)
+ return;
+
+ d_ptr->pen = newPen;
+ emit penChanged(pen);
+}
+
+/*!
+ \property QGeoMapTextObject::brush
+ \brief This property holds the brush that will be used to draw this object.
+
+ The brush is used to fill in the glyphs of the text.
+
+ The outline around the perimeter of the glyphs is drawn using the
+ QGeoMapTextObject::pen property.
+*/
+QBrush QGeoMapTextObject::brush() const
+{
+ return d_ptr->brush;
+}
+
+void QGeoMapTextObject::setBrush(const QBrush &brush)
+{
+ if (d_ptr->brush != brush) {
+ d_ptr->brush = brush;
+ emit brushChanged(brush);
+ }
+}
+
+/*!
+ \property QGeoMapTextObject::offset
+ \brief This property holds the offset in pixels from the screen position of
+ QGeoMapTextObject::coordinate at which the text will be rendered when
+ drawing this text object.
+
+ The default value of this property is QPoint(0,0).
+*/
+QPoint QGeoMapTextObject::offset() const
+{
+ return QPoint(d_ptr->offset.x(), d_ptr->offset.y());
+}
+
+void QGeoMapTextObject::setOffset(const QPoint &off)
+{
+ QPointF offset = off;
+ if (d_ptr->offset != off) {
+ d_ptr->offset = off;
+ emit offsetChanged(off);
+ }
+}
+
+/*!
+ \property QGeoMapTextObject::alignment
+ \brief This property holds the alignment options used to align the
+ text when drawing this text object.
+
+ The default value of this property will align the text so that it is
+ centered both horizontally and vertically around the point that is
+ QGeoMapTextObject::offset pixels away from the position of
+ QGeoMapTextObject::coordinate on the screen.
+
+ Using
+ \code
+ textObject->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ \endcode
+ will place the text so that the point halway up the left edge of
+ the text is at the anchor point defined by
+ QGeoMapTextObject::offset and QGeoMapTextObject::coordinate.
+
+ The alignment property is a flag, so using
+ \code
+ textObject->setAlignment(Qt::AlignLeft);
+ \endcode
+ may alter the vertical alignment as well.
+
+ The Qt::AlignVertical_Mask and Qt::AlignHorizontal_Mask enum
+ values can be used to alter one component of the alignment
+ independent of the other.
+ \code
+ textObject->setAlignment(Qt::AlignLeft | (textObject->alignment() & Qt::AlignVertical_Mask));
+ \endcode
+
+ The alignment does not take the width of QGeoMapTextObject::pen into
+ consideration.
+*/
+Qt::Alignment QGeoMapTextObject::alignment() const
+{
+ return d_ptr->alignment;
+}
+
+void QGeoMapTextObject::setAlignment(Qt::Alignment alignment)
+{
+ if (d_ptr->alignment != alignment) {
+ d_ptr->alignment = alignment;
+ emit alignmentChanged(d_ptr->alignment);
+ }
+}
+
+/*!
+\fn void QGeoMapTextObject::coordinateChanged(const QGeoCoordinate &coordinate)
+
+ This signal is emitted when the coordinate at which this text
+ object will be drawn has changed.
+
+ The new value is \a coordinate.
+*/
+
+/*!
+\fn void QGeoMapTextObject::textChanged(const QString &text)
+
+ This signal is emitted when the text to be drawn by this text object
+ has changed.
+
+ The new value is \a text.
+*/
+
+/*!
+\fn void QGeoMapTextObject::fontChanged(const QFont &font)
+
+ This signal is emitted when the font use to draw this text object
+ has changed.
+
+ The new value is \a font.
+*/
+
+/*!
+\fn void QGeoMapTextObject::penChanged(const QPen &pen)
+
+ This signal is emitted when the pen used to draw the outline of the
+ letters for this text object has changed.
+
+ The new value is \a pen.
+*/
+
+/*!
+\fn void QGeoMapTextObject::brushChanged(const QBrush &brush)
+
+ This signal is emitted when the brush used to fill the inside of the
+ letters for this text object has changed.
+
+ The new value is \a brush.
+*/
+
+/*!
+\fn void QGeoMapTextObject::offsetChanged(const QPoint &offset)
+
+ This signal is emitted when the on screen offset from the coordinate at
+ which this text object will be drawn has changed.
+
+ The new value is \a offset.
+*/
+
+/*!
+\fn void QGeoMapTextObject::alignmentChanged(Qt::Alignment alignment)
+
+ This signal is emitted when the alignment of this text object has changed.
+
+ The new value is \a alignment.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoMapTextObjectPrivate::QGeoMapTextObjectPrivate() :
+ offset(0, 0)
+{
+ pen.setCosmetic(true);
+ alignment = Qt::AlignCenter;
+}
+
+QGeoMapTextObjectPrivate::~QGeoMapTextObjectPrivate() {}
+
+#include "moc_qgeomaptextobject.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeomaptextobject.h b/src/location/maps/qgeomaptextobject.h
new file mode 100644
index 00000000..8bd26dbe
--- /dev/null
+++ b/src/location/maps/qgeomaptextobject.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPTEXTOBJECT_H
+#define QGEOMAPTEXTOBJECT_H
+
+#include "qgeomapobject.h"
+#include "qgeocoordinate.h"
+
+#include <QFont>
+#include <QPoint>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapTextObjectPrivate;
+
+class Q_LOCATION_EXPORT QGeoMapTextObject : public QGeoMapObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
+ Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+
+public:
+ QGeoMapTextObject();
+ QGeoMapTextObject(const QGeoCoordinate &coordinate,
+ const QString &text = QString(),
+ const QFont &font = QFont(),
+ const QPoint &offset = QPoint(),
+ Qt::Alignment alignment = Qt::AlignCenter);
+ ~QGeoMapTextObject();
+
+ QGeoMapObject::Type type() const;
+
+ QGeoCoordinate coordinate() const;
+ void setCoordinate(const QGeoCoordinate &coordinate);
+
+ QString text() const;
+ void setText(const QString &text);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QPen pen() const;
+ void setPen(const QPen &pen);
+
+ QBrush brush() const;
+ void setBrush(const QBrush &brush);
+
+ QPoint offset() const;
+ void setOffset(const QPoint &offset);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment alignment);
+
+Q_SIGNALS:
+ void coordinateChanged(const QGeoCoordinate &coordinate);
+ void textChanged(const QString &text);
+ void fontChanged(const QFont &font);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+ void offsetChanged(const QPoint &offset);
+ void alignmentChanged(Qt::Alignment alignment);
+
+private:
+ QGeoMapTextObjectPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapTextObject)
+ Q_DISABLE_COPY(QGeoMapTextObject)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeomaptextobject_p.h b/src/location/maps/qgeomaptextobject_p.h
new file mode 100644
index 00000000..e8a815c9
--- /dev/null
+++ b/src/location/maps/qgeomaptextobject_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPTEXTOBJECT_P_H
+#define QGEOMAPTEXTOBJECT_P_H
+
+#include "qgeocoordinate.h"
+
+#include <QFont>
+#include <QString>
+#include <QPen>
+#include <QBrush>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapTextObjectPrivate
+{
+public:
+ QGeoMapTextObjectPrivate();
+ ~QGeoMapTextObjectPrivate();
+
+ QString text;
+ QFont font;
+ QPen pen;
+ QBrush brush;
+ QPoint offset;
+ Qt::Alignment alignment;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroute.cpp b/src/location/maps/qgeoroute.cpp
new file mode 100644
index 00000000..564bef3f
--- /dev/null
+++ b/src/location/maps/qgeoroute.cpp
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoroute.h"
+#include "qgeoroute_p.h"
+
+#include "qgeoboundingbox.h"
+#include "qgeoroutesegment.h"
+
+#include <QDateTime>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRoute
+ \brief The QGeoRoute class represents a route between two points.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ A QGeoRoute object contains high level information about a route, such
+ as the length the route, the estimated travel time for the route,
+ and enough information to render a basic image of the route on a map.
+
+ The QGeoRoute object also contains a list of QGeoRouteSegment objecs which
+ describe subsections of the route in greater detail.
+
+ Routing information is normally requested using
+ QGeoRoutingManager::calculateRoute(), which returns a QGeoRouteReply
+ instance. If the operation is completed successfully the routing
+ information can be accessed with QGeoRouteReply::routes()
+
+ \sa QGeoRoutingManager
+*/
+
+/*!
+ Constructs a route object.
+*/
+QGeoRoute::QGeoRoute()
+ : d_ptr(new QGeoRoutePrivate()) {}
+
+/*!
+ Constructs a route object from the contents of \a other.
+*/
+QGeoRoute::QGeoRoute(const QGeoRoute &other)
+ : d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys this route object.
+*/
+QGeoRoute::~QGeoRoute()
+{
+}
+
+/*!
+ Assigns the contents of \a other to this route and returns a reference to
+ this route.
+*/
+QGeoRoute& QGeoRoute::operator= (const QGeoRoute & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this route and \a other are equal.
+*/
+bool QGeoRoute::operator ==(const QGeoRoute &other) const
+{
+ return (d_ptr.constData() == other.d_ptr.constData());
+}
+
+/*!
+ Returns whether this route and \a other are not equal.
+*/
+bool QGeoRoute::operator !=(const QGeoRoute &other) const
+{
+ return (d_ptr.constData() != other.d_ptr.constData());
+}
+
+/*!
+ Sets the ID of this route to \a id.
+
+ Service providers which support the updating of routes commonly assign
+ IDs to routes. If this route came from such a service provider changing
+ the ID will probably cause route updates to stop working.
+*/
+void QGeoRoute::setRouteId(const QString &id)
+{
+ d_ptr->id = id;
+}
+
+/*!
+ Returns the ID of this route.
+
+ Service providers which support the updating of routes commonly assign
+ IDs to routes. If this route did not come from such a service provider
+ the function will return an empty string.
+*/
+QString QGeoRoute::routeId() const
+{
+ return d_ptr->id;
+}
+
+/*!
+ Sets the route request which describes the criteria used in the
+ calculcation of this route to \a request.
+*/
+void QGeoRoute::setRequest(const QGeoRouteRequest &request)
+{
+ d_ptr->request = request;
+}
+
+/*!
+ Returns the route request which describes the criteria used in
+ the calculation of this route.
+*/
+QGeoRouteRequest QGeoRoute::request() const
+{
+ return d_ptr->request;
+}
+
+/*!
+ Sets the bounding box which encompasses the entire route to \a bounds.
+*/
+void QGeoRoute::setBounds(const QGeoBoundingBox &bounds)
+{
+ d_ptr->bounds = bounds;
+}
+
+/*!
+ Returns a bounding box which encompasses the entire route.
+*/
+QGeoBoundingBox QGeoRoute::bounds() const
+{
+ return d_ptr->bounds;
+}
+
+/*!
+ Sets the first route segment in the route to \a routeSegment.
+*/
+void QGeoRoute::setFirstRouteSegment(const QGeoRouteSegment &routeSegment)
+{
+ d_ptr->firstSegment = routeSegment;
+}
+
+/*!
+ Returns the first route segment in the route.
+
+ Will return an invalid route segment if there are no route segments
+ associated with the route.
+
+ The remaining route segments can be accessed sequentially with
+ QGeoRouteSegment::nextRouteSegment.
+*/
+QGeoRouteSegment QGeoRoute::firstRouteSegment() const
+{
+ return d_ptr->firstSegment;
+}
+
+/*!
+ Sets the estimated amount of time it will take to traverse this route,
+ in seconds, to \a secs.
+*/
+void QGeoRoute::setTravelTime(int secs)
+{
+ d_ptr->travelTime = secs;
+}
+
+/*!
+ Returns the estimated amount of time it will take to traverse this route,
+ in seconds.
+*/
+int QGeoRoute::travelTime() const
+{
+ return d_ptr->travelTime;
+}
+
+/*!
+ Sets the distance covered by this route, in metres, to \a distance.
+*/
+void QGeoRoute::setDistance(qreal distance)
+{
+ d_ptr->distance = distance;
+}
+
+/*!
+ Returns the distance covered by this route, in metres.
+*/
+qreal QGeoRoute::distance() const
+{
+ return d_ptr->distance;
+}
+
+/*!
+ Sets the travel mode for this route to \a mode.
+
+ This should be one of the travel modes returned by request().travelModes().
+*/
+void QGeoRoute::setTravelMode(QGeoRouteRequest::TravelMode mode)
+{
+ d_ptr->travelMode = mode;
+}
+
+/*!
+ Returns the travel mode for the this route.
+
+ This should be one of the travel modes returned by request().travelModes().
+*/
+QGeoRouteRequest::TravelMode QGeoRoute::travelMode() const
+{
+ return d_ptr->travelMode;
+}
+
+/*!
+ Sets the geometric shape of the route to \a path.
+
+ The coordinates in \a path should be listed in the order in which they
+ would be traversed by someone traveling along this segment of the route.
+*/
+void QGeoRoute::setPath(const QList<QGeoCoordinate> &path)
+{
+ d_ptr->path = path;
+}
+
+/*!
+ Returns the geometric shape of the route.
+
+ The coordinates should be listed in the order in which they
+ would be traversed by someone traveling along this segment of the route.
+*/
+QList<QGeoCoordinate> QGeoRoute::path() const
+{
+ return d_ptr->path;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRoutePrivate::QGeoRoutePrivate()
+ : travelTime(0),
+ distance(0.0),
+ travelMode(QGeoRouteRequest::CarTravel) {}
+
+QGeoRoutePrivate::QGeoRoutePrivate(const QGeoRoutePrivate &other)
+ : QSharedData(other),
+ id(other.id),
+ request(other.request),
+ bounds(other.bounds),
+ travelTime(other.travelTime),
+ distance(other.distance),
+ travelMode(other.travelMode),
+ path(other.path),
+ firstSegment(other.firstSegment) {}
+
+QGeoRoutePrivate::~QGeoRoutePrivate() {}
+
+bool QGeoRoutePrivate::operator ==(const QGeoRoutePrivate &other) const
+{
+ QGeoRouteSegment s1 = firstSegment;
+ QGeoRouteSegment s2 = other.firstSegment;
+
+ while (true) {
+ if (s1.isValid() != s2.isValid())
+ return false;
+ if (!s1.isValid())
+ break;
+ if (s1 != s2)
+ return false;
+ s1 = s1.nextRouteSegment();
+ s2 = s2.nextRouteSegment();
+ }
+
+ return ((id == other.id)
+ && (request == other.request)
+ && (bounds == other.bounds)
+ && (travelTime == other.travelTime)
+ && (distance == other.distance)
+ && (travelMode == other.travelMode)
+ && (path == other.path));
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeoroute.h b/src/location/maps/qgeoroute.h
new file mode 100644
index 00000000..58e19614
--- /dev/null
+++ b/src/location/maps/qgeoroute.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTE_H
+#define QGEOROUTE_H
+
+#include "qgeocoordinate.h"
+#include "qgeorouterequest.h"
+
+#include <QExplicitlySharedDataPointer>
+#include <QList>
+#include <QHash>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoBoundingBox;
+class QGeoRouteSegment;
+
+class QGeoRoutePrivate;
+
+class Q_LOCATION_EXPORT QGeoRoute
+{
+public:
+ QGeoRoute();
+ QGeoRoute(const QGeoRoute &other);
+ ~QGeoRoute();
+
+ QGeoRoute& operator = (const QGeoRoute &other);
+
+ bool operator == (const QGeoRoute &other) const;
+ bool operator != (const QGeoRoute &other) const;
+
+ void setRouteId(const QString &id);
+ QString routeId() const;
+
+ void setRequest(const QGeoRouteRequest &request);
+ QGeoRouteRequest request() const;
+
+ void setBounds(const QGeoBoundingBox &bounds);
+ QGeoBoundingBox bounds() const;
+
+ void setFirstRouteSegment(const QGeoRouteSegment &routeSegment);
+ QGeoRouteSegment firstRouteSegment() const;
+
+ void setTravelTime(int secs);
+ int travelTime() const;
+
+ void setDistance(qreal distance);
+ qreal distance() const;
+
+ void setTravelMode(QGeoRouteRequest::TravelMode mode);
+ QGeoRouteRequest::TravelMode travelMode() const;
+
+ void setPath(const QList<QGeoCoordinate> &path);
+ QList<QGeoCoordinate> path() const;
+
+private:
+ QExplicitlySharedDataPointer<QGeoRoutePrivate> d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeoroute_p.h b/src/location/maps/qgeoroute_p.h
new file mode 100644
index 00000000..fcb1473b
--- /dev/null
+++ b/src/location/maps/qgeoroute_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTE_P_H
+#define QGEOROUTE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeoroute.h"
+#include "qgeorouterequest.h"
+#include "qgeoboundingbox.h"
+#include "qgeoroutesegment.h"
+
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class QGeoRoutePrivate : public QSharedData
+{
+public:
+ QGeoRoutePrivate();
+ QGeoRoutePrivate(const QGeoRoutePrivate &other);
+ ~QGeoRoutePrivate();
+
+ bool operator == (const QGeoRoutePrivate &other) const;
+
+ QString id;
+ QGeoRouteRequest request;
+
+ QGeoBoundingBox bounds;
+// QList<QGeoRouteSegment> routeSegments;
+
+ int travelTime;
+ qreal distance;
+
+ QGeoRouteRequest::TravelMode travelMode;
+
+ QList<QGeoCoordinate> path;
+
+ QGeoRouteSegment firstSegment;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutereply.cpp b/src/location/maps/qgeoroutereply.cpp
new file mode 100644
index 00000000..22966b90
--- /dev/null
+++ b/src/location/maps/qgeoroutereply.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoroutereply.h"
+#include "qgeoroutereply_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRouteReply
+
+ \brief The QGeoRouteReply class manages an operation started by an instance
+ of QGeoRoutingManager.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ Instances of QGeoRouteReply manage the state and results of these
+ operations.
+
+ The isFinished(), error() and errorString() methods provide information
+ on whether the operation has completed and if it completed successfully.
+
+ The finished() and error(QGeoRouteReply::Error,QString)
+ signals can be used to monitor the progress of the operation.
+
+ It is possible that a newly created QGeoRouteReply may be in a finished
+ state, most commonly because an error has occurred. Since such an instance
+ will never emit the finished() or
+ error(QGeoRouteReply::Error,QString) signals, it is
+ important to check the result of isFinished() before making the connections
+ to the signals. The documentation for QGeoRoutingManager demonstrates how
+ this might be carried out.
+
+ If the operation completes successfully the results will be able to be
+ accessed with routes().
+*/
+
+/*!
+ \enum QGeoRouteReply::Error
+
+ Describes an error which prevented the completion of the operation.
+
+ \value NoError
+ No error has occurred.
+ \value EngineNotSetError
+ The routing manager that was used did not have a QGeoRoutingManagerEngine instance associated with it.
+ \value CommunicationError
+ An error occurred while communicating with the service provider.
+ \value ParseError
+ The response from the service provider was in an unrecognizable format.
+ \value UnsupportedOptionError
+ The requested operation or one of the options for the operation are not
+ supported by the service provider.
+ \value UnknownError
+ An error occurred which does not fit into any of the other categories.
+*/
+
+/*!
+ Constructs a route reply object based on \a request, with the specified \a parent.
+*/
+QGeoRouteReply::QGeoRouteReply(const QGeoRouteRequest &request, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoRouteReplyPrivate(request))
+{
+}
+
+/*!
+ Constructs a route reply with a given \a error and \a errorString and the specified \a parent.
+*/
+QGeoRouteReply::QGeoRouteReply(Error error, const QString &errorString, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoRouteReplyPrivate(error, errorString)) {}
+
+/*!
+ Destroys this route reply object.
+*/
+QGeoRouteReply::~QGeoRouteReply()
+{
+ delete d_ptr;
+}
+
+/*!
+ Sets whether or not this reply has finished to \a finished.
+
+ If \a finished is true, this will cause the finished() signal to be
+ emitted.
+
+ If the operation completed successfully, QGeoRouteReply::setRoutes() should
+ be called before this function. If an error occurred,
+ QGeoRouteReply::setError() should be used instead.
+*/
+void QGeoRouteReply::setFinished(bool finished)
+{
+ d_ptr->isFinished = finished;
+ if (d_ptr->isFinished)
+ emit this->finished();
+}
+
+/*!
+ Return true if the operation completed successfully or encountered an
+ error which cause the operation to come to a halt.
+*/
+bool QGeoRouteReply::isFinished() const
+{
+ return d_ptr->isFinished;
+}
+
+/*!
+ Sets the error state of this reply to \a error and the textual
+ representation of the error to \a errorString.
+
+ This wil also cause error() and finished() signals to be emitted, in that
+ order.
+*/
+void QGeoRouteReply::setError(QGeoRouteReply::Error error, const QString &errorString)
+{
+ d_ptr->error = error;
+ d_ptr->errorString = errorString;
+ emit this->error(error, errorString);
+ setFinished(true);
+}
+
+/*!
+ Returns the error state of this reply.
+
+ If the result is QGeoRouteReply::NoError then no error has occurred.
+*/
+QGeoRouteReply::Error QGeoRouteReply::error() const
+{
+ return d_ptr->error;
+}
+
+/*!
+ Returns the textual representation of the error state of this reply.
+
+ If no error has occurred this will return an empty string. It is possible
+ that an error occurred which has no associated textual representation, in
+ which case this will also return an empty string.
+
+ To determine whether an error has occurred, check to see if
+ QGeoRouteReply::error() is equal to QGeoRouteReply::NoError.
+*/
+QString QGeoRouteReply::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+/*!
+ Returns the route request which specified the route.
+*/
+QGeoRouteRequest QGeoRouteReply::request() const
+{
+ return d_ptr->request;
+}
+
+/*!
+ Returns the list of routes which were requested.
+*/
+QList<QGeoRoute> QGeoRouteReply::routes() const
+{
+ return d_ptr->routes;
+}
+
+/*!
+ Sets the list of routes in the reply to \a routes.
+*/
+void QGeoRouteReply::setRoutes(const QList<QGeoRoute> &routes)
+{
+ d_ptr->routes = routes;
+}
+
+/*!
+ Cancels the operation immediately.
+
+ This will do nothing if the reply is finished.
+*/
+void QGeoRouteReply::abort()
+{
+ if (!isFinished())
+ setFinished(true);
+}
+
+/*!
+ \fn void QGeoRouteReply::finished()
+
+ This signal is emitted when this reply has finished processing.
+
+ If error() equals QGeoRouteReply::NoError then the processing
+ finished successfully.
+
+ This signal and QGeoRoutingManager::finished() will be
+ emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+/*!
+ \fn void QGeoRouteReply::error(QGeoRouteReply::Error error, const QString &errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ this reply. The finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ This signal and QGeoRoutingManager::error() will be emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRouteReplyPrivate::QGeoRouteReplyPrivate(const QGeoRouteRequest &request)
+ : error(QGeoRouteReply::NoError),
+ errorString(""),
+ isFinished(false),
+ request(request) {}
+
+QGeoRouteReplyPrivate::QGeoRouteReplyPrivate(QGeoRouteReply::Error error, QString errorString)
+ : error(error),
+ errorString(errorString),
+ isFinished(true) {}
+
+QGeoRouteReplyPrivate::~QGeoRouteReplyPrivate() {}
+
+#include "moc_qgeoroutereply.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeoroutereply.h b/src/location/maps/qgeoroutereply.h
new file mode 100644
index 00000000..897c718b
--- /dev/null
+++ b/src/location/maps/qgeoroutereply.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTEREPLY_H
+#define QGEOROUTEREPLY_H
+
+#include "qgeoroute.h"
+
+#include <QList>
+#include <QObject>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRouteRequest;
+class QGeoRouteReplyPrivate;
+
+class Q_LOCATION_EXPORT QGeoRouteReply : public QObject
+{
+ Q_OBJECT
+public:
+ enum Error {
+ NoError,
+ EngineNotSetError,
+ CommunicationError,
+ ParseError,
+ UnsupportedOptionError,
+ UnknownError
+ };
+
+ QGeoRouteReply(Error error, const QString &errorString, QObject *parent = 0);
+ virtual ~QGeoRouteReply();
+
+ bool isFinished() const;
+ Error error() const;
+ QString errorString() const;
+
+ QGeoRouteRequest request() const;
+ QList<QGeoRoute> routes() const;
+
+ virtual void abort();
+
+Q_SIGNALS:
+ void finished();
+ void error(QGeoRouteReply::Error error, const QString &errorString = QString());
+
+protected:
+ QGeoRouteReply(const QGeoRouteRequest &request, QObject *parent = 0);
+
+ void setError(Error error, const QString &errorString);
+ void setFinished(bool finished);
+
+ void setRoutes(const QList<QGeoRoute> &routes);
+
+private:
+ QGeoRouteReplyPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoRouteReply)
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeoroutereply_p.h b/src/location/maps/qgeoroutereply_p.h
new file mode 100644
index 00000000..4c4e5f59
--- /dev/null
+++ b/src/location/maps/qgeoroutereply_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTEREPLY_P_H
+#define QGEOROUTEREPLY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeorouterequest.h"
+#include "qgeoroutereply.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRoute;
+
+class QGeoRouteReplyPrivate
+{
+public:
+ QGeoRouteReplyPrivate(const QGeoRouteRequest &request);
+ QGeoRouteReplyPrivate(QGeoRouteReply::Error error, QString errorString);
+ ~QGeoRouteReplyPrivate();
+
+ QGeoRouteReply::Error error;
+ QString errorString;
+ bool isFinished;
+
+ QGeoRouteRequest request;
+ QList<QGeoRoute> routes;
+
+private:
+ Q_DISABLE_COPY(QGeoRouteReplyPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp
new file mode 100644
index 00000000..d4a41ac0
--- /dev/null
+++ b/src/location/maps/qgeorouterequest.cpp
@@ -0,0 +1,488 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeorouterequest.h"
+#include "qgeorouterequest_p.h"
+
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRouteRequest
+ \brief The QGeoRouteRequest class represents the parameters and restrictions
+ which define a request for routing information.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ The default state of a QGeoRouteRequest instance will result in a request
+ for basic route segment and navigation maneuvers describing the fastest
+ route by car which covers the given waypoints.
+
+ There may be signifcant variation in the features supported by different
+ providers of routing information, or even in the features supported by
+ the same provider if different levels of authorization are used.
+
+ There are several functions in QGeoRoutingManager which can be used to
+ check which features are supported with the current provider and
+ authorization level.
+ \sa QGeoRoutingManager
+*/
+
+/*
+ DESIGN NOTE
+
+ There are plans to make this extensible by allowing the user to set a
+ list of QGeoTransportOptions (or QGeoTransitOptions). We don't have any
+ subclasses for that just yet, otherwise they'd be present.
+
+ A QGeoPublicTransportOption subclass would allow users to specify things
+ like cost limits, the maximum number of changes of vehicle, the maximum
+ walking time / distance between changes of vehicle.
+
+ There's Nokia / Navteq support for specifying things like Truck attributes
+ so you can route around various road restrictions and conditions which
+ effect trucks.
+
+ A QGeoTrafficAwareTransportOption is probably also a good place to put the
+ inputs for the various traffic / time aware bits of information. A
+ departure / arrrival time could be set, and the presence of this transport
+ options subclass (and the fact that user auth said that the user had
+ support) would mean we could provide better values for the estimated
+ travel times etc...
+
+ This all relies on at least one service making this data available to us,
+ which would probably be tied to token based authorization. It could be
+ some time before this becomes available.
+*/
+
+/*!
+ \enum QGeoRouteRequest::TravelMode
+
+ Defines modes of travel to be used for a route.
+
+ \value CarTravel
+ The route will be optimized for someone who is driving a car.
+ \value PedestrianTravel
+ The route will be optimized for someone who is walking.
+ \value BicycleTravel
+ The route will be optimized for someone who is riding a bicycle.
+ \value PublicTransitTravel
+ The route will be optimized for someone who is making use of public transit.
+ \value TruckTravel
+ The route will be optimized for someone who is driving a truck.
+*/
+
+/*!
+ \enum QGeoRouteRequest::FeatureType
+
+ Defines a feature which is important to the planning of a route.
+
+ These values will be used in combination with
+ QGeoRouteRequest::FeatureWeight to determine if they should or should
+ not be part of the route.
+
+ \value NoFeature
+ Used by QGeoRoutingManager::supportedFeatureTypes() to indicate that
+ no features will be taken into account when planning the route.
+ \value TollFeature
+ Consdier tollways when planning the route.
+ \value HighwayFeature
+ Consider highways when planning the route.
+ \value PublicTransitFeature
+ Consider public transit when planning the route.
+ \value FerryFeature
+ Consider ferries when planning the route.
+ \value TunnelFeature
+ Consider tunnels when planning the route.
+ \value DirtRoadFeature
+ Consider dirt roads when planning the route.
+ \value ParksFeature
+ Consider parks when planning the route.
+ \value MotorPoolLaneFeature
+ Consider motor pool lanes when planning the route.
+*/
+
+/*!
+ \enum QGeoRouteRequest::FeatureWeight
+
+ Defines the weight to associate with a feature during the
+ planning of a route.
+
+ These values will be used in combination with
+ QGeoRouteRequest::Feature to determine if they should or should
+ not be part of the route.
+
+ \value NeutralFeatureWeight
+ The presence or absence of the feature will not affect the
+ planning of the route.
+ \value PreferFeatureWeight
+ Routes which contain the feature will be preferred over those that do
+ not.
+ \value RequireFeatureWeight
+ Only routes which contain the feature will be considered, otherwise
+ no route will be returned.
+ \value AvoidFeatureWeight
+ Routes which do not contain the feature will be preferred over those
+ that do.
+ \value DisallowFeatureWeight
+ Only routes which do not contain the feature will be considered,
+ otherwise no route will be returned.
+*/
+
+// TODO improve description of MostScenicRoute
+/*!
+ \enum QGeoRouteRequest::RouteOptimization
+
+ Defines the type of optimization which is applied to the planning of the route.
+
+ \value ShortestRoute
+ Minimize the length of the journey.
+ \value FastestRoute
+ Minimize the traveling time for the journey.
+ \value MostEconomicRoute
+ Minimize the cost of the journey.
+ \value MostScenicRoute
+ Maximize the scenic potential of the journey.
+*/
+
+/*!
+ \enum QGeoRouteRequest::SegmentDetail
+
+ Defines the amount of route segment information that shoudl be included
+ with the route.
+
+ \value NoSegmentData
+ No segment data should be included with the route. A route requested
+ with this level of segment detail will initialise
+ QGeoRouteSegment::path() as a straight line between the positions of
+ the previous and next QGeoManeuver instances.
+
+ \value BasicSegmentData
+ Basic segment data will be included with the route. This will include
+ QGeoRouteSegment::path().
+*/
+
+/*!
+ \enum QGeoRouteRequest::ManeuverDetail
+
+ Defines the amount of maneuver information that should be included with
+ the route.
+
+ \value NoManeuvers
+ No maneuvers should be included with the route.
+
+ \value BasicManeuvers
+ Basic manevuers will be included with the route. This will
+ include QGeoManeuver::instructionText().
+*/
+
+/*!
+ Constructs a request to calculate a route through the coordinates \a waypoints.
+
+ The route will traverse the elements of \a waypoints in order.
+*/
+QGeoRouteRequest::QGeoRouteRequest(const QList<QGeoCoordinate> &waypoints)
+ : d_ptr(new QGeoRouteRequestPrivate())
+{
+ d_ptr->waypoints = waypoints;
+}
+
+/*!
+ Constructs a request to calculate a route between \a origin and
+ \a destination.
+*/
+QGeoRouteRequest::QGeoRouteRequest(const QGeoCoordinate &origin, const QGeoCoordinate &destination)
+ : d_ptr(new QGeoRouteRequestPrivate())
+{
+ d_ptr->waypoints.append(origin);
+ d_ptr->waypoints.append(destination);
+}
+
+/*!
+ Constructs a route request object from the contents of \a other.
+*/
+QGeoRouteRequest::QGeoRouteRequest(const QGeoRouteRequest &other)
+ : d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys the request.
+*/
+QGeoRouteRequest::~QGeoRouteRequest() {}
+
+/*!
+ Assigns \a other to this route request object and then returns a reference
+ to this route request object.
+*/
+QGeoRouteRequest& QGeoRouteRequest::operator= (const QGeoRouteRequest & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this route request and \a other are equal.
+*/
+bool QGeoRouteRequest::operator ==(const QGeoRouteRequest &other) const
+{
+ return (d_ptr.constData() == other.d_ptr.constData());
+}
+
+/*!
+ Returns whether this route request and \a other are equal.
+*/
+bool QGeoRouteRequest::operator !=(const QGeoRouteRequest &other) const
+{
+ return (d_ptr.constData() != other.d_ptr.constData());
+}
+
+/*!
+ Sets \a waypoints as the waypoints that the route should pass through.
+
+ The waypoints should be given in order from origin to destination.
+
+ This request will be invalid until the waypoints have been set to a
+ list containing two or more coordinates.
+*/
+void QGeoRouteRequest::setWaypoints(const QList<QGeoCoordinate> &waypoints)
+{
+ d_ptr->waypoints = waypoints;
+}
+
+/*!
+ Returns the waypoints that the route will pass through.
+*/
+QList<QGeoCoordinate> QGeoRouteRequest::waypoints() const
+{
+ return d_ptr->waypoints;
+}
+
+/*!
+ Sets \a areas as excluded areas that the route must not cross.
+*/
+void QGeoRouteRequest::setExcludeAreas(const QList<QGeoBoundingBox> &areas)
+{
+ d_ptr->excludeAreas = areas;
+}
+
+/*!
+ Returns areas the route must not cross.
+*/
+QList<QGeoBoundingBox> QGeoRouteRequest::excludeAreas() const
+{
+ return d_ptr->excludeAreas;
+}
+
+/*!
+ Sets the number of alternative routes to request to \a alternatives.
+
+ The default value is 0.
+*/
+void QGeoRouteRequest::setNumberAlternativeRoutes(int alternatives)
+{
+ d_ptr->numberAlternativeRoutes = alternatives;
+}
+
+/*!
+ Returns the number of alternative routes which will be requested.
+*/
+int QGeoRouteRequest::numberAlternativeRoutes() const
+{
+ return d_ptr->numberAlternativeRoutes;
+}
+
+/*!
+ Sets the travel modes which should be considered during the planning of the
+ route to \a travelModes.
+
+ The default value is QGeoRouteRequest::CarTravel.
+*/
+void QGeoRouteRequest::setTravelModes(QGeoRouteRequest::TravelModes travelModes)
+{
+ d_ptr->travelModes = travelModes;
+}
+
+/*!
+ Returns the travel modes which this request specifies should be considered
+ during the planning of the route.
+*/
+QGeoRouteRequest::TravelModes QGeoRouteRequest::travelModes() const
+{
+ return d_ptr->travelModes;
+}
+
+/*!
+ Assigns the weight \a featureWeight to the feauture \a featureType during
+ the planning of the route.
+
+ By default all features are assigned a weight of NeutralFeatureWeight.
+
+ It is impossible to assign a weight to QGeoRouteRequest::NoFeature.
+*/
+void QGeoRouteRequest::setFeatureWeight(QGeoRouteRequest::FeatureType featureType, QGeoRouteRequest::FeatureWeight featureWeight)
+{
+ if (featureWeight != QGeoRouteRequest::NeutralFeatureWeight) {
+ if (featureType != QGeoRouteRequest::NoFeature)
+ d_ptr->featureWeights[featureType] = featureWeight;
+ } else {
+ d_ptr->featureWeights.remove(featureType);
+ }
+}
+
+/*!
+ Returns the weight assigned to \a featureType in the planning of the route.
+
+ If no feature weight has been specified for \a featureType then
+ NeutralFeatureWeight will be returned.
+*/
+QGeoRouteRequest::FeatureWeight QGeoRouteRequest::featureWeight(QGeoRouteRequest::FeatureType featureType) const
+{
+ return d_ptr->featureWeights.value(featureType, QGeoRouteRequest::NeutralFeatureWeight);
+}
+
+/*!
+ Returns the list of features that will be considered when planning the
+ route. Features with a weight of NeutralFeatureWeight will not be returned.
+*/
+QList<QGeoRouteRequest::FeatureType> QGeoRouteRequest::featureTypes() const
+{
+ return d_ptr->featureWeights.keys();
+}
+
+/*!
+ Sets the optimization criteria to use while planning the route to
+ \a optimization.
+
+ The default value is QGeoRouteRequest::FastestRoute.
+*/
+void QGeoRouteRequest::setRouteOptimization(QGeoRouteRequest::RouteOptimizations optimization)
+{
+ d_ptr->routeOptimization = optimization;
+}
+
+/*!
+ Returns the optimization criteria which this request specifies should be
+ used while planning the route.
+*/
+QGeoRouteRequest::RouteOptimizations QGeoRouteRequest::routeOptimization() const
+{
+ return d_ptr->routeOptimization;
+}
+
+/*!
+ Sets the level of detail to use when representing routing segments to
+ \a segmentDetail.
+*/
+void QGeoRouteRequest::setSegmentDetail(QGeoRouteRequest::SegmentDetail segmentDetail)
+{
+ d_ptr->segmentDetail = segmentDetail;
+}
+
+/*!
+ Returns the level of detail which will be used in the representation of
+ routing segments.
+*/
+QGeoRouteRequest::SegmentDetail QGeoRouteRequest::segmentDetail() const
+{
+ return d_ptr->segmentDetail;
+}
+
+/*!
+ Sets the level of detail to use when representing routing maneuvers to
+ \a maneuverDetail.
+
+ The default value is QGeoRouteRequest::BasicManeuvers.
+*/
+void QGeoRouteRequest::setManeuverDetail(QGeoRouteRequest::ManeuverDetail maneuverDetail)
+{
+ d_ptr->maneuverDetail = maneuverDetail;
+}
+
+/*!
+ Returns the level of detail which will be used in the representation of
+ routing maneuvers.
+*/
+QGeoRouteRequest::ManeuverDetail QGeoRouteRequest::maneuverDetail() const
+{
+ return d_ptr->maneuverDetail;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRouteRequestPrivate::QGeoRouteRequestPrivate()
+ : QSharedData(),
+ numberAlternativeRoutes(0),
+ travelModes(QGeoRouteRequest::CarTravel),
+ routeOptimization(QGeoRouteRequest::FastestRoute),
+ segmentDetail(QGeoRouteRequest::BasicSegmentData),
+ maneuverDetail(QGeoRouteRequest::BasicManeuvers) {}
+
+QGeoRouteRequestPrivate::QGeoRouteRequestPrivate(const QGeoRouteRequestPrivate &other)
+ : QSharedData(other),
+ waypoints(other.waypoints),
+ excludeAreas(other.excludeAreas),
+ numberAlternativeRoutes(other.numberAlternativeRoutes),
+ travelModes(other.travelModes),
+ featureWeights(other.featureWeights),
+ routeOptimization(other.routeOptimization),
+ segmentDetail(other.segmentDetail),
+ maneuverDetail(other.maneuverDetail) {}
+
+QGeoRouteRequestPrivate::~QGeoRouteRequestPrivate() {}
+
+bool QGeoRouteRequestPrivate::operator ==(const QGeoRouteRequestPrivate &other) const
+{
+ return ((waypoints == other.waypoints)
+ && (excludeAreas == other.excludeAreas)
+ && (numberAlternativeRoutes == other.numberAlternativeRoutes)
+ && (travelModes == other.travelModes)
+ && (featureWeights == other.featureWeights)
+ && (routeOptimization == other.routeOptimization)
+ && (segmentDetail == other.segmentDetail)
+ && (maneuverDetail == other.maneuverDetail));
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeorouterequest.h b/src/location/maps/qgeorouterequest.h
new file mode 100644
index 00000000..64581fff
--- /dev/null
+++ b/src/location/maps/qgeorouterequest.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTEREQUEST_H
+#define QGEOROUTEREQUEST_H
+
+#include "qmobilityglobal.h"
+
+#include <QList>
+#include <QExplicitlySharedDataPointer>
+#include <QDateTime>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBox;
+class QGeoRouteRequestPrivate;
+
+class Q_LOCATION_EXPORT QGeoRouteRequest
+{
+public:
+ enum TravelMode {
+ CarTravel = 0x0001,
+ PedestrianTravel = 0x0002,
+ BicycleTravel = 0x0004,
+ PublicTransitTravel = 0x0008,
+ TruckTravel = 0x0010
+ };
+ Q_DECLARE_FLAGS(TravelModes, TravelMode)
+
+ enum FeatureType {
+ NoFeature = 0x00000000,
+ TollFeature = 0x00000001,
+ HighwayFeature = 0x00000002,
+ PublicTransitFeature = 0x00000004,
+ FerryFeature = 0x00000008,
+ TunnelFeature = 0x00000010,
+ DirtRoadFeature = 0x00000020,
+ ParksFeature = 0x00000040,
+ MotorPoolLaneFeature = 0x00000080
+ };
+ Q_DECLARE_FLAGS(FeatureTypes, FeatureType)
+
+ enum FeatureWeight {
+ NeutralFeatureWeight = 0x00000000,
+ PreferFeatureWeight = 0x00000001,
+ RequireFeatureWeight = 0x00000002,
+ AvoidFeatureWeight = 0x00000004,
+ DisallowFeatureWeight = 0x00000008
+ };
+ Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)
+
+ enum RouteOptimization {
+ ShortestRoute = 0x0001,
+ FastestRoute = 0x0002,
+ MostEconomicRoute = 0x0004,
+ MostScenicRoute = 0x0008
+ };
+ Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)
+
+ enum SegmentDetail {
+ NoSegmentData = 0x0000,
+ BasicSegmentData = 0x0001
+ };
+ Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)
+
+ enum ManeuverDetail {
+ NoManeuvers = 0x0000,
+ BasicManeuvers = 0x0001
+ };
+ Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)
+
+ QGeoRouteRequest(const QList<QGeoCoordinate> &waypoints = QList<QGeoCoordinate>());
+ QGeoRouteRequest(const QGeoCoordinate &origin,
+ const QGeoCoordinate &destination);
+ QGeoRouteRequest(const QGeoRouteRequest &other);
+
+ ~QGeoRouteRequest();
+
+ QGeoRouteRequest& operator= (const QGeoRouteRequest &other);
+
+ bool operator == (const QGeoRouteRequest &other) const;
+ bool operator != (const QGeoRouteRequest &other) const;
+
+ void setWaypoints(const QList<QGeoCoordinate> &waypoints);
+ QList<QGeoCoordinate> waypoints() const;
+
+ void setExcludeAreas(const QList<QGeoBoundingBox> &areas);
+ QList<QGeoBoundingBox> excludeAreas() const;
+
+ // defaults to 0
+ void setNumberAlternativeRoutes(int alternatives);
+ int numberAlternativeRoutes() const;
+
+ // defaults to TravelByCar
+ void setTravelModes(TravelModes travelModes);
+ TravelModes travelModes() const;
+
+ void setFeatureWeight(FeatureType featureType, FeatureWeight featureWeight);
+ FeatureWeight featureWeight(FeatureType featureType) const;
+ QList<FeatureType> featureTypes() const;
+
+ // defaults to OptimizeFastest
+ void setRouteOptimization(RouteOptimizations optimization);
+ RouteOptimizations routeOptimization() const;
+
+ // defaults to BasicSegmentData
+ void setSegmentDetail(SegmentDetail segmentDetail);
+ SegmentDetail segmentDetail() const;
+
+ // defaults to BasicManeuvers
+ void setManeuverDetail(ManeuverDetail maneuverDetail);
+ ManeuverDetail maneuverDetail() const;
+
+private:
+ QExplicitlySharedDataPointer<QGeoRouteRequestPrivate> d_ptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::TravelModes)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::FeatureTypes)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::FeatureWeights)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::RouteOptimizations)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::SegmentDetails)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoRouteRequest::ManeuverDetails)
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeorouterequest_p.h b/src/location/maps/qgeorouterequest_p.h
new file mode 100644
index 00000000..726b91c5
--- /dev/null
+++ b/src/location/maps/qgeorouterequest_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTEREQUEST_P_H
+#define QGEOROUTEREQUEST_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeorouterequest.h"
+
+#include <QList>
+#include <QSharedData>
+#include <QDateTime>
+#include <QMap>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRouteRequestPrivate : public QSharedData
+{
+public:
+ QGeoRouteRequestPrivate();
+ QGeoRouteRequestPrivate(const QGeoRouteRequestPrivate &other);
+ ~QGeoRouteRequestPrivate();
+
+ bool operator ==(const QGeoRouteRequestPrivate &other) const;
+
+ QList<QGeoCoordinate> waypoints;
+ QList<QGeoBoundingBox> excludeAreas;
+ int numberAlternativeRoutes;
+ QGeoRouteRequest::TravelModes travelModes;
+ QMap < QGeoRouteRequest::FeatureType,
+ QGeoRouteRequest::FeatureWeight > featureWeights;
+ QGeoRouteRequest::RouteOptimizations routeOptimization;
+ QGeoRouteRequest::SegmentDetail segmentDetail;
+ QGeoRouteRequest::ManeuverDetail maneuverDetail;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutesegment.cpp b/src/location/maps/qgeoroutesegment.cpp
new file mode 100644
index 00000000..d86e8dfe
--- /dev/null
+++ b/src/location/maps/qgeoroutesegment.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoroutesegment.h"
+#include "qgeoroutesegment_p.h"
+
+#include "qgeocoordinate.h"
+#include <QDateTime>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRouteSegment
+ \brief The QGeoRouteSegment class represents a segment of a route.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ A QGeoRouteSegment instance has information about the physcial layout
+ of the route segment, the length of the route and estimated time required
+ to traverse the route segment and an optional QGeoManeuver associated with
+ the end of the route segment.
+
+ QGeoRouteSegment instances can be thought of as edges on a routing
+ graph, with QGeoManeuver instances as optional labels attached to the
+ vertices of the graph.
+*/
+
+/*!
+ Constructs an invalid route segment object.
+
+ The route segment will remain invalid until one of setNextRouteSegment(),
+ setTravelTime(), setDistance(), setPath() or setManeuver() is called.
+*/
+QGeoRouteSegment::QGeoRouteSegment()
+ : d_ptr(new QGeoRouteSegmentPrivate()) {}
+
+/*!
+ Constructs a route segment object from the contents of \a other.
+*/
+QGeoRouteSegment::QGeoRouteSegment(const QGeoRouteSegment &other)
+ : d_ptr(other.d_ptr) {}
+
+/*!
+ \internal
+*/
+QGeoRouteSegment::QGeoRouteSegment(QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> &d_ptr)
+ : d_ptr(d_ptr) {}
+
+/*!
+ Destroys this route segment object.
+*/
+QGeoRouteSegment::~QGeoRouteSegment() {}
+
+
+/*!
+ Assigns \a other to this route segment object and then returns a
+ reference to this route segment object.
+*/
+QGeoRouteSegment& QGeoRouteSegment::operator= (const QGeoRouteSegment & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this route segment and \a other are equal.
+
+ The value of nextRouteSegment() is not considered in the comparison.
+*/
+bool QGeoRouteSegment::operator ==(const QGeoRouteSegment &other) const
+{
+ return (d_ptr.constData() == other.d_ptr.constData());
+}
+
+/*!
+ Returns whether this route segment and \a other are not equal.
+
+ The value of nextRouteSegment() is not considered in the comparison.
+*/
+bool QGeoRouteSegment::operator !=(const QGeoRouteSegment &other) const
+{
+ return !(operator==(other));
+}
+
+/*!
+ Returns whether this route segment is valid or not.
+
+ If nextRouteSegment() is called on the last route segment of a route, the
+ returned value will be an invalid route segment.
+*/
+bool QGeoRouteSegment::isValid() const
+{
+ return d_ptr->valid;
+}
+
+/*!
+ Sets the next route segment in the route to \a routeSegment.
+*/
+void QGeoRouteSegment::setNextRouteSegment(const QGeoRouteSegment &routeSegment)
+{
+ d_ptr->valid = true;
+ d_ptr->nextSegment = routeSegment.d_ptr;
+}
+
+/*!
+ Returns the next route segment in the route.
+
+ Will return an invalid route segment if this is the last route
+ segment in the route.
+*/
+QGeoRouteSegment QGeoRouteSegment::nextRouteSegment() const
+{
+ if (d_ptr->valid && d_ptr->nextSegment)
+ return QGeoRouteSegment(d_ptr->nextSegment);
+
+ QGeoRouteSegment segment;
+ segment.d_ptr->valid = false;
+ return segment;
+}
+
+/*!
+ Sets the estimated amount of time it will take to traverse this segment of
+ the route, in seconds, to \a secs.
+*/
+void QGeoRouteSegment::setTravelTime(int secs)
+{
+ d_ptr->valid = true;
+ d_ptr->travelTime = secs;
+}
+
+/*!
+ Returns the estimated amount of time it will take to traverse this segment
+ of the route, in seconds.
+*/
+int QGeoRouteSegment::travelTime() const
+{
+ return d_ptr->travelTime;
+}
+
+/*!
+ Sets the distance covered by this segment of the route, in metres, to \a distance.
+*/
+void QGeoRouteSegment::setDistance(qreal distance)
+{
+ d_ptr->valid = true;
+ d_ptr->distance = distance;
+}
+
+/*!
+ Returns the distance covered by this segment of the route, in metres.
+*/
+qreal QGeoRouteSegment::distance() const
+{
+ return d_ptr->distance;
+}
+
+/*!
+ Sets the geometric shape of this segment of the route to \a path.
+
+ The coordinates in \a path should be listed in the order in which they
+ would be traversed by someone traveling along this segment of the route.
+*/
+void QGeoRouteSegment::setPath(const QList<QGeoCoordinate> &path)
+{
+ d_ptr->valid = true;
+ d_ptr->path = path;
+}
+
+/*!
+ Returns the geometric shape of this route segment of the route.
+
+ The coordinates should be listed in the order in which they
+ would be traversed by someone traveling along this segment of the route.
+*/
+
+QList<QGeoCoordinate> QGeoRouteSegment::path() const
+{
+ return d_ptr->path;
+}
+
+/*!
+ Sets the maneuver for this route segement to \a maneuver.
+*/
+void QGeoRouteSegment::setManeuver(const QGeoManeuver &maneuver)
+{
+ d_ptr->valid = true;
+ d_ptr->maneuver = maneuver;
+}
+
+/*!
+ Returns the manevuer for this route segment.
+
+ Will return an invalid QGeoManeuver if no information has been attached
+ to the endpoint of this route segment.
+*/
+QGeoManeuver QGeoRouteSegment::maneuver() const
+{
+ return d_ptr->maneuver;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate()
+ : valid(false),
+ travelTime(0),
+ distance(0.0) {}
+
+QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate(const QGeoRouteSegmentPrivate &other)
+ : QSharedData(other),
+ valid(other.valid),
+ travelTime(other.travelTime),
+ distance(other.distance),
+ path(other.path),
+ maneuver(other.maneuver),
+ nextSegment(other.nextSegment) {}
+
+QGeoRouteSegmentPrivate::~QGeoRouteSegmentPrivate()
+{
+ nextSegment.reset();
+}
+
+bool QGeoRouteSegmentPrivate::operator ==(const QGeoRouteSegmentPrivate &other) const
+{
+ return ((valid == other.valid)
+ && (travelTime == other.travelTime)
+ && (distance == other.distance)
+ && (path == other.path)
+ && (maneuver == other.maneuver));
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeoroutesegment.h b/src/location/maps/qgeoroutesegment.h
new file mode 100644
index 00000000..58f45a4c
--- /dev/null
+++ b/src/location/maps/qgeoroutesegment.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTESEGMENT_H
+#define QGEOROUTESEGMENT_H
+
+#include "qmobilityglobal.h"
+
+#include <QExplicitlySharedDataPointer>
+#include <QList>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoManeuver;
+class QGeoRouteSegmentPrivate;
+
+class Q_LOCATION_EXPORT QGeoRouteSegment
+{
+
+public:
+ QGeoRouteSegment();
+ QGeoRouteSegment(const QGeoRouteSegment &other);
+ ~QGeoRouteSegment();
+
+ QGeoRouteSegment& operator= (const QGeoRouteSegment &other);
+
+ bool operator ==(const QGeoRouteSegment &other) const;
+ bool operator !=(const QGeoRouteSegment &other) const;
+
+ bool isValid() const;
+
+ void setNextRouteSegment(const QGeoRouteSegment &routeSegment);
+ QGeoRouteSegment nextRouteSegment() const;
+
+ void setTravelTime(int secs);
+ int travelTime() const;
+
+ void setDistance(qreal distance);
+ qreal distance() const;
+
+ void setPath(const QList<QGeoCoordinate> &path);
+ QList<QGeoCoordinate> path() const;
+
+ void setManeuver(const QGeoManeuver &maneuver);
+ QGeoManeuver maneuver() const;
+
+protected:
+ QGeoRouteSegment(QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> &d_ptr);
+
+private:
+ QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeoroutesegment_p.h b/src/location/maps/qgeoroutesegment_p.h
new file mode 100644
index 00000000..474fb1ca
--- /dev/null
+++ b/src/location/maps/qgeoroutesegment_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTESEGMENT_P_H
+#define QGEOROUTESEGMENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomaneuver.h"
+
+#include <QSharedData>
+#include <QList>
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class QGeoRouteSegmentPrivate : public QSharedData
+{
+public:
+ QGeoRouteSegmentPrivate();
+ QGeoRouteSegmentPrivate(const QGeoRouteSegmentPrivate &other);
+ ~QGeoRouteSegmentPrivate();
+
+ bool operator ==(const QGeoRouteSegmentPrivate &other) const;
+
+ bool valid;
+
+ int travelTime;
+ qreal distance;
+ QList<QGeoCoordinate> path;
+ QGeoManeuver maneuver;
+
+ QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> nextSegment;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutingmanager.cpp b/src/location/maps/qgeoroutingmanager.cpp
new file mode 100644
index 00000000..539369d7
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanager.cpp
@@ -0,0 +1,419 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoroutingmanager.h"
+#include "qgeoroutingmanager_p.h"
+#include "qgeoroutingmanagerengine.h"
+
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRoutingManager
+
+ \brief The QGeoRoutingManager class provides support for geographic routing
+ operations.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-routing
+
+ The calculateRoute() and updateRoute() methods function QGeoRouteReply
+ objects, which manage these operations and report on the result of the
+ operations and any errors which may have occurred.
+
+ The calculateRoute() function is used to find a route (or routes) that
+ follows a set of waypoints and matches various other criteria. The
+ QGeoRouteRequest class is used to specify this information.
+
+ If supportsRouteUpdates() returns true then the QGeoRoutingManager
+ supports updating route information based on position updates. This
+ will cause the travel time and distance estimates to be updated, and
+ any QGeoRouteSegments already traversed to be removed from the route.
+
+ The updates can be triggered with the updateRoute() function, which makes
+ use of the QGeoPositionInfo instances emitted as position updates by
+ QGeoPositionInfoSource.
+
+ Instances of QGeoRoutingManager can be accessed with
+ QGeoServiceProvider::routingManager().
+
+ A small example of the usage of QGeoRoutingManager and QGeoRouteRequests
+ follows:
+
+ \code
+class MyRouteHandler : public QObject
+{
+ Q_OBJECT
+public:
+ MyRouteHandler(QGeoRoutingManager *routingManager,
+ const QGeoCoordinate &origin,
+ const QGeoCoordinate &destination) {
+
+ QGeoRouteRequest request(origin, destination);
+
+ // The request defaults to the fastest route by car, which is
+ // equivalent to:
+ // request.setTravelMode(QGeoRouteRequest::CarTravel);
+ // request.setRouteOptimization(QGeoRouteRequest::FastestRoute);
+
+ request.setAvoidFeatureTypes(QGeoRouteRequest::AvoidTolls);
+ request.setAvoidFeatureTypes(QGeoRouteRequest::AvoidMotorPoolLanes);
+
+ QGeoRouteRequest::AvoidFeaturesTypes avoidableFeatures = routingManager->supportedAvoidFeatureTypes();
+
+ if (!(avoidableFeatures & request.avoidFeatureTypes())) {
+ // ... inform the user that the routing manager does not
+ // provide support for avoiding tolls and/or motor pool lanes ...
+ return;
+ }
+
+ QGeoRouteReply *reply = routingManager->calculateRoute(request);
+
+ if (reply->isFinished()) {
+ if (reply->error() == QGeoRouteReply::NoError) {
+ routeCalculated(reply);
+ } else {
+ routeError(reply, reply->error(), reply->errorString());
+ }
+ return;
+ }
+
+ connect(routingManager,
+ SIGNAL(finished(QGeoRouteReply*)),
+ this,
+ SLOT(routeCalculated(QGeoRouteReply*)));
+
+ connect(routingManager,
+ SIGNAL(error(QGeoRouteReply*,QGeoRouteReply::Error,QString)),
+ this,
+ SLOT(routeError(QGeoRouteReply*,QGeoRouteReply::Error,QString)));
+ }
+
+private slots:
+ void routeCalculated(QGeoRouteReply *reply)
+ {
+ // A route request can ask for several alternative routes ...
+ if (reply->routes().size() != 0) {
+
+ // ... but by default it will only get a single route
+ QGeoRoute route = reply->routes().at(0);
+
+ //... now we have to make use of the route ...
+ }
+
+ reply->deleteLater();
+ }
+
+ void routeError(QGeoRouteReply *reply, QGeoRouteReply:Error error, const QString &errorString)
+ {
+ // ... inform the user that an error has occurred ...
+ reply->deleteLater();
+ }
+};
+ \endcode
+*/
+
+/*!
+ Constructs a new manager with the specified \a parent and with the
+ implementation provided by \a engine.
+
+ This constructor is used internally by QGeoServiceProviderFactory. Regular
+ users should acquire instances of QGeoRoutingManager with
+ QGeoServiceProvider::routingManager();
+*/
+QGeoRoutingManager::QGeoRoutingManager(QGeoRoutingManagerEngine *engine, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoRoutingManagerPrivate())
+{
+ d_ptr->engine = engine;
+ if (d_ptr->engine) {
+ d_ptr->engine->setParent(this);
+
+ connect(d_ptr->engine,
+ SIGNAL(finished(QGeoRouteReply*)),
+ this,
+ SIGNAL(finished(QGeoRouteReply*)));
+
+ connect(d_ptr->engine,
+ SIGNAL(error(QGeoRouteReply*, QGeoRouteReply::Error, QString)),
+ this,
+ SIGNAL(error(QGeoRouteReply*, QGeoRouteReply::Error, QString)));
+ } else {
+ qFatal("The routing manager engine that was set for this routing manager was NULL.");
+ }
+}
+
+/*!
+ Destroys this manager.
+*/
+QGeoRoutingManager::~QGeoRoutingManager()
+{
+ delete d_ptr;
+}
+
+/*!
+ Returns the name of the engine which implements the behaviour of this
+ routing manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+QString QGeoRoutingManager::managerName() const
+{
+ return d_ptr->engine->managerName();
+}
+
+/*!
+ Returns the version of the engine which implements the behaviour of this
+ routin manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+int QGeoRoutingManager::managerVersion() const
+{
+ return d_ptr->engine->managerVersion();
+}
+
+/*!
+ Begins the calculation of the route specified by \a request.
+
+ A QGeoRouteReply object will be returned, which can be used to manage the
+ routing operation and to return the results of the operation.
+
+ This manager and the returned QGeoRouteReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ Once the operation has completed, QGeoRouteReply::routes can be used to
+ retrieve the calculated route or routes.
+
+ If \a request includes features which are not supported by this manager, as
+ reported by the methods in this manager, then a
+ QGeoRouteReply::UnsupportedOptionError will occur.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoRoutingManager::finished(),
+ QGeoRoutingManager::error(), QGeoRouteReply::finished() or
+ QGeoRouteReply::error() with deleteLater().
+*/
+QGeoRouteReply* QGeoRoutingManager::calculateRoute(const QGeoRouteRequest& request)
+{
+ return d_ptr->engine->calculateRoute(request);
+}
+
+/*!
+ Begins the process of updating \a route based on the current position \a
+ position.
+
+ A QGeoRouteReply object will be returned, which can be used to manage the
+ routing operation and to return the results of the operation.
+
+ This manager and the returned QGeoRouteReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsRouteUpdates() returns false an
+ QGeoRouteReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoRouteReply::routes can be used to
+ retrieve the updated route.
+
+ The returned route could be entirely different to the original route,
+ especially if \a position is far away from the initial route.
+ Otherwise the route will be similar, although the remaining time and
+ distance will be updated and any segments of the original route which
+ have been traversed will be removed.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoRoutingManager::finished(),
+ QGeoRoutingManager::error(), QGeoRouteReply::finished() or
+ QGeoRouteReply::error() with deleteLater().
+*/
+QGeoRouteReply* QGeoRoutingManager::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position)
+{
+ return d_ptr->engine->updateRoute(route, position);
+}
+
+/*!
+ Returns whether this manager supports updating routes.
+*/
+bool QGeoRoutingManager::supportsRouteUpdates() const
+{
+ return d_ptr->engine->supportsRouteUpdates();
+}
+
+/*!
+ Returns whether this manager supports request for alternative routes.
+*/
+bool QGeoRoutingManager::supportsAlternativeRoutes() const
+{
+ return d_ptr->engine->supportsAlternativeRoutes();
+}
+
+/*!
+ Returns whether this engine supports the exclusion of areas from routes.
+*/
+bool QGeoRoutingManager::supportsExcludeAreas() const
+{
+ return d_ptr->engine->supportsExcludeAreas();
+}
+
+/*!
+ Returns the travel modes supported by this manager.
+*/
+QGeoRouteRequest::TravelModes QGeoRoutingManager::supportedTravelModes() const
+{
+ return d_ptr->engine->supportedTravelModes();
+}
+
+/*!
+ Returns the types of features that this manager can take into account
+ during route planning.
+*/
+QGeoRouteRequest::FeatureTypes QGeoRoutingManager::supportedFeatureTypes() const
+{
+ return d_ptr->engine->supportedFeatureTypes();
+}
+
+/*!
+ Returns the weightings which this manager can apply to different features
+ during route planning.
+*/
+QGeoRouteRequest::FeatureWeights QGeoRoutingManager::supportedFeatureWeights() const
+{
+ return d_ptr->engine->supportedFeatureWeights();
+}
+
+/*!
+ Returns the route optimizations supported by this manager.
+*/
+QGeoRouteRequest::RouteOptimizations QGeoRoutingManager::supportedRouteOptimizations() const
+{
+ return d_ptr->engine->supportedRouteOptimizations();
+}
+
+/*!
+ Returns the levels of detail for routing segments which can be requested
+ with this manager.
+*/
+QGeoRouteRequest::SegmentDetails QGeoRoutingManager::supportedSegmentDetails() const
+{
+ return d_ptr->engine->supportedSegmentDetails();
+}
+
+/*!
+ Returns the levels of detail for navigation maneuvers which can be
+ requested by this manager.
+*/
+QGeoRouteRequest::ManeuverDetails QGeoRoutingManager::supportedManeuverDetails() const
+{
+ return d_ptr->engine->supportedManeuverDetails();
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this routing manager supports returning addresses and instructions
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoRoutingManager::setLocale(const QLocale &locale)
+{
+ d_ptr->engine->setLocale(locale);
+}
+
+/*!
+ Returns the locale used to hint to this routing manager about what
+ language to use for addresses and instructions.
+*/
+QLocale QGeoRoutingManager::locale() const
+{
+ return d_ptr->engine->locale();
+}
+
+/*!
+\fn void QGeoRoutingManager::finished(QGeoRouteReply* reply)
+
+This signal is emitted when \a reply has finished processing.
+
+If reply::error() equals QGeoRouteReply::NoError then the processing
+finished successfully.
+
+This signal and QGeoRouteReply::finished() will be emitted at the same time.
+
+\note Do no delete the \a reply object in the slot connected to this signal.
+Use deleteLater() instead.
+*/
+
+/*!
+\fn void QGeoRoutingManager::error(QGeoRouteReply* reply, QGeoRouteReply::Error error, QString errorString)
+
+This signal is emitted when an error has been detected in the processing of
+\a reply. The QGeoRoutingManager::finished() signal will probably follow.
+
+The error will be described by the error code \a error. If \a errorString is
+not empty it will contain a textual description of the error.
+
+This signal and QGeoRouteReply::error() will be emitted at the same time.
+
+\note Do no delete the \a reply object in the slot connected to this signal.
+Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRoutingManagerPrivate::QGeoRoutingManagerPrivate()
+ : engine(0) {}
+
+QGeoRoutingManagerPrivate::~QGeoRoutingManagerPrivate()
+{
+ if (engine)
+ delete engine;
+}
+
+#include "moc_qgeoroutingmanager.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeoroutingmanager.h b/src/location/maps/qgeoroutingmanager.h
new file mode 100644
index 00000000..0442e968
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanager.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGER_H
+#define QGEOROUTINGMANAGER_H
+
+#include "qgeorouterequest.h"
+#include "qgeoroutereply.h"
+
+#include <QObject>
+#include <QMap>
+
+class QLocale;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRoutingManagerEngine;
+class QGeoRoutingManagerPrivate;
+
+class Q_LOCATION_EXPORT QGeoRoutingManager : public QObject
+{
+ Q_OBJECT
+public:
+ ~QGeoRoutingManager();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request);
+ QGeoRouteReply* updateRoute(const QGeoRoute &route, const QGeoCoordinate &position);
+
+ bool supportsRouteUpdates() const;
+ bool supportsAlternativeRoutes() const;
+ bool supportsExcludeAreas() const;
+ QGeoRouteRequest::TravelModes supportedTravelModes() const;
+ QGeoRouteRequest::FeatureTypes supportedFeatureTypes() const;
+ QGeoRouteRequest::FeatureWeights supportedFeatureWeights() const;
+ QGeoRouteRequest::RouteOptimizations supportedRouteOptimizations() const;
+ QGeoRouteRequest::SegmentDetails supportedSegmentDetails() const;
+ QGeoRouteRequest::ManeuverDetails supportedManeuverDetails() const;
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+Q_SIGNALS:
+ void finished(QGeoRouteReply* reply);
+ void error(QGeoRouteReply* reply, QGeoRouteReply::Error error, QString errorString = QString());
+
+private:
+ QGeoRoutingManager(QGeoRoutingManagerEngine *engine, QObject *parent = 0);
+
+ QGeoRoutingManagerPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoRoutingManager)
+
+ friend class QGeoServiceProvider;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutingmanager_p.h b/src/location/maps/qgeoroutingmanager_p.h
new file mode 100644
index 00000000..f469e808
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanager_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGER_P_H
+#define QGEOROUTINGMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRoutingManagerEngine;
+
+class QGeoRoutingManagerPrivate
+{
+public:
+ QGeoRoutingManagerPrivate();
+ ~QGeoRoutingManagerPrivate();
+
+ QGeoRoutingManagerEngine *engine;
+
+private:
+ Q_DISABLE_COPY(QGeoRoutingManagerPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutingmanagerengine.cpp b/src/location/maps/qgeoroutingmanagerengine.cpp
new file mode 100644
index 00000000..cdcb0def
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanagerengine.cpp
@@ -0,0 +1,468 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoroutingmanagerengine.h"
+#include "qgeoroutingmanagerengine_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoRoutingManagerEngine
+
+ \brief The QGeoRoutingManagerEngine class provides an interface and
+ convenience methods to implementers of QGeoServiceProvider plugins who want
+ to provide access to geographic routing information.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ Subclasses of QGeoRoutingManagerEngine need to provide an implementation of
+ calculateRoute().
+
+ In the default implementation, supportsRouteUpdates() returns false and
+ updateRoute() returns a QGeoRouteReply object containing a
+ QGeoRouteReply::UnsupportedOptionError.
+
+ If the routing service supports updating routes as they are being
+ travelled, the subclass should provide an implementation of updateRoute()
+ and call setSupportsRouteUpdates(true) at some point in time before
+ updateRoute() is called.
+
+ The function setSupportsRouteUpdates() is one of several functions which
+ configure the reported capabilities of the engine. If the capabilities
+ of an engine differ from the default values these functions should be
+ used so that the reported capabilies are accurate.
+
+ It is important that this is done before calculateRoute(), updateRoute()
+ or any of the capability reporting functions are used to prevent
+ incorrect or inconsistent behaviour.
+
+ A subclass of QGeoRouteManagerEngine will often make use of a subclass
+ fo QGeoRouteReply internally, in order to add any engine-specific
+ data (such as a QNetworkReply object for network-based services) to the
+ QGeoRouteReply instances used by the engine.
+
+ \sa QGeoRoutingManager
+*/
+
+/*!
+ Constructs a new engine with the specified \a parent, using \a parameters
+ to pass any implementation specific data to the engine.
+*/
+QGeoRoutingManagerEngine::QGeoRoutingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoRoutingManagerEnginePrivate())
+{
+ Q_UNUSED(parameters)
+}
+
+/*!
+ Destroys this engine.
+*/
+QGeoRoutingManagerEngine::~QGeoRoutingManagerEngine()
+{
+ delete d_ptr;
+}
+
+/*!
+ Sets the name which this engine implementation uses to distinguish itself
+ from the implementations provided by other plugins to \a managerName.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoRoutingManagerEngine::setManagerName(const QString &managerName)
+{
+ d_ptr->managerName = managerName;
+}
+
+/*!
+ Returns the name which this engine implementation uses to distinguish
+ itself from the implementations provided by other plugins.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+QString QGeoRoutingManagerEngine::managerName() const
+{
+ return d_ptr->managerName;
+}
+
+/*!
+ Sets the version of this engine implementation to \a managerVersion.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoRoutingManagerEngine::setManagerVersion(int managerVersion)
+{
+ d_ptr->managerVersion = managerVersion;
+}
+
+/*!
+ Returns the version of this engine implementation.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+int QGeoRoutingManagerEngine::managerVersion() const
+{
+ return d_ptr->managerVersion;
+}
+
+/*!
+\fn QGeoRouteReply* QGeoRoutingManagerEngine::calculateRoute(const QGeoRouteRequest& request)
+
+ Begins the calculation of the route specified by \a request.
+
+ A QGeoRouteReply object will be returned, which can be used to manage the
+ routing operation and to return the results of the operation.
+
+ This engine and the returned QGeoRouteReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ Once the operation has completed, QGeoRouteReply::routes can be used to
+ retrieve the calculated route or routes.
+
+ If \a request includes features which are not supported by this engine, as
+ reported by the methods in this engine, then a
+ QGeoRouteReply::UnsupportedOptionError will occur.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoRoutingManagerEngine::finished(),
+ QGeoRoutingManagerEngine::error(), QGeoRouteReply::finished() or
+ QGeoRouteReply::error() with deleteLater().
+*/
+
+/*!
+ Begins the process of updating \a route based on the current position \a
+ position.
+
+ A QGeoRouteReply object will be returned, which can be used to manage the
+ routing operation and to return the results of the operation.
+
+ This engine and the returned QGeoRouteReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsRouteUpdates() returns false an
+ QGeoRouteReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoRouteReply::routes can be used to
+ retrieve the updated route.
+
+ The returned route could be entirely different to the original route,
+ especially if \a position is far enough away from the initial route.
+ Otherwise the route will be similar, although the remaining time and
+ distance will be updated and any segments of the original route which
+ have been traversed will be removed.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoRoutingManagerEngine::finished(),
+ QGeoRoutingManagerEngine::error(), QGeoRouteReply::finished() or
+ QGeoRouteReply::error() with deleteLater().
+*/
+QGeoRouteReply* QGeoRoutingManagerEngine::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position)
+{
+ Q_UNUSED(route)
+ Q_UNUSED(position)
+ return new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError,
+ "The updating of routes is not supported by this service provider.", this);
+}
+
+/*!
+ Sets whether this engine supports updating routes to \a supported.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support updating routes.
+*/
+void QGeoRoutingManagerEngine::setSupportsRouteUpdates(bool supported)
+{
+ d_ptr->supportsRouteUpdates = supported;
+}
+
+/*!
+ Returns whether this engine supports updating routes.
+*/
+bool QGeoRoutingManagerEngine::supportsRouteUpdates() const
+{
+ return d_ptr->supportsRouteUpdates;
+}
+
+/*!
+ Sets whether this engine supports request for alternative routes to \a supported.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support alternative routes.
+*/
+void QGeoRoutingManagerEngine::setSupportsAlternativeRoutes(bool supported)
+{
+ d_ptr->supportsAlternativeRoutes = supported;
+}
+
+/*!
+ Returns whether this engine supports request for alternative routes.
+*/
+bool QGeoRoutingManagerEngine::supportsAlternativeRoutes() const
+{
+ return d_ptr->supportsAlternativeRoutes;
+}
+
+/*!
+ Sets whether this engine supports request for excluding areas from routes to \a supported.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support excluding areas.
+*/
+void QGeoRoutingManagerEngine::setSupportsExcludeAreas(bool supported)
+{
+ d_ptr->supportsExcludeAreas = supported;
+}
+
+/*!
+ Returns whether this engine supports the exclusion of areas from routes.
+*/
+bool QGeoRoutingManagerEngine::supportsExcludeAreas() const
+{
+ return d_ptr->supportsExcludeAreas;
+}
+
+/*!
+ Sets the travel modes supported by this engine to \a travelModes.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no travel modes at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedTravelModes(QGeoRouteRequest::TravelModes travelModes)
+{
+ d_ptr->supportedTravelModes = travelModes;
+}
+
+/*!
+ Returns the travel modes supported by this engine.
+*/
+QGeoRouteRequest::TravelModes QGeoRoutingManagerEngine::supportedTravelModes() const
+{
+ return d_ptr->supportedTravelModes;
+}
+
+/*!
+ Sets the types of features that this engine can take into account
+ during route planning to \a featureTypes.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no feature types at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedFeatureTypes(QGeoRouteRequest::FeatureTypes featureTypes)
+{
+ d_ptr->supportedFeatureTypes = featureTypes;
+}
+
+/*!
+ Returns the types of features that this engine can take into account
+ during route planning.
+*/
+QGeoRouteRequest::FeatureTypes QGeoRoutingManagerEngine::supportedFeatureTypes() const
+{
+ return d_ptr->supportedFeatureTypes;
+}
+
+/*!
+ Sets the weightings which this engine can apply to different features
+ during route planning to \a featureWeights.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no feaure weights at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedFeatureWeights(QGeoRouteRequest::FeatureWeights featureWeights)
+{
+ d_ptr->supportedFeatureWeights = featureWeights;
+ d_ptr->supportedFeatureWeights |= QGeoRouteRequest::NeutralFeatureWeight;
+}
+
+/*!
+ Returns the weightings which this engine can apply to different features
+ during route planning.
+*/
+QGeoRouteRequest::FeatureWeights QGeoRoutingManagerEngine::supportedFeatureWeights() const
+{
+ return d_ptr->supportedFeatureWeights;
+}
+
+/*!
+ Sets the route optimizations supported by this engine to \a optimizations.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no route optimizations at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedRouteOptimizations(QGeoRouteRequest::RouteOptimizations optimizations)
+{
+ d_ptr->supportedRouteOptimizations = optimizations;
+}
+
+/*!
+ Returns the route optimizations supported by this engine.
+*/
+QGeoRouteRequest::RouteOptimizations QGeoRoutingManagerEngine::supportedRouteOptimizations() const
+{
+ return d_ptr->supportedRouteOptimizations;
+}
+
+/*!
+ Sets the levels of detail for routing segments which can be
+ requested by this engine to \a segmentDetails.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no segment detail at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedSegmentDetails(QGeoRouteRequest::SegmentDetails segmentDetails)
+{
+ d_ptr->supportedSegmentDetails = segmentDetails;
+}
+
+/*!
+ Returns the levels of detail for routing segments which can be
+ requested by this engine.
+*/
+QGeoRouteRequest::SegmentDetails QGeoRoutingManagerEngine::supportedSegmentDetails() const
+{
+ return d_ptr->supportedSegmentDetails;
+}
+
+/*!
+ Sets the levels of detail for navigation manuevers which can be
+ requested by this engine to \a maneuverDetails.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it supports no maneuver details at all.
+*/
+void QGeoRoutingManagerEngine::setSupportedManeuverDetails(QGeoRouteRequest::ManeuverDetails maneuverDetails)
+{
+ d_ptr->supportedManeuverDetails = maneuverDetails;
+}
+
+/*!
+ Returns the levels of detail for navigation maneuvers which can be
+ requested by this engine.
+*/
+QGeoRouteRequest::ManeuverDetails QGeoRoutingManagerEngine::supportedManeuverDetails() const
+{
+ return d_ptr->supportedManeuverDetails;
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this routing manager supports returning addresses and instructions
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoRoutingManagerEngine::setLocale(const QLocale &locale)
+{
+ d_ptr->locale = locale;
+}
+
+/*!
+ Returns the locale used to hint to this routing manager about what
+ language to use for addresses and instructions.
+*/
+QLocale QGeoRoutingManagerEngine::locale() const
+{
+ return d_ptr->locale;
+}
+
+/*!
+\fn void QGeoRoutingManagerEngine::finished(QGeoRouteReply* reply)
+
+This signal is emitted when \a reply has finished processing.
+
+If reply::error() equals QGeoRouteReply::NoError then the processing
+finished successfully.
+
+This signal and QGeoRouteReply::finished() will be emitted at the same time.
+
+\note Do no delete the \a reply object in the slot connected to this signal.
+Use deleteLater() instead.
+*/
+
+/*!
+\fn void QGeoRoutingManagerEngine::error(QGeoRouteReply* reply, QGeoRouteReply::Error error, QString errorString)
+
+This signal is emitted when an error has been detected in the processing of
+\a reply. The QGeoRoutingManagerEngine::finished() signal will probably follow.
+
+The error will be described by the error code \a error. If \a errorString is
+not empty it will contain a textual description of the error.
+
+This signal and QGeoRouteReply::error() will be emitted at the same time.
+
+\note Do no delete the \a reply object in the slot connected to this signal.
+Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoRoutingManagerEnginePrivate::QGeoRoutingManagerEnginePrivate()
+ : managerVersion(-1),
+ supportsRouteUpdates(false),
+ supportsAlternativeRoutes(false),
+ supportsExcludeAreas(false)
+{
+}
+
+QGeoRoutingManagerEnginePrivate::~QGeoRoutingManagerEnginePrivate() {}
+
+#include "moc_qgeoroutingmanagerengine.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeoroutingmanagerengine.h b/src/location/maps/qgeoroutingmanagerengine.h
new file mode 100644
index 00000000..4d3bbb00
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanagerengine.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGERENGINE_H
+#define QGEOROUTINGMANAGERENGINE_H
+
+#include "qgeorouterequest.h"
+#include "qgeoroutereply.h"
+
+#include <QObject>
+#include <QMap>
+
+class QLocale;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRoutingManagerEnginePrivate;
+
+class Q_LOCATION_EXPORT QGeoRoutingManagerEngine : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoRoutingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ virtual ~QGeoRoutingManagerEngine();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ virtual QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request) = 0;
+ virtual QGeoRouteReply* updateRoute(const QGeoRoute &route, const QGeoCoordinate &position);
+
+ bool supportsRouteUpdates() const;
+ bool supportsAlternativeRoutes() const;
+ bool supportsExcludeAreas() const;
+ QGeoRouteRequest::TravelModes supportedTravelModes() const;
+ QGeoRouteRequest::FeatureTypes supportedFeatureTypes() const;
+ QGeoRouteRequest::FeatureWeights supportedFeatureWeights() const;
+ QGeoRouteRequest::RouteOptimizations supportedRouteOptimizations() const;
+ QGeoRouteRequest::SegmentDetails supportedSegmentDetails() const;
+ QGeoRouteRequest::ManeuverDetails supportedManeuverDetails() const;
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+Q_SIGNALS:
+ void finished(QGeoRouteReply* reply);
+ void error(QGeoRouteReply* reply, QGeoRouteReply::Error error, QString errorString = QString());
+
+protected:
+ void setSupportsRouteUpdates(bool supported);
+ void setSupportsAlternativeRoutes(bool supported);
+ void setSupportsExcludeAreas(bool supported);
+ void setSupportedTravelModes(QGeoRouteRequest::TravelModes travelModes);
+ void setSupportedFeatureTypes(QGeoRouteRequest::FeatureTypes featureTypes);
+ void setSupportedFeatureWeights(QGeoRouteRequest::FeatureWeights featureWeights);
+ void setSupportedRouteOptimizations(QGeoRouteRequest::RouteOptimizations optimizations);
+ void setSupportedSegmentDetails(QGeoRouteRequest::SegmentDetails segmentDetails);
+ void setSupportedManeuverDetails(QGeoRouteRequest::ManeuverDetails maneuverDetails);
+
+private:
+ void setManagerName(const QString &managerName);
+ void setManagerVersion(int managerVersion);
+
+ QGeoRoutingManagerEnginePrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoRoutingManagerEngine)
+
+ friend class QGeoServiceProvider;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoroutingmanagerengine_p.h b/src/location/maps/qgeoroutingmanagerengine_p.h
new file mode 100644
index 00000000..82732913
--- /dev/null
+++ b/src/location/maps/qgeoroutingmanagerengine_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOROUTINGMANAGERENGINE_P_H
+#define QGEOROUTINGMANAGERENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeorouterequest.h"
+
+#include <QMap>
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoRoutingManagerEnginePrivate
+{
+public:
+ QGeoRoutingManagerEnginePrivate();
+ ~QGeoRoutingManagerEnginePrivate();
+
+ QString managerName;
+ int managerVersion;
+
+ bool supportsRouteUpdates;
+ bool supportsAlternativeRoutes;
+ bool supportsExcludeAreas;
+ QGeoRouteRequest::TravelModes supportedTravelModes;
+ QGeoRouteRequest::FeatureTypes supportedFeatureTypes;
+ QGeoRouteRequest::FeatureWeights supportedFeatureWeights;
+ QGeoRouteRequest::RouteOptimizations supportedRouteOptimizations;
+ QGeoRouteRequest::SegmentDetails supportedSegmentDetails;
+ QGeoRouteRequest::ManeuverDetails supportedManeuverDetails;
+
+ QLocale locale;
+
+private:
+ Q_DISABLE_COPY(QGeoRoutingManagerEnginePrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeosearchmanager.cpp b/src/location/maps/qgeosearchmanager.cpp
new file mode 100644
index 00000000..57ebf891
--- /dev/null
+++ b/src/location/maps/qgeosearchmanager.cpp
@@ -0,0 +1,682 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosearchmanager.h"
+#include "qgeosearchmanager_p.h"
+#include "qgeosearchmanagerengine.h"
+
+#include "qlandmarkmanager.h"
+
+#include "qgeoboundingbox.h"
+#include "qgeoboundingcircle.h"
+
+#include "qlandmarkboxfilter.h"
+#include "qlandmarkfetchrequest.h"
+#include "qlandmarkintersectionfilter.h"
+#include "qlandmarknamefilter.h"
+#include "qlandmarkproximityfilter.h"
+
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoSearchManager
+
+ \brief The QGeoSearchManager class provides support for searching
+ operations related to geographic information.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-places
+
+ The geocode(), reverseGeocode() and search() functions return
+ QGeoSearchReply objects, which manage these operations and report on the
+ result of the operations and any errors which may have occurred.
+
+ The geocode() and reverseGeocode() functions can be used to convert
+ QGeoAddress instances to QGeoCoordinate instances and vice-versa.
+
+ The search() function allows a user to perform a free text search
+ for place information. If the string provided can be interpreted as
+ an address it can be geocoded to coordinate information, and the string
+ can also be used to search a landmarks database, depending on the level
+ of support supplied by the service provider.
+
+ The defaultLandmarkManager() function will return a QLandmarkManager
+ instance if access to the service providers landmark database is
+ available outside of the search() method.
+
+ A user can supply other QLandmarkManager instances to be searched during
+ the execution of search() with setAdditionalLandmarkManagers(). This
+ means that a personal database store can be combined with a public source
+ of database information with very little effort.
+
+ \note At present the additional landmark managers only search for the
+ search string in the name of the landmarks.
+
+ Instances of QGeoSearchManager can be accessed with
+ QGeoServiceProvider::searchManager().
+
+ A small example of the usage of QGeoSearchManager and the handling of
+ QLandmark results follows:
+
+ \code
+class MySearchHandler : public QObject
+{
+ Q_OBJECT
+public:
+ MySearchHandler(QGeoSearchManager *searchManager, QString searchString)
+ {
+ QGeoSearchReply *reply = searchManager->search(searchString);
+
+ if (reply->isFinished()) {
+ if (reply->error() == QGeoSearchReply::NoError) {
+ searchResults(reply);
+ else
+ searchError(reply, reply->error(), reply->errorString());
+ return;
+ }
+
+ connect(searchManager,
+ SIGNAL(finished(QGeoSearchReply*)),
+ this,
+ SLOT(searchResults(QGeoSearchReply*)));
+
+ connect(searchManager,
+ SIGNAL(error(QGeoSearchReply*,QGeoSearchReply::Error,QString)),
+ this
+ SLOT(searchError(QGeoSearchReply*,QGeoSearchReply::Error,QString)));
+ }
+
+private slots:
+ void searchResults(QGeoSearchReply *reply)
+ {
+ // The QLandmark results can be created from the simpler
+ // QGeoPlace results if that is required.
+ QList<QLandmark> landmarks;
+ for (int i = 0; i < reply->places().size(); ++i) {
+ if (reply->places().at(i).isLandmark())
+ landmarks.append(QLandmark(reply->places().at(i)));
+ }
+
+ // ... now we have to make use of the places and landmarks ...
+ reply->deleteLater();
+ }
+
+ void searchError(QGeoSearchReply *reply, QGeoSearchReply::Error error, const QString &errorString)
+ {
+ // ... inform the user that an error has occurred ...
+ reply->deleteLater();
+ }
+};
+ \endcode
+*/
+
+/*!
+\enum QGeoSearchManager::SearchType
+
+Describes the type of search that should be performed by search().
+
+\value SearchNone
+ Do not use the search string.
+\value SearchGeocode
+ Use the search string as a textual address in a geocoding operation.
+\value SearchLandmarks
+ Use the search string for free-text search against the available landmark
+ information sources.
+\value SearchAll
+ All available information sources should be used as part of the search.
+*/
+
+/*!
+ Constructs a new manager with the specified \a parent and with the
+ implementation provided by \a engine.
+
+ This constructor is used interally by QGeoServiceProviderFactory. Regular
+ users should acquire instances of QGeoSearchManager with
+ QGeoServiceProvider::searchManager();
+*/
+QGeoSearchManager::QGeoSearchManager(QGeoSearchManagerEngine *engine, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoSearchManagerPrivate())
+{
+ d_ptr->engine = engine;
+ if (d_ptr->engine) {
+ d_ptr->engine->setParent(this);
+
+ connect(d_ptr->engine,
+ SIGNAL(finished(QGeoSearchReply*)),
+ this,
+ SIGNAL(finished(QGeoSearchReply*)));
+
+ connect(d_ptr->engine,
+ SIGNAL(error(QGeoSearchReply*, QGeoSearchReply::Error, QString)),
+ this,
+ SIGNAL(error(QGeoSearchReply*, QGeoSearchReply::Error, QString)));
+ } else {
+ qFatal("The search manager engine that was set for this search manager was NULL.");
+ }
+}
+
+/*!
+ Destroys this manager.
+*/
+QGeoSearchManager::~QGeoSearchManager()
+{
+ delete d_ptr;
+}
+
+/*!
+ Returns the name of the engine which implements the behaviour of this
+ search manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+QString QGeoSearchManager::managerName() const
+{
+// if (!d_ptr->engine)
+// return QString();
+
+ return d_ptr->engine->managerName();
+}
+
+/*!
+ Returns the version of the engine which implements the behaviour of this
+ search manager.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst the plugin implementations.
+*/
+int QGeoSearchManager::managerVersion() const
+{
+// if (!d_ptr->engine)
+// return -1;
+
+ return d_ptr->engine->managerVersion();
+}
+
+/*!
+ Begins the geocoding of \a address. Geocoding is the process of finding a
+ coordinate that corresponds to a given address.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ geocoding operation and to return the results of the operation.
+
+ This manager and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsGeocoding() returns false an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoSearchReply::places() can be used to
+ retrieve the results, which will consist of a list of QGeoPlace objects.
+ These object represent a combination of coordinate and address data.
+
+ The address data returned in the results may be different from \a address.
+ This will usually occur if the geocoding service backend uses a different
+ canonical form of addresses or if \a address was only partially filled out.
+
+ If \a bounds is non-null and valid QGeoBoundingArea it will be used to
+ limit the results to thos that are contained within \a bounds. This is
+ particularly useful if \a address is only partially filled out, as the
+ service will attempt to geocode all matches for the specified data.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManager::finished(),
+ QGeoSearchManager::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManager::geocode(const QGeoAddress &address, QGeoBoundingArea *bounds)
+{
+// if (!d_ptr->engine)
+// return new QGeoSearchReply(QGeoSearchReply::EngineNotSetError, "The search manager was not created with a valid engine.", this);
+
+ return d_ptr->engine->geocode(address, bounds);
+}
+
+
+/*!
+ Begins the reverse geocoding of \a coordinate. Reverse geocoding is the
+ process of finding an address that corresponds to a given coordinate.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ reverse geocoding operation and to return the results of the operation.
+
+ This manager and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsReverseGeocoding() returns false an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ At that point QGeoSearchReply::places() can be used to retrieve the
+ results, which will consist of a list of QGeoPlace objects. These object
+ represent a combination of coordinate and address data.
+
+ The coordinate data returned in the results may be different from \a
+ coordinate. This will usually occur if the reverse geocoding service
+ backend shifts the coordinates to be closer to the matching addresses, or
+ if the backend returns results at multiple levels of detail.
+
+ If multiple results are returned by the reverse geocoding service backend
+ they will be provided in order of specificity. This normally occurs if the
+ backend is configured to reverse geocode across multiple levels of detail.
+ As an example, some services will return address and coordinate pairs for
+ the street address, the city, the state and the country.
+
+ If \a bounds is non-null and a valid QGeoBoundingBox it will be used to
+ limit the results to thos that are contained within \a bounds.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManager::finished(),
+ QGeoSearchManager::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManager::reverseGeocode(const QGeoCoordinate &coordinate, QGeoBoundingArea *bounds)
+{
+// if (!d_ptr->engine)
+// return new QGeoSearchReply(QGeoSearchReply::EngineNotSetError, "The search manager was not created with a valid engine.", this);
+
+ return d_ptr->engine->reverseGeocode(coordinate, bounds);
+}
+
+/*!
+ Begins searching for a place matching \a searchString. The value of
+ \a searchTypes will determine whether the search is for addresses only,
+ for landmarks only or for both.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ geocoding operation and to return the results of the operation.
+
+ This manager and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsGeocoding() returns false and \a searchTypes is
+ QGeoSearchManager::SearchGeocode an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoSearchReply::places() can be used to
+ retrieve the results, which will consist of a list of QGeoPlace objects.
+ These object represent a combination of coordinate and address data.
+
+ If any of the QGeoPlace instances in the results have landmark associated
+ data, QGeoPlace::isLandmark() will return true and
+ QLandmark::QLandmark(const QGeoPlace &place) can be used to convert the
+ QGeoPlace instance into a QLandmark instance.
+
+ If \a searchTypes is QGeoSearchManager::SearchLandmarks or
+ QGeoSearchManager::SearchAll, a free text landmark search will be
+ performed. The results will be a combination of the backend specific
+ landmark search and the same free text search applied to each of the
+ QLandmarkManager instances in additionalLandmarkManagers().
+
+ \note At present the additional landmark managers only search for the
+ search string in the name of the landmarks.
+
+ If \a limit is -1 the entire result set will be returned, otherwise at most
+ \a limit results will be returned.
+
+ The \a offset parameter is used to ask the search service to not return the
+ first \a offset results.
+
+ The \a limit and \a offset results are used together to implement paging.
+
+ If additional landmark managers have been setup the number of results
+ returned will be at most (1 + number of additional landmark managers) *
+ \a limit. This happens because the results are requested from all sources, combined, and returned once
+ all sources have responded.
+
+ If \a bounds is non-null and a valid QGeoBoundingArea it will be used to
+ limit the results to thos that are contained within \a bounds.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManager::finished(),
+ QGeoSearchManager::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManager::search(const QString &searchString,
+ QGeoSearchManager::SearchTypes searchTypes,
+ int limit,
+ int offset,
+ QGeoBoundingArea *bounds)
+{
+// if (!d_ptr->engine)
+// return new QGeoSearchReply(QGeoSearchReply::EngineNotSetError, "The search manager was not created with a valid engine.", this);
+
+ QGeoSearchReply *reply = d_ptr->engine->search(searchString,
+ searchTypes,
+ limit,
+ offset,
+ bounds);
+
+ if ((d_ptr->engine->additionalLandmarkManagers().size() == 0)
+ || (searchTypes == QGeoSearchManager::SearchNone)
+ || (searchTypes == QGeoSearchManager::SearchGeocode))
+ return reply;
+
+ // TODO add default LM to this list and change doc?
+
+ QList<QLandmarkFetchRequest*> fetchRequests;
+
+
+ // TODO replace with free text search filter when it becomes available
+ QLandmarkNameFilter searchFilter;
+ searchFilter.setName(searchString);
+ searchFilter.setMatchFlags(QLandmarkFilter::MatchContains);
+
+ QLandmarkIntersectionFilter intersectFilter;
+ intersectFilter.append(searchFilter);
+ if (bounds) {
+ QGeoBoundingBox* box = 0;
+ QGeoBoundingCircle* circle = 0;
+ switch (bounds->type()) {
+ case QGeoBoundingArea::BoxType:
+ box = static_cast<QGeoBoundingBox*>(bounds);
+ if (box->isValid() && !box->isEmpty()) {
+ QLandmarkBoxFilter boxFilter;
+ boxFilter.setBoundingBox(*box);
+ intersectFilter.append(boxFilter);
+ }
+ break;
+ case QGeoBoundingArea::CircleType:
+ circle = static_cast<QGeoBoundingCircle*>(bounds);
+ if (circle->isValid() && !circle->isEmpty()) {
+ QLandmarkProximityFilter proximityFilter(circle->center(),
+ circle->radius());
+ intersectFilter.append(proximityFilter);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ for (int i = 0; i < d_ptr->engine->additionalLandmarkManagers().size(); ++i) {
+ QLandmarkManager* lm = d_ptr->engine->additionalLandmarkManagers().at(i);
+
+ QLandmarkFetchRequest* fetchRequest = new QLandmarkFetchRequest(lm, this);
+ fetchRequest->setFilter(intersectFilter);
+ fetchRequest->setLimit(limit);
+ fetchRequest->setOffset(offset);
+ fetchRequests.append(fetchRequest);
+ }
+
+ return new QGeoCombiningSearchReply(reply, fetchRequests);
+}
+
+/*!
+ Returns whether this manager supports geocoding.
+*/
+bool QGeoSearchManager::supportsGeocoding() const
+{
+// if (!d_ptr->engine)
+// return false;
+
+ return d_ptr->engine->supportsGeocoding();
+}
+
+/*!
+ Returns whether this manager supports reverse geocoding.
+*/
+bool QGeoSearchManager::supportsReverseGeocoding() const
+{
+ return d_ptr->engine->supportsReverseGeocoding();
+}
+
+/*!
+ Returns the search types supported by the search() function with this manager.
+*/
+QGeoSearchManager::SearchTypes QGeoSearchManager::supportedSearchTypes() const
+{
+// if (!d_ptr->engine)
+// return QGeoSearchManager::SearchTypes();
+
+ return d_ptr->engine->supportedSearchTypes();
+}
+
+/*!
+ Returns the landmark manager provided by the service provider for
+ use with search().
+
+ Will return 0 if the no landmark manager is associated with the service
+ provider. This does not indicate that search() does not support
+ landmark searching, only that any landmark searching which occurs within in
+ search() is done without the use of a QLandmarkManager.
+*/
+QLandmarkManager* QGeoSearchManager::defaultLandmarkManager() const
+{
+// if (!d_ptr->engine)
+// return 0;
+
+ return d_ptr->engine->defaultLandmarkManager();
+}
+
+/*!
+ Sets the landmark managers to be used with search() to \a landmarkManagers.
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+void QGeoSearchManager::setAdditionalLandmarkManagers(const QList<QLandmarkManager *> &landmarkManagers)
+{
+// if (d_ptr->engine)
+ d_ptr->engine->setAdditionalLandmarkManagers(landmarkManagers);
+}
+
+/*!
+ Returns the landmark managers that will be used with search().
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+QList<QLandmarkManager *> QGeoSearchManager::additionalLandmarkManagers() const
+{
+// if (!d_ptr->engine)
+// return QList<QLandmarkManager *>();
+
+ return d_ptr->engine->additionalLandmarkManagers();
+}
+
+/*!
+ Adds \a landmarkManager to the list of landmark managers that will be used
+ with search().
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+void QGeoSearchManager::addAdditionalLandmarkManager(QLandmarkManager *landmarkManager)
+{
+// if (d_ptr->engine && landmarkManager)
+ if (landmarkManager)
+ d_ptr->engine->addAdditionalLandmarkManager(landmarkManager);
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this search manager supports returning the results
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoSearchManager::setLocale(const QLocale &locale)
+{
+ d_ptr->engine->setLocale(locale);
+}
+
+/*!
+ Returns the locale used to hint to this search manager about what
+ language to use for the results.
+*/
+QLocale QGeoSearchManager::locale() const
+{
+ return d_ptr->engine->locale();
+}
+
+/*!
+\fn void QGeoSearchManager::finished(QGeoSearchReply* reply)
+
+ This signal is emitted when \a reply has finished processing.
+
+ If reply::error() equals QGeoSearchReply::NoError then the processing
+ finished successfully.
+
+ This signal and QGeoSearchReply::finished() will be emitted at the same
+ time.
+
+ \note Do no delete the \a reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*!
+\fn void QGeoSearchManager::error(QGeoSearchReply* reply, QGeoSearchReply::Error error, QString errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ \a reply. The QGeoSearchManager::finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ This signal and QGeoSearchReply::error() will be emitted at the same time.
+
+ \note Do no delete the \a reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoSearchManagerPrivate::QGeoSearchManagerPrivate()
+ : engine(0) {}
+
+QGeoSearchManagerPrivate::~QGeoSearchManagerPrivate()
+{
+ if (engine)
+ delete engine;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+
+QGeoCombiningSearchReply::QGeoCombiningSearchReply(QGeoSearchReply* searchReply,
+ QList<QLandmarkFetchRequest*> fetchRequests,
+ QObject *parent)
+ : QGeoSearchReply(parent),
+ searchReply(searchReply),
+ fetchRequests(fetchRequests)
+{
+ connect(searchReply,
+ SIGNAL(finished()),
+ this,
+ SLOT(searchReplyFinished()));
+
+ for (int i = 0; i < fetchRequests.size(); ++i)
+ connect(fetchRequests[i],
+ SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
+ this,
+ SLOT(landmarkFetchStateChanged(QLandmarkAbstractRequest::State)));
+}
+
+QGeoCombiningSearchReply::~QGeoCombiningSearchReply()
+{
+ if (searchReply)
+ delete searchReply;
+
+ qDeleteAll(fetchRequests);
+}
+
+void QGeoCombiningSearchReply::searchReplyFinished()
+{
+ if (searchReply->error() == QGeoSearchReply::NoError) {
+ QList<QGeoPlace> searchReplyPlaces = searchReply->places();
+ for (int i = 0; i < searchReplyPlaces.size(); ++i)
+ addPlace(searchReplyPlaces.at(i));
+
+ if (fetchRequests.size() == 0)
+ emit finished();
+ } else {
+ emit error(error(), errorString());
+ qDeleteAll(fetchRequests);
+ fetchRequests.clear();
+ }
+
+ delete searchReply;
+ searchReply = 0;
+}
+
+void QGeoCombiningSearchReply::landmarkFetchStateChanged(QLandmarkAbstractRequest::State newState)
+{
+ if (newState == QLandmarkAbstractRequest::FinishedState) {
+ QLandmarkFetchRequest *req = qobject_cast<QLandmarkFetchRequest*>(sender());
+ if (req->error() == QLandmarkManager::NoError) {
+
+ QList<QLandmark> landmarks = req->landmarks();
+ for (int i = 0; i < landmarks.size(); ++i)
+ addPlace(landmarks.at(i));
+
+ fetchRequests.removeAll(req);
+ delete req;
+
+ if (!searchReply && (fetchRequests.size() == 0))
+ emit finished();
+ } else {
+
+ emit error(QGeoSearchReply::CombinationError, req->errorString());
+
+ delete searchReply;
+ searchReply = 0;
+ qDeleteAll(fetchRequests);
+ fetchRequests.clear();
+ }
+ }
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+#include "moc_qgeosearchmanager.cpp"
+#include "moc_qgeosearchmanager_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeosearchmanager.h b/src/location/maps/qgeosearchmanager.h
new file mode 100644
index 00000000..5a82bb13
--- /dev/null
+++ b/src/location/maps/qgeosearchmanager.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGER_H
+#define QGEOSEARCHMANAGER_H
+
+#include "qgeosearchreply.h"
+#include "qgeoboundingbox.h"
+
+#include <QObject>
+#include <QList>
+#include <QMap>
+
+class QLocale;
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManager;
+
+class QGeoSearchManagerEngine;
+class QGeoSearchManagerPrivate;
+
+class Q_LOCATION_EXPORT QGeoSearchManager : public QObject
+{
+ Q_OBJECT
+public:
+ enum SearchType {
+ SearchNone = 0x0000,
+ SearchGeocode = 0x0001,
+ SearchLandmarks = 0x0002,
+ SearchAll = 0xFFFF
+ };
+ Q_DECLARE_FLAGS(SearchTypes, SearchType)
+
+ ~QGeoSearchManager();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ QGeoSearchReply* geocode(const QGeoAddress &address,
+ QGeoBoundingArea *bounds = 0);
+ QGeoSearchReply* reverseGeocode(const QGeoCoordinate &coordinate,
+ QGeoBoundingArea *bounds = 0);
+
+ QGeoSearchReply* search(const QString &searchString,
+ SearchTypes searchTypes = SearchTypes(SearchAll),
+ int limit = -1,
+ int offset = 0,
+ QGeoBoundingArea *bounds = 0);
+
+ bool supportsGeocoding() const;
+ bool supportsReverseGeocoding() const;
+ SearchTypes supportedSearchTypes() const;
+
+ QLandmarkManager* defaultLandmarkManager() const;
+
+ void setAdditionalLandmarkManagers(const QList<QLandmarkManager *> &landmarkManagers);
+ QList<QLandmarkManager *> additionalLandmarkManagers() const;
+ void addAdditionalLandmarkManager(QLandmarkManager *landmarkManager);
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+Q_SIGNALS:
+ void finished(QGeoSearchReply* reply);
+ void error(QGeoSearchReply* reply, QGeoSearchReply::Error error, QString errorString = QString());
+
+private:
+ QGeoSearchManager(QGeoSearchManagerEngine *engine, QObject *parent = 0);
+
+ QGeoSearchManagerPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoSearchManager)
+
+ friend class QGeoServiceProvider;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoSearchManager::SearchTypes)
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeosearchmanager_p.h b/src/location/maps/qgeosearchmanager_p.h
new file mode 100644
index 00000000..1542bcf0
--- /dev/null
+++ b/src/location/maps/qgeosearchmanager_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGER_P_H
+#define QGEOSEARCHMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeosearchmanager.h"
+
+#include "qgeosearchreply.h"
+#include "qlandmarkfetchrequest.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManager;
+class QGeoSearchManagerEngine;
+
+class QGeoSearchManagerPrivate
+{
+public:
+ QGeoSearchManagerPrivate();
+ ~QGeoSearchManagerPrivate();
+
+ QGeoSearchManagerEngine *engine;
+
+private:
+ Q_DISABLE_COPY(QGeoSearchManagerPrivate)
+};
+
+class QGeoCombiningSearchReply : public QGeoSearchReply
+{
+ Q_OBJECT
+public:
+ QGeoCombiningSearchReply(QGeoSearchReply* searchReply,
+ QList<QLandmarkFetchRequest*> fetchRequests,
+ QObject *parent = 0);
+ ~QGeoCombiningSearchReply();
+
+private slots:
+ void searchReplyFinished();
+ void landmarkFetchStateChanged(QLandmarkAbstractRequest::State newState);
+
+private:
+ QGeoSearchReply* searchReply;
+ QList<QLandmarkFetchRequest*> fetchRequests;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/maps/qgeosearchmanagerengine.cpp b/src/location/maps/qgeosearchmanagerengine.cpp
new file mode 100644
index 00000000..1c4510ed
--- /dev/null
+++ b/src/location/maps/qgeosearchmanagerengine.cpp
@@ -0,0 +1,515 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosearchmanagerengine.h"
+#include "qgeosearchmanagerengine_p.h"
+
+#include "qgeoaddress.h"
+#include "qgeocoordinate.h"
+#include "qlandmarkmanager.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoSearchManagerEngine
+
+ \brief The QGeoSearchManagerEngine class provides an interface and
+ convenience methods to implementers of QGeoServiceProvider plugins who want
+ to provide support for searching operations related to geographic data.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ In the default implementation, supportsGeocoding() and supportsReverseGeocoding() returns false while
+ geocode() and reverseGeocode()
+ cause QGeoSearchReply::UnsupportedOptionError to occur.
+
+ If the service provider supports geocoding the subclass should provide an
+ implementation of geocode() and call setSupportsGeocoding(true) at
+ some point in time before geoocode() is called.
+
+ Similarly, if the service provider supports reverse geocoding the subclass
+ should provide an implementation reverseGeocode() and call
+ setSupportsReverseGeocoding(true) at some point in time before
+ reverseGeoocode() is called.
+
+ The search() function will make use of the QLandmarkManager instances
+ returned by additionalLandmarkManagers(). If a QLandmarkManager is used
+ internally to query the service providers landmark data the
+ QLandmarkManager can be made available to the users with
+ setDefaultLandmarkManager().
+
+ The subclass should call setSupportedSearchTypes() at some point in time
+ before search() is called.
+
+ If the service supports searching for places the subclass should provide
+ an implementetation of search() and call setSupportedSearchTypes() at
+ some point in time before search() is called.
+
+ A subclass of QGeoSearchManagerEngine will often make use of a subclass
+ fo QGeoSearchReply internally, in order to add any engine-specific
+ data (such as a QNetworkReply object for network-based services) to the
+ QGeoSearchReply instances used by the engine.
+
+ \sa QGeoSearchManager
+*/
+
+/*!
+ Constructs a new engine with the specified \a parent, using \a parameters
+ to pass any implementation specific data to the engine.
+*/
+QGeoSearchManagerEngine::QGeoSearchManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoSearchManagerEnginePrivate())
+{
+ Q_UNUSED(parameters)
+}
+
+/*!
+ Destroys this engine.
+*/
+QGeoSearchManagerEngine::~QGeoSearchManagerEngine()
+{
+ delete d_ptr;
+}
+
+/*!
+ Sets the name which this engine implementation uses to distinguish itself
+ from the implementations provided by other plugins to \a managerName.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoSearchManagerEngine::setManagerName(const QString &managerName)
+{
+ d_ptr->managerName = managerName;
+}
+
+/*!
+ Returns the name which this engine implementation uses to distinguish
+ itself from the implementations provided by other plugins.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+QString QGeoSearchManagerEngine::managerName() const
+{
+ return d_ptr->managerName;
+}
+
+/*!
+ Sets the version of this engine implementation to \a managerVersion.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+void QGeoSearchManagerEngine::setManagerVersion(int managerVersion)
+{
+ d_ptr->managerVersion = managerVersion;
+}
+
+/*!
+ Returns the version of this engine implementation.
+
+ The combination of managerName() and managerVersion() should be unique
+ amongst plugin implementations.
+*/
+int QGeoSearchManagerEngine::managerVersion() const
+{
+ return d_ptr->managerVersion;
+}
+
+/*!
+ Begins the geocoding of \a address. Geocoding is the process of finding a
+ coordinate that corresponds to a given address.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ geocoding operation and to return the results of the operation.
+
+ This engine and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsGeocoding() returns false an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoSearchReply::places() can be used to
+ retrieve the results, which will consist of a list of QGeoPlace objects.
+ These object represent a combination of coordinate and address data.
+
+ The address data returned in the results may be different from \a address.
+ This will usually occur if the geocoding service backend uses a different
+ canonical form of addresses or if \a address was only partially filled out.
+
+ If \a bounds is non-null and a valid QGeoBoundingArea it will be used to
+ limit the results to those that are contained by \a bounds. This is
+ particularly useful if \a address is only partially filled out, as the
+ service will attempt to geocode all matches for the specified data.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManagerEngine::finished(),
+ QGeoSearchManagerEngine::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManagerEngine::geocode(const QGeoAddress &address,
+ QGeoBoundingArea *bounds)
+{
+ Q_UNUSED(address)
+ Q_UNUSED(bounds)
+ return new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError,
+ "Geocoding is not supported by this service provider.", this);
+}
+
+/*!
+ Begins the reverse geocoding of \a coordinate. Reverse geocoding is the
+ process of finding an address that corresponds to a given coordinate.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ reverse geocoding operation and to return the results of the operation.
+
+ This engine and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsReverseGeocoding() returns false an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ At that point QGeoSearchReply::places() can be used to retrieve the
+ results, which will consist of a list of QGeoPlace objects. These object
+ represent a combination of coordinate and address data.
+
+ The coordinate data returned in the results may be different from \a
+ coordinate. This will usually occur if the reverse geocoding service
+ backend shifts the coordinates to be closer to the matching addresses, or
+ if the backend returns results at multiple levels of detail.
+
+ If multiple results are returned by the reverse geocoding service backend
+ they will be provided in order of specificity. This normally occurs if the
+ backend is configured to reverse geocode across multiple levels of detail.
+ As an example, some services will return address and coordinate pairs for
+ the street address, the city, the state and the country.
+
+ If \a bounds is non-null and a valid QGeoBoundingArea it will be used to
+ limit the results to those that are contained by \a bounds.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManagerEngine::finished(),
+ QGeoSearchManagerEngine::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManagerEngine::reverseGeocode(const QGeoCoordinate &coordinate,
+ QGeoBoundingArea *bounds)
+{
+ Q_UNUSED(coordinate)
+ Q_UNUSED(bounds)
+ return new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError,
+ "Reverse geocoding is not supported by this service provider.", this);
+}
+
+/*!
+ Begins searching for a place matching \a searchString. The value of
+ \a searchTypes will determine whether the search is for addresses only,
+ for landmarks only or for both.
+
+ A QGeoSearchReply object will be returned, which can be used to manage the
+ geocoding operation and to return the results of the operation.
+
+ This engine and the returned QGeoSearchReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ If supportsGeocoding() returns false and \a searchTypes is
+ QGeoSearchManagerEngine::SearchGeocode an
+ QGeoSearchReply::UnsupportedOptionError will occur.
+
+ Once the operation has completed, QGeoSearchReply::places() can be used to
+ retrieve the results, which will consist of a list of QGeoPlace objects.
+ These object represent a combination of coordinate and address data.
+
+ If any of the QGeoPlace instances in the results have landmark associated
+ data, QGeoPlace::isLandmark() will return true and
+ QLandmark::QLandmark(const QGeoPlace &place) can be used to convert the
+ QGeoPlace instance into a QLandmark instance.
+
+ If \a searchTypes is QGeoSearchManagerEngine::SearchLandmarks or
+ QGeoSearchManagerEngine::SearchAll, a free text landmark search will be
+ performed. The results will be a combination of the backend specific
+ landmark search and the same free text search applied to each of the
+ QLandmarkManager instances in additionalLandmarkManagers().
+
+ \note At present the additional landmark managers only search for the
+ search string in the name of the landmarks.
+
+ If \a limit is -1 the entire result set will be returned, otherwise at most
+ \a limit results will be returned.
+
+ The \a offset parameter is used to ask the search service to not return the
+ first \a offset results.
+
+ The \a limit and \a offset results are used together to implement paging.
+
+ If additional landmark managers have been setup the number of results
+ returned will be at most (1 + number of additional landmark managers) *
+ \a limit. This happens because the results are requested from all sources, combined, and returned once
+ all sources have responded.
+
+
+ If \a bounds is non-null and a valid QGeoBoundingArea it will be used to
+ limit the results to those that are contained by \a bounds.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoSearchManagerEngine::finished(),
+ QGeoSearchManagerEngine::error(), QGeoSearchReply::finished() or
+ QGeoSearchReply::error() with deleteLater().
+*/
+QGeoSearchReply* QGeoSearchManagerEngine::search(const QString &searchString,
+ QGeoSearchManager::SearchTypes searchTypes,
+ int limit,
+ int offset,
+ QGeoBoundingArea *bounds)
+{
+ Q_UNUSED(searchString)
+ Q_UNUSED(searchTypes)
+ Q_UNUSED(limit)
+ Q_UNUSED(offset)
+ Q_UNUSED(bounds)
+
+ return new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError,
+ "Searching is not supported by this service provider.", this);
+}
+
+/*!
+ Sets whether geocoding is supported by this engine to \a supported.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support geocoding.
+*/
+void QGeoSearchManagerEngine::setSupportsGeocoding(bool supported)
+{
+ d_ptr->supportsGeocoding = supported;
+}
+
+/*!
+ Returns whether this engine supports geocoding.
+*/
+bool QGeoSearchManagerEngine::supportsGeocoding() const
+{
+ return d_ptr->supportsGeocoding;
+}
+
+/*!
+ Sets whether reverse geocoding is supported by this engine to \a supported.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support reverse geocoding.
+*/
+void QGeoSearchManagerEngine::setSupportsReverseGeocoding(bool supported)
+{
+ d_ptr->supportsReverseGeocoding = supported;
+}
+
+/*!
+ Returns whether this engine supports reverse geocoding.
+*/
+bool QGeoSearchManagerEngine::supportsReverseGeocoding() const
+{
+ return d_ptr->supportsReverseGeocoding;
+}
+
+/*!
+ Sets the search types supported by the search() with this engine to \a searchTypes.
+
+ It is important that subclasses use this method to ensure that the engine
+ reports its capabilities correctly. If this function is not used the
+ engine will report that it does not support any search types.
+*/
+void QGeoSearchManagerEngine::setSupportedSearchTypes(QGeoSearchManager::SearchTypes searchTypes)
+{
+ d_ptr->supportedSearchTypes = searchTypes;
+}
+
+/*!
+ Returns the search types supported by the search() with this engine.
+*/
+QGeoSearchManager::SearchTypes QGeoSearchManagerEngine::supportedSearchTypes() const
+{
+ return d_ptr->supportedSearchTypes;
+}
+
+/*!
+ Sets the landmark manager provided by the service provider for
+ use with search() to \a landmarkManager.
+
+ This should only be set if search() makes use of a QLandmarkManager
+ instance to provide landmark searching functionality.
+
+ It is important that subclasses use this method to ensure that the engine
+ is able to carry out landmark searches. If this function is not used the
+ engine will not be able to use or return the default landmark manager.
+*/
+void QGeoSearchManagerEngine::setDefaultLandmarkManager(QLandmarkManager *landmarkManager)
+{
+ d_ptr->defaultLandmarkManager = landmarkManager;
+}
+
+/*!
+ Returns the landmark manager provided by the service provider for
+ use with search().
+
+ Will return 0 if the no landmark manager is associated with the service
+ provider. This does not indicate that search() does not support
+ landmark searching, only that any landmark searching which occurs within in
+ search() is done without the use of a QLandmarkManager.
+*/
+QLandmarkManager* QGeoSearchManagerEngine::defaultLandmarkManager() const
+{
+ return d_ptr->defaultLandmarkManager;
+}
+
+/*!
+ Sets the landmark managers to be used with search() to \a landmarkManagers.
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+void QGeoSearchManagerEngine::setAdditionalLandmarkManagers(const QList<QLandmarkManager *> &landmarkManagers)
+{
+ for (int i = 0; i < landmarkManagers.size(); ++i)
+ if (landmarkManagers.at(i))
+ d_ptr->additionalLandmarkManagers.append(landmarkManagers.at(i));
+}
+
+/*!
+ Returns the landmark managers that will be used with search().
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+QList<QLandmarkManager *> QGeoSearchManagerEngine::additionalLandmarkManagers() const
+{
+ return d_ptr->additionalLandmarkManagers;
+}
+
+/*!
+ Adds \a landmarkManager to the list of landmark managers that will be used with search().
+
+ These landmark managers will be used along with the landmark manager returned
+ by defaultLandmarkManager().
+*/
+void QGeoSearchManagerEngine::addAdditionalLandmarkManager(QLandmarkManager *landmarkManager)
+{
+ if (landmarkManager)
+ d_ptr->additionalLandmarkManagers.append(landmarkManager);
+}
+
+/*!
+ Sets the locale to be used by the this manager to \a locale.
+
+ If this search manager supports returning the results
+ in different languages, they will be returned in the language of \a locale.
+
+ The locale used defaults to the system locale if this is not set.
+*/
+void QGeoSearchManagerEngine::setLocale(const QLocale &locale)
+{
+ d_ptr->locale = locale;
+}
+
+/*!
+ Returns the locale used to hint to this search manager about what
+ language to use for the results.
+*/
+QLocale QGeoSearchManagerEngine::locale() const
+{
+ return d_ptr->locale;
+}
+
+/*!
+\fn void QGeoSearchManagerEngine::finished(QGeoSearchReply* reply)
+
+ This signal is emitted when \a reply has finished processing.
+
+ If reply::error() equals QGeoSearchReply::NoError then the processing
+ finished successfully.
+
+ This signal and QGeoSearchReply::finished() will be emitted at the same
+ time.
+
+ \note Do no delete the \a reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*!
+\fn void QGeoSearchManagerEngine::error(QGeoSearchReply* reply, QGeoSearchReply::Error error, QString errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ \a reply. The QGeoSearchManagerEngine::finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ This signal and QGeoSearchReply::error() will be emitted at the same time.
+
+ \note Do no delete the \a reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoSearchManagerEnginePrivate::QGeoSearchManagerEnginePrivate()
+ : managerVersion(-1),
+ defaultLandmarkManager(0),
+ supportsGeocoding(false),
+ supportsReverseGeocoding(false) {}
+
+QGeoSearchManagerEnginePrivate::~QGeoSearchManagerEnginePrivate()
+{
+ if (defaultLandmarkManager)
+ delete defaultLandmarkManager;
+ // TODO check for null? or do that in the setter?
+ qDeleteAll(additionalLandmarkManagers);
+}
+
+#include "moc_qgeosearchmanagerengine.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeosearchmanagerengine.h b/src/location/maps/qgeosearchmanagerengine.h
new file mode 100644
index 00000000..143815a2
--- /dev/null
+++ b/src/location/maps/qgeosearchmanagerengine.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGERENGINE_H
+#define QGEOSEARCHMANAGERENGINE_H
+
+#include "qgeosearchmanager.h"
+#include "qgeosearchreply.h"
+#include "qgeoboundingbox.h"
+
+#include <QObject>
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManager;
+
+class QGeoSearchManagerEnginePrivate;
+
+class Q_LOCATION_EXPORT QGeoSearchManagerEngine : public QObject
+{
+ Q_OBJECT
+public:
+ QGeoSearchManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ virtual ~QGeoSearchManagerEngine();
+
+ QString managerName() const;
+ int managerVersion() const;
+
+ virtual QGeoSearchReply* geocode(const QGeoAddress &address,
+ QGeoBoundingArea *bounds);
+ virtual QGeoSearchReply* reverseGeocode(const QGeoCoordinate &coordinate,
+ QGeoBoundingArea *bounds);
+
+ virtual QGeoSearchReply* search(const QString &searchString,
+ QGeoSearchManager::SearchTypes searchTypes,
+ int limit,
+ int offset,
+ QGeoBoundingArea *bounds);
+
+ bool supportsGeocoding() const;
+ bool supportsReverseGeocoding() const;
+ QGeoSearchManager::SearchTypes supportedSearchTypes() const;
+
+ QLandmarkManager* defaultLandmarkManager() const;
+
+ void setAdditionalLandmarkManagers(const QList<QLandmarkManager *> &landmarkManagers);
+ QList<QLandmarkManager *> additionalLandmarkManagers() const;
+ void addAdditionalLandmarkManager(QLandmarkManager *landmarkManager);
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+Q_SIGNALS:
+ void finished(QGeoSearchReply* reply);
+ void error(QGeoSearchReply* reply, QGeoSearchReply::Error error, QString errorString = QString());
+
+protected:
+ void setDefaultLandmarkManager(QLandmarkManager *landmarkManager);
+ void setSupportsGeocoding(bool supported);
+ void setSupportsReverseGeocoding(bool supported);
+ void setSupportedSearchTypes(QGeoSearchManager::SearchTypes searchTypes);
+
+private:
+ void setManagerName(const QString &managerName);
+ void setManagerVersion(int managerVersion);
+
+ QGeoSearchManagerEnginePrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoSearchManagerEngine)
+
+ friend class QGeoServiceProvider;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeosearchmanagerengine_p.h b/src/location/maps/qgeosearchmanagerengine_p.h
new file mode 100644
index 00000000..90ccf43a
--- /dev/null
+++ b/src/location/maps/qgeosearchmanagerengine_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHMANAGERENGINE_P_H
+#define QGEOSEARCHMANAGERENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeosearchmanagerengine.h"
+
+#include <QList>
+#include <QLocale>
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmarkManager;
+
+class QGeoSearchManagerEnginePrivate
+{
+public:
+ QGeoSearchManagerEnginePrivate();
+ ~QGeoSearchManagerEnginePrivate();
+
+ QString managerName;
+ int managerVersion;
+
+ QLandmarkManager *defaultLandmarkManager;
+ QList<QLandmarkManager*> additionalLandmarkManagers;
+
+ bool supportsGeocoding;
+ bool supportsReverseGeocoding;
+ QGeoSearchManager::SearchTypes supportedSearchTypes;
+
+ QLocale locale;
+
+private:
+ Q_DISABLE_COPY(QGeoSearchManagerEnginePrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeosearchreply.cpp b/src/location/maps/qgeosearchreply.cpp
new file mode 100644
index 00000000..6e4c3cc8
--- /dev/null
+++ b/src/location/maps/qgeosearchreply.cpp
@@ -0,0 +1,344 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosearchreply.h"
+#include "qgeosearchreply_p.h"
+
+QTM_BEGIN_NAMESPACE
+/*!
+ \class QGeoSearchReply
+
+ \brief The QGeoSearchReply class manages an operation started by an
+ instance of QGeoSearchManager.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-places
+
+ Instances of QGeoSearchReply manage the state and results of these
+ operations.
+
+ The isFinished(), error() and errorString() methods provide information
+ on whether the operation has completed and if it completed successfully.
+
+ The finished() and error(QGeoSearchReply::Error,QString)
+ signals can be used to monitor the progress of the operation.
+
+ It is possible that a newly created QGeoSearchReply may be in a finished
+ state, most commonly because an error has occurred. Since such an instance
+ will never emit the finished() or
+ error(QGeoSearchReply::Error,QString) signals, it is
+ important to check the result of isFinished() before making the connections
+ to the signals. The documentation for QGeoSearchManager demonstrates how
+ this might be carried out.
+
+ If the operation completes successfully the results will be able to be
+ accessed with places().
+*/
+
+/*!
+ \enum QGeoSearchReply::Error
+
+ Describes an error which prevented the completion of the operation.
+
+ \value NoError
+ No error has occurred.
+ \value EngineNotSetError
+ The search manager that was used did not have a QGeoSearchManagerEngine instance associated with it.
+ \value CommunicationError
+ An error occurred while communicating with the service provider.
+ \value ParseError
+ The response from the service provider was in an unrecognizable format.
+ \value UnsupportedOptionError
+ The requested operation or one of the options for the operation are not
+ supported by the service provider.
+ \value CombinationError
+ An error occurred while results where being combined from multiple sources.
+ \value UnknownError
+ An error occurred which does not fit into any of the other categories.
+*/
+
+/*!
+ Constructs a search reply with the specified \a parent.
+*/
+QGeoSearchReply::QGeoSearchReply(QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoSearchReplyPrivate()) {}
+
+/*!
+ Constructs a search reply with a given \a error and \a errorString and the specified \a parent.
+*/
+QGeoSearchReply::QGeoSearchReply(Error error, const QString &errorString, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoSearchReplyPrivate(error, errorString)) {}
+
+/*!
+ Destroys this search reply object.
+*/
+QGeoSearchReply::~QGeoSearchReply()
+{
+ delete d_ptr;
+}
+
+/*!
+ Sets whether or not this reply has finished to \a finished.
+
+ If \a finished is true, this will cause the finished() signal to be
+ emitted.
+
+ If the operation completed successfully, QGeoSearchReply::setPlaces()
+ should be called before this function. If an error occurred,
+ QGeoSearchReply::setError() should be used instead.
+*/
+void QGeoSearchReply::setFinished(bool finished)
+{
+ d_ptr->isFinished = finished;
+ if (d_ptr->isFinished)
+ emit this->finished();
+}
+
+/*!
+ Return true if the operation completed successfully or encountered an
+ error which cause the operation to come to a halt.
+*/
+bool QGeoSearchReply::isFinished() const
+{
+ return d_ptr->isFinished;
+}
+
+/*!
+ Sets the error state of this reply to \a error and the textual
+ representation of the error to \a errorString.
+
+ This wil also cause error() and finished() signals to be emitted, in that
+ order.
+*/
+void QGeoSearchReply::setError(QGeoSearchReply::Error error, const QString &errorString)
+{
+ d_ptr->error = error;
+ d_ptr->errorString = errorString;
+ emit this->error(error, errorString);
+ setFinished(true);
+}
+
+/*!
+ Returns the error state of this reply.
+
+ If the result is QGeoSearchReply::NoError then no error has occurred.
+*/
+QGeoSearchReply::Error QGeoSearchReply::error() const
+{
+ return d_ptr->error;
+}
+
+/*!
+ Returns the textual representation of the error state of this reply.
+
+ If no error has occurred this will return an empty string. It is possible
+ that an error occurred which has no associated textual representation, in
+ which case this will also return an empty string.
+
+ To determine whether an error has occurred, check to see if
+ QGeoSearchReply::error() is equal to QGeoSearchReply::NoError.
+*/
+QString QGeoSearchReply::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+/*!
+ Sets the viewport which contains the results to \a viewport.
+*/
+void QGeoSearchReply::setViewport(QGeoBoundingArea *viewport)
+{
+ d_ptr->viewport = viewport;
+}
+
+/*!
+ Returns the viewport which contains the results.
+
+ This function will return 0 if no viewport bias
+ was specified in the QGeoSearchManager function which created this reply.
+*/
+QGeoBoundingArea* QGeoSearchReply::viewport() const
+{
+ return d_ptr->viewport;
+}
+
+/*!
+ Returns a list of places.
+
+ The places are the results of the operation corresponding to the
+ QGeoSearchManager function which created this reply.
+*/
+QList<QGeoPlace> QGeoSearchReply::places() const
+{
+ return d_ptr->places;
+}
+
+/*!
+ Adds \a place to the list of places in this reply.
+*/
+void QGeoSearchReply::addPlace(const QGeoPlace &place)
+{
+ d_ptr->places.append(place);
+}
+
+/*!
+ Sets the list of \a places in the reply.
+*/
+void QGeoSearchReply::setPlaces(const QList<QGeoPlace> &places)
+{
+ d_ptr->places = places;
+}
+
+/*!
+ Cancels the operation immediately.
+
+ This will do nothing if the reply is finished.
+*/
+void QGeoSearchReply::abort()
+{
+ if (!isFinished())
+ setFinished(true);
+}
+
+/*!
+ Returns the limit on the number of responses from each data source.
+
+ If no limit was set this function will return -1.
+
+ This may be more than places().length() if the number of responses
+ was less than the number requested.
+
+ If QGeoSearchManager::search() is used along with
+ QGeoSearchManager::setAdditionalLandmarkManagers the number of results can
+ be as high as limit * (1 + number of additional landmark managers).
+*/
+int QGeoSearchReply::limit() const
+{
+ return d_ptr->limit;
+}
+
+/*!
+ Returns the offset into the entire result set at which to start
+ fetching results.
+*/
+int QGeoSearchReply::offset() const
+{
+ return d_ptr->offset;
+}
+
+/*!
+ Sets the limit on the number of responses from each data source to \a limit.
+
+ If \a limit is -1 then all available responses will be returned.
+*/
+void QGeoSearchReply::setLimit(int limit)
+{
+ d_ptr->limit = limit;
+}
+
+/*!
+ Sets the offset in the entire result set at which to start
+ fetching result to \a offset.
+*/
+void QGeoSearchReply::setOffset(int offset)
+{
+ d_ptr->offset = offset;
+}
+
+/*!
+ \fn void QGeoSearchReply::finished()
+
+ This signal is emitted when this reply has finished processing.
+
+ If error() equals QGeoSearchReply::NoError then the processing
+ finished successfully.
+
+ This signal and QGeoSearchManager::finished() will be
+ emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+/*!
+ \fn void QGeoSearchReply::error(QGeoSearchReply::Error error, const QString &errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ this reply. The finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ This signal and QGeoSearchManager::error() will be emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoSearchReplyPrivate::QGeoSearchReplyPrivate()
+ : error(QGeoSearchReply::NoError),
+ errorString(""),
+ isFinished(false),
+ viewport(0),
+ limit(-1),
+ offset(0) {}
+
+QGeoSearchReplyPrivate::QGeoSearchReplyPrivate(QGeoSearchReply::Error error, const QString &errorString)
+ : error(error),
+ errorString(errorString),
+ isFinished(true),
+ viewport(0),
+ limit(-1),
+ offset(0) {}
+
+QGeoSearchReplyPrivate::~QGeoSearchReplyPrivate() {}
+
+
+#include "moc_qgeosearchreply.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeosearchreply.h b/src/location/maps/qgeosearchreply.h
new file mode 100644
index 00000000..1620a0d2
--- /dev/null
+++ b/src/location/maps/qgeosearchreply.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHREPLY_H
+#define QGEOSEARCHREPLY_H
+
+#include "qgeoplace.h"
+
+#include <QObject>
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSearchReplyPrivate;
+
+class Q_LOCATION_EXPORT QGeoSearchReply : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum Error {
+ NoError,
+ EngineNotSetError,
+ CommunicationError,
+ ParseError,
+ UnsupportedOptionError,
+ CombinationError,
+ UnknownError
+ };
+
+ QGeoSearchReply(Error error, const QString &errorString, QObject *parent = 0);
+ virtual ~QGeoSearchReply();
+
+ bool isFinished() const;
+ Error error() const;
+ QString errorString() const;
+
+ QGeoBoundingArea* viewport() const;
+ QList<QGeoPlace> places() const;
+
+ int limit() const;
+ int offset() const;
+
+ virtual void abort();
+
+Q_SIGNALS:
+ void finished();
+ void error(QGeoSearchReply::Error error, const QString &errorString = QString());
+
+protected:
+ QGeoSearchReply(QObject* parent = 0);
+
+ void setError(Error error, const QString &errorString);
+ void setFinished(bool finished);
+
+ void setViewport(QGeoBoundingArea *viewport);
+ void addPlace(const QGeoPlace &place);
+ void setPlaces(const QList<QGeoPlace> &places);
+
+ void setLimit(int limit);
+ void setOffset(int offset);
+
+private:
+ QGeoSearchReplyPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoSearchReply)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeosearchreply_p.h b/src/location/maps/qgeosearchreply_p.h
new file mode 100644
index 00000000..4f8066f2
--- /dev/null
+++ b/src/location/maps/qgeosearchreply_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSEARCHREPLY_P_H
+#define QGEOSEARCHREPLY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeosearchreply.h"
+
+#include "qgeoboundingarea.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPlace;
+
+class QGeoSearchReplyPrivate
+{
+public:
+ QGeoSearchReplyPrivate();
+ QGeoSearchReplyPrivate(QGeoSearchReply::Error error, const QString& errorString);
+ ~QGeoSearchReplyPrivate();
+
+ QGeoSearchReply::Error error;
+ QString errorString;
+ bool isFinished;
+
+ QGeoBoundingArea* viewport;
+ QList<QGeoPlace> places;
+
+ int limit;
+ int offset;
+private:
+ Q_DISABLE_COPY(QGeoSearchReplyPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
new file mode 100644
index 00000000..093540c7
--- /dev/null
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -0,0 +1,430 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoserviceprovider.h"
+#include "qgeoserviceprovider_p.h"
+#include "qgeoserviceproviderfactory.h"
+
+#include "qgeosearchmanager.h"
+#include "qgeomappingmanager.h"
+#include "qgeoroutingmanager.h"
+#include "qgeosearchmanagerengine.h"
+#include "qgeomappingmanagerengine.h"
+#include "qgeoroutingmanagerengine.h"
+
+#include <QList>
+#include <QString>
+#include <QVariant>
+
+#include <QPluginLoader>
+#include <QDebug>
+#include <QStringList>
+#include <QCoreApplication>
+#include <QObject>
+#include <QProcess>
+#include <QEventLoop>
+
+#include "qmobilitypluginsearch.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoServiceProvider
+ \brief The QGeoServiceProvider class aggregates access to services which provide
+ geographical information.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps
+
+ The Maps and Navigation API allows people to access various kinds of
+ geographical information, including functionality to perform geocoding,
+ routing and the display of maps. The QGeoServiceProvider aggregates the
+ access to a set of these services that are provided by a single vendor.
+
+ It is possible to mix and match service providers for the various domains,
+ so that a geocoding manager from one service provider can be used with
+ a geographic routing manager from another service provider.
+
+ This is not recommended unless the client is able to verify that the
+ data provided by the different services are compatible, as differences
+ in the underlying data sets could cause serious incongruences between
+ the services.
+
+ Subclasses of QGeoServiceProvider guarantee that the different services
+ that they provide are interoperable.
+
+ At this point only the Nokia Services plugin is pacakged with Qt Mobility,
+ which is accessible using the provider name "nokia".
+*/
+
+/*!
+\enum QGeoServiceProvider::Error
+
+Describes an error related to the loading and setup of a service provider
+plugin.
+
+\value NoError
+No error has occurred.
+
+\value NotSupportedError
+The plugin does not support this functionality.
+
+\value UnknownParameterError
+The plugin did not recognise one of the parameters it was given.
+
+\value MissingRequiredParameterError
+The plugin did not find one of the parameters it was expecting.
+*/
+
+/*!
+ Returns a list of names of the available service providers, for use with
+ the QGeoServiceProvider constructors.
+*/
+QStringList QGeoServiceProvider::availableServiceProviders()
+{
+ return QGeoServiceProviderPrivate::plugins().keys();
+}
+
+/*!
+ Constructs a QGeoServiceProvider whose backend has the name \a
+ providerName, using the provided \a parameters.
+
+ If multiple plugins have the same \a providerName, the plugin with the
+ highest reported providerVersion() will be used.
+
+ If no plugin matching \a providerName was able to be loaded then error()
+ and errorString() will provide details about why this is the case.
+*/
+QGeoServiceProvider::QGeoServiceProvider(const QString &providerName, const QMap<QString, QVariant> &parameters)
+ : d_ptr(new QGeoServiceProviderPrivate())
+{
+ d_ptr->loadPlugin(providerName, parameters);
+ d_ptr->parameterMap = parameters;
+}
+
+/*!
+ Destroys the service provider object.
+*/
+QGeoServiceProvider::~QGeoServiceProvider()
+{
+ delete d_ptr;
+}
+
+/*!
+ Returns the QGeoSearchManager made available by the service
+ provider.
+
+ This function will return 0 if the service provider does not provide
+ any geocoding services.
+
+ This function will attempt to construct a QGeoSearchManager instance
+ when it is called for the first time. If the attempt is successful the
+ QGeoSearchManager will be cached, otherwise each call of this function
+ will attempt to construct a QGeoSearchManager instance until the
+ construction is successful.
+
+ After this function has been called, error() and errorString() will
+ report any errors which occurred during the construction of the
+ QGeoSearchManager.
+*/
+QGeoSearchManager* QGeoServiceProvider::searchManager() const
+{
+ if (!d_ptr->factory || (d_ptr->searchError != QGeoServiceProvider::NoError))
+ return 0;
+
+ if (!d_ptr->searchManager) {
+ QGeoSearchManagerEngine *engine = d_ptr->factory->createSearchManagerEngine(d_ptr->parameterMap,
+ &(d_ptr->searchError),
+ &(d_ptr->searchErrorString));
+ if (engine) {
+ engine->setManagerName(d_ptr->factory->providerName());
+ engine->setManagerVersion(d_ptr->factory->providerVersion());
+ d_ptr->searchManager = new QGeoSearchManager(engine);
+ } else {
+ d_ptr->searchError = QGeoServiceProvider::NotSupportedError;
+ d_ptr->searchErrorString = "The service provider does not support searchManager().";
+ }
+
+ if (d_ptr->searchError != QGeoServiceProvider::NoError) {
+ if (d_ptr->searchManager)
+ delete d_ptr->searchManager;
+ d_ptr->searchManager = 0;
+ d_ptr->error = d_ptr->searchError;
+ d_ptr->errorString = d_ptr->searchErrorString;
+ }
+ }
+
+ return d_ptr->searchManager;
+}
+
+/*!
+ Returns the QGeoMappingManager made available by the service provider.
+
+ This function will return 0 if the service provider does not provide
+ any mapping services.
+
+ This function will attempt to construct a QGeoMappingManager instance
+ when it is called for the first time. If the attempt is successful the
+ QGeoMappingManager will be cached, otherwise each call of this function
+ will attempt to construct a QGeoMappingManager instance until the
+ construction is successful.
+
+ After this function has been called, error() and errorString() will
+ report any errors which occurred during the construction of the
+ QGeoMappingManager.
+*/
+QGeoMappingManager* QGeoServiceProvider::mappingManager() const
+{
+ if (!d_ptr->factory || (d_ptr->mappingError != QGeoServiceProvider::NoError))
+ return 0;
+
+ if (!d_ptr->mappingManager) {
+ QGeoMappingManagerEngine *engine = d_ptr->factory->createMappingManagerEngine(d_ptr->parameterMap,
+ &(d_ptr->mappingError),
+ &(d_ptr->mappingErrorString));
+
+ if (engine) {
+ engine->setManagerName(d_ptr->factory->providerName());
+ engine->setManagerVersion(d_ptr->factory->providerVersion());
+ d_ptr->mappingManager = new QGeoMappingManager(engine);
+ } else {
+ d_ptr->mappingError = QGeoServiceProvider::NotSupportedError;
+ d_ptr->mappingErrorString = "The service provider does not support mappingManager().";
+ }
+
+ if (d_ptr->mappingError != QGeoServiceProvider::NoError) {
+ if (d_ptr->mappingManager)
+ delete d_ptr->mappingManager;
+ d_ptr->mappingManager = 0;
+ d_ptr->error = d_ptr->mappingError;
+ d_ptr->errorString = d_ptr->mappingErrorString;
+ }
+ }
+
+ return d_ptr->mappingManager;
+}
+
+/*!
+ Returns the QGeoRoutingManager made available by the service provider.
+
+ This function will return 0 if the service provider does not provide
+ any geographic routing services.
+
+ This function will attempt to construct a QGeoRoutingManager instance
+ when it is called for the first time. If the attempt is successful the
+ QGeoRoutingManager will be cached, otherwise each call of this function
+ will attempt to construct a QGeoRoutingManager instance until the
+ construction is successful.
+
+ After this function has been called, error() and errorString() will
+ report any errors which occurred during the construction of the
+ QGeoRoutingManager.
+*/
+QGeoRoutingManager* QGeoServiceProvider::routingManager() const
+{
+ if (!d_ptr->factory || (d_ptr->routingError != QGeoServiceProvider::NoError))
+ return 0;
+
+ if (!d_ptr->routingManager) {
+ QGeoRoutingManagerEngine *engine = d_ptr->factory->createRoutingManagerEngine(d_ptr->parameterMap,
+ &(d_ptr->routingError),
+ &(d_ptr->routingErrorString));
+
+ if (engine) {
+ engine->setManagerName(d_ptr->factory->providerName());
+ engine->setManagerVersion(d_ptr->factory->providerVersion());
+ d_ptr->routingManager = new QGeoRoutingManager(engine);
+ } else {
+ d_ptr->routingError = QGeoServiceProvider::NotSupportedError;
+ d_ptr->routingErrorString = "The service provider does not support routingManager().";
+ }
+
+ if (d_ptr->routingError != QGeoServiceProvider::NoError) {
+ if (d_ptr->routingManager)
+ delete d_ptr->routingManager;
+ d_ptr->routingManager = 0;
+ d_ptr->error = d_ptr->routingError;
+ d_ptr->errorString = d_ptr->routingErrorString;
+ }
+ }
+
+ return d_ptr->routingManager;
+}
+
+/*!
+ Returns an error code describing the error which occurred during the
+ last operation that was performed by this class.
+*/
+QGeoServiceProvider::Error QGeoServiceProvider::error() const
+{
+ return d_ptr->error;
+}
+
+/*!
+ Returns a string describing the error which occurred during the
+ last operation that was performed by this class.
+*/
+QString QGeoServiceProvider::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoServiceProviderPrivate::QGeoServiceProviderPrivate()
+ : factory(0),
+ searchManager(0),
+ routingManager(0),
+ mappingManager(0),
+ searchError(QGeoServiceProvider::NoError),
+ routingError(QGeoServiceProvider::NoError),
+ mappingError(QGeoServiceProvider::NoError),
+ error(QGeoServiceProvider::NoError) {}
+
+QGeoServiceProviderPrivate::~QGeoServiceProviderPrivate()
+{
+ if (searchManager)
+ delete searchManager;
+
+ if (routingManager)
+ delete routingManager;
+
+ if (mappingManager)
+ delete mappingManager;
+}
+
+void QGeoServiceProviderPrivate::loadPlugin(const QString &providerName, const QMap<QString, QVariant> &parameters)
+{
+ Q_UNUSED(parameters)
+
+ if (!QGeoServiceProviderPrivate::plugins().keys().contains(providerName)) {
+ error = QGeoServiceProvider::NotSupportedError;
+ errorString = QString("The geoservices provider %1 is not supported.").arg(providerName);
+ factory = 0;
+ return;
+ }
+
+ factory = 0;
+
+ error = QGeoServiceProvider::NoError;
+ errorString = "";
+
+ QList<QGeoServiceProviderFactory*> candidates = QGeoServiceProviderPrivate::plugins().values(providerName);
+
+ int versionFound = -1;
+
+ for (int i = 0; i < candidates.size(); ++i) {
+ QGeoServiceProviderFactory* f = candidates[i];
+ if (f && (f->providerVersion() > versionFound)) {
+ versionFound = f->providerVersion();
+ factory = f;
+ }
+ }
+}
+
+QHash<QString, QGeoServiceProviderFactory*> QGeoServiceProviderPrivate::plugins(bool reload)
+{
+ static QHash<QString, QGeoServiceProviderFactory*> plugins;
+ static bool alreadyDiscovered = false;
+
+ if (reload == true)
+ alreadyDiscovered = false;
+
+ if (!alreadyDiscovered) {
+ loadStaticPlugins(&plugins);
+ loadDynamicPlugins(&plugins);
+ alreadyDiscovered = true;
+ }
+ return plugins;
+}
+
+void QGeoServiceProviderPrivate::loadDynamicPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins)
+{
+ QStringList paths;
+ paths << mobilityPlugins(QLatin1String("geoservices"));
+
+ QPluginLoader qpl;
+ for (int i = 0; i < paths.count(); ++i) {
+ qpl.setFileName(paths.at(i));
+
+ QGeoServiceProviderFactory *f = qobject_cast<QGeoServiceProviderFactory*>(qpl.instance());
+ if (f) {
+ QString name = f->providerName();
+
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+ if (showDebug)
+ qDebug() << "Dynamic: found a service provider plugin with name" << name;
+#endif
+ plugins->insertMulti(name, f);
+ }
+ }
+}
+
+void QGeoServiceProviderPrivate::loadStaticPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins)
+{
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+#endif
+
+ QObjectList staticPlugins = QPluginLoader::staticInstances();
+ for (int i = 0; i < staticPlugins.count(); ++i) {
+ QGeoServiceProviderFactory *f = qobject_cast<QGeoServiceProviderFactory*>(staticPlugins.at(i));
+ if (f) {
+ QString name = f->providerName();
+
+#if !defined QT_NO_DEBUG
+ if (showDebug)
+ qDebug() << "Static: found a service provider plugin with name" << name;
+#endif
+ if (!name.isEmpty()) {
+ plugins->insertMulti(name, f);
+ }
+ }
+
+ }
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/qgeoserviceprovider.h b/src/location/maps/qgeoserviceprovider.h
new file mode 100644
index 00000000..83482ae7
--- /dev/null
+++ b/src/location/maps/qgeoserviceprovider.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDER_H
+#define QGEOSERVICEPROVIDER_H
+
+#include "qmobilityglobal.h"
+
+#include <QMap>
+#include <QVariant>
+#include <QString>
+
+class QStringList;
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSearchManager;
+class QGeoMappingManager;
+class QGeoRoutingManager;
+class QGeoSearchManagerEngine;
+class QGeoMappingManagerEngine;
+class QGeoRoutingManagerEngine;
+class QGeoServiceProviderPrivate;
+
+class Q_LOCATION_EXPORT QGeoServiceProvider
+{
+public:
+ enum Error {
+ NoError,
+ NotSupportedError,
+ UnknownParameterError,
+ MissingRequiredParameterError
+ };
+
+ static QStringList availableServiceProviders();
+ QGeoServiceProvider(const QString &providerName,
+ const QMap<QString,QVariant> &parameters = (QMap<QString,QVariant>()));
+
+ ~QGeoServiceProvider();
+
+ QGeoSearchManager* searchManager() const;
+ QGeoMappingManager* mappingManager() const;
+ QGeoRoutingManager* routingManager() const;
+
+ Error error() const;
+ QString errorString() const;
+
+private:
+ QGeoServiceProviderPrivate* d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h
new file mode 100644
index 00000000..22ea2337
--- /dev/null
+++ b/src/location/maps/qgeoserviceprovider_p.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDER_P_H
+#define QGEOSERVICEPROVIDER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeoserviceprovider.h"
+
+#include <QHash>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSearchManager;
+class QGeoRoutingManager;
+class QGeoMappingManager;
+
+class QGeoServiceProviderFactory;
+
+class QGeoServiceProviderPrivate
+{
+public:
+ QGeoServiceProviderPrivate();
+ ~QGeoServiceProviderPrivate();
+
+ void loadPlugin(const QString &providerName, const QMap<QString, QVariant> &parameters);
+
+ QGeoServiceProviderFactory *factory;
+
+ QMap<QString, QVariant> parameterMap;
+
+ QGeoSearchManager *searchManager;
+ QGeoRoutingManager *routingManager;
+ QGeoMappingManager *mappingManager;
+
+ QGeoServiceProvider::Error searchError;
+ QGeoServiceProvider::Error routingError;
+ QGeoServiceProvider::Error mappingError;
+
+ QString searchErrorString;
+ QString routingErrorString;
+ QString mappingErrorString;
+
+ QGeoServiceProvider::Error error;
+ QString errorString;
+
+ static QHash<QString, QGeoServiceProviderFactory*> plugins(bool reload = false);
+ static void loadDynamicPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins);
+ static void loadStaticPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins);
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgeoserviceproviderfactory.cpp b/src/location/maps/qgeoserviceproviderfactory.cpp
new file mode 100644
index 00000000..600c4469
--- /dev/null
+++ b/src/location/maps/qgeoserviceproviderfactory.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoserviceproviderfactory.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoServiceProviderFactory
+
+ \brief The QGeoServiceProviderFactory class is a factory class used as the
+ plugin interface for services related to geographical information.
+
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-impl
+
+ Implementers must provide a unique combination of providerName() and
+ providerVersion() per plugin.
+
+ The other functions should be overridden if the plugin supports the
+ associated set of functionality.
+*/
+
+/*!
+\fn QGeoServiceProviderFactory::~QGeoServiceProviderFactory()
+
+Destroys this QGeoServiceProviderFactory instance.
+*/
+
+
+/*!
+\fn QString QGeoServiceProviderFactory::providerName() const
+
+Returns the string used to identify the service provider behind this implementation.
+
+The combination of providerName() and providerVersion() should be unique
+amongst the plugins.
+*/
+
+/*!
+\fn int QGeoServiceProviderFactory::providerVersion() const
+
+Returns the version of the plugin.
+
+The combination of providerName() and providerVersion() should be unique
+amongst the plugins.
+*/
+
+/*!
+ Returns a new QGeoSearchManagerEngine instance, initialized with \a
+ parameters, which implements as much of the places searching functionality
+ as the service provider supports.
+
+ If \a error is not 0 it should be set to QGeoServiceProvider::NoError on
+ success or an appropriate QGeoServiceProvider::Error on failure.
+
+ If \a errorString is not 0 it should be set to a string describing any
+ error which occurred.
+
+ The default implementation returns 0, which causes a
+ QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
+*/
+QGeoSearchManagerEngine* QGeoServiceProviderFactory::createSearchManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+/*!
+ Returns a new QGeoMappingManagerEngine instance, initialized with \a
+ parameters, which implements as much of the places searching functionality
+ as the service provider supports.
+
+ If \a error is not 0 it should be set to QGeoServiceProvider::NoError on
+ success or an appropriate QGeoServiceProvider::Error on failure.
+
+ If \a errorString is not 0 it should be set to a string describing any
+ error which occurred.
+
+ The default implementation returns 0, which causes a
+ QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
+*/
+QGeoMappingManagerEngine* QGeoServiceProviderFactory::createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+/*!
+ Returns a new QGeoRoutingManagerEngine instance, initialized with \a
+ parameters, which implements as much of the places searching functionality
+ as the service provider supports.
+
+ If \a error is not 0 it should be set to QGeoServiceProvider::NoError on
+ success or an appropriate QGeoServiceProvider::Error on failure.
+
+ If \a errorString is not 0 it should be set to a string describing any
+ error which occurred.
+
+ The default implementation returns 0, which causes a
+ QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
+*/
+QGeoRoutingManagerEngine* QGeoServiceProviderFactory::createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const
+
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgeoserviceproviderfactory.h b/src/location/maps/qgeoserviceproviderfactory.h
new file mode 100644
index 00000000..acaadb6d
--- /dev/null
+++ b/src/location/maps/qgeoserviceproviderfactory.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDERFACTORY_H
+#define QGEOSERVICEPROVIDERFACTORY_H
+
+#include "qmobilityglobal.h"
+#include "qgeoserviceprovider.h"
+
+#include <QtPlugin>
+#include <QMap>
+#include <QString>
+
+QTM_BEGIN_NAMESPACE
+
+class Q_LOCATION_EXPORT QGeoServiceProviderFactory
+{
+public:
+ virtual ~QGeoServiceProviderFactory() {}
+
+ virtual QString providerName() const = 0;
+ virtual int providerVersion() const = 0;
+
+ virtual QGeoSearchManagerEngine* createSearchManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ virtual QGeoMappingManagerEngine* createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ virtual QGeoRoutingManagerEngine* createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+};
+
+QTM_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+#define QT_GEOSERVICE_BACKEND_INTERFACE "com.nokia.qt.mobility.geoservice.serviceproviderfactory/1.0"
+Q_DECLARE_INTERFACE(QtMobility::QGeoServiceProviderFactory, QT_GEOSERVICE_BACKEND_INTERFACE);
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgraphicsgeomap.cpp b/src/location/maps/qgraphicsgeomap.cpp
new file mode 100644
index 00000000..f7fb49ee
--- /dev/null
+++ b/src/location/maps/qgraphicsgeomap.cpp
@@ -0,0 +1,809 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgraphicsgeomap.h"
+#include "qgraphicsgeomap_p.h"
+
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+#include "qgeomapobject.h"
+#include "qgeomapoverlay.h"
+
+#include "qgeoserviceprovider.h"
+#include "qgeomappingmanager.h"
+#include "qgeomapdata.h"
+
+#include <QGraphicsSceneResizeEvent>
+#include <QTimer>
+
+#include <QNetworkProxyFactory>
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGraphicsGeoMap
+ \brief The QGraphicsGeoMap class is used to display a map and manager the
+ interactions between the user and the map.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps-mapping
+
+ Most of the functionality is provided by QGeoMappingManager, which
+ handles most aspects of the display.
+
+ The map viewport can be panned, the zoom level can be changed and the
+ center coordinate of the viewport can be set explicitly.
+
+ The screenPositionToCoordinate() and coordinateToScreenPoisition()
+ functions can be used to convert between positions on the screen and
+ global coordinates.
+
+ Mouse and keyboard events should be handled by subclassing QGraphicsGeoMap
+ and providing implementations of the event handling functions present in
+ QGraphicsWidget.
+*/
+
+/*!
+\enum QGraphicsGeoMap::MapType
+
+Describes a type of map data.
+
+\value NoMap
+Indicates a lack of map valid data.
+
+\value StreetMap
+The map data is a graphical representation of streets and building boundaries.
+
+\value SatelliteMapDay
+The map data is composed of images collected by satellites during the daytime.
+
+\value SatelliteMapNight
+The map data is composed of images collected by satellites during the nighttime.
+
+\value TerrainMap
+The map data is a graphical representation of terrain features. This may also
+include some of the information provided by QGraphicsGeoMap::StreetMap.
+*/
+
+/*!
+\enum QGraphicsGeoMap::ConnectivityMode
+
+Describes the method of obtaining the mapping data.
+
+\value NoConnectivity
+There is no map data.
+
+\value OfflineMode
+The map data will come from an offline source.
+
+\value OnlineMode
+The map data will come from an online source.
+
+\value HybridMode
+The map data will come from a combination of offline and online sources.
+*/
+
+/*!
+ Creates a new mapping widget, with the mapping operations managed by
+ \a manager, and the specified \a parent.
+
+ Note that the \a manager will typically be accessed from an instance of
+ QGeoServiceProvider:
+ \code
+ QGeoServiceProvider serviceProvider("nokia");
+ QGeoMappingManager *manager = serviceProvider.mappingManager();
+ QGraphicsGeoMap *widget = new QGraphicsGeoMap(manager);
+ \endcode
+*/
+QGraphicsGeoMap::QGraphicsGeoMap(QGeoMappingManager *manager, QGraphicsItem *parent)
+ : QGraphicsWidget(parent),
+ d_ptr(new QGraphicsGeoMapPrivate())
+{
+ Q_ASSERT(manager != 0);
+ d_ptr->manager = manager;
+
+ d_ptr->mapData = d_ptr->manager->createMapData();
+ d_ptr->mapData->init();
+
+ connect(d_ptr->mapData,
+ SIGNAL(updateMapDisplay(QRectF)),
+ this,
+ SLOT(updateMapDisplay(QRectF)));
+
+ setMapType(QGraphicsGeoMap::StreetMap);
+ d_ptr->mapData->setWindowSize(size());
+
+ connect(d_ptr->mapData,
+ SIGNAL(zoomLevelChanged(qreal)),
+ this,
+ SIGNAL(zoomLevelChanged(qreal)));
+ connect(d_ptr->mapData,
+ SIGNAL(bearingChanged(qreal)),
+ this,
+ SIGNAL(bearingChanged(qreal)));
+ connect(d_ptr->mapData,
+ SIGNAL(tiltChanged(qreal)),
+ this,
+ SIGNAL(tiltChanged(qreal)));
+ connect(d_ptr->mapData,
+ SIGNAL(mapTypeChanged(QGraphicsGeoMap::MapType)),
+ this,
+ SIGNAL(mapTypeChanged(QGraphicsGeoMap::MapType)));
+ connect(d_ptr->mapData,
+ SIGNAL(centerChanged(QGeoCoordinate)),
+ this,
+ SIGNAL(centerChanged(QGeoCoordinate)));
+ connect(d_ptr->mapData,
+ SIGNAL(connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode)),
+ this,
+ SIGNAL(connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode)));
+
+ setFlag(QGraphicsItem::ItemIsFocusable);
+ setFocus();
+
+ setMinimumSize(QSizeF(0, 0));
+ setPreferredSize(QSizeF(500, 500));
+}
+
+/*!
+ Destroys this map widget.
+*/
+QGraphicsGeoMap::~QGraphicsGeoMap()
+{
+ delete d_ptr;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsGeoMap::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+ if (d_ptr->mapData) {
+ d_ptr->mapData->setWindowSize(event->newSize());
+ }
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsGeoMap::shape() const
+{
+ QPainterPath path;
+ path.addRect(boundingRect());
+ return path;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsGeoMap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
+{
+ if (d_ptr->mapData)
+ d_ptr->mapData->paint(painter, option);
+}
+
+void QGraphicsGeoMap::updateMapDisplay(const QRectF &target)
+{
+ update(target);
+}
+
+/*!
+ \property QGraphicsGeoMap::minimumZoomLevel
+ \brief This property holds the minimum zoom level supported by the
+ QGeoMappingManager associated with this widget.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGraphicsGeoMap::minimumZoomLevel() const
+{
+ if (d_ptr->manager)
+ return d_ptr->manager->minimumZoomLevel();
+
+ return -1;
+}
+
+/*!
+ \property QGraphicsGeoMap::maximumZoomLevel
+ \brief This property holds the maximum zoom level supported by the
+ QGeoMappingManager associated with this widget.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+*/
+qreal QGraphicsGeoMap::maximumZoomLevel() const
+{
+ if (d_ptr->manager)
+ return d_ptr->manager->maximumZoomLevel();
+
+ return -1;
+}
+
+/*!
+ \property QGraphicsGeoMap::zoomLevel
+ \brief This property holds the zoom level of the map.
+
+ Larger values of the zoom level correspond to more detailed views of the
+ map.
+
+ If zoomLevel is less than minimumZoomLevel then minimumZoomLevel
+ will be used, and if zoomLevel is larger than
+ maximumZoomLevel then maximumZoomLevel will be used.
+*/
+void QGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
+{
+ if (d_ptr->mapData)
+ d_ptr->mapData->setZoomLevel(zoomLevel);
+}
+
+qreal QGraphicsGeoMap::zoomLevel() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->zoomLevel();
+
+ return -1;
+}
+/*!
+ \property QGraphicsGeoMap::supportsBearing
+ \brief This property holds whether bearing is supported by the
+ QGeoMappingManager associated with this widget.
+*/
+bool QGraphicsGeoMap::supportsBearing() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->supportsBearing();
+
+ return false;
+}
+
+/*!
+ \property QGraphicsGeoMap::bearing
+ \brief This property holds the bearing of the map.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+void QGraphicsGeoMap::setBearing(qreal bearing)
+{
+ if (d_ptr->mapData)
+ d_ptr->mapData->setBearing(bearing);
+}
+
+qreal QGraphicsGeoMap::bearing() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->bearing();
+
+ return 0;
+}
+
+/*!
+ \property QGraphicsGeoMap::supportsTilting
+ \brief This property holds whether tilting is supported by the
+ QGeoMappingManager associated with this widget.
+*/
+bool QGraphicsGeoMap::supportsTilting() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->supportsTilting();
+
+ return false;
+}
+
+/*!
+ \property QGraphicsGeoMap::minimumTilt
+ \brief This property holds the minimum tilt supported by the
+ QGeoMappingManager associated with this widget.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGraphicsGeoMap::minimumTilt() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->minimumTilt();
+
+ return 0;
+}
+
+/*!
+ \property QGraphicsGeoMap::maximumTilt
+ \brief This property holds the maximum tilt supported by the
+ QGeoMappingManager associated with this widget.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+*/
+qreal QGraphicsGeoMap::maximumTilt() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->maximumTilt();
+
+ return 0;
+}
+
+/*!
+ \property QGraphicsGeoMap::tilt
+ \brief This property holds the tilt of the map.
+
+ Value in degrees where 0 is equivalent to 90 degrees between view and earth's
+ surface i.e. looking straight down to earth.
+
+ If \a tilt is less than minimumTilt() then minimumTilt()
+ will be used, and if \a tilt is larger than
+ maximumTilt() then maximumTilt() will be used.
+*/
+void QGraphicsGeoMap::setTilt(qreal tilt)
+{
+ if (d_ptr->mapData)
+ d_ptr->mapData->setTilt(tilt);
+}
+
+qreal QGraphicsGeoMap::tilt() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->tilt();
+
+ return 0;
+}
+
+/*!
+ Pans the map view \a dx pixels in the x direction and \a dy pixels
+ in the y direction.
+
+ The x and y axes are specified in Graphics View Framework coordinates.
+ By default this will mean that positive values of \a dx move the
+ viewed area to the right and that positive values of \a dy move the
+ viewed area down.
+
+ After the panning has occurred the centerChanged() signal will be emitted.
+*/
+void QGraphicsGeoMap::pan(int dx, int dy)
+{
+ if (d_ptr->mapData) {
+ d_ptr->mapData->pan(dx, dy);
+ update();
+ }
+}
+
+/*!
+ \property QGraphicsGeoMap::center
+ \brief This property holds the coordinate at the center of the map viewport.
+
+ Panning the map can be more efficient than changing the center by small
+ increments.
+*/
+void QGraphicsGeoMap::setCenter(const QGeoCoordinate &center)
+{
+ if (d_ptr->mapData)
+ d_ptr->mapData->setCenter(center);
+}
+
+QGeoCoordinate QGraphicsGeoMap::center() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->center();
+
+ return QGeoCoordinate();
+}
+
+/*!
+ Returns the map types supported by the QGeoMappingManager associated with
+ this widget.
+*/
+QList<QGraphicsGeoMap::MapType> QGraphicsGeoMap::supportedMapTypes() const
+{
+ if (d_ptr->manager)
+ return d_ptr->manager->supportedMapTypes();
+
+ return QList<QGraphicsGeoMap::MapType>();
+}
+
+/*!
+ \property QGraphicsGeoMap::mapType
+ \brief This property holds the type of map data displayed by the map.
+
+ Setting mapType to a type not present in supportedMapTypes() will do
+ nothing.
+*/
+void QGraphicsGeoMap::setMapType(QGraphicsGeoMap::MapType mapType)
+{
+ if (d_ptr->mapData && d_ptr->manager) {
+ if (!d_ptr->manager->supportedMapTypes().contains(mapType))
+ return;
+
+ d_ptr->mapData->setMapType(mapType);
+ }
+}
+
+QGraphicsGeoMap::MapType QGraphicsGeoMap::mapType() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->mapType();
+
+ return QGraphicsGeoMap::NoMap;
+}
+
+/*!
+ Returns the connectivity modes supported by the QGeoMappingManager associated with
+ this widget.
+*/
+QList<QGraphicsGeoMap::ConnectivityMode> QGraphicsGeoMap::supportedConnectivityModes() const
+{
+ if (d_ptr->manager)
+ return d_ptr->manager->supportedConnectivityModes();
+
+ return QList<QGraphicsGeoMap::ConnectivityMode>();
+}
+
+/*!
+ \property QGraphicsGeoMap::connectivityMode
+ \brief This property holds the connectivity mode used to obtain the map data.
+
+ Setting connectivityMode to a mode not present in supportedConnectivityModes() will do
+ nothing.
+*/
+void QGraphicsGeoMap::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
+{
+ if (d_ptr->mapData && d_ptr->manager) {
+ if (!d_ptr->manager->supportedConnectivityModes().contains(connectivityMode))
+ return;
+
+ d_ptr->mapData->setConnectivityMode(connectivityMode);
+ }
+}
+
+QGraphicsGeoMap::ConnectivityMode QGraphicsGeoMap::connectivityMode() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->connectivityMode();
+
+ return QGraphicsGeoMap::NoConnectivity;
+}
+
+/*!
+ Returns whether custom map objects are supported by this engine.
+
+ Custom map objects are map objects based on QGraphicsItem instances, which
+ are hard to support in cases where the map rendering is not being
+ performed by the Qt Graphics View framwork.
+*/
+bool QGraphicsGeoMap::supportsCustomMapObjects() const
+{
+ if (d_ptr->manager)
+ return d_ptr->manager->supportsCustomMapObjects();
+
+ return false;
+}
+
+/*!
+ Returns the map objects associated with this map.
+*/
+QList<QGeoMapObject*> QGraphicsGeoMap::mapObjects() const
+{
+ if (!d_ptr->mapData)
+ return QList<QGeoMapObject*>();
+
+ return d_ptr->mapData->mapObjects();
+}
+
+/*!
+ Adds \a mapObject to the list of map objects managed by this widget.
+
+ If \a mapObject is within the viewport of the map and
+ QGeoMapObject::isVisible() returns true then the map will display the map
+ object immediately.
+
+ The map will take ownership of the \a mapObject.
+
+ If supportsCustomMapObject() returns false and \a mapObject is a custom map
+ object then \a mapObject will not be added to the map.
+*/
+void QGraphicsGeoMap::addMapObject(QGeoMapObject *mapObject)
+{
+ if (!mapObject || !d_ptr->mapData)
+ return;
+
+ if ((mapObject->type() == QGeoMapObject::CustomType) && !supportsCustomMapObjects())
+ return;
+
+ d_ptr->mapData->addMapObject(mapObject);
+
+ this->update();
+}
+
+/*!
+ Removes \a mapObject from the list of map objects managed by this widget.
+
+ If \a mapObject is within the viewport of the map and
+ QGeoMapObject::isVisible() returns true then the map will stop displaying
+ the map object immediately.
+
+ The map will release ownership of the \a mapObject.
+*/
+void QGraphicsGeoMap::removeMapObject(QGeoMapObject *mapObject)
+{
+ if (!mapObject || !d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->removeMapObject(mapObject);
+
+ this->update();
+}
+
+/*!
+ Clears the map objects associated with this map.
+
+ The map objects will be deleted.
+*/
+void QGraphicsGeoMap::clearMapObjects()
+{
+ if (!d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->clearMapObjects();
+}
+
+/*!
+ Returns the map overlays associated with this map.
+*/
+QList<QGeoMapOverlay*> QGraphicsGeoMap::mapOverlays() const
+{
+ if (!d_ptr->mapData)
+ return QList<QGeoMapOverlay*>();
+
+ return d_ptr->mapData->mapOverlays();
+}
+
+/*!
+ Adds \a overlay to the list of map overlays associated with this map.
+
+ The overlays will be drawn in the order in which they were added.
+
+ The map will take ownership of \a overlay.
+*/
+void QGraphicsGeoMap::addMapOverlay(QGeoMapOverlay *overlay)
+{
+ if (!overlay || !d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->addMapOverlay(overlay);
+
+ this->update();
+}
+
+/*!
+ Removes \a overlay from the list of map overlays associated with this map.
+
+ The map will release ownership of \a overlay.
+*/
+void QGraphicsGeoMap::removeMapOverlay(QGeoMapOverlay *overlay)
+{
+ if (!overlay || !d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->removeMapOverlay(overlay);
+
+ this->update();
+}
+
+/*!
+ Clears the map overlays associated with this map.
+
+ The map overlays will be deleted.
+*/
+void QGraphicsGeoMap::clearMapOverlays()
+{
+ if (!d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->clearMapOverlays();
+}
+
+/*!
+ Returns a bounding box corresponding to the physical area displayed
+ in the viewport of the map.
+
+ The bounding box which is returned is defined by the upper left and
+ lower right corners of the visible area of the map.
+*/
+QGeoBoundingBox QGraphicsGeoMap::viewport() const
+{
+ if (!d_ptr->mapData)
+ return QGeoBoundingBox();
+
+ return d_ptr->mapData->viewport();
+}
+
+/*!
+ Attempts to fit the bounding box \a bounds into the viewport of the map.
+
+ This method will change the zoom level to the maximum zoom level such
+ that all of \a bounds is visible within the resulting viewport.
+
+ If \a preserveViewportCenter is false the map will be centered on the
+ bounding box \a bounds before the zoom level is changed, otherwise the
+ center of the map will not be changed.
+*/
+void QGraphicsGeoMap::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
+{
+ if (!d_ptr->mapData)
+ return;
+
+ d_ptr->mapData->fitInViewport(bounds, preserveViewportCenter);
+}
+
+/*!
+ Returns the list of visible map objects managed by this widget which
+ contain the point \a screenPosition within their boundaries.
+*/
+QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->mapObjectsAtScreenPosition(screenPosition);
+
+ return QList<QGeoMapObject*>();
+}
+
+/*!
+ Returns the list of visible map objects managed by this widget which are
+ displayed at least partially within the on screen rectangle
+ \a screenRect.
+*/
+QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsInScreenRect(const QRectF &screenRect) const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->mapObjectsInScreenRect(screenRect);
+
+ return QList<QGeoMapObject*>();
+}
+
+/*!
+ Returns the list of visible map objects manager by this widget which
+ are displayed at least partially within the viewport of the map.
+*/
+QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsInViewport() const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->mapObjectsInViewport();
+
+ return QList<QGeoMapObject*>();
+}
+
+/*!
+ Returns the position on the screen at which \a coordinate is displayed.
+
+ An invalid QPointF will be returned if \a coordinate is invalid or is not
+ within the current viewport.
+*/
+QPointF QGraphicsGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->coordinateToScreenPosition(coordinate);
+
+ return QPointF();
+}
+
+/*!
+ Returns the coordinate corresponding to the point in the viewport at \a
+ screenPosition.
+
+ An invalid QGeoCoordinate will be returned if \a screenPosition is invalid
+ or is not within the current viewport.
+*/
+QGeoCoordinate QGraphicsGeoMap::screenPositionToCoordinate(QPointF screenPosition) const
+{
+ if (d_ptr->mapData)
+ return d_ptr->mapData->screenPositionToCoordinate(screenPosition);
+
+ return QGeoCoordinate();
+}
+
+/*!
+\fn void QGraphicsGeoMap::zoomLevelChanged(qreal zoomLevel)
+
+ This signal is emitted when the zoom level of the map changes.
+
+ The new value is \a zoomLevel.
+*/
+
+/*!
+\fn void QGraphicsGeoMap::bearingChanged(qreal bearing)
+
+ This signal is emitted when the bearing of the map changes.
+
+ The new value is \a bearing.
+*/
+
+/*!
+\fn void QGraphicsGeoMap::tiltChanged(qreal tilt)
+
+ This signal is emitted when the tilt of the map changes.
+
+ The new value is \a tilt.
+*/
+
+/*!
+\fn void QGraphicsGeoMap::centerChanged(const QGeoCoordinate &coordinate)
+
+ This signal is emitted when the center of the map changes.
+
+ The new value is \a coordinate.
+*/
+
+/*!
+\fn void QGraphicsGeoMap::mapTypeChanged(QGraphicsGeoMap::MapType mapType)
+
+ This signal is emitted when the map type changes.
+
+ The new value is \a mapType.
+*/
+
+/*!
+\fn void QGraphicsGeoMap::connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode)
+
+ This signal is emitted when the connectivity mode used to fetch the
+ map data changes.
+
+ The new value is \a connectivityMode.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGraphicsGeoMapPrivate::QGraphicsGeoMapPrivate()
+ : manager(0),
+ mapData(0),
+ panActive(false) {}
+
+QGraphicsGeoMapPrivate::~QGraphicsGeoMapPrivate()
+{
+ if (mapData)
+ delete mapData;
+}
+
+#include "moc_qgraphicsgeomap.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/qgraphicsgeomap.h b/src/location/maps/qgraphicsgeomap.h
new file mode 100644
index 00000000..1f19a12a
--- /dev/null
+++ b/src/location/maps/qgraphicsgeomap.h
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSGEOMAP_H
+#define QGRAPHICSGEOMAP_H
+
+#include "qmobilityglobal.h"
+
+#include <QGraphicsWidget>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoMappingManager;
+class QGeoBoundingBox;
+class QGeoMapObject;
+class QGeoMapOverlay;
+class QGraphicsGeoMapPrivate;
+
+class Q_LOCATION_EXPORT QGraphicsGeoMap : public QGraphicsWidget
+{
+ Q_OBJECT
+ Q_ENUMS(MapType)
+ Q_ENUMS(ConnectivityMode)
+
+ Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel CONSTANT)
+ Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel CONSTANT)
+ Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
+ Q_PROPERTY(MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
+ Q_PROPERTY(ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
+ Q_PROPERTY(qreal minimumTilt READ minimumTilt CONSTANT)
+ Q_PROPERTY(qreal maximumTilt READ maximumTilt CONSTANT)
+ Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
+ Q_PROPERTY(bool supportsTilting READ supportsTilting CONSTANT)
+ Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
+ Q_PROPERTY(bool supportsBearing READ supportsBearing CONSTANT)
+
+public:
+ enum MapType {
+ NoMap,
+ StreetMap,
+ SatelliteMapDay,
+ SatelliteMapNight,
+ TerrainMap
+ };
+
+ enum ConnectivityMode {
+ NoConnectivity,
+ OfflineMode,
+ OnlineMode,
+ HybridMode
+ };
+
+ QGraphicsGeoMap(QGeoMappingManager *manager, QGraphicsItem *parent = 0);
+ virtual ~QGraphicsGeoMap();
+
+ QPainterPath shape() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *parent);
+
+ qreal minimumZoomLevel() const;
+ qreal maximumZoomLevel() const;
+
+ void setZoomLevel(qreal zoomLevel);
+ qreal zoomLevel() const;
+
+ bool supportsBearing() const;
+ void setBearing(qreal bearing);
+ qreal bearing() const;
+
+ bool supportsTilting() const;
+ void setTilt(qreal tilt);
+ qreal tilt() const;
+ qreal minimumTilt() const;
+ qreal maximumTilt() const;
+
+ void setCenter(const QGeoCoordinate &center);
+ QGeoCoordinate center() const;
+
+ QList<MapType> supportedMapTypes() const;
+ void setMapType(MapType mapType);
+ MapType mapType() const;
+
+ QList<ConnectivityMode> supportedConnectivityModes() const;
+ void setConnectivityMode(ConnectivityMode connectivityMode);
+ ConnectivityMode connectivityMode() const;
+
+ bool supportsCustomMapObjects() const;
+
+ QList<QGeoMapObject*> mapObjects() const;
+ void addMapObject(QGeoMapObject *mapObject);
+ void removeMapObject(QGeoMapObject *mapObject);
+ void clearMapObjects();
+
+ QList<QGeoMapOverlay*> mapOverlays() const;
+ void addMapOverlay(QGeoMapOverlay *overlay);
+ void removeMapOverlay(QGeoMapOverlay *overlay);
+ void clearMapOverlays();
+
+ QGeoBoundingBox viewport() const;
+ void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false);
+
+ QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
+ QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
+ QList<QGeoMapObject*> mapObjectsInViewport() const;
+
+ QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate screenPositionToCoordinate(QPointF screenPosition) const;
+
+public Q_SLOTS:
+ void pan(int dx, int dy);
+
+protected:
+ void resizeEvent(QGraphicsSceneResizeEvent *event);
+
+Q_SIGNALS:
+ void zoomLevelChanged(qreal zoomLevel);
+ void centerChanged(const QGeoCoordinate &coordinate);
+ void mapTypeChanged(QGraphicsGeoMap::MapType mapType);
+ void connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode);
+ void bearingChanged(qreal bearing);
+ void tiltChanged(qreal tilt);
+
+private Q_SLOTS:
+ void updateMapDisplay(const QRectF& target);
+
+private:
+ QGraphicsGeoMapPrivate *d_ptr;
+ Q_DISABLE_COPY(QGraphicsGeoMap)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/qgraphicsgeomap_p.h b/src/location/maps/qgraphicsgeomap_p.h
new file mode 100644
index 00000000..a737bf5a
--- /dev/null
+++ b/src/location/maps/qgraphicsgeomap_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSGEOMAP_P_H
+#define QGRAPHICSGEOMAP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoServiceProvider;
+class QGeoMappingManager;
+class QGeoMapData;
+
+class QGraphicsGeoMapPrivate
+{
+public:
+ QGraphicsGeoMapPrivate();
+ ~QGraphicsGeoMapPrivate();
+
+ QGeoMappingManager *manager;
+ QGeoMapData *mapData;
+ bool panActive;
+
+private:
+ Q_DISABLE_COPY(QGraphicsGeoMapPrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/makepoly_p.h b/src/location/maps/tiled/makepoly_p.h
new file mode 100644
index 00000000..da8451b1
--- /dev/null
+++ b/src/location/maps/tiled/makepoly_p.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAKEPOLY_P_H
+#define MAKEPOLY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+#include "qgeocoordinate.h"
+
+#include <QList>
+#include <QPolygonF>
+#include <QGraphicsPolygonItem>
+
+QTM_BEGIN_NAMESPACE
+
+// TODO: replace boolean parameter by enum
+static inline void makepoly(QPolygonF &points, const QList<QGeoCoordinate> & path, const QGeoTiledMapDataPrivate * mapData, bool closedPath, qreal ypole = -100)
+{
+ points.clear();
+
+ QGeoCoordinate lastCoord = closedPath ? path.last() : path.first();
+ QPointF lastPoint = mapData->q_ptr->coordinateToWorldPixel(lastCoord);
+
+ int width = mapData->maxZoomSize.width();
+
+ for (int i = 0; i < path.size(); ++i) {
+ const QGeoCoordinate &coord = path.at(i);
+
+ if (!coord.isValid())
+ continue;
+
+ const qreal lng = coord.longitude();
+ const qreal lastLng = lastCoord.longitude();
+
+ // is the dateline crossed = different sign AND gap is large enough
+ const bool crossesDateline = lastLng * lng < 0 && abs(lastLng - lng) > 180;
+
+ // calculate base point
+ QPointF point = mapData->q_ptr->coordinateToWorldPixel(coord);
+
+ // if the dateline is crossed, draw "around" the map over the chosen pole
+ if (crossesDateline) {
+ // is the shortest route east = dateline crossed XOR longitude is east by simple comparison
+ const bool goesEast = crossesDateline != (lng > lastLng);
+ // direction = positive if east, negative otherwise
+ const qreal dir = goesEast ? 1 : -1;
+
+ // lastPoint on this side
+ const QPointF & L = lastPoint;
+
+ // point on the other side
+ const QPointF & P = point;
+
+ // lastPoint on the other side
+ QPointF L_ = L - QPointF(width * dir, 0);
+
+ // point on this side
+ QPointF P_ = P + QPointF(width * dir, 0);
+
+ // TODO: make a better algorithm to make sure the off-screen points P' and L' are far enough from the dateline so the lines to the poles don't flicker through.
+ // this works for now :)
+ L_ += (L_ - P) * 7;
+ P_ += (P_ - L) * 7;
+
+ // pole point on this side
+ QPointF O1 = QPointF(P_.x(), ypole);
+ // pole point on the other side
+ QPointF O2 = QPointF(L_.x(), ypole);
+
+ //points.append(L); // implicit
+ points.append(P_); // P'
+ points.append(O1);
+ points.append(O2);
+ points.append(L_); // L'
+ points.append(P);
+ } else {
+ // add point to polygon
+ points.append(point);
+ }
+
+ lastCoord = coord;
+ lastPoint = point;
+ }
+}
+
+QTM_END_NAMESPACE
+
+#endif //MAKEPOLY_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp
new file mode 100644
index 00000000..109b91be
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapcircleobjectinfo_p.h"
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomapcircleobject.h"
+
+#include <QGraphicsItem>
+#include <QGraphicsEllipseItem>
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapCircleObjectInfo::QGeoTiledMapCircleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ circle = static_cast<QGeoMapCircleObject*>(mapObject);
+
+ connect(circle,
+ SIGNAL(radiusChanged(qreal)),
+ this,
+ SLOT(radiusChanged(qreal)));
+ connect(circle,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+ connect(circle,
+ SIGNAL(brushChanged(QBrush)),
+ this,
+ SLOT(brushChanged(QBrush)));
+
+ ellipseItem = new QGraphicsEllipseItem;
+ ellipseItem->setPos(0, 0);
+
+ graphicsItem = ellipseItem;
+
+ radiusChanged(circle->radius());
+ brushChanged(circle->brush());
+ penChanged(circle->pen());
+}
+
+QGeoTiledMapCircleObjectInfo::~QGeoTiledMapCircleObjectInfo() {}
+
+void QGeoTiledMapCircleObjectInfo::radiusChanged(qreal /*radius*/)
+{
+ qreal radius = circle->radius();
+ ellipseItem->setRect(-1*radius, -1*radius, 2*radius, 2*radius);
+ updateItem();
+}
+
+void QGeoTiledMapCircleObjectInfo::penChanged(const QPen &pen)
+{
+ ellipseItem->setPen(pen);
+ updateItem();
+}
+
+void QGeoTiledMapCircleObjectInfo::brushChanged(const QBrush &brush)
+{
+ ellipseItem->setBrush(brush);
+ updateItem();
+}
+
+#include "moc_qgeotiledmapcircleobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h
new file mode 100644
index 00000000..c4158026
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
+#define QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include <QPolygonF>
+#include <QPen>
+#include <QBrush>
+
+class QGraphicsEllipseItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapCircleObject;
+
+class QGeoTiledMapCircleObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapCircleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapCircleObjectInfo();
+
+ QGeoMapCircleObject* circle;
+ QGraphicsEllipseItem *ellipseItem;
+
+public slots:
+ void radiusChanged(qreal radius);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp
new file mode 100644
index 00000000..e36c17f4
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapcustomobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomapcustomobject.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapCustomObjectInfo::QGeoTiledMapCustomObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ custom = static_cast<QGeoMapCustomObject*>(mapObject);
+
+ connect(custom,
+ SIGNAL(triggerUpdate()),
+ this,
+ SLOT(updateTriggered()));
+ connect(custom,
+ SIGNAL(graphicsItemChanged(QGraphicsItem*)),
+ this,
+ SLOT(graphicsItemChanged(QGraphicsItem*)));
+ connect(custom,
+ SIGNAL(offsetChanged(QPoint)),
+ this,
+ SLOT(offsetChanged(QPoint)));
+
+ graphicsItem = 0;
+
+ graphicsItemChanged(this->custom->graphicsItem());
+ offsetChanged(this->custom->offset());
+}
+
+QGeoTiledMapCustomObjectInfo::~QGeoTiledMapCustomObjectInfo()
+{
+ //custom->setGraphicsItem(0);
+}
+
+void QGeoTiledMapCustomObjectInfo::updateTriggered()
+{
+ updateItem();
+}
+
+void QGeoTiledMapCustomObjectInfo::graphicsItemChanged(QGraphicsItem * /*graphicsItem*/)
+{
+ graphicsItem = this->custom->graphicsItem();
+ updateItem();
+}
+
+void QGeoTiledMapCustomObjectInfo::offsetChanged(const QPoint &/*offset*/)
+{
+ graphicsItem->setPos(custom->offset());
+ updateItem();
+}
+
+#include "moc_qgeotiledmapcustomobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h
new file mode 100644
index 00000000..cfb8fd1f
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
+#define QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeoboundingbox.h"
+
+#include <QPixmap>
+
+class QGraphicsPixmapItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapCustomObject;
+
+class QGeoTiledMapCustomObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapCustomObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapCustomObjectInfo();
+
+ QGeoMapCustomObject* custom;
+
+public slots:
+ void updateTriggered();
+ void graphicsItemChanged(QGraphicsItem *graphicsItem);
+ void offsetChanged(const QPoint &offset);
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmapdata.cpp b/src/location/maps/tiled/qgeotiledmapdata.cpp
new file mode 100644
index 00000000..bbae6c71
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapdata.cpp
@@ -0,0 +1,1428 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeotiledmappingmanagerengine.h"
+#include "qgeotiledmappingmanagerengine_p.h"
+#include "qgeotiledmaprequest.h"
+#include "qgeocoordinate.h"
+#include "qgeoboundingbox.h"
+#include "qgeomapoverlay.h"
+#include "projwrapper_p.h"
+#include "qgeomapobjectengine_p.h"
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeotiledmapcircleobjectinfo_p.h"
+#include "qgeotiledmapgroupobjectinfo_p.h"
+#include "qgeotiledmappixmapobjectinfo_p.h"
+#include "qgeotiledmappolygonobjectinfo_p.h"
+#include "qgeotiledmappolylineobjectinfo_p.h"
+#include "qgeotiledmaprectangleobjectinfo_p.h"
+#include "qgeotiledmaprouteobjectinfo_p.h"
+#include "qgeotiledmaptextobjectinfo_p.h"
+#include "qgeotiledmapcustomobjectinfo_p.h"
+
+#include "qgeomaptextobject.h"
+
+#include <QTimer>
+#include <QImage>
+#include <QGraphicsScene>
+
+#include <QDebug>
+
+//#define DEFAULT_ZOOMLEVEL 8
+#define PI 3.14159265
+//#define HIT_DETECTION_COLOR qRgba(0, 0, 255, 127) //semi-transparent blue
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#include <math.h>
+
+uint qHash(const QRectF& key)
+{
+ uint result = qHash(qRound(key.x()));
+ result += qHash(qRound(key.y()));
+ result += qHash(qRound(key.width()));
+ result += qHash(qRound(key.height()));
+ return result;
+}
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoTiledMapData
+ \brief The QGeoTiledMapData class is a subclass of QGeoMapData provided
+ to make working with tile based mapping services more convenient.
+
+ \inmodule QtLocation
+
+ \ingroup maps-impl-tiled
+
+ \since 1.2
+
+ This class assumes that at a zoom level of z the world is represented as a
+ 2^z by 2^z grid of tiles, and that the Mercator projection is used to map
+ back and forth between coordinate and positions on the map.
+
+ Different projections can be provided by reimplementing
+ coordinateToWorldReferencePosition() and worldReferencePositionToCoordinate().
+
+ Many of the internal calculations deal with positions as though they are
+ pixel positions on the map at the maximum zoom level. Several functions are
+ provided which expose information about the map and the viewport onto the
+ map in these terms for use with custom QGeoMapObjectInfo subclasses.
+
+ These functions include worldReferenceViewportCenter(), worldReferenceSize() and
+ worldReferenceViewportRect().
+
+ NOTE: QGeoTiledMapData blocks property change signals from QGeoMapData by calling
+ QGeoMapData::setBlockPropertyChangeSignals() with true. Changing this in
+ QGeoTiledMapData subclasses will cause the signals being emitted at wrong time.
+*/
+
+/*!
+ Constructs a new tiled map data object, which makes use of the functionality provided by \a engine.
+*/
+QGeoTiledMapData::QGeoTiledMapData(QGeoMappingManagerEngine *engine)
+ : QGeoMapData(new QGeoTiledMapDataPrivate(this, engine))
+{
+ Q_D(QGeoTiledMapData);
+
+ QGeoTiledMappingManagerEngine *tileEngine = static_cast<QGeoTiledMappingManagerEngine *>(d->engine);
+
+ setBlockPropertyChangeSignals(true);
+
+ setZoomLevel(8.0);
+
+ d->worldReferenceSize = (1 << qRound(tileEngine->maximumZoomLevel())) * tileEngine->tileSize();
+
+ // TODO get this from the engine, which should give different values depending on if this is running on a device or not
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ d->cache.setMaxCost(5 * 1024 * 1024);
+ d->zoomCache.setMaxCost(5 * 1024 * 1024);
+#else
+ d->cache.setMaxCost(10 * 1024 * 1024);
+ d->zoomCache.setMaxCost(10 * 1024 * 1024);
+#endif
+}
+
+/*!
+ Destroys this tiled map data object.
+*/
+QGeoTiledMapData::~QGeoTiledMapData()
+{
+}
+
+
+QPointF QGeoTiledMapDataPrivate::coordinateToScreenPosition(double lon, double lat) const
+{
+ QPointF offset = windowOffset();
+
+ QPoint pos(coordinateToWorldReferencePosition(lon, lat));
+
+ const int x = pos.x() - worldReferenceViewportRect.left();
+// if (x < 0)
+// x += worldReferenceSize.width();
+
+ const int y = pos.y() - worldReferenceViewportRect.top();
+
+ QPointF posF(offset.x() + qreal(x) / zoomFactor, offset.y() + qreal(y) / zoomFactor);
+
+ return posF;
+}
+
+/*!
+ \reimp
+*/
+QPointF QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordwgs) const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->coordinateToScreenPosition(coordwgs.longitude(), coordwgs.latitude());
+}
+
+/*!
+ \reimp
+*/
+QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QPointF &screenPosition) const
+{
+ Q_D(const QGeoTiledMapData);
+
+ QPoint worldRef = d->screenPositionToWorldReferencePosition(screenPosition);
+
+ if (worldRef.isNull())
+ return QGeoCoordinate();
+
+ const QGeoCoordinate insph = worldReferencePositionToCoordinate(worldRef);
+
+ //ProjCoordinate c(insph.longitude(), insph.latitude(), 0.0, d->spherical);
+ //c.convert(d->wgs84);
+ return insph;
+}
+
+// this belongs to QGeoTiledMapDataPrivate in order to avoid
+// breaking B.C.
+QPoint QGeoTiledMapDataPrivate::screenPositionToWorldReferencePosition(const QPointF &screenPosition) const
+{
+ QPointF offset = windowOffset();
+
+ QPointF pos(screenPosition.x() - offset.x(), screenPosition.y() - offset.y());
+
+ const int worldX = int(worldReferenceViewportRect.left() + pos.x() * zoomFactor + 0.5) % worldReferenceSize.width();
+ const int worldY = int(worldReferenceViewportRect.top() + pos.y() * zoomFactor + 0.5) % worldReferenceSize.height();
+
+ return QPoint(worldX, worldY);
+}
+
+QPoint QGeoTiledMapDataPrivate::coordinateToWorldReferencePosition(double lng, double lat) const
+{
+ lng = lng / 360.0 + 0.5;
+
+ lat = 0.5 - (log(tan((PI / 4.0) + (PI / 2.0) * lat / 180.0)) / PI) / 2.0;
+ lat = qMax(0.0, lat);
+ lat = qMin(1.0, lat);
+
+ const double x = lng * worldReferenceSize.width();
+ const double y = lat * worldReferenceSize.height();
+
+ const QPoint r(int(x > 0 ? x + 0.5 : x - 0.5),
+ int(y > 0 ? y + 0.5 : y - 0.5));
+ return r;
+}
+
+/*!
+ Converts the coordinate \a coordinate to a pixel position on the entire
+ map at the maximum zoom level.
+
+ The default implementation is based on the Mercator projection.
+*/
+QPoint QGeoTiledMapData::coordinateToWorldReferencePosition(const QGeoCoordinate &coordinate) const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->coordinateToWorldReferencePosition(coordinate.longitude(),
+ coordinate.latitude());
+}
+
+qreal rmod(const qreal a, const qreal b)
+{
+ quint64 div = static_cast<quint64>(a / b);
+ return a - static_cast<qreal>(div) * b;
+}
+
+/*!
+ Converts the pixel position \a pixel on the map to a coordinate.
+
+ The pixel position is relative the entire map at the maximum zoom level.
+
+ The default implementation is based on the Mercator projection.
+*/
+QGeoCoordinate QGeoTiledMapData::worldReferencePositionToCoordinate(const QPoint &pixel) const
+{
+ Q_D(const QGeoTiledMapData);
+
+ qreal fx = qreal(pixel.x()) / d->worldReferenceSize.width();
+ qreal fy = qreal(pixel.y()) / d->worldReferenceSize.height();
+
+ if (fy < 0.0f)
+ fy = 0.0f;
+ else if (fy > 1.0f)
+ fy = 1.0f;
+
+ qreal lat;
+
+ if (fy == 0.0f)
+ lat = 90.0f;
+ else if (fy == 1.0f)
+ lat = -90.0f;
+ else
+ lat = (180.0f / PI) * (2.0f * atan(exp(PI * (1.0f - 2.0f * fy))) - (PI / 2.0f));
+
+ qreal lng;
+ if (fx >= 0) {
+ lng = rmod(fx, 1.0f);
+ } else {
+ lng = rmod(1.0f - rmod(-1.0f * fx, 1.0f), 1.0f);
+ }
+
+ lng = lng * 360.0f - 180.0f;
+
+ return QGeoCoordinate(lat, lng, 0.0);
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::setCenter(const QGeoCoordinate &center)
+{
+ Q_D(QGeoTiledMapData);
+
+ bool changed = (d->center != center);
+
+ if (!changed)
+ return;
+
+ d->worldReferenceViewportCenter = coordinateToWorldReferencePosition(center);
+ d->updateScreenRect();
+ emit updateMapDisplay();
+
+ emit centerChanged(center);
+
+ d->updateMapImage();
+
+ QGeoMapData::setCenter(center);
+ d->oe->invalidatePixelsForViewport();
+ d->oe->trimPixelTransforms();
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::setMapType(QGraphicsGeoMap::MapType mapType)
+{
+ Q_D(QGeoTiledMapData);
+
+ bool changed = (d->mapType != mapType);
+
+ if (!changed)
+ return;
+
+ QGeoMapData::setMapType(mapType);
+
+ d->clearRequests();
+ d->cache.clear();
+ d->zoomCache.clear();
+ emit updateMapDisplay();
+
+ emit mapTypeChanged(d->mapType);
+
+ d->updateMapImage();
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
+{
+ QGraphicsGeoMap::ConnectivityMode oldMode = QGeoMapData::connectivityMode();
+
+ if (oldMode == connectivityMode)
+ return;
+
+ QGeoMapData::setConnectivityMode(connectivityMode);
+
+ if (oldMode == QGeoMapData::connectivityMode())
+ return;
+
+ emit connectivityModeChanged(connectivityMode);
+}
+
+/*!
+ \reimp
+*/
+QGeoCoordinate QGeoTiledMapData::center() const
+{
+ Q_D(const QGeoTiledMapData);
+ return worldReferencePositionToCoordinate(d->worldReferenceViewportCenter);
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::setZoomLevel(qreal zoomLevelf)
+{
+ Q_D(QGeoTiledMapData);
+
+ QPixmap oldImage(windowSize().toSize());
+ if (!oldImage.isNull()) {
+ // grab the old image
+ QPainter painter1(&oldImage);
+ d->paintMap(&painter1, 0);
+ painter1.end();
+ }
+
+ qreal oldZoomLevel = d->zoomLevel;
+ int zoomLevel = qRound(zoomLevelf);
+
+ QGeoMapData::setZoomLevel(zoomLevel);
+
+ d->oe->invalidateZoomDependents();
+ d->oe->invalidatePixelsForViewport();
+ d->oe->trimPixelTransforms();
+
+ // QGeoMapData::setZoomLevel clips the zoom level to be
+ // in between the minimum and maximum zoom levels
+ zoomLevel = QGeoMapData::zoomLevel();
+
+ int zoomDiff = qRound(zoomLevel - oldZoomLevel);
+
+ if (zoomDiff == 0)
+ return;
+
+ d->zoomFactor = 1 << qRound(d->engine->maximumZoomLevel() - d->zoomLevel);
+
+ QGeoTiledMappingManagerEngine *tileEngine = static_cast<QGeoTiledMappingManagerEngine *>(d->engine);
+ QSize tileSize = tileEngine->tileSize();
+
+ d->updateScreenRect();
+
+ if (oldImage.isNull()) {
+ d->updateMapImage();
+ emit zoomLevelChanged(d->zoomLevel);
+ return;
+ }
+
+ //scale old image
+ QRectF target = oldImage.rect();
+ qreal width = target.width() / (1 << qAbs(zoomDiff));
+ qreal height = target.height() / (1 << qAbs(zoomDiff));
+ qreal x = target.x() + ((target.width() - width) / 2.0);
+ qreal y = target.y() + ((target.height() - height) / 2.0);
+ QRectF source = QRectF(x, y, width, height);
+
+ QPixmap newImage(oldImage.size());
+ newImage.fill(Qt::lightGray);
+ QPainter painter2(&newImage);
+#if !(defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6))
+ painter2.setRenderHint(QPainter::SmoothPixmapTransform, true);
+#endif
+ if (zoomDiff < 0) {
+ painter2.drawPixmap(source, oldImage, target);
+ } else {
+ painter2.drawPixmap(target, oldImage, source);
+ }
+ painter2.end();
+
+ d->zoomCache.clear();
+
+ QGeoTileIterator it(d);
+
+ QPointF offset = d->windowOffset();
+
+ while (it.hasNext()) {
+ QGeoTiledMapRequest req = it.next();
+ QRect tileRect = req.tileRect();
+
+ if (d->cache.contains(req))
+ continue;
+
+ if (!d->intersectsScreen(tileRect))
+ continue;
+
+ QList<QPair<QRect, QRect> > overlaps = d->intersectedScreen(tileRect);
+ for (int i = 0; i < overlaps.size(); ++i) {
+ QRect s = overlaps.at(i).first;
+ QRect t = overlaps.at(i).second;
+
+ QRectF source = QRectF(offset.x() + int(t.left()) / d->zoomFactor,
+ offset.y() + int(t.top()) / d->zoomFactor,
+ int(t.width()) / d->zoomFactor,
+ int(t.height()) / d->zoomFactor);
+
+ QPixmap *tile = new QPixmap(tileSize);
+ tile->fill(Qt::lightGray); // TODO: this looks useless
+
+ QRectF target = QRectF(int(s.left()) / d->zoomFactor,
+ int(s.top()) / d->zoomFactor,
+ int(s.width()) / d->zoomFactor,
+ int(s.height()) / d->zoomFactor);
+
+ QPainter painter3(tile);
+ painter3.drawPixmap(target, newImage, source);
+ painter3.end();
+
+ d->zoomCache.insert(req, tile, (tile->depth() * tile->width() * tile->height()) / 8);
+ }
+ }
+
+ emit updateMapDisplay();
+
+ d->clearRequests();
+ d->updateMapImage();
+
+ emit zoomLevelChanged(d->zoomLevel);
+
+ // call again
+ QGeoMapData::setZoomLevel(zoomLevel);
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::setWindowSize(const QSizeF &size)
+{
+ Q_D(QGeoTiledMapData);
+
+ bool changed = (d->windowSize != size);
+
+ if (!changed)
+ return;
+
+ QGeoMapData::setWindowSize(size);
+
+ d->oe->invalidatePixelsForViewport();
+ d->oe->trimPixelTransforms();
+
+ d->updateScreenRect();
+
+ emit windowSizeChanged(d->windowSize);
+
+ d->updateMapImage();
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::pan(int dx, int dy)
+{
+ Q_D(QGeoTiledMapData);
+
+ int x = d->worldReferenceViewportCenter.x();
+ int y = d->worldReferenceViewportCenter.y();
+
+ x = (x + dx * d->zoomFactor) % d->worldReferenceSize.width();
+ if (x < 0)
+ x += d->worldReferenceSize.width();
+
+ y = (y + dy * d->zoomFactor);
+ int height = int(d->worldReferenceViewportRect.height() / 2.0);
+ if (y < height)
+ y = height;
+ if (y > d->worldReferenceSize.height() - height)
+ y = d->worldReferenceSize.height() - height;
+
+ d->worldReferenceViewportCenter.setX(x);
+ d->worldReferenceViewportCenter.setY(y);
+
+ QGeoCoordinate centerCoord = center();
+
+ QGeoMapData::setCenter(centerCoord);
+ d->oe->invalidatePixelsForViewport();
+ d->oe->trimPixelTransforms();
+
+ d->updateScreenRect();
+
+ emit centerChanged(centerCoord);
+
+ d->updateMapImage();
+}
+
+/*!
+ \reimp
+*/
+QGeoBoundingBox QGeoTiledMapData::viewport() const
+{
+ Q_D(const QGeoTiledMapData);
+ if (d->worldReferenceViewportRectRight.isValid()) {
+ return QGeoBoundingBox(worldReferencePositionToCoordinate(d->worldReferenceViewportRectLeft.topLeft()),
+ worldReferencePositionToCoordinate(d->worldReferenceViewportRectRight.bottomRight()));
+ } else {
+ return QGeoBoundingBox(worldReferencePositionToCoordinate(d->worldReferenceViewportRect.topLeft()),
+ worldReferencePositionToCoordinate(d->worldReferenceViewportRect.bottomRight()));
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
+{
+ Q_D(QGeoTiledMapData);
+
+ if (!preserveViewportCenter)
+ setCenter(bounds.center());
+
+ int minZoomLevel = engine()->minimumZoomLevel();
+ int maxZoomLevel = engine()->maximumZoomLevel();
+
+ int zoomFactor = 1 << maxZoomLevel;
+
+ for (int i = minZoomLevel; i <= maxZoomLevel; ++i) {
+ QRect rect = d->screenRectForZoomFactor(zoomFactor);
+ QGeoBoundingBox viewport = QGeoBoundingBox(worldReferencePositionToCoordinate(rect.topLeft()),
+ worldReferencePositionToCoordinate(rect.bottomRight()));
+
+// qWarning() << i << zoomFactor
+// << viewport.topLeft()
+// << viewport.bottomRight();
+
+ if (!viewport.contains(bounds)) {
+ setZoomLevel(qMax(minZoomLevel, i - 1));
+ return;
+ }
+
+ zoomFactor /= 2;
+ }
+
+ setZoomLevel(maxZoomLevel);
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ Q_D(QGeoTiledMapData);
+ d->paintMap(painter, option);
+}
+
+/*!
+ \reimp
+*/
+void QGeoTiledMapData::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ Q_D(QGeoTiledMapData);
+ d->paintObjects(painter, option);
+}
+
+/*!
+ \reimp
+*/
+QGeoMapObjectInfo *QGeoTiledMapData::createMapObjectInfo(QGeoMapObject *mapObject)
+{
+ switch (mapObject->type()) {
+ case QGeoMapObject::GroupType:
+ return new QGeoTiledMapGroupObjectInfo(this, mapObject);
+ case QGeoMapObject::RectangleType:
+ return new QGeoTiledMapRectangleObjectInfo(this, mapObject);
+ case QGeoMapObject::CircleType:
+ return new QGeoTiledMapCircleObjectInfo(this, mapObject);
+ case QGeoMapObject::PolylineType:
+ return new QGeoTiledMapPolylineObjectInfo(this, mapObject);
+ case QGeoMapObject::PolygonType:
+ return new QGeoTiledMapPolygonObjectInfo(this, mapObject);
+ case QGeoMapObject::PixmapType:
+ return new QGeoTiledMapPixmapObjectInfo(this, mapObject);
+ case QGeoMapObject::TextType:
+ return new QGeoTiledMapTextObjectInfo(this, mapObject);
+ case QGeoMapObject::RouteType:
+ return new QGeoTiledMapRouteObjectInfo(this, mapObject);
+ case QGeoMapObject::CustomType:
+ return new QGeoTiledMapCustomObjectInfo(this, mapObject);
+ default:
+ return 0;
+ }
+}
+
+void QGeoTiledMapData::processRequests()
+{
+ Q_D(QGeoTiledMapData);
+
+ QMutableSetIterator<QGeoTiledMapReply*> replyIter(d->replies);
+ // Abort off-screen replies
+ while (replyIter.hasNext()) {
+ QGeoTiledMapReply *reply = replyIter.next();
+ if (!d->intersectsScreen(reply->request().tileRect())
+ || (zoomLevel() != reply->request().zoomLevel())
+ || (mapType() != reply->request().mapType())
+ || (connectivityMode() != reply->request().connectivityMode())) {
+ d->replyRects.remove(reply->request().tileRect());
+ d->zoomCache.remove(reply->request());
+ replyIter.remove();
+ reply->abort();
+ }
+ }
+
+ QGeoTiledMappingManagerEngine *tiledEngine
+ = static_cast<QGeoTiledMappingManagerEngine*>(engine());
+
+ QMutableListIterator<QGeoTiledMapRequest> requestIter(d->requests);
+ while (requestIter.hasNext()) {
+ QGeoTiledMapRequest req = requestIter.next();
+
+ d->requestRects.remove(req.tileRect());
+ requestIter.remove();
+
+ // Do not use the requests which have pending replies or are off screen
+ if (d->replyRects.contains(req.tileRect()) || !d->intersectsScreen(req.tileRect())) {
+ continue;
+ }
+
+ QGeoTiledMapReply *reply = tiledEngine->getTileImage(req);
+
+ if (!reply) {
+ continue;
+ }
+
+ if (reply->error() != QGeoTiledMapReply::NoError) {
+ tileError(reply->error(), reply->errorString());
+ reply->deleteLater();
+ d->zoomCache.remove(reply->request());
+ continue;
+ }
+
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(tileFinished()));
+
+ connect(reply,
+ SIGNAL(error(QGeoTiledMapReply::Error, QString)),
+ this,
+ SLOT(tileError(QGeoTiledMapReply::Error, QString)));
+
+ d->replies.insert(reply);
+ d->replyRects.insert(reply->request().tileRect());
+
+ if (reply->isFinished())
+ replyFinished(reply);
+ }
+}
+
+void QGeoTiledMapData::tileFinished()
+{
+ Q_D(QGeoTiledMapData);
+
+ QGeoTiledMapReply *reply = qobject_cast<QGeoTiledMapReply*>(sender());
+
+ if (!reply) {
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+ return;
+ } else {
+ replyFinished(reply);
+ }
+}
+
+void QGeoTiledMapData::replyFinished(QGeoTiledMapReply *reply)
+{
+ Q_D(QGeoTiledMapData);
+
+ d->replyRects.remove(reply->request().tileRect());
+ d->replies.remove(reply);
+ d->zoomCache.remove(reply->request());
+
+ if (reply->error() != QGeoTiledMapReply::NoError) {
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+ reply->deleteLater();
+ return;
+ }
+
+ if ((zoomLevel() != reply->request().zoomLevel())
+ || (mapType() != reply->request().mapType())
+ || (connectivityMode() != reply->request().connectivityMode())) {
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+ reply->deleteLater();
+ return;
+ }
+
+ //QPixmap *tile = new QPixmap();
+ QImage *tile = new QImage();
+
+ if (!tile->loadFromData(reply->mapImageData(), reply->mapImageFormat().toAscii())) {
+ delete tile;
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+ reply->deleteLater();
+ return;
+ //setError(QGeoTiledMapReply::ParseError, "The response from the service was not in a recognisable format.");
+ }
+
+ if (tile->isNull() || tile->size().isEmpty()) {
+ delete tile;
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+ reply->deleteLater();
+ return;
+ //setError(QGeoTiledMapReply::ParseError, "The map image is empty.");
+ }
+
+ d->cache.insert(reply->request(), tile, (tile->depth() * tile->width() * tile->height()) / 8);
+
+ d->cleanupCaches();
+
+ QRect tileRect = reply->request().tileRect();
+
+ QPointF offset = d->windowOffset();
+
+ QList<QPair<QRect, QRect> > overlaps = d->intersectedScreen(tileRect);
+ for (int i = 0; i < overlaps.size(); ++i) {
+ QRect t = overlaps.at(i).second;
+ QRectF target = QRectF(offset.x() + int(t.left()) / d->zoomFactor,
+ offset.y() + int(t.top()) / d->zoomFactor,
+ int(t.width()) / d->zoomFactor,
+ int(t.height()) / d->zoomFactor);
+
+ emit updateMapDisplay(target);
+ }
+
+ if (d->requests.size() > 0)
+ QTimer::singleShot(0, this, SLOT(processRequests()));
+
+ reply->deleteLater();
+}
+
+void QGeoTiledMapData::tileError(QGeoTiledMapReply::Error error, QString errorString)
+{
+ Q_UNUSED(error)
+ qWarning() << errorString;
+}
+
+/*!
+ \reimp
+*/
+QList<QGeoMapObject*> QGeoTiledMapData::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
+{
+ if (screenPosition.isNull())
+ return QList<QGeoMapObject*>();
+
+ Q_D(const QGeoTiledMapData);
+
+ QList<QGeoMapObject*> results;
+ QSet<QGeoMapObject*> considered;
+
+ d->oe->updateTransforms();
+
+ QList<QGraphicsItem*> pixelItems;
+ pixelItems = d->oe->pixelScene->items(QRectF(screenPosition - QPointF(1,1),
+ screenPosition + QPointF(1,1)),
+ Qt::IntersectsItemShape,
+ Qt::AscendingOrder);
+
+ foreach (QGraphicsItem *item, pixelItems) {
+ QGeoMapObject *object = d->oe->pixelItems.value(item);
+ Q_ASSERT(object);
+
+ if (object->isVisible() && !considered.contains(object)) {
+ bool contains = false;
+
+ if (d->oe->pixelExact.contains(object)) {
+ foreach (QGraphicsItem *item, d->oe->pixelExact.values(object)) {
+ if (item->shape().contains(screenPosition)) {
+ contains = true;
+ break;
+ }
+ }
+ } else {
+ QGraphicsItem *item
+ = d->oe->graphicsItemFromMapObject(object);
+
+ if (item) {
+ QList<QTransform> trans = d->oe->pixelTrans.values(object);
+
+ foreach (QTransform t, trans) {
+ bool ok;
+ QTransform inv = t.inverted(&ok);
+ if (ok) {
+ QPointF testPt = screenPosition * inv;
+
+ // we have to special case text objects here
+ // in order to maintain their old (1.1) behaviour
+ QGeoMapTextObject *tobj = qobject_cast<QGeoMapTextObject*>(object);
+ if (tobj) {
+ if (item->boundingRect().contains(testPt)) {
+ contains = true;
+ break;
+ }
+ } else {
+ if (item->shape().contains(testPt)) {
+ contains = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (contains)
+ results << object;
+
+ considered.insert(object);
+ }
+ }
+
+ return results;
+}
+
+/*!
+ \reimp
+*/
+QList<QGeoMapObject*> QGeoTiledMapData::mapObjectsInScreenRect(const QRectF &screenRect) const
+{
+ QList<QGeoMapObject*> results;
+ QSet<QGeoMapObject*> considered;
+
+ Q_D(const QGeoTiledMapData);
+
+ d->oe->updateTransforms();
+
+ QList<QGraphicsItem*> pixelItems = d->oe->pixelScene->items(screenRect,
+ Qt::IntersectsItemShape,
+ Qt::AscendingOrder);
+
+ foreach (QGraphicsItem *item, pixelItems) {
+ QGeoMapObject *object = d->oe->pixelItems.value(item);
+ Q_ASSERT(object);
+
+ if (object->isVisible() && !considered.contains(object)) {
+ bool contains = false;
+
+ if (d->oe->pixelExact.contains(object)) {
+ foreach (QGraphicsItem *item, d->oe->pixelExact.values(object))
+ if (item->shape().intersects(screenRect))
+ contains = true;
+ } else {
+ QGraphicsItem *item
+ = d->oe->graphicsItemFromMapObject(object);
+
+ if (item) {
+ QList<QTransform> trans = d->oe->pixelTrans.values(object);
+
+ foreach (QTransform t, trans) {
+ bool ok;
+ QTransform inv = t.inverted(&ok);
+ if (ok) {
+ QPolygonF testPoly = screenRect * inv;
+
+ QPainterPath testPath;
+ testPath.moveTo(testPoly[0]);
+ testPath.lineTo(testPoly[1]);
+ testPath.lineTo(testPoly[2]);
+ testPath.lineTo(testPoly[3]);
+ testPath.closeSubpath();
+
+ if (item->shape().intersects(testPath))
+ contains = true;
+ }
+ }
+ }
+ }
+
+ if (contains)
+ results << object;
+
+ considered.insert(object);
+ }
+ }
+
+ return results;
+}
+
+/*!
+ Returns the center of the viewport, in pixels on the entire
+ map as a pixmap at the maximum zoom level.
+*/
+QPoint QGeoTiledMapData::worldReferenceViewportCenter() const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->worldReferenceViewportCenter;
+}
+
+/*!
+ Returns the size, in pixels, of the entire map as a pixmap at the maximum
+ zoom level.
+*/
+QSize QGeoTiledMapData::worldReferenceSize() const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->worldReferenceSize;
+}
+
+/*!
+ Returns the visible screen rectangle, in pixels on the entire map
+ as a pixmap at the maximum zoom level.
+*/
+QRect QGeoTiledMapData::worldReferenceViewportRect() const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->worldReferenceViewportRect;
+}
+
+/*!
+ Returns the ratio between a single pixel on the screen and a pixel on
+ the entire map as a pixmap at the maximum zoom level.
+*/
+int QGeoTiledMapData::zoomFactor() const
+{
+ Q_D(const QGeoTiledMapData);
+ return d->zoomFactor;
+}
+
+/*!
+ Forces the map display to update in the region specified by \a target.
+
+ If \a target is empty the entire map display will be updated.
+*/
+void QGeoTiledMapData::triggerUpdateMapDisplay(const QRectF &target)
+{
+ emit updateMapDisplay(target);
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoTiledMapDataPrivate::QGeoTiledMapDataPrivate(QGeoTiledMapData *parent, QGeoMappingManagerEngine *engine)
+ : QGeoMapDataPrivate(parent, engine),
+ oe(new QGeoMapObjectEngine(parent, this)),
+ zoomFactor(0),
+ spherical("+proj=latlon +ellps=sphere"),
+ wgs84("+proj=latlon +ellps=WGS84") {}
+
+QGeoTiledMapDataPrivate::~QGeoTiledMapDataPrivate()
+{
+ foreach(QGeoTiledMapReply * reply, replies) {
+ reply->abort();
+ reply->deleteLater();
+ }
+
+ if (oe)
+ delete oe;
+}
+
+QPointF QGeoTiledMapDataPrivate::windowOffset() const
+{
+ qreal offsetX = ((windowSize.width() * zoomFactor) - worldReferenceViewportRect.width()) / 2.0;
+ if (offsetX < 0.0)
+ offsetX = 0.0;
+ offsetX /= zoomFactor;
+
+ qreal offsetY = ((windowSize.height() * zoomFactor) - worldReferenceViewportRect.height()) / 2.0;
+ if (offsetY < 0.0)
+ offsetY = 0.0;
+ offsetY /= zoomFactor;
+
+ return QPointF(offsetX, offsetY);
+}
+
+void QGeoTiledMapDataPrivate::updateMapImage()
+{
+ Q_Q(QGeoTiledMapData);
+
+ if ((zoomLevel == -1.0) || !windowSize.isValid())
+ return;
+
+ bool wasEmpty = (requests.size() == 0);
+ QGeoTileIterator it(this);
+
+ while (it.hasNext()) {
+ QGeoTiledMapRequest req = it.next();
+ QRect tileRect = req.tileRect();
+
+ if (!cache.contains(req)) {
+ if (!requestRects.contains(tileRect) && !replyRects.contains(tileRect)) {
+ requests.append(req);
+ requestRects.insert(tileRect);
+ }
+ }
+ }
+
+// qWarning()
+// << d->requests.size()
+// << d->cache.size()
+// << d->cache.totalCost()
+// << d->zoomCache.size()
+// << d->zoomCache.totalCost();
+
+ if (wasEmpty && requests.size() > 0) {
+ QTimer::singleShot(0, q, SLOT(processRequests()));
+ }
+}
+
+void QGeoTiledMapDataPrivate::clearRequests()
+{
+ requests.clear();
+ requestRects.clear();
+}
+
+void QGeoTiledMapDataPrivate::paintMap(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/)
+{
+ QPointF offset = windowOffset();
+
+ QGeoTileIterator it(this);
+
+ while (it.hasNext()) {
+ QGeoTiledMapRequest req = it.next();
+ QRect tileRect = req.tileRect();
+
+ QList<QPair<QRect, QRect> > overlaps = intersectedScreen(tileRect);
+ for (int i = 0; i < overlaps.size(); ++i) {
+ QRect s = overlaps.at(i).first;
+ QRect t = overlaps.at(i).second;
+
+ QRectF source = QRectF(int(s.left()) / zoomFactor,
+ int(s.top()) / zoomFactor,
+ int(s.width()) / zoomFactor,
+ int(s.height()) / zoomFactor);
+ QRectF target = QRectF(offset.x() + int(t.left()) / zoomFactor,
+ offset.y() + int(t.top()) / zoomFactor,
+ int(t.width()) / zoomFactor,
+ int(t.height()) / zoomFactor);
+
+ if (cache.contains(req)) {
+ //painter->drawPixmap(target, *cache.object(req), source);
+ painter->drawImage(target, *cache.object(req), source);
+ } else {
+ if (zoomCache.contains(req)) {
+ painter->drawPixmap(target, *zoomCache.object(req), source);
+ } else {
+ painter->fillRect(target, Qt::lightGray);
+ }
+ }
+ }
+ }
+}
+
+void QGeoTiledMapDataPrivate::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem * option)
+{
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+
+ QRectF target = option ? option->rect : QRectF(QPointF(0,0), windowSize);
+
+ QPointF offset = windowOffset();
+
+ target.adjust(offset.x(), offset.y(), -1.0 * offset.x(), -1.0 * offset.y());
+
+ painter->setClipRect(target);
+
+ oe->updateTransforms();
+
+ QList<QGraphicsItem*> items = oe->pixelScene->items(target,
+ Qt::IntersectsItemShape,
+ Qt::AscendingOrder);
+ QSet<QGeoMapObject*> objsDone;
+
+ QTransform baseTrans = painter->transform();
+
+ QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
+
+ foreach (QGraphicsItem *item, items) {
+ QGeoMapObject *object = oe->pixelItems.value(item);
+ Q_ASSERT(object);
+ if (object->isVisible() && !objsDone.contains(object)) {
+ if (oe->pixelExact.contains(object)) {
+ foreach (QGraphicsItem *it, oe->pixelExact.values(object)) {
+ painter->setTransform(baseTrans);
+
+// QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
+ it->paint(painter, style);
+// delete style;
+ }
+ } else {
+ QGraphicsItem *item = oe->graphicsItemFromMapObject(object);
+ if (item) {
+ foreach (QTransform trans, oe->pixelTrans.values(object)) {
+ painter->setTransform(trans * baseTrans);
+
+// QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
+ item->paint(painter, style);
+ foreach (QGraphicsItem *child, item->children()) {
+ painter->setTransform(child->transform() * trans * baseTrans);
+ painter->translate(child->pos());
+ child->paint(painter, style);
+ }
+
+// delete style;
+ }
+ }
+ }
+ objsDone.insert(object);
+ }
+ }
+
+ painter->restore();
+
+ delete style;
+}
+
+void QGeoTiledMapDataPrivate::cleanupCaches()
+{
+ int boundaryTiles = 3;
+
+ QGeoTiledMappingManagerEngine *tiledEngine = static_cast<QGeoTiledMappingManagerEngine*>(engine);
+
+ QSize tileSize = tiledEngine->tileSize();
+
+ QRectF cacheRect1;
+ QRectF cacheRect2;
+
+ cacheRect1 = worldReferenceViewportRect.adjusted(-boundaryTiles * tileSize.width(),
+ -boundaryTiles * tileSize.height(),
+ boundaryTiles * tileSize.width(),
+ boundaryTiles * tileSize.height());
+
+ if (cacheRect1.width() > worldReferenceSize.width()) {
+ cacheRect1.setX(0);
+ cacheRect1.setWidth(worldReferenceSize.width());
+ } else {
+ if (cacheRect1.x() + cacheRect1.width() > worldReferenceSize.width()) {
+ int oldWidth = cacheRect1.width();
+ cacheRect1.setWidth(worldReferenceSize.width() - cacheRect1.x());
+ cacheRect2 = QRectF(0,
+ cacheRect1.y(),
+ oldWidth - cacheRect1.width(),
+ cacheRect1.height());
+ }
+ }
+
+ QList<QGeoTiledMapRequest> keys = cache.keys();
+ for (int i = 0; i < keys.size(); ++i) {
+ QRectF tileRect = keys.at(i).tileRect();
+ if (!cacheRect1.intersects(tileRect)) {
+ if (cacheRect2.isNull() || !cacheRect2.intersects(tileRect)) {
+ cache.remove(keys.at(i));
+ }
+ }
+ }
+}
+
+QRect QGeoTiledMapDataPrivate::screenRectForZoomFactor(int factor)
+{
+ qreal viewportWidth = q_ptr->windowSize().width();
+ qreal viewportHeight = q_ptr->windowSize().height();
+
+ int width = int(viewportWidth * factor);
+ int height = int(viewportHeight * factor);
+
+ if (width > worldReferenceSize.width())
+ width = worldReferenceSize.width();
+
+ if (height > worldReferenceSize.height())
+ height = worldReferenceSize.height();
+
+ int x = (worldReferenceViewportCenter.x() - (width / 2)) % worldReferenceSize.width();
+ if (x < 0)
+ x += worldReferenceSize.width();
+
+ int y = worldReferenceViewportCenter.y() - (height / 2);
+
+ if (y < 0)
+ y = 0;
+
+ if ((y + height) >= worldReferenceSize.height())
+ y = worldReferenceSize.height() - height;
+
+ return QRect(x, y, width, height);
+}
+
+void QGeoTiledMapDataPrivate::updateScreenRect()
+{
+ worldReferenceViewportRect = screenRectForZoomFactor(zoomFactor);
+
+ int x = worldReferenceViewportRect.x();
+ int y = worldReferenceViewportRect.y();
+ int width = worldReferenceViewportRect.width();
+ int height = worldReferenceViewportRect.height();
+
+ if (x + width < worldReferenceSize.width()) {
+ worldReferenceViewportRectLeft = worldReferenceViewportRect;
+ worldReferenceViewportRectRight = QRect();
+ } else {
+ int widthLeft = worldReferenceSize.width() - x;
+ int widthRight = width - widthLeft;
+ worldReferenceViewportRectLeft = QRect(x, y, widthLeft, height);
+ worldReferenceViewportRectRight = QRect(0, y, widthRight, height);
+ }
+}
+
+bool QGeoTiledMapDataPrivate::containedInScreen(const QPoint &point) const
+{
+ return (worldReferenceViewportRectLeft.contains(point)
+ || (worldReferenceViewportRectRight.isValid()
+ && worldReferenceViewportRectRight.contains(point)));
+}
+
+bool QGeoTiledMapDataPrivate::intersectsScreen(const QRect &rect) const
+{
+ return (worldReferenceViewportRectLeft.intersects(rect)
+ || (worldReferenceViewportRectRight.isValid()
+ && worldReferenceViewportRectRight.intersects(rect)));
+}
+
+QList<QPair<QRect, QRect> > QGeoTiledMapDataPrivate::intersectedScreen(const QRect &rect, bool translateToScreen) const
+{
+ QList<QPair<QRect, QRect> > result;
+
+ QRect rectL = rect.intersected(worldReferenceViewportRectLeft);
+ if (!rectL.isEmpty()) {
+ QRect source = QRect(rectL.topLeft() - rect.topLeft(), rectL.size());
+ QRect target = QRect(rectL.topLeft() - worldReferenceViewportRectLeft.topLeft(), rectL.size());
+ result << QPair<QRect, QRect>(source, target);
+ }
+
+ if (worldReferenceViewportRectRight.isValid()) {
+ QRect rectR = rect.intersected(worldReferenceViewportRectRight);
+ if (!rectR.isEmpty()) {
+ QRect source = QRect(rectR.topLeft() - rect.topLeft(), rectR.size());
+ QRect target = QRect(rectR.topLeft() - worldReferenceViewportRectRight.topLeft(), rectR.size());
+ if (translateToScreen)
+ target.translate(worldReferenceViewportRectLeft.width(), 0);
+ result << QPair<QRect, QRect>(source, target);
+ }
+ }
+
+ return result;
+}
+
+// Old version, for reference
+
+//void QGeoMapDataPrivate::addObject(QGeoMapObject *object)
+//{
+// containerObject->addChildObject(object);
+// oe->addObject(object);
+// emit q_ptr->updateMapDisplay();
+//}
+
+//void QGeoMapDataPrivate::removeObject(QGeoMapObject *object)
+//{
+// containerObject->removeChildObject(object);
+// oe->removeObject(object);
+//}
+
+void QGeoTiledMapDataPrivate::addObject(QGeoMapObject *object)
+{
+// containerObject->addChildObject(object);
+// oe->addObject(object);
+// emit q_ptr->updateMapDisplay();
+
+ QGeoMapDataPrivate::addObject(object);
+ oe->addObject(object);
+}
+
+void QGeoTiledMapDataPrivate::removeObject(QGeoMapObject *object)
+{
+ QGeoMapDataPrivate::removeObject(object);
+ oe->removeObject(object);
+}
+
+void QGeoTiledMapDataPrivate::update(QObject *object)
+{
+ QGeoMapObject *obj = qobject_cast<QGeoMapObject*>(object);
+ if (obj) {
+ QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
+ if (group) {
+ oe->objectsForLatLonUpdate << group;
+ oe->objectsForPixelUpdate << group;
+ static_cast<QGeoTiledMapData*>(q_ptr)->triggerUpdateMapDisplay();
+ } else {
+ oe->invalidateObject(obj);
+ }
+ } else {
+ static_cast<QGeoTiledMapData*>(q_ptr)->triggerUpdateMapDisplay();
+ }
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoTileIterator::QGeoTileIterator(const QGeoTiledMapDataPrivate *mapDataPrivate)
+ : atEnd(false),
+ row(-1),
+ col(-1),
+ screenRect(mapDataPrivate->worldReferenceViewportRect),
+ mapType(mapDataPrivate->mapType),
+ connectivityMode(mapDataPrivate->connectivityMode),
+ zoomLevel(mapDataPrivate->zoomLevel)
+{
+ QGeoTiledMappingManagerEngine *tiledEngine
+ = static_cast<QGeoTiledMappingManagerEngine*>(mapDataPrivate->engine);
+ tileSize = tiledEngine->tileSize() * mapDataPrivate->zoomFactor;
+ tileRect = QRect(QPoint(0, 0), tileSize);
+
+ qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
+ qulonglong y = static_cast<qulonglong>(screenRect.topLeft().y() / tileSize.height());
+
+ width = tileSize.width() * (1 << zoomLevel);
+
+ currTopLeft.setX(x * tileSize.width());
+ currTopLeft.setY(y * tileSize.height());
+}
+
+QGeoTileIterator::QGeoTileIterator(QGraphicsGeoMap::ConnectivityMode connectivityMode,
+ QGraphicsGeoMap::MapType mapType,
+ const QRect &screenRect,
+ const QSize &tileSize,
+ int zoomLevel)
+ : atEnd(false),
+ row(-1),
+ col(-1),
+ screenRect(screenRect),
+ tileSize(tileSize),
+ mapType(mapType),
+ connectivityMode(connectivityMode),
+ zoomLevel(zoomLevel),
+ tileRect(QPoint(0, 0), tileSize)
+{
+ qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
+ qulonglong y = static_cast<qulonglong>(screenRect.topLeft().y() / tileSize.height());
+
+ width = tileSize.width() * (1 << zoomLevel);
+
+ currTopLeft.setX(x * tileSize.width());
+ currTopLeft.setY(y * tileSize.height());
+}
+
+bool QGeoTileIterator::hasNext()
+{
+ return !atEnd;
+}
+
+QGeoTiledMapRequest QGeoTileIterator::next()
+{
+ int numCols = 1 << zoomLevel;
+ col = static_cast<int>(currTopLeft.x() / tileSize.width()) % numCols;
+ row = static_cast<int>(currTopLeft.y() / tileSize.height()) % numCols;
+ tileRect.moveTopLeft(currTopLeft);
+ if (tileRect.left() >= width)
+ tileRect.translate(-width, 0);
+
+ currTopLeft.rx() += tileSize.width();
+
+ if (currTopLeft.x() > screenRect.right()) { //next row
+ qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
+ currTopLeft.setX(x * tileSize.width());
+ currTopLeft.ry() += tileSize.height();
+ }
+
+ if (currTopLeft.y() > screenRect.bottom()) //done
+ atEnd = true;
+
+ return QGeoTiledMapRequest(connectivityMode, mapType, zoomLevel, row, col, tileRect);
+}
+
+#include "moc_qgeotiledmapdata.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapdata.h b/src/location/maps/tiled/qgeotiledmapdata.h
new file mode 100644
index 00000000..9516356f
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapdata.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPDATA_H
+#define QGEOTILEDMAPDATA_H
+
+#include "qgeomapdata.h"
+#include "qgeotiledmapreply.h"
+
+#include <QRectF>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapDataPrivate;
+
+class Q_LOCATION_EXPORT QGeoTiledMapData : public QGeoMapData
+{
+ Q_OBJECT
+
+public:
+ QGeoTiledMapData(QGeoMappingManagerEngine *engine);
+ virtual ~QGeoTiledMapData();
+
+ void setWindowSize(const QSizeF &size);
+
+ void setZoomLevel(qreal zoomLevel);
+
+ void pan(int dx, int dy);
+
+ void setCenter(const QGeoCoordinate &center);
+ QGeoCoordinate center() const;
+
+ void setMapType(QGraphicsGeoMap::MapType mapType);
+
+ void setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode);
+
+ virtual QGeoBoundingBox viewport() const;
+ virtual void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false);
+
+ QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
+ QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
+
+ QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition) const;
+
+ virtual QPoint coordinateToWorldReferencePosition(const QGeoCoordinate &coordinate) const;
+ virtual QGeoCoordinate worldReferencePositionToCoordinate(const QPoint &pixel) const;
+
+ QPoint worldReferenceViewportCenter() const;
+ QSize worldReferenceSize() const;
+ QRect worldReferenceViewportRect() const;
+ int zoomFactor() const;
+
+ void triggerUpdateMapDisplay(const QRectF &target = QRectF());
+
+protected:
+ void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
+ void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
+
+ QGeoMapObjectInfo* createMapObjectInfo(QGeoMapObject *mapObject);
+
+private Q_SLOTS:
+ void processRequests();
+ void tileFinished();
+ void replyFinished(QGeoTiledMapReply *reply);
+ void tileError(QGeoTiledMapReply::Error error, QString errorString);
+
+private:
+ Q_DECLARE_PRIVATE(QGeoTiledMapData)
+ Q_DISABLE_COPY(QGeoTiledMapData)
+ friend class QGeoTiledMappingManagerEngine;
+ friend class QGeoTiledMapObjectInfo;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmapdata_p.h b/src/location/maps/tiled/qgeotiledmapdata_p.h
new file mode 100644
index 00000000..f5a68088
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapdata_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPDATA_P_H
+#define QGEOTILEDMAPDATA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomapdata_p.h"
+#include "qgeomapobject.h"
+#include "qgeomapobject_p.h"
+#include "projwrapper_p.h"
+
+#include <QRectF>
+#include <QHash>
+#include <QCache>
+#include <QPair>
+#include <QList>
+
+class QGraphicsScene;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapData;
+class QGeoTiledMapRequest;
+class QGeoTiledMapReply;
+class QGeoTiledMapObjectInfo;
+class QGeoMapObjectEngine;
+
+class QGeoTiledMapDataPrivate : public QGeoMapDataPrivate
+{
+public:
+ QGeoTiledMapDataPrivate(QGeoTiledMapData *parent, QGeoMappingManagerEngine *engine);
+ ~QGeoTiledMapDataPrivate();
+
+ void updateMapImage();
+ void clearRequests();
+
+ QPointF windowOffset() const;
+
+ void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
+ void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
+
+ void cleanupCaches();
+
+ bool intersects(QGeoMapObject *mapObject, const QRectF &rect);
+
+ QRect screenRectForZoomFactor(int zoomFactor);
+ void updateScreenRect();
+
+ bool containedInScreen(const QPoint &point) const;
+ bool intersectsScreen(const QRect &rect) const;
+ QList<QPair<QRect, QRect> > intersectedScreen(const QRect &rect, bool translateToScreen = true) const;
+
+ virtual QPoint screenPositionToWorldReferencePosition(const QPointF &screenPosition) const;
+ virtual QPoint coordinateToWorldReferencePosition(double lon, double lat) const;
+ virtual QPointF coordinateToScreenPosition(double lon, double lat) const;
+
+ virtual void addObject(QGeoMapObject *object);
+ virtual void removeObject(QGeoMapObject *object);
+
+ virtual void update(QObject *object);
+
+ QGeoMapObjectEngine *oe;
+
+ int zoomFactor;
+
+ QPoint worldReferenceViewportCenter;
+ QSize worldReferenceSize;
+ QRect worldReferenceViewportRect;
+
+ QRect worldReferenceViewportRectLeft;
+ QRect worldReferenceViewportRectRight;
+
+ QSet<QRect> requestRects;
+ QSet<QRect> replyRects;
+
+ QList<QGeoTiledMapRequest> requests;
+ QSet<QGeoTiledMapReply*> replies;
+
+ QCache<QGeoTiledMapRequest, QImage> cache;
+ QCache<QGeoTiledMapRequest, QPixmap> zoomCache;
+
+ ProjCoordinateSystem spherical;
+ ProjCoordinateSystem wgs84;
+
+ Q_DECLARE_PUBLIC(QGeoTiledMapData)
+private:
+ Q_DISABLE_COPY(QGeoTiledMapDataPrivate)
+};
+
+class QGeoTileIterator
+{
+public:
+ QGeoTileIterator(const QGeoTiledMapDataPrivate *mapData);
+ QGeoTileIterator(QGraphicsGeoMap::ConnectivityMode connectivityMode,
+ QGraphicsGeoMap::MapType mapType,
+ const QRect &screenRect,
+ const QSize &tileSize,
+ int zoomLevel);
+
+ bool hasNext();
+ QGeoTiledMapRequest next();
+
+private:
+ bool atEnd;
+ int row;
+ int col;
+ int width;
+ QRect screenRect;
+ QSize tileSize;
+ QGraphicsGeoMap::MapType mapType;
+ QGraphicsGeoMap::ConnectivityMode connectivityMode;
+ int zoomLevel;
+ QPoint currTopLeft;
+ QRect tileRect;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp
new file mode 100644
index 00000000..a768623d
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapgroupobjectinfo_p.h"
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomapobject.h"
+#include "qgeomapgroupobject.h"
+
+#include "qgeomapobjectengine_p.h"
+
+#include <QGraphicsItem>
+#include <QGraphicsScene>
+#include <QGraphicsPathItem>
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapGroupObjectInfo::QGeoTiledMapGroupObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+
+ group = static_cast<QGeoMapGroupObject*>(mapObject);
+
+ connect(group,
+ SIGNAL(childAdded(QGeoMapObject*)),
+ this,
+ SLOT(childAdded(QGeoMapObject*)));
+ connect(group,
+ SIGNAL(childUpdated(QGeoMapObject*)),
+ this,
+ SLOT(childUpdated(QGeoMapObject*)));
+ connect(group,
+ SIGNAL(childRemoved(QGeoMapObject*)),
+ this,
+ SLOT(childRemoved(QGeoMapObject*)));
+
+ pathItem = new QGraphicsPathItem();
+ graphicsItem = pathItem;
+ pathItem->setPos(0.0, 0.0);
+
+ QList<QGeoMapObject*> objects = group->childObjects();
+
+ foreach(QGeoMapObject * object, objects) {
+ QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(object->info());
+
+ if (info)
+ info->graphicsItem->setParentItem(graphicsItem);
+ }
+
+ updateItem();
+}
+
+QGeoTiledMapGroupObjectInfo::~QGeoTiledMapGroupObjectInfo()
+{
+}
+
+void QGeoTiledMapGroupObjectInfo::childAdded(QGeoMapObject *childObject)
+{
+ if (!childObject)
+ return;
+
+ QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(childObject->info());
+ if (info && info->graphicsItem) {
+ // the child's z value will get updated in QGeoTiledMapGroupObjectInfo::childUpdated
+ // we do this in order to keep the same order of operations that we had previously
+ childObject->disconnect(childObject, SIGNAL(zValueChanged(int)), info, SLOT(zValueChanged(int)));
+ info->graphicsItem->setParentItem(graphicsItem);
+ tiledMapDataPrivate->update(mapObject());
+ //tiledMapDataPrivate->update(childObject);
+ }
+}
+
+void QGeoTiledMapGroupObjectInfo::childUpdated(QGeoMapObject *childObject)
+{
+ if (!childObject)
+ return;
+
+ QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(childObject->info());
+ if (info && info->graphicsItem) {
+ //info->graphicsItem->setParentItem(graphicsItem);
+ tiledMapDataPrivate->update(mapObject());
+ info->zValueChanged(childObject->zValue());
+ }
+}
+
+void QGeoTiledMapGroupObjectInfo::childRemoved(QGeoMapObject *childObject)
+{
+ if (childObject && tiledMapDataPrivate->oe) {
+ tiledMapDataPrivate->oe->removeObject(childObject);
+ updateItem();
+ }
+}
+
+#include "moc_qgeotiledmapgroupobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h
new file mode 100644
index 00000000..0f4fd57c
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPGROUPOBJECT_INFO_P_H
+#define QGEOTILEDMAPGROUPOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+class QGraphicsPathItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapGroupObject;
+
+class QGeoTiledMapGroupObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapGroupObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapGroupObjectInfo();
+
+ QGeoMapGroupObject *group;
+ QGraphicsPathItem *pathItem;
+
+public slots:
+ void childAdded(QGeoMapObject *childObject);
+ void childUpdated(QGeoMapObject *childObject);
+ void childRemoved(QGeoMapObject *childObject);
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPGROUPOBJECT_INFO_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp
new file mode 100644
index 00000000..900dd718
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+#include "qgeoboundingbox.h"
+#include "qgeomapobjectengine_p.h"
+
+#include <QGraphicsScene>
+
+#include <QPolygonF>
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapObjectInfo::QGeoTiledMapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoMapObjectInfo(mapData, mapObject),
+ graphicsItem(0),
+ inited(false),
+ updateAfterInit(false)
+{
+ tiledMapData = mapData;
+ tiledMapDataPrivate = static_cast<QGeoTiledMapDataPrivate*>(mapData->d_ptr);
+}
+
+QGeoTiledMapObjectInfo::~QGeoTiledMapObjectInfo()
+{
+ if (graphicsItem) {
+ delete graphicsItem;
+ graphicsItem = 0;
+ }
+}
+
+void QGeoTiledMapObjectInfo::init()
+{
+ if (graphicsItem) {
+ graphicsItem->setZValue(mapObject()->zValue());
+ graphicsItem->setVisible(mapObject()->isVisible());
+ //graphicsItem->setFlag(QGraphicsItem::ItemIsSelectable);
+ }
+ inited = true;
+ if (updateAfterInit) {
+ tiledMapData->updateMapDisplay();
+ updateAfterInit = false;
+ }
+}
+
+QGeoMapObject* QGeoTiledMapObjectInfo::mapObject() const
+{
+ return QGeoMapObjectInfo::mapObject();
+}
+
+void QGeoTiledMapObjectInfo::zValueChanged(int zValue)
+{
+ if (graphicsItem) {
+ graphicsItem->setZValue(zValue);
+ updateItem();
+ if (tiledMapDataPrivate && tiledMapDataPrivate->oe)
+ tiledMapDataPrivate->oe->rebuildScenes();
+ }
+}
+
+void QGeoTiledMapObjectInfo::visibleChanged(bool visible)
+{
+ if (graphicsItem) {
+ graphicsItem->setVisible(visible);
+ updateItem();
+ }
+}
+
+void QGeoTiledMapObjectInfo::selectedChanged(bool /*selected*/)
+{
+ // don't want to draw the selection box
+// if (graphicsItem) {
+// graphicsItem->setSelected(selected);
+// updateItem();
+// }
+}
+
+void QGeoTiledMapObjectInfo::originChanged(const QGeoCoordinate &origin)
+{
+ if (graphicsItem)
+ updateItem();
+}
+
+void QGeoTiledMapObjectInfo::unitsChanged(QGeoMapObject::CoordinateUnit units)
+{
+ if (graphicsItem)
+ updateItem();
+}
+
+void QGeoTiledMapObjectInfo::transformTypeChanged(QGeoMapObject::TransformType transformType)
+{
+ if (graphicsItem)
+ updateItem();
+}
+
+QGeoBoundingBox QGeoTiledMapObjectInfo::boundingBox() const
+{
+ if (!graphicsItem || !tiledMapData)
+ return QGeoBoundingBox();
+
+ QGeoMapObjectEngine *e = tiledMapDataPrivate->oe;
+
+ QGeoMapObject *object = mapObject();
+
+ e->updateTransforms();
+
+ if (e->latLonExact.contains(object)) {
+ QList<QGraphicsItem*> items = e->latLonExact.values(object);
+ QGeoBoundingBox box;
+ foreach (QGraphicsItem *item, items) {
+ QRectF latLonBounds = item->boundingRect();
+ QPointF topLeft = latLonBounds.bottomLeft();
+ if (topLeft.x() >= 180.0 * 3600.0)
+ topLeft.setX(topLeft.x() - 360.0 * 3600.0);
+ if (topLeft.x() < -180.0 * 3600.0)
+ topLeft.setX(topLeft.x() + 360.0 * 3600.0);
+
+ QPointF bottomRight = latLonBounds.topRight();
+ if (bottomRight.x() >= 180.0 * 3600.0)
+ bottomRight.setX(bottomRight.x() - 360.0 * 3600.0);
+ if (bottomRight.x() < -180.0 * 3600.0)
+ bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
+
+ QGeoCoordinate tlc(topLeft.y() / 3600.0, topLeft.x() / 3600.0);
+ QGeoCoordinate brc(bottomRight.y() / 3600.0, bottomRight.x() / 3600.0);
+
+ return QGeoBoundingBox(tlc, brc);
+
+ // it looks like the following is overkill
+// if (box.isValid()) {
+// box |= QGeoBoundingBox(tlc, brc);
+// } else {
+// box = QGeoBoundingBox(tlc, brc);
+// }
+ }
+ return box;
+ } else {
+ QTransform trans = e->latLonTrans.value(object);
+
+ QRectF bounds = graphicsItem->boundingRect();
+ QPolygonF poly = bounds * trans;
+
+ QRectF latLonBounds = poly.boundingRect();
+ QPointF topLeft = latLonBounds.bottomLeft();
+ if (topLeft.x() >= 180.0 * 3600.0)
+ topLeft.setX(topLeft.x() - 360.0 * 3600.0);
+ if (topLeft.x() < -180.0 * 3600.0)
+ topLeft.setX(topLeft.x() + 360.0 * 3600.0);
+
+ QPointF bottomRight = latLonBounds.topRight();
+ if (bottomRight.x() >= 180.0 * 3600.0)
+ bottomRight.setX(bottomRight.x() - 360.0 * 3600.0);
+ if (bottomRight.x() < -180.0 * 3600.0)
+ bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
+
+ QGeoCoordinate tlc(topLeft.y() / 3600.0, topLeft.x() / 3600.0);
+ QGeoCoordinate brc(bottomRight.y() / 3600.0, bottomRight.x() / 3600.0);
+
+ return QGeoBoundingBox(tlc, brc);
+ }
+}
+
+bool QGeoTiledMapObjectInfo::contains(const QGeoCoordinate &coordinate) const
+{
+ if (!graphicsItem || !tiledMapData)
+ return false;
+
+ QGeoMapObjectEngine *e = tiledMapDataPrivate->oe;
+
+ e->updateTransforms();
+ QPointF latLonPoint(coordinate.longitude()*3600.0, coordinate.latitude()*3600.0);
+
+ QGeoMapObject *object = mapObject();
+
+ if (e->latLonExact.contains(object)) {
+ QList<QGraphicsItem*> items = e->latLonExact.values(object);
+ foreach (QGraphicsItem *item, items) {
+ if (item->contains(latLonPoint))
+ return true;
+ }
+ } else {
+ QList<QTransform> transList = e->latLonTrans.values(object);
+ foreach (QTransform trans, transList) {
+ bool ok;
+ QTransform inv = trans.inverted(&ok);
+ if (!ok)
+ continue;
+
+ QPointF localPoint = latLonPoint * inv;
+
+ if (graphicsItem->contains(localPoint))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void QGeoTiledMapObjectInfo::updateItem(const QRectF& target)
+{
+ if (!inited) {
+ updateAfterInit = true;
+ return;
+ }
+
+ QGeoMapObject *object = mapObject();
+ if (object)
+ tiledMapDataPrivate->update(object);
+ if (graphicsItem)
+ tiledMapData->triggerUpdateMapDisplay(target);
+}
+
+#include "moc_qgeotiledmapobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h
new file mode 100644
index 00000000..6d4ea267
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPOBJECT_INFO_P_H
+#define QGEOTILEDMAPOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomapobject_p.h"
+
+#include <QRectF>
+
+class QGraphicsItem;
+class QRect;
+class QPolygonF;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapData;
+class QGeoBoundingBox;
+class QGeoCoordinate;
+class QGeoTiledMapDataPrivate;
+
+class QGeoTiledMapObjectInfo : public QGeoMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapObjectInfo();
+
+ virtual void init();
+
+ QGeoMapObject* mapObject() const;
+
+ QGeoBoundingBox boundingBox() const;
+ bool contains(const QGeoCoordinate &coordinate) const;
+
+ void updateItem(const QRectF &target = QRectF());
+
+ bool inited;
+ bool updateAfterInit;
+
+ QGraphicsItem *graphicsItem;
+ QGeoTiledMapData *tiledMapData;
+
+public slots:
+ virtual void zValueChanged(int zValue);
+ virtual void visibleChanged(bool visible);
+ virtual void selectedChanged(bool selected);
+
+ virtual void originChanged(const QGeoCoordinate &origin);
+ virtual void unitsChanged(QGeoMapObject::CoordinateUnit units);
+ virtual void transformTypeChanged(QGeoMapObject::TransformType transformType);
+
+protected:
+ QGeoTiledMapDataPrivate *tiledMapDataPrivate;
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp b/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp
new file mode 100644
index 00000000..21705d17
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmappingmanagerengine.h"
+#include "qgeotiledmappingmanagerengine_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoTiledMappingManagerEngine
+
+ \brief The QGeoTiledMappingManagerEngine class is provided to make writing
+ Qt Maps and Navigation API plugins for tiled based mapping services easier.
+
+ \inmodule QtLocation
+
+ \ingroup maps-impl-tiled
+
+ \since 1.2
+
+ Subclasses of QGeoTiledMappingManagerEngine need to provide an implementation
+ of getTileImage().
+
+ It is important that the function setTileSize() is called before
+ getTileImage() to ensure that the tile is dealt with correctly after it is
+ fetched. If setTileSize() is not calle dfirst the behaviour is undefined.
+
+ A subclass of QGeoTiledMappingManagerEngine will often make use of a subclass
+ fo QGeoTiledMapReply internally, in order to add any engine-specific
+ data (such as a QNetworkReply object for network-based services) to the
+ QGeoTiledMapReply instances used by the engine.
+
+ QGeoTiledMappingManagerEngine will report that custom map objects are supported
+ by default.
+*/
+
+/*!
+ Constructs a new tiled mapping manager using the parameters \a parameters
+ and the parent \a parent.
+*/
+QGeoTiledMappingManagerEngine::QGeoTiledMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
+ : QGeoMappingManagerEngine(new QGeoTiledMappingManagerEnginePrivate(), parent)
+{
+ Q_UNUSED(parameters)
+ setSupportsCustomMapObjects(true);
+}
+
+/*!
+ Destroys this tiled mapping manager.
+*/
+QGeoTiledMappingManagerEngine::~QGeoTiledMappingManagerEngine()
+{
+ // deleted in superclass destructor
+}
+
+/*
+ Requests the map tiled specified by \a request.
+
+ A QGeoTiledMapReply object will be returned, which can be used to manage the
+ fetching of the tile and to return the tile data.
+
+ This manager and the returned QGeoTiledMapReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ Once the operation has completed, QGeoTiledMapReply::mapImageData() and
+ QGeoTiledMapReply::mapImageFormat() can be used to generate the tile image.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoTiledMappingManagerEngine::finished(),
+ QGeoTiledMappingManagerEngine::error(), QGeoTiledMapReply::finished() or
+ QGeoTiledMapReply::error() with deleteLater().
+*/
+
+/*!
+\fn virtual QGeoTiledMapReply* QGeoTiledMappingManagerEngine::getTileImage(const QGeoTiledMapRequest &request)
+ Requests the map tiled specified by \a request.
+
+ A QGeoTiledMapReply object will be returned, which can be used to manage the
+ fetching of the tile and to return the tile data.
+
+ The returned QGeoTiledMapReply object will emit signals
+ indicating if the operation completes or if errors occur.
+
+ Once the operation has completed, QGeoTiledMapReply::mapImageData() and
+ QGeoTiledMapReply::mapImageFormat() can be used to generate the tile image.
+
+ The user is responsible for deleting the returned reply object, although
+ this can be done in the slot connected to QGeoTiledMapReply::finished() or
+ QGeoTiledMapReply::error() with deleteLater().
+
+*/
+
+/*!
+ Returns a new QGeoMapData instance which will be managed by
+ this manager.
+
+ A QGeoMapData instance contains and manages the information about
+ what a map widget is looking at. A single manager can be used by several
+ QGraphcisGeoMap instances since each instance has an associated QGeoMapData instance.
+
+ The QGeoMapData instance can be treated as a kind of session object, or
+ as a model in a model-view-controller architecture, with QGraphicsGeoMap
+ as the view and QGeoMappingManagerEngine as the controller.
+
+ The instance returned by the default implementation will be a
+ QGeoTiledMapData instance. Subclasses of QGeoTiledMappingManagerEngine are
+ free to override this function to return subclasses of QGeoTiledMapData in
+ order to customize the map.
+*/
+QGeoMapData* QGeoTiledMappingManagerEngine::createMapData()
+{
+ return new QGeoTiledMapData(this);
+}
+
+/*!
+ Returns the size of the tiles returned by this tiled mapping manager.
+*/
+QSize QGeoTiledMappingManagerEngine::tileSize() const
+{
+ Q_D(const QGeoTiledMappingManagerEngine);
+ return d->tileSize;
+}
+
+/*!
+ Sets the size of the tiles returned by this tiled mapping manager to \a
+ tileSize.
+
+ Subclasses of QGeoTiledMappingManagerEngine should use this function to
+ ensure tileSize() provides accurate information.
+*/
+void QGeoTiledMappingManagerEngine::setTileSize(const QSize &tileSize)
+{
+ Q_D(QGeoTiledMappingManagerEngine);
+ d->tileSize = tileSize;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoTiledMappingManagerEnginePrivate::QGeoTiledMappingManagerEnginePrivate()
+ : QGeoMappingManagerEnginePrivate() {}
+
+QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate() {}
+
+/*******************************************************************************
+*******************************************************************************/
+
+#include "moc_qgeotiledmappingmanagerengine.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine.h b/src/location/maps/tiled/qgeotiledmappingmanagerengine.h
new file mode 100644
index 00000000..4995f2a3
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappingmanagerengine.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPINGMANAGERENGINE_H
+#define QGEOTILEDMAPPINGMANAGERENGINE_H
+
+#include "qgeomappingmanagerengine.h"
+
+#include "qgeotiledmapreply.h"
+#include "qgeotiledmaprequest.h"
+#include "qgeotiledmapdata.h"
+
+#include <QMap>
+#include <QVariant>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMappingManagerEnginePrivate;
+
+class Q_LOCATION_EXPORT QGeoTiledMappingManagerEngine : public QGeoMappingManagerEngine
+{
+ Q_OBJECT
+public:
+ virtual ~QGeoTiledMappingManagerEngine();
+
+ virtual QGeoTiledMapReply* getTileImage(const QGeoTiledMapRequest &request) = 0;
+
+ virtual QGeoMapData* createMapData();
+
+ QSize tileSize() const;
+
+protected:
+ QGeoTiledMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ void setTileSize(const QSize &tileSize);
+
+private:
+ Q_DECLARE_PRIVATE(QGeoTiledMappingManagerEngine)
+ Q_DISABLE_COPY(QGeoTiledMappingManagerEngine)
+};
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QGeoTiledMapReply::Error))
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h b/src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h
new file mode 100644
index 00000000..62e784aa
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPINGMANAGERENGINE_P_H
+#define QGEOTILEDMAPPINGMANAGERENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeomappingmanagerengine_p.h"
+#include "qgeotiledmapreply.h"
+
+#include <QSize>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMappingManagerEngine;
+class QGeoTiledMapRequestHandler;
+class QGeoTiledMapData;
+class QGeoTiledMapRequest;
+
+class QGeoTiledMappingManagerEnginePrivate : public QGeoMappingManagerEnginePrivate
+{
+public:
+ QGeoTiledMappingManagerEnginePrivate();
+ ~QGeoTiledMappingManagerEnginePrivate();
+
+ QSize tileSize;
+
+private:
+ Q_DISABLE_COPY(QGeoTiledMappingManagerEnginePrivate)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp
new file mode 100644
index 00000000..7142094d
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmappixmapobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomappixmapobject.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapPixmapObjectInfo::QGeoTiledMapPixmapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ pixmap = static_cast<QGeoMapPixmapObject*>(mapObject);
+
+ connect(pixmap,
+ SIGNAL(pixmapChanged(QPixmap)),
+ this,
+ SLOT(pixmapChanged(QPixmap)));
+ connect(pixmap,
+ SIGNAL(offsetChanged(QPoint)),
+ this,
+ SLOT(offsetChanged(QPoint)));
+
+ pixmapItem = new QGraphicsPixmapItem();
+ graphicsItem = pixmapItem;
+
+ originChanged(this->pixmap->origin());
+ pixmapChanged(this->pixmap->pixmap());
+ offsetChanged(this->pixmap->offset());
+}
+
+QGeoTiledMapPixmapObjectInfo::~QGeoTiledMapPixmapObjectInfo() {}
+
+void QGeoTiledMapPixmapObjectInfo::pixmapChanged(const QPixmap &/*pixmap*/)
+{
+ pixmapItem->setPixmap(this->pixmap->pixmap());
+ pixmapItem->setScale(1.0);
+ updateItem();
+}
+
+void QGeoTiledMapPixmapObjectInfo::offsetChanged(const QPoint &/*offset*/)
+{
+ pixmapItem->setOffset(pixmap->offset());
+ updateItem();
+}
+
+#include "moc_qgeotiledmappixmapobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h
new file mode 100644
index 00000000..103aa6bf
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
+#define QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeoboundingbox.h"
+
+#include <QPixmap>
+
+class QGraphicsPixmapItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPixmapObject;
+
+class QGeoTiledMapPixmapObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapPixmapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapPixmapObjectInfo();
+
+ QGeoMapPixmapObject* pixmap;
+ QGraphicsPixmapItem *pixmapItem;
+
+public slots:
+ void pixmapChanged(const QPixmap &pixmap);
+ void offsetChanged(const QPoint &offset);
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp
new file mode 100644
index 00000000..ca65c397
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmappolygonobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomappolygonobject.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapPolygonObjectInfo::QGeoTiledMapPolygonObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ polygon = static_cast<QGeoMapPolygonObject*>(mapObject);
+
+ connect(polygon,
+ SIGNAL(pathChanged(QList<QGeoCoordinate>)),
+ this,
+ SLOT(pathChanged(QList<QGeoCoordinate>)));
+ connect(polygon,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+ connect(polygon,
+ SIGNAL(brushChanged(QBrush)),
+ this,
+ SLOT(brushChanged(QBrush)));
+
+ polygonItem = new QGraphicsPolygonItem();
+ graphicsItem = polygonItem;
+
+ penChanged(polygon->pen());
+ brushChanged(polygon->brush());
+ pathChanged(polygon->path());
+}
+
+QGeoTiledMapPolygonObjectInfo::~QGeoTiledMapPolygonObjectInfo() {}
+
+void QGeoTiledMapPolygonObjectInfo::pathChanged(const QList<QGeoCoordinate> &/*path*/)
+{
+ genPoly();
+ updateItem();
+}
+
+void QGeoTiledMapPolygonObjectInfo::penChanged(const QPen &/*pen*/)
+{
+ polygonItem->setPen(polygon->pen());
+ updateItem();
+}
+
+void QGeoTiledMapPolygonObjectInfo::brushChanged(const QBrush &/*brush*/)
+{
+ polygonItem->setBrush(polygon->brush());
+ updateItem();
+}
+
+void QGeoTiledMapPolygonObjectInfo::genPoly()
+{
+ QPolygonF poly;
+
+ QList<QGeoCoordinate> path = polygon->path();
+
+ if (path.size() > 0) {
+ QGeoCoordinate origin = path.at(0);
+ double ox = origin.longitude() * 3600.0;
+ double oy = origin.latitude() * 3600.0;
+
+ double oldx = ox;
+ double oldy = oy;
+
+ poly << QPointF(0,0);
+ for (int i = 0; i < path.size(); ++i) {
+ QGeoCoordinate pt = path.at(i);
+ double x = pt.longitude() * 3600.0;
+ double y = pt.latitude() * 3600.0;
+
+ if (qAbs(x - oldx) > 180.0 * 3600.0) {
+ if (x > oldx) {
+ x -= 360.0 * 3600.0;
+ } else if (x < oldx) {
+ x += 360.0 * 3600.0;
+ }
+ }
+
+ poly << QPointF(x - ox, y - oy);
+
+ oldx = x;
+ oldy = y;
+ }
+ }
+
+ polygonItem->setPolygon(poly);
+}
+
+#include "moc_qgeotiledmappolygonobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h
new file mode 100644
index 00000000..d2df8f77
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
+#define QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include <QPen>
+#include <QBrush>
+#include <QPolygonF>
+
+class QGraphicsPolygonItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPolygonObject;
+
+class QGeoTiledMapPolygonObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapPolygonObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapPolygonObjectInfo();
+
+ QGeoMapPolygonObject *polygon;
+ QGraphicsPolygonItem *polygonItem;
+
+public slots:
+ void pathChanged(const QList<QGeoCoordinate> &path);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+
+private:
+ void genPoly();
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp
new file mode 100644
index 00000000..e9cf1da9
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmappolylineobjectinfo_p.h"
+//#include "makepoly_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomappolylineobject.h"
+
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapPolylineObjectInfo::QGeoTiledMapPolylineObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ polyline = static_cast<QGeoMapPolylineObject*>(mapObject);
+
+ connect(polyline,
+ SIGNAL(pathChanged(QList<QGeoCoordinate>)),
+ this,
+ SLOT(pathChanged(QList<QGeoCoordinate>)));
+ connect(polyline,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+
+ pathItem = new QGraphicsPathItem();
+ graphicsItem = pathItem;
+
+ penChanged(polyline->pen());
+ pathChanged(polyline->path());
+}
+
+QGeoTiledMapPolylineObjectInfo::~QGeoTiledMapPolylineObjectInfo() {}
+
+void QGeoTiledMapPolylineObjectInfo::pathChanged(const QList<QGeoCoordinate> &/*path*/)
+{
+ genPath();
+ updateItem();
+}
+
+void QGeoTiledMapPolylineObjectInfo::penChanged(const QPen &/*pen*/)
+{
+ pathItem->setPen(polyline->pen());
+ updateItem();
+}
+
+void QGeoTiledMapPolylineObjectInfo::genPath()
+{
+ QPainterPath p;
+
+ QList<QGeoCoordinate> path = polyline->path();
+
+ if (path.size() > 0) {
+ QGeoCoordinate origin = path.at(0);
+ double ox = origin.longitude() * 3600.0;
+ double oy = origin.latitude() * 3600.0;
+
+ double oldx = ox;
+ double oldy = oy;
+
+ p.moveTo(0, 0);
+ for (int i = 1; i < path.size(); ++i) {
+ QGeoCoordinate pt = path.at(i);
+ double x = pt.longitude() * 3600.0;
+ double y = pt.latitude() * 3600.0;
+
+ if (qAbs(x - oldx) > 180.0 * 3600.0) {
+ if (x > oldx) {
+ x -= 360.0 * 3600.0;
+ } else if (x < oldx) {
+ x += 360.0 * 3600.0;
+ }
+ }
+
+ p.lineTo(x - ox, y - oy);
+
+ oldx = x;
+ oldy = y;
+ }
+ }
+
+ pathItem->setPath(p);
+}
+
+#include "moc_qgeotiledmappolylineobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h
new file mode 100644
index 00000000..10a3be8d
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
+#define QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include <QPen>
+#include <QPolygonF>
+
+class QGraphicsPathItem;
+class QPointF;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapPolylineObject;
+
+class QGeoTiledMapPolylineObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapPolylineObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapPolylineObjectInfo();
+
+ QGeoMapPolylineObject *polyline;
+ QGraphicsPathItem *pathItem;
+
+public slots:
+ void pathChanged(const QList<QGeoCoordinate> &path);
+ void penChanged(const QPen &pen);
+
+private:
+ void genPath();
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
diff --git a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp
new file mode 100644
index 00000000..e323c0c4
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmaprectangleobjectinfo_p.h"
+
+#include <QGraphicsPolygonItem>
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeoboundingbox.h"
+
+#include "qgeomaprectangleobject.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapRectangleObjectInfo::QGeoTiledMapRectangleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ rectangle = static_cast<QGeoMapRectangleObject*>(mapObject);
+
+ connect(rectangle,
+ SIGNAL(topLeftChanged(QGeoCoordinate)),
+ this,
+ SLOT(topLeftChanged(QGeoCoordinate)));
+ connect(rectangle,
+ SIGNAL(bottomRightChanged(QGeoCoordinate)),
+ this,
+ SLOT(bottomRightChanged(QGeoCoordinate)));
+ connect(rectangle,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+ connect(rectangle,
+ SIGNAL(brushChanged(QBrush)),
+ this,
+ SLOT(brushChanged(QBrush)));
+
+ polygonItem = new QGraphicsPolygonItem();
+ graphicsItem = polygonItem;
+
+ topLeftChanged(rectangle->topLeft());
+ bottomRightChanged(rectangle->bottomRight());
+ penChanged(rectangle->pen());
+ brushChanged(rectangle->brush());
+}
+
+QGeoTiledMapRectangleObjectInfo::~QGeoTiledMapRectangleObjectInfo() {}
+
+void QGeoTiledMapRectangleObjectInfo::topLeftChanged(const QGeoCoordinate &/*topLeft*/)
+{
+ regenPolygon();
+ updateItem();
+}
+
+void QGeoTiledMapRectangleObjectInfo::bottomRightChanged(const QGeoCoordinate &/*bottomRight*/)
+{
+ regenPolygon();
+ updateItem();
+}
+
+void QGeoTiledMapRectangleObjectInfo::penChanged(const QPen &/*pen*/)
+{
+ polygonItem->setPen(rectangle->pen());
+ updateItem();
+}
+
+void QGeoTiledMapRectangleObjectInfo::brushChanged(const QBrush &/*brush*/)
+{
+ polygonItem->setBrush(rectangle->brush());
+ updateItem();
+}
+
+void QGeoTiledMapRectangleObjectInfo::regenPolygon()
+{
+ QPolygonF poly;
+
+ if (!rectangle->bounds().isValid())
+ return;
+
+ const QGeoCoordinate tl = rectangle->bounds().topLeft();
+ if (!tl.isValid())
+ return;
+
+ const QGeoCoordinate br = rectangle->bounds().bottomRight();
+ if (!br.isValid())
+ return;
+
+ double left = tl.longitude() * 3600.0;
+ double right = br.longitude() * 3600.0;
+ double top = tl.latitude() * 3600.0;
+ double bottom = br.latitude() * 3600.0;
+
+ if (left > right)
+ right += 360.0 * 3600.0;
+
+ poly << QPointF(left, top);
+ poly << QPointF(right, top);
+ poly << QPointF(right, bottom);
+ poly << QPointF(left, bottom);
+
+ polygonItem->setPolygon(poly);
+}
+
+#include "moc_qgeotiledmaprectangleobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
+
diff --git a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h
new file mode 100644
index 00000000..b3623e0d
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
+#define QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include <QPen>
+#include <QBrush>
+
+class QGraphicsPolygonItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRectangleObject;
+
+class QGeoTiledMapRectangleObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapRectangleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapRectangleObjectInfo();
+
+ QGeoMapRectangleObject* rectangle;
+ QGraphicsPolygonItem *polygonItem;
+
+public slots:
+ void topLeftChanged(const QGeoCoordinate &topLeft);
+ void bottomRightChanged(const QGeoCoordinate &bottomRight);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+
+private:
+ void regenPolygon();
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmapreply.cpp b/src/location/maps/tiled/qgeotiledmapreply.cpp
new file mode 100644
index 00000000..4a545f4f
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapreply.cpp
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapreply.h"
+#include "qgeotiledmapreply_p.h"
+
+#include "qgeotiledmaprequest.h"
+
+#include <qdebug.h>
+
+QTM_BEGIN_NAMESPACE
+/*!
+ \class QGeoTiledMapReply
+
+ \brief The QGeoTiledMapReply class manages a tile fetch operation started
+ by an instance of QGeoTiledManagerEngine.
+
+ \inmodule QtLocation
+
+ \ingroup maps-impl-tiled
+
+ \since 1.2
+
+ Instances of QGeoTiledMapReply manage the state and results of these
+ operations.
+
+ The isFinished(), error() and errorString() methods provide information
+ on whether the operation has completed and if it completed successfully.
+
+ The finished() and error(QGeoTiledMapReply::Error,QString)
+ signals can be used to monitor the progress of the operation.
+
+ It is possible that a newly created QGeoTiledMapReply may be in a finished
+ state, most commonly because an error has occurred. Since such an instance
+ will never emit the finished() or
+ error(QGeoTiledMapReply::Error,QString) signals, it is
+ important to check the result of isFinished() before making the connections
+ to the signals.
+
+ If the operation completes successfully the results will be able to be
+ accessed with mapImageData() and mapImageFormat().
+*/
+
+/*!
+ \enum QGeoTiledMapReply::Error
+
+ Describes an error which prevented the completion of the operation.
+
+ \value NoError
+ No error has occurred.
+ \value CommunicationError
+ An error occurred while communicating with the service provider.
+ \value ParseError
+ The response from the service provider was in an unrecognizable format.
+ supported by the service provider.
+ \value UnknownError
+ An error occurred which does not fit into any of the other categories.
+*/
+
+/*!
+ Constructs a tiled map reply object based on \a request, with parent \a parent.
+*/
+QGeoTiledMapReply::QGeoTiledMapReply(const QGeoTiledMapRequest &request, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoTiledMapReplyPrivate(request))
+{
+}
+
+/*!
+ Constructs a tiled map reply object with a given \a error and \a errorString and the specified \a parent.
+*/
+QGeoTiledMapReply::QGeoTiledMapReply(Error error, const QString &errorString, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QGeoTiledMapReplyPrivate(error, errorString)) {}
+
+/*!
+ Destroys this tiled map reply object.
+*/
+QGeoTiledMapReply::~QGeoTiledMapReply()
+{
+ delete d_ptr;
+}
+
+/*!
+ Sets whether or not this reply has finished to \a finished.
+
+ If \a finished is true, this will cause the finished() signal to be
+ emitted.
+
+ If the operation completed successfully,
+ QGeoTiledMapReply::setMapImageData() and
+ QGeoTiledMapReply::setTiledMapFormat() should be called before this
+ function. If an error occurred, QGeoTiledMapReply::setError() should be used
+ instead.
+*/
+void QGeoTiledMapReply::setFinished(bool finished)
+{
+ d_ptr->isFinished = finished;
+ if (d_ptr->isFinished)
+ emit this->finished();
+}
+
+/*!
+ Return true if the operation completed successfully or encountered an
+ error which cause the operation to come to a halt.
+*/
+bool QGeoTiledMapReply::isFinished() const
+{
+ return d_ptr->isFinished;
+}
+
+/*!
+ Sets the error state of this reply to \a error and the textual
+ representation of the error to \a errorString.
+
+ This wil also cause error() and finished() signals to be emitted, in that
+ order.
+*/
+void QGeoTiledMapReply::setError(QGeoTiledMapReply::Error error, const QString &errorString)
+{
+ d_ptr->error = error;
+ d_ptr->errorString = errorString;
+ emit this->error(error, errorString);
+ setFinished(true);
+}
+
+/*!
+ Returns the error state of this reply.
+
+ If the result is QGeoTiledMapReply::NoError then no error has occurred.
+*/
+QGeoTiledMapReply::Error QGeoTiledMapReply::error() const
+{
+ return d_ptr->error;
+}
+
+/*!
+ Returns the textual representation of the error state of this reply.
+
+ If no error has occurred this will return an empty string. It is possible
+ that an error occurred which has no associated textual representation, in
+ which case this will also return an empty string.
+
+ To determine whether an error has occurred, check to see if
+ QGeoTiledMapReply::error() is equal to QGeoTiledMapReply::NoError.
+*/
+QString QGeoTiledMapReply::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+/*!
+ Returns whether the reply is coming from a cache.
+*/
+bool QGeoTiledMapReply::isCached() const
+{
+ return d_ptr->isCached;
+}
+
+/*!
+ Sets whether the reply is coming from a cache to \a cached.
+*/
+void QGeoTiledMapReply::setCached(bool cached)
+{
+ d_ptr->isCached = cached;
+}
+
+/*!
+ Returns the request which corresponds to this reply.
+*/
+QGeoTiledMapRequest QGeoTiledMapReply::request() const
+{
+ return d_ptr->request;
+}
+
+/*!
+ Returns the tile image data.
+*/
+QByteArray QGeoTiledMapReply::mapImageData() const
+{
+ return d_ptr->mapImageData;
+}
+
+/*!
+ Sets the tile image data to \a data.
+*/
+void QGeoTiledMapReply::setMapImageData(const QByteArray &data)
+{
+ d_ptr->mapImageData = data;
+}
+
+/*!
+ Returns the format of the tile image.
+*/
+QString QGeoTiledMapReply::mapImageFormat() const
+{
+ return d_ptr->mapImageFormat;
+}
+
+/*!
+ Sets the format of the tile image to \a format.
+*/
+void QGeoTiledMapReply::setMapImageFormat(const QString &format)
+{
+ d_ptr->mapImageFormat = format;
+}
+
+/*!
+ Cancels the operation immediately.
+
+ This will do nothing if the reply is finished.
+*/
+void QGeoTiledMapReply::abort()
+{
+ if (!isFinished())
+ setFinished(true);
+}
+
+/*
+ \fn void QGeoTiledMapReply::finished()
+
+ This signal is emitted when this reply has finished processing.
+
+ If error() equals QGeoTiledMapReply::NoError then the processing
+ finished successfully.
+
+ This signal and QGeoRoutingManager::finished() will be
+ emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+
+ \fn void QGeoTiledMapReply::error(QGeoTiledMapReply::Error error, const QString &errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ this reply. The finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ This signal and QGeoRoutingManager::error() will be emitted at the same time.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*!
+ \fn void QGeoTiledMapReply::finished()
+
+ This signal is emitted when this reply has finished processing.
+
+ If error() equals QGeoTiledMapReply::NoError then the processing
+ finished successfully.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+/*!
+ \fn void QGeoTiledMapReply::error(QGeoTiledMapReply::Error error, const QString &errorString)
+
+ This signal is emitted when an error has been detected in the processing of
+ this reply. The finished() signal will probably follow.
+
+ The error will be described by the error code \a error. If \a errorString is
+ not empty it will contain a textual description of the error.
+
+ \note Do no delete this reply object in the slot connected to this
+ signal. Use deleteLater() instead.
+*/
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(const QGeoTiledMapRequest &request)
+ : error(QGeoTiledMapReply::NoError),
+ errorString(""),
+ isFinished(false),
+ isCached(false),
+ request(request) {}
+
+QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(QGeoTiledMapReply::Error error, const QString &errorString)
+ : error(error),
+ errorString(errorString),
+ isFinished(true),
+ isCached(false) {}
+
+QGeoTiledMapReplyPrivate::~QGeoTiledMapReplyPrivate() {}
+
+#include "moc_qgeotiledmapreply.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapreply.h b/src/location/maps/tiled/qgeotiledmapreply.h
new file mode 100644
index 00000000..19584ef4
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapreply.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPREPLY_H
+#define QGEOTILEDMAPREPLY_H
+
+#include "qmobilityglobal.h"
+
+#include <QObject>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapRequest;
+class QGeoTiledMapReplyPrivate;
+
+class Q_LOCATION_EXPORT QGeoTiledMapReply : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum Error {
+ NoError,
+ CommunicationError,
+ ParseError,
+ UnknownError
+ };
+
+ QGeoTiledMapReply(const QGeoTiledMapRequest &request, QObject *parent = 0);
+ QGeoTiledMapReply(Error error, const QString &errorString, QObject *parent = 0);
+ virtual ~QGeoTiledMapReply();
+
+ bool isFinished() const;
+ Error error() const;
+ QString errorString() const;
+
+ bool isCached() const;
+
+ QGeoTiledMapRequest request() const;
+
+ QByteArray mapImageData() const;
+ QString mapImageFormat() const;
+
+ virtual void abort();
+
+Q_SIGNALS:
+ void finished();
+ void error(QGeoTiledMapReply::Error error, const QString &errorString = QString());
+
+protected:
+ void setError(Error error, const QString &errorString);
+ void setFinished(bool finished);
+
+ void setCached(bool cached);
+
+ void setMapImageData(const QByteArray &data);
+ void setMapImageFormat(const QString &format);
+
+private:
+ QGeoTiledMapReplyPrivate *d_ptr;
+ Q_DISABLE_COPY(QGeoTiledMapReply)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmapreply_p.h b/src/location/maps/tiled/qgeotiledmapreply_p.h
new file mode 100644
index 00000000..aa590052
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmapreply_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPREPLY_P_H
+#define QGEOTILEDMAPREPLY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapreply.h"
+#include "qgeotiledmaprequest.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapReplyPrivate
+{
+public:
+ QGeoTiledMapReplyPrivate(const QGeoTiledMapRequest &request);
+ QGeoTiledMapReplyPrivate(QGeoTiledMapReply::Error error, const QString& errorString);
+ ~QGeoTiledMapReplyPrivate();
+
+ QGeoTiledMapReply::Error error;
+ QString errorString;
+ bool isFinished;
+ bool isCached;
+
+ QGeoTiledMapRequest request;
+ QByteArray mapImageData;
+ QString mapImageFormat;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmaprequest.cpp b/src/location/maps/tiled/qgeotiledmaprequest.cpp
new file mode 100644
index 00000000..09c906a6
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprequest.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmaprequest.h"
+#include "qgeotiledmaprequest_p.h"
+
+#include "qgeotiledmapdata.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoTiledMapRequest
+ \brief The QGeoTiledMapRequest class represents a request for a map tile
+ from a tile-based mapping service.
+
+ \inmodule QtLocation
+
+ \ingroup maps-impl-tiled
+
+ \since 1.2
+
+ The tile is specified by a map type, a zoom level, a row and a column.
+
+ At a zoom level of z the world is represented as a 2^z by 2^z grid
+ of tiles, and the row and column are relative to the grid of tiles
+ for the zoom level of the request.
+*/
+
+/*!
+ Constructs a new tiled map request.
+*/
+QGeoTiledMapRequest::QGeoTiledMapRequest()
+ : d_ptr(new QGeoTiledMapRequestPrivate()) {}
+
+/*!
+ Constructs a new tiled map request.
+
+ At a zoom level of z the world is represented as a 2^z by 2^z grid
+ of tiles.
+
+ This tiled map request represents a request for the tile at row \a row and
+ column \a column at zoom level \a zoomLevel and type
+ \a mapType.
+
+ The request will use connectivity mode \a connectivityMode when
+ accessing the map data.
+
+ The rectangle that the tile occupies on the map at the maximum zoom level
+ is also given as \a tileRect.
+*/
+QGeoTiledMapRequest::QGeoTiledMapRequest(QGraphicsGeoMap::ConnectivityMode connectivityMode,
+ QGraphicsGeoMap::MapType mapType,
+ qreal zoomLevel,
+ int row,
+ int column,
+ const QRect &tileRect)
+ : d_ptr(new QGeoTiledMapRequestPrivate())
+{
+ //d_ptr->mapData = mapData;
+ d_ptr->row = row;
+ d_ptr->column = column;
+ d_ptr->tileRect = tileRect;
+
+ d_ptr->zoomLevel = zoomLevel;
+ d_ptr->mapType = mapType;
+ d_ptr->connectivityMode = connectivityMode;
+}
+
+/*!
+ Constructs a tiled map request from the contents of \a other.
+*/
+QGeoTiledMapRequest::QGeoTiledMapRequest(const QGeoTiledMapRequest &other)
+ : d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys this tiled map request.
+*/
+QGeoTiledMapRequest::~QGeoTiledMapRequest() {}
+
+/*!
+ Assigns \a other to this tiled map request and then returns a reference to
+ this tiled map request.
+*/
+QGeoTiledMapRequest& QGeoTiledMapRequest::operator= (const QGeoTiledMapRequest & other)
+{
+ d_ptr = other.d_ptr;
+
+ return *this;
+}
+
+/*!
+ Returns with this tiled map request is equal to \a other.
+*/
+bool QGeoTiledMapRequest::operator== (const QGeoTiledMapRequest &other) const
+{
+ return (d_ptr->row == other.d_ptr->row) &&
+ (d_ptr->column == other.d_ptr->column) &&
+ (d_ptr->zoomLevel == other.d_ptr->zoomLevel) &&
+ (d_ptr->mapType == other.d_ptr->mapType) &&
+ (d_ptr->connectivityMode == other.d_ptr->connectivityMode);
+}
+
+/*
+ Returns the QGeoMapData instance associated with this request.
+*/
+//QGeoTiledMapData* QGeoTiledMapRequest::mapData() const
+//{
+// return d_ptr->mapData;
+//}
+
+/*!
+ Returns the connectivity mode of the tile request.
+*/
+QGraphicsGeoMap::ConnectivityMode QGeoTiledMapRequest::connectivityMode() const
+{
+ return d_ptr->connectivityMode;
+}
+
+/*!
+ Returns the map type of the requested tile.
+*/
+QGraphicsGeoMap::MapType QGeoTiledMapRequest::mapType() const
+{
+ return d_ptr->mapType;
+}
+
+/*!
+ Returns the zoom level of the requested tile.
+
+ The lower and upper bounds of the zoom level are set by
+ the QGeoMappingManager that created this request.
+*/
+int QGeoTiledMapRequest::zoomLevel() const
+{
+ return d_ptr->zoomLevel;
+}
+
+/*!
+ Returns the row of the requested tile.
+
+ At a zoom level of z the world is represented as a 2^z by 2^z grid
+ of tiles, and so the row will be between 0 and 2^z - 1.
+*/
+int QGeoTiledMapRequest::row() const
+{
+ return d_ptr->row;
+}
+
+/*!
+ Returns the column of the requested tile.
+
+ At a zoom level of z the world is represented as a 2^z by 2^z grid
+ of tiles, and so the column will be between 0 and 2^z - 1.
+*/
+int QGeoTiledMapRequest::column() const
+{
+ return d_ptr->column;
+}
+
+/*!
+ Returns the rectangle that the tile covers on the map at the maximum zoon
+ level.
+
+ At a zoom level of z the world is represented as a 2^z by 2^z grid of
+ tiles. If m is the maximum zoom level and the tiles are t by t pixel
+ squares, then the entire world could be viewed as a 2^m * t by 2^m * t
+ pixel image.
+
+ The rectangle returned is specified relative to the pixel coordinates of
+ the map at the maximum zoom level.
+*/
+QRect QGeoTiledMapRequest::tileRect() const
+{
+ return d_ptr->tileRect;
+}
+
+/*!
+ Returns a hash of the tiled map request \a key.
+*/
+uint qHash(const QGeoTiledMapRequest &key)
+{
+ uint result = QT_PREPEND_NAMESPACE(qHash)(key.row() * 13);
+ result += QT_PREPEND_NAMESPACE(qHash)(key.column() * 17);
+ result += QT_PREPEND_NAMESPACE(qHash)(key.zoomLevel() * 19);
+ result += QT_PREPEND_NAMESPACE(qHash)(static_cast<int>(key.mapType()));
+ return result;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate()
+ : QSharedData(),
+ connectivityMode(QGraphicsGeoMap::NoConnectivity),
+ mapType(QGraphicsGeoMap::NoMap),
+ zoomLevel(0),
+ row(0),
+ column(0),
+ tileRect(QRect()) {}
+//mapData(0) {}
+
+QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate(const QGeoTiledMapRequestPrivate &other)
+ : QSharedData(other),
+// mapData(other.mapData),
+ connectivityMode(other.connectivityMode),
+ mapType(other.mapType),
+ zoomLevel(other.zoomLevel),
+ row(other.row),
+ column(other.column),
+ tileRect(other.tileRect) {}
+
+QGeoTiledMapRequestPrivate::~QGeoTiledMapRequestPrivate() {}
+
+QGeoTiledMapRequestPrivate& QGeoTiledMapRequestPrivate::operator= (const QGeoTiledMapRequestPrivate & other)
+{
+// mapData = other.mapData;
+ connectivityMode = other.connectivityMode;
+ mapType = other.mapType;
+ zoomLevel = other.zoomLevel;
+ row = other.row;
+ column = other.column;
+ tileRect = other.tileRect;
+
+ return *this;
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmaprequest.h b/src/location/maps/tiled/qgeotiledmaprequest.h
new file mode 100644
index 00000000..973aeff7
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprequest.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPREQUEST_H
+#define QGEOTILEDMAPREQUEST_H
+
+#include "qgraphicsgeomap.h"
+
+#include <QRect>
+#include <QExplicitlySharedDataPointer>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoTiledMapData;
+class QGeoTiledMapRequestPrivate;
+
+class Q_LOCATION_EXPORT QGeoTiledMapRequest
+{
+public:
+ QGeoTiledMapRequest();
+ QGeoTiledMapRequest(QGraphicsGeoMap::ConnectivityMode connectivityMode,
+ QGraphicsGeoMap::MapType mapType,
+ qreal zoomLevel,
+ int row,
+ int column,
+ const QRect &tileRect);
+ QGeoTiledMapRequest(const QGeoTiledMapRequest &other);
+ ~QGeoTiledMapRequest();
+
+ QGeoTiledMapRequest& operator= (const QGeoTiledMapRequest &other);
+
+ bool operator== (const QGeoTiledMapRequest &other) const;
+
+ //QGeoTiledMapData *mapData() const;
+
+ QGraphicsGeoMap::ConnectivityMode connectivityMode() const;
+ QGraphicsGeoMap::MapType mapType() const;
+ int zoomLevel() const;
+
+ int row() const;
+ int column() const;
+ QRect tileRect() const;
+
+private:
+ QExplicitlySharedDataPointer<QGeoTiledMapRequestPrivate> d_ptr;
+};
+
+Q_LOCATION_EXPORT uint qHash(const QGeoTiledMapRequest &key);
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmaprequest_p.h b/src/location/maps/tiled/qgeotiledmaprequest_p.h
new file mode 100644
index 00000000..b3f32f87
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprequest_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPREQUEST_P_H
+#define QGEOTILEDMAPREQUEST_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgraphicsgeomap.h"
+
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+//class QGeoTiledMapData;
+
+class QGeoTiledMapRequestPrivate : public QSharedData
+{
+public:
+ QGeoTiledMapRequestPrivate();
+ QGeoTiledMapRequestPrivate(const QGeoTiledMapRequestPrivate &other);
+ ~QGeoTiledMapRequestPrivate();
+
+ QGeoTiledMapRequestPrivate& operator= (const QGeoTiledMapRequestPrivate &other);
+
+ //QGeoTiledMapData *mapData;
+ QGraphicsGeoMap::ConnectivityMode connectivityMode;
+ QGraphicsGeoMap::MapType mapType;
+ int zoomLevel;
+ int row;
+ int column;
+ QRect tileRect;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp
new file mode 100644
index 00000000..1ee9e5b7
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmaprouteobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomaprouteobject.h"
+
+#include "qgeoroutesegment.h"
+
+#include <QPointF>
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapRouteObjectInfo::QGeoTiledMapRouteObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ route = static_cast<QGeoMapRouteObject*>(mapObject);
+
+ connect(route,
+ SIGNAL(routeChanged(QGeoRoute)),
+ this,
+ SLOT(routeChanged(QGeoRoute)));
+ connect(route,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+ connect(route,
+ SIGNAL(detailLevelChanged(quint32)),
+ this,
+ SLOT(detailLevelChanged(quint32)));
+
+ pathItem = new QGraphicsPathItem();
+ graphicsItem = pathItem;
+
+ routeChanged(route->route());
+ penChanged(route->pen());
+ routeChanged(route->route());
+}
+
+QGeoTiledMapRouteObjectInfo::~QGeoTiledMapRouteObjectInfo() {}
+
+void QGeoTiledMapRouteObjectInfo::routeChanged(const QGeoRoute &/*route*/)
+{
+ regenPath();
+ updateItem();
+}
+
+void QGeoTiledMapRouteObjectInfo::penChanged(const QPen &/*pen*/)
+{
+ pathItem->setPen(route->pen());
+ updateItem();
+}
+
+void QGeoTiledMapRouteObjectInfo::detailLevelChanged(quint32 /*detailLevel*/)
+{
+ updateItem();
+}
+
+void QGeoTiledMapRouteObjectInfo::regenPath()
+{
+ QList<QGeoCoordinate> path;
+
+ QGeoRouteSegment segment = route->route().firstRouteSegment();
+ while (segment.isValid()) {
+ path.append(segment.path());
+ segment = segment.nextRouteSegment();
+ }
+
+ QPainterPath pth;
+
+ if (path.size() > 0) {
+ double oldx = 0.0;
+ double oldy = 0.0;
+
+ for (int i = 0; i < path.size(); ++i) {
+ double x = path.at(i).longitude() * 3600.0;
+ double y = path.at(i).latitude() * 3600.0;
+ if (i == 0) {
+ pth.moveTo(x, y);
+ } else {
+ if (qAbs(x - oldx) > 180.0 * 3600.0) {
+ if (x > oldx) {
+ x -= 360.0 * 3600.0;
+ } else if (x < oldx) {
+ x += 360.0 * 3600.0;
+ }
+ }
+
+ pth.lineTo(x, y);
+ }
+
+ oldx = x;
+ oldy = y;
+ }
+ }
+
+ pathItem->setPath(pth);
+}
+
+#include "moc_qgeotiledmaprouteobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h
new file mode 100644
index 00000000..5489aca1
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPROUTEOBJECT_INFO_P_H
+#define QGEOTILEDMAPROUTEOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+
+#include "qgeoroute.h"
+
+#include <QPen>
+
+class QGraphicsPathItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapRouteObject;
+
+class QGeoTiledMapRouteObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapRouteObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapRouteObjectInfo();
+
+ QGeoMapRouteObject *route;
+ QGraphicsPathItem *pathItem;
+
+public slots:
+ void routeChanged(const QGeoRoute &route);
+ void penChanged(const QPen &pen);
+ void detailLevelChanged(quint32 detailLevel);
+
+private:
+ void regenPath();
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPROUTEOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp
new file mode 100644
index 00000000..19c46061
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmaptextobjectinfo_p.h"
+
+#include "qgeotiledmapdata.h"
+#include "qgeotiledmapdata_p.h"
+
+#include "qgeomaptextobject.h"
+
+#include <QFontMetrics>
+
+QTM_BEGIN_NAMESPACE
+
+QGeoTiledMapTextObjectInfo::QGeoTiledMapTextObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
+ : QGeoTiledMapObjectInfo(mapData, mapObject)
+{
+ text = static_cast<QGeoMapTextObject*>(mapObject);
+
+ connect(text,
+ SIGNAL(textChanged(QString)),
+ this,
+ SLOT(textChanged(QString)));
+ connect(text,
+ SIGNAL(fontChanged(QFont)),
+ this,
+ SLOT(fontChanged(QFont)));
+ connect(text,
+ SIGNAL(penChanged(QPen)),
+ this,
+ SLOT(penChanged(QPen)));
+ connect(text,
+ SIGNAL(brushChanged(QBrush)),
+ this,
+ SLOT(brushChanged(QBrush)));
+ connect(text,
+ SIGNAL(offsetChanged(QPoint)),
+ this,
+ SLOT(offsetChanged(QPoint)));
+ connect(text,
+ SIGNAL(alignmentChanged(Qt::Alignment)),
+ this,
+ SLOT(alignmentChanged(Qt::Alignment)));
+
+ textItem = new QGraphicsSimpleTextItem();
+ graphicsItem = textItem;
+
+ penChanged(text->pen());
+ brushChanged(text->brush());
+ originChanged(text->origin());
+ fontChanged(text->font());
+ textChanged(text->text());
+}
+
+QGeoTiledMapTextObjectInfo::~QGeoTiledMapTextObjectInfo() {}
+
+void QGeoTiledMapTextObjectInfo::textChanged(const QString &/*text*/)
+{
+ textItem->setText(text->text());
+ doAlignment();
+ updateItem();
+}
+
+void QGeoTiledMapTextObjectInfo::fontChanged(const QFont &/*font*/)
+{
+ textItem->setFont(text->font());
+ doAlignment();
+ updateItem();
+}
+
+void QGeoTiledMapTextObjectInfo::offsetChanged(const QPoint &/*offset*/)
+{
+ doAlignment();
+ updateItem();
+}
+
+void QGeoTiledMapTextObjectInfo::alignmentChanged(Qt::Alignment /*alignment*/)
+{
+ doAlignment();
+ updateItem();
+}
+
+void QGeoTiledMapTextObjectInfo::penChanged(const QPen &/*pen*/)
+{
+ textItem->setPen(text->pen());
+ doAlignment();
+ updateItem();
+}
+
+void QGeoTiledMapTextObjectInfo::brushChanged(const QBrush &/*brush*/)
+{
+ if (textItem) {
+ textItem->setBrush(text->brush());
+ doAlignment();
+ updateItem();
+ }
+}
+
+void QGeoTiledMapTextObjectInfo::doAlignment()
+{
+ Qt::Alignment align = text->alignment();
+ QTransform trans;
+ textItem->setTransform(trans);
+
+ QRectF rect = textItem->boundingRect();
+ QPointF center = rect.center();
+
+ if (align & Qt::AlignVCenter) {
+ trans.translate(0, -1 * center.y());
+ } else if (align & Qt::AlignTop) {
+ trans.translate(0, -1 * rect.top());
+ } else if (align & Qt::AlignBottom) {
+ trans.translate(0, -1 * rect.bottom());
+ }
+ if (align & Qt::AlignHCenter) {
+ trans.translate(-1 * center.x(), 0);
+ } else if (align & Qt::AlignLeft) {
+ trans.translate(-1 * rect.left(), 0);
+ } else if (align & Qt::AlignRight) {
+ trans.translate(-1 * rect.right(), 0);
+ }
+
+ QPoint offset = text->offset();
+ trans.translate(offset.x(), offset.y());
+ textItem->setTransform(trans);
+}
+
+#include "moc_qgeotiledmaptextobjectinfo_p.cpp"
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h
new file mode 100644
index 00000000..c7215d65
--- /dev/null
+++ b/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPTEXTOBJECT_INFO_P_H
+#define QGEOTILEDMAPTEXTOBJECT_INFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeotiledmapobjectinfo_p.h"
+#include "qgeoboundingbox.h"
+
+#include <QFont>
+#include <QPen>
+#include <QBrush>
+
+class QGraphicsSimpleTextItem;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoMapTextObject;
+
+class QGeoTiledMapTextObjectInfo : public QGeoTiledMapObjectInfo
+{
+ Q_OBJECT
+public:
+ QGeoTiledMapTextObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
+ ~QGeoTiledMapTextObjectInfo();
+
+ QGeoMapTextObject* text;
+ QGraphicsSimpleTextItem *textItem;
+
+public slots:
+ void textChanged(const QString &text);
+ void fontChanged(const QFont &font);
+ void penChanged(const QPen &pen);
+ void brushChanged(const QBrush &brush);
+ void offsetChanged(const QPoint &offset);
+ void alignmentChanged(Qt::Alignment alignment);
+
+private:
+ void doAlignment();
+};
+
+QTM_END_NAMESPACE
+
+#endif //QGEOTILEDMAPTEXTOBJECT_INFO_P_H
+
diff --git a/src/location/maps/tiled/tiled.pri b/src/location/maps/tiled/tiled.pri
new file mode 100644
index 00000000..c6a2c108
--- /dev/null
+++ b/src/location/maps/tiled/tiled.pri
@@ -0,0 +1,40 @@
+
+INCLUDEPATH += maps/tiled
+
+PUBLIC_HEADERS += \
+ maps/tiled/qgeotiledmapdata.h \
+ maps/tiled/qgeotiledmappingmanagerengine.h \
+ maps/tiled/qgeotiledmapreply.h \
+ maps/tiled/qgeotiledmaprequest.h
+
+PRIVATE_HEADERS += \
+ maps/tiled/qgeotiledmapdata_p.h \
+ maps/tiled/qgeotiledmapobjectinfo_p.h \
+ maps/tiled/qgeotiledmapcircleobjectinfo_p.h \
+ maps/tiled/qgeotiledmapcustomobjectinfo_p.h \
+ maps/tiled/qgeotiledmapgroupobjectinfo_p.h \
+ maps/tiled/qgeotiledmappixmapobjectinfo_p.h \
+ maps/tiled/qgeotiledmappolygonobjectinfo_p.h \
+ maps/tiled/qgeotiledmappolylineobjectinfo_p.h \
+ maps/tiled/qgeotiledmaprectangleobjectinfo_p.h \
+ maps/tiled/qgeotiledmaprouteobjectinfo_p.h \
+ maps/tiled/qgeotiledmaptextobjectinfo_p.h \
+ maps/tiled/qgeotiledmappingmanagerengine_p.h \
+ maps/tiled/qgeotiledmapreply_p.h \
+ maps/tiled/qgeotiledmaprequest_p.h
+
+SOURCES += \
+ maps/tiled/qgeotiledmapdata.cpp \
+ maps/tiled/qgeotiledmapobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmaptextobjectinfo_p.cpp \
+ maps/tiled/qgeotiledmappingmanagerengine.cpp \
+ maps/tiled/qgeotiledmapreply.cpp \
+ maps/tiled/qgeotiledmaprequest.cpp
diff --git a/src/location/notificationcallback_s60_p.h b/src/location/notificationcallback_s60_p.h
new file mode 100644
index 00000000..8350ba25
--- /dev/null
+++ b/src/location/notificationcallback_s60_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOTIFICATIONCALLBACK_H
+#define NOTIFICATIONCALLBACK_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qmobilityglobal.h>
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+#include <lbscommon.h>
+
+QTM_BEGIN_NAMESPACE
+
+class INotificationCallback
+{
+public:
+
+ virtual void updateDeviceStatus(void) = 0 ;
+
+ virtual void updatePosition(HPositionGenericInfo *mPosInfo, int error) = 0 ;
+};
+
+QTM_END_NAMESPACE
+
+#endif // NOTIFICATIONCALLBACK_H
diff --git a/src/location/notificationmonitorcallback_s60_p.h b/src/location/notificationmonitorcallback_s60_p.h
new file mode 100644
index 00000000..42bc1dc3
--- /dev/null
+++ b/src/location/notificationmonitorcallback_s60_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef NOTIFICATIONMONITORCALLBACK_H_
+#define NOTIFICATIONMONITORCALLBACK_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qmobilityglobal.h>
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+
+QTM_BEGIN_NAMESPACE
+
+class INotificationMonitorCallback
+{
+public:
+ //callback called for trigger change event
+ virtual void handleTriggerEvent(TPositionInfo aPosInfo, enTriggerType aStatus) = 0;
+
+};
+
+QTM_END_NAMESPACE
+
+#endif /* NOTIFICATIONMONITORCALLBACK_H_ */
diff --git a/src/location/notificationsatellitecallback_s60_p.h b/src/location/notificationsatellitecallback_s60_p.h
new file mode 100644
index 00000000..506c3510
--- /dev/null
+++ b/src/location/notificationsatellitecallback_s60_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOTIFICATIONSATELLITECALLBACK_H_
+#define NOTIFICATIONSATELLITECALLBACK_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+#include <lbscommon.h>
+#include <lbssatellite.h>
+
+QTM_BEGIN_NAMESPACE
+
+class INotificationSatelliteCallback
+{
+public:
+
+ virtual void updateDeviceStatus(void) = 0 ;
+
+ virtual void updatePosition(TPositionSatelliteInfo &aSatInfo, int error, bool isStartUpdate) = 0 ;
+};
+
+QTM_END_NAMESPACE
+
+#endif /* NOTIFICATIONSATELLITECALLBACK_H_ */
diff --git a/src/location/projwrapper_p.cpp b/src/location/projwrapper_p.cpp
new file mode 100644
index 00000000..07dade3b
--- /dev/null
+++ b/src/location/projwrapper_p.cpp
@@ -0,0 +1,267 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "projwrapper_p.h"
+#include <proj_api.h>
+#include <QSharedData>
+#include <QString>
+#include <QPolygonF>
+#include <QPointF>
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+class ProjCoordinateSystemPrivate : public QSharedData
+{
+public:
+ ProjCoordinateSystemPrivate(const QString &projection, bool latLon);
+ ProjCoordinateSystemPrivate(const ProjCoordinateSystemPrivate &other);
+ ~ProjCoordinateSystemPrivate();
+
+ projPJ projection;
+ bool latLon;
+};
+
+ProjCoordinateSystemPrivate::ProjCoordinateSystemPrivate(const QString &projStr, bool isLatLon)
+{
+ projection = pj_init_plus(projStr.toLatin1().constData());
+ Q_ASSERT_X(projection, "pj_init_plus", "invalid projection string");
+ latLon = isLatLon;
+}
+
+ProjCoordinateSystemPrivate::ProjCoordinateSystemPrivate(const ProjCoordinateSystemPrivate &other) :
+ QSharedData(other),
+ latLon(other.latLon)
+{
+ char *str = pj_get_def(other.projection, 0);
+ projection = pj_init_plus(str);
+ Q_ASSERT_X(projection, "pj_init_plus", "invalid projection string");
+ free(str);
+}
+
+ProjCoordinateSystemPrivate::~ProjCoordinateSystemPrivate()
+{
+ pj_free(projection);
+}
+
+ProjCoordinateSystem::ProjCoordinateSystem(const QString &projection, bool latLon) :
+ d(new ProjCoordinateSystemPrivate(projection, latLon))
+{}
+
+ProjCoordinateSystem::ProjCoordinateSystem(const ProjCoordinateSystem &other) :
+ d(other.d)
+{}
+
+ProjCoordinateSystem::~ProjCoordinateSystem()
+{}
+
+bool ProjCoordinateSystem::isLatLon() const
+{
+ return d->latLon;
+}
+
+class ProjCoordinatePrivate
+{
+public:
+ ProjCoordinateSystem currentSystem;
+ double x;
+ double y;
+ double z;
+};
+
+ProjCoordinate::ProjCoordinate(double x, double y, double z, const ProjCoordinateSystem &system) :
+ d(new ProjCoordinatePrivate)
+{
+ d->x = x;
+ d->y = y;
+ d->z = z;
+ d->currentSystem = system;
+}
+
+ProjCoordinate::ProjCoordinate(const ProjCoordinate &other) :
+ d(new ProjCoordinatePrivate)
+{
+ *this = other;
+}
+
+ProjCoordinate &ProjCoordinate::operator=(const ProjCoordinate &other)
+{
+ d->x = other.d->x;
+ d->y = other.d->y;
+ d->z = other.d->z;
+ d->currentSystem = other.d->currentSystem;
+ return *this;
+}
+
+ProjCoordinate::~ProjCoordinate()
+{
+ delete d;
+}
+
+double ProjCoordinate::x() const
+{
+ return d->x;
+}
+
+double ProjCoordinate::y() const
+{
+ return d->y;
+}
+
+double ProjCoordinate::z() const
+{
+ return d->z;
+}
+
+bool ProjCoordinate::convert(const ProjCoordinateSystem &system)
+{
+ int result;
+ double x = d->x, y = d->y, z = d->z;
+
+ if (d->currentSystem.isLatLon()) {
+ x *= DEG_TO_RAD;
+ y *= DEG_TO_RAD;
+ }
+
+ result = pj_transform(d->currentSystem.d->projection,
+ system.d->projection,
+ 1, 1, &x, &y, &z);
+ if (result) {
+ return false;
+ } else {
+ if (system.isLatLon()) {
+ x *= RAD_TO_DEG;
+ y *= RAD_TO_DEG;
+ }
+ d->x = x;
+ d->y = y;
+ d->z = z;
+ d->currentSystem = system;
+ return true;
+ }
+}
+
+QGeoCoordinate ProjCoordinate::toGeoCoordinate() const
+{
+ double x = d->x;
+ double y = d->y;
+
+ if (x < -180.0)
+ x = -180.0;
+ if (x > 180.0)
+ x = 180.0;
+
+ if (y < -90.0)
+ y = -90.0;
+ if (y > 90.0)
+ y = 90.0;
+
+ return QGeoCoordinate(y, x, d->z);
+}
+
+class ProjPolygonPrivate
+{
+public:
+ ProjCoordinateSystem currentSystem;
+};
+
+ProjPolygon::ProjPolygon(const ProjCoordinateSystem &system) :
+ QList<ProjCoordinate>(),
+ d(new ProjPolygonPrivate)
+{
+ d->currentSystem = system;
+}
+
+ProjPolygon::ProjPolygon(const QPolygonF &poly, const ProjCoordinateSystem &system, double scale) :
+ QList<ProjCoordinate>(),
+ d(new ProjPolygonPrivate)
+{
+ d->currentSystem = system;
+ foreach (QPointF point, poly) {
+ double x = point.x();
+ x /= scale;
+ double y = point.y();
+ y /= scale;
+ append(ProjCoordinate(x, y, 0.0, system));
+ }
+}
+
+ProjPolygon::~ProjPolygon()
+{
+ delete d;
+}
+
+bool ProjPolygon::convert(const ProjCoordinateSystem &system)
+{
+ for (int i=0; i<size(); ++i) {
+ ProjCoordinate coord = at(i);
+ if (!coord.convert(system))
+ return false;
+ replace(i, coord);
+ }
+
+ d->currentSystem = system;
+ return true;
+}
+
+void ProjPolygon::scalarMultiply(double sx, double sy, double sz)
+{
+ for (int i=0; i<size(); ++i) {
+ ProjCoordinate &c = operator [](i);
+ c.d->x *= sx;
+ c.d->y *= sy;
+ c.d->z *= sz;
+ }
+}
+
+QPolygonF ProjPolygon::toPolygonF(double scale) const
+{
+ QPolygonF poly;
+ for (int i=0; i<size(); ++i) {
+ const ProjCoordinate &coord = at(i);
+ double x = coord.x() * scale;
+ double y = coord.y() * scale;
+ poly << QPointF(x, y);
+ }
+ return poly;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/projwrapper_p.h b/src/location/projwrapper_p.h
new file mode 100644
index 00000000..e0307dba
--- /dev/null
+++ b/src/location/projwrapper_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef PROJWRAPPER_P_H
+#define PROJWRAPPER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include <QSharedDataPointer>
+#include <QString>
+#include <QList>
+#include <QPolygonF>
+
+QTM_BEGIN_NAMESPACE
+
+class ProjCoordinate;
+class QGeoCoordinate;
+
+class ProjCoordinateSystemPrivate;
+class ProjCoordinateSystem
+{
+public:
+ ProjCoordinateSystem(const QString &projection = QString("+proj=latlon +ellps=WGS84"), bool latLon=true);
+ ProjCoordinateSystem(const ProjCoordinateSystem &other);
+ ~ProjCoordinateSystem();
+
+ bool isLatLon() const;
+
+private:
+ QSharedDataPointer<ProjCoordinateSystemPrivate> d;
+
+ friend class ProjCoordinate;
+};
+
+class ProjPolygon;
+
+class ProjCoordinatePrivate;
+class ProjCoordinate
+{
+public:
+ ProjCoordinate(double x, double y, double z, const ProjCoordinateSystem &system);
+ ProjCoordinate(const ProjCoordinate &other);
+ ~ProjCoordinate();
+
+ double x() const;
+ double y() const;
+ double z() const;
+
+ QGeoCoordinate toGeoCoordinate() const;
+
+ bool convert(const ProjCoordinateSystem &system);
+
+ ProjCoordinate &operator=(const ProjCoordinate &other);
+
+private:
+ ProjCoordinatePrivate *d;
+
+ friend class ProjPolygon;
+};
+
+class ProjPolygonPrivate;
+class ProjPolygon : public QList<ProjCoordinate>
+{
+public:
+ ProjPolygon(const ProjCoordinateSystem &system);
+ ProjPolygon(const QPolygonF &poly, const ProjCoordinateSystem &system, double scale=1.0);
+ ~ProjPolygon();
+
+ void scalarMultiply(double sx, double sy, double sz);
+
+ bool convert(const ProjCoordinateSystem &system);
+ QPolygonF toPolygonF(double scale=1.0) const;
+
+private:
+ ProjPolygonPrivate *d;
+};
+
+QTM_END_NAMESPACE
+
+#endif // PROJWRAPPER_P_H
diff --git a/src/location/qgeoaddress.cpp b/src/location/qgeoaddress.cpp
new file mode 100644
index 00000000..e01402d6
--- /dev/null
+++ b/src/location/qgeoaddress.cpp
@@ -0,0 +1,322 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoaddress.h"
+#include "qgeoaddress_p.h"
+
+#ifdef QGEOADDRESS_DEBUG
+#include <QDebug>
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+QGeoAddressPrivate::QGeoAddressPrivate()
+ : QSharedData()
+{
+}
+
+QGeoAddressPrivate::QGeoAddressPrivate(const QGeoAddressPrivate &other)
+ : QSharedData(other),
+ sCountry(other.sCountry),
+ sCountryCode(other.sCountryCode),
+ sState(other.sState),
+ sCounty(other.sCounty),
+ sCity(other.sCity),
+ sDistrict(other.sDistrict),
+ sStreet(other.sStreet),
+ sPostCode(other.sPostCode)
+{
+}
+
+QGeoAddressPrivate::~QGeoAddressPrivate()
+{
+}
+
+/*!
+ \class QGeoAddress
+ \brief The QGeoAddress class represents an address
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup location
+
+ This class represents an address of a location.
+*/
+
+/*!
+ Default constructor.
+*/
+QGeoAddress::QGeoAddress()
+ : d(new QGeoAddressPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QGeoAddress::QGeoAddress(const QGeoAddress &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys this address.
+*/
+QGeoAddress::~QGeoAddress()
+{
+}
+
+/*!
+ Assigns the given \a address to this address and
+ returns a reference to this address.
+*/
+QGeoAddress &QGeoAddress::operator=(const QGeoAddress & address)
+{
+ d = address.d;
+ return *this;
+}
+
+/*!
+ Returns true if this address is equal to \a other,
+ otherwise returns false.
+*/
+bool QGeoAddress::operator==(const QGeoAddress &other) const
+{
+#ifdef QGEOADDRESS_DEBUG
+ qDebug() << "country" << (d->sCountry == other.country());
+ qDebug() << "countryCode" << (d->sCountryCode == other.countryCode());
+ qDebug() << "state:" << (d->sState == other.state());
+ qDebug() << "county:" << (d->sCounty == other.county());
+ qDebug() << "city:" << (d->sCity == other.city());
+ qDebug() << "district:" << (d->sDistrict == other.district());
+ qDebug() << "street:" << (d->sStreet == other.street());
+ qDebug() << "postcode:" << (d->sPostCode == other.postcode());
+#endif
+
+ return d->sCountry == other.country() &&
+ d->sCountryCode == other.countryCode() &&
+ d->sState == other.state() &&
+ d->sCounty == other.county() &&
+ d->sCity == other.city() &&
+ d->sDistrict == other.district() &&
+ d->sStreet == other.street() &&
+ d->sPostCode == other.postcode();
+}
+
+/*!
+ \fn bool QGeoAddress::operator!=(const QGeoAddress &other) const
+
+ Returns true if this address is not equal to \a other,
+ otherwise returns false.
+*/
+
+/*!
+ Returns the country name.
+*/
+QString QGeoAddress::country() const
+{
+ return d->sCountry;
+}
+
+/*!
+ Sets the \a country name.
+*/
+void QGeoAddress::setCountry(const QString &country)
+{
+ d->sCountry = country;
+}
+
+/*!
+ Returns the country code according to ISO 3166-1 alpha-3
+*/
+QString QGeoAddress::countryCode() const
+{
+ return d->sCountryCode;
+}
+
+/*!
+ Sets the \a countryCode according to ISO 3166-1 alpha-3
+*/
+void QGeoAddress::setCountryCode(const QString &countryCode)
+{
+ d->sCountryCode = countryCode;
+}
+
+/*!
+ Returns the state. The state is considered the first subdivision below country.
+*/
+QString QGeoAddress::state() const
+{
+ return d->sState;
+}
+
+/*!
+ Sets the \a state.
+*/
+void QGeoAddress::setState(const QString &state)
+{
+ d->sState = state;
+}
+
+/*!
+ Returns the county. The county is considered the second subdivision below country.
+*/
+QString QGeoAddress::county() const
+{
+ return d->sCounty;
+}
+
+/*!
+ Sets the \a county.
+*/
+void QGeoAddress::setCounty(const QString &county)
+{
+ d->sCounty = county;
+}
+
+/*!
+ Returns the city.
+*/
+QString QGeoAddress::city() const
+{
+ return d->sCity;
+}
+
+/*!
+ Sets the \a city.
+*/
+void QGeoAddress::setCity(const QString &city)
+{
+ d->sCity = city;
+}
+
+/*!
+ Returns the district. The district is considered the subdivison below city.
+*/
+QString QGeoAddress::district() const
+{
+ return d->sDistrict;
+}
+
+/*!
+ Sets the \a district.
+*/
+void QGeoAddress::setDistrict(const QString &district)
+{
+ d->sDistrict = district;
+}
+
+/*!
+ Returns the street-level component of the address.
+
+ This typically includes a street number and street name
+ but may also contain things like a unit number, a building
+ name, or anything else that might be used to
+ distinguish one address from another.
+*/
+QString QGeoAddress::street() const
+{
+ return d->sStreet;
+}
+
+/*!
+ Sets the street-level component of the address to \a street.
+
+ This typically includes a street number and street name
+ but may also contain things like a unit number, a building
+ name, or anything else that might be used to
+ distinguish one address from another.
+*/
+void QGeoAddress::setStreet(const QString &street)
+{
+ d->sStreet = street;
+}
+
+/*!
+ Returns the post code.
+*/
+QString QGeoAddress::postcode() const
+{
+ return d->sPostCode;
+}
+
+/*!
+ Sets the \a postcode.
+*/
+void QGeoAddress::setPostcode(const QString &postcode)
+{
+ d->sPostCode = postcode;
+}
+
+/*!
+ Returns whether this address is empty. An address is considered empty
+ if \i all of its fields are empty.
+*/
+bool QGeoAddress::isEmpty() const
+{
+ return d->sCountry.isEmpty() &&
+ d->sCountryCode.isEmpty() &&
+ d->sState.isEmpty() &&
+ d->sCounty.isEmpty() &&
+ d->sCity.isEmpty() &&
+ d->sDistrict.isEmpty() &&
+ d->sStreet.isEmpty() &&
+ d->sPostCode.isEmpty();
+}
+/*!
+ Clears the all the address' data fields.
+*/
+void QGeoAddress::clear()
+{
+ d->sCountry.clear();
+ d->sCountryCode.clear();
+ d->sState.clear();
+ d->sCounty.clear();
+ d->sCity.clear();
+ d->sDistrict.clear();
+ d->sStreet.clear();
+ d->sPostCode.clear();
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeoaddress.h b/src/location/qgeoaddress.h
new file mode 100644
index 00000000..f05a657b
--- /dev/null
+++ b/src/location/qgeoaddress.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOADDRESS_H
+#define QGEOADDRESS_H
+
+#include "qmobilityglobal.h"
+#include <QSharedDataPointer>
+
+class QString;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoAddressPrivate;
+class Q_LOCATION_EXPORT QGeoAddress
+{
+public:
+ QGeoAddress();
+ QGeoAddress(const QGeoAddress &other);
+ ~QGeoAddress();
+
+ QGeoAddress &operator=(const QGeoAddress &other);
+ bool operator==(const QGeoAddress &other) const;
+ bool operator!=(const QGeoAddress &other) const {
+ return !(other == *this);
+ }
+
+ QString country() const;
+ void setCountry(const QString &country);
+
+ QString countryCode() const;
+ void setCountryCode(const QString &countryCode);
+
+ QString state() const;
+ void setState(const QString &state);
+
+ QString county() const;
+ void setCounty(const QString &county);
+
+ QString city() const;
+ void setCity(const QString &city);
+
+ QString district() const;
+ void setDistrict(const QString &district);
+
+ QString street() const;
+ void setStreet(const QString &street);
+
+ QString postcode() const;
+ void setPostcode(const QString &postcode);
+
+ bool isEmpty() const;
+ void clear();
+
+private:
+ QSharedDataPointer<QGeoAddressPrivate> d;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeoaddress_p.h b/src/location/qgeoaddress_p.h
new file mode 100644
index 00000000..54b8c800
--- /dev/null
+++ b/src/location/qgeoaddress_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLOCATION_GEOADDRESS_P_H
+#define QLOCATION_GEOADDRESS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QString>
+#include <QSharedData>
+
+#include "qmobilityglobal.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoAddressPrivate : public QSharedData
+{
+public:
+ QGeoAddressPrivate();
+ QGeoAddressPrivate(const QGeoAddressPrivate &other);
+ ~QGeoAddressPrivate();
+
+ QString sCountry; //!< country field
+ QString sCountryCode; //!< country code field
+ QString sState; //!< state field
+ QString sCounty; //!< county field
+ QString sCity; //!< city field
+ QString sDistrict; //!< district field
+ QString sStreet; //!< street name field
+ QString sPostCode; //!< post code field
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeoareamonitor.cpp b/src/location/qgeoareamonitor.cpp
new file mode 100644
index 00000000..6917bdd6
--- /dev/null
+++ b/src/location/qgeoareamonitor.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgeoareamonitor.h"
+
+#if defined(Q_OS_SYMBIAN) && defined(QT_LOCATION_S60_MONITORING)
+#include "qgeoareamonitor_s60_p.h"
+#endif
+#include "qgeoareamonitor_polling_p.h"
+
+/*!
+ \class QGeoAreaMonitor
+ \brief The QGeoAreaMonitor class enables the detection of proximity
+ changes for a specified set of coordinates.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ A QGeoAreaMonitor emits signals when the current position is in
+ range, or has moved out of range, of a specified circular area.
+ The area is specified by a coordinate (the center point) and a
+ radius (in meters).
+
+ For example:
+
+ \code
+ public:
+ MyClass::MyClass()
+ {
+ QGeoAreaMonitor *monitor = QGeoAreaMonitor::createDefaultMonitor();
+ connect(monitor, SIGNAL(areaEntered(QGeoPositionInfo)),
+ this, SLOT(areaEntered(QGeoPositionInfo)));
+ connect(monitor, SIGNAL(areaExited(QGeoPositionInfo)),
+ this, SLOT(areaExited(QGeoPositionInfo)));
+
+ QGeoCoordinate bigBenLocation(51.50104, -0.124632);
+ monitor->setCenter(bigBenLocation);
+ monitor->setRadius(100);
+ }
+
+ public Q_SLOTS:
+ void areaEntered(const QGeoPositionInfo &update)
+ {
+ qDebug() << "Now within 100 meters, current position is" << update.coordinate();
+ }
+
+ void areaExited(const QGeoPositionInfo &update)
+ {
+ qDebug() << "No longer within 100 meters, current position is" << update.coordinate();
+ }
+ \endcode
+*/
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoAreaMonitorPrivate
+{
+public:
+ QGeoCoordinate coord;
+ qreal radius;
+};
+
+
+/*!
+ Creates a monitor with the given \a parent.
+*/
+QGeoAreaMonitor::QGeoAreaMonitor(QObject *parent)
+ : QObject(parent),
+ d(new QGeoAreaMonitorPrivate)
+{
+ d->radius = qreal(0.0);
+}
+
+/*!
+ Destroys the monitor.
+*/
+QGeoAreaMonitor::~QGeoAreaMonitor()
+{
+ delete d;
+}
+
+/*!
+ \property QGeoAreaMonitor::center
+ \brief holds the center of the area to be monitored.
+
+ When the center is set, if the radius has already been set and
+ the current position is within the monitored area, areaEntered()
+ is emitted immediately.
+
+ By default, contains an invalid coordinate.
+
+ Note: Subclass implementations must call the base implementation of
+ setCenter() so that center() returns the correct value.
+*/
+void QGeoAreaMonitor::setCenter(const QGeoCoordinate &coordinate)
+{
+ d->coord = coordinate;
+}
+
+QGeoCoordinate QGeoAreaMonitor::center() const
+{
+ return d->coord;
+}
+
+/*!
+ \property QGeoAreaMonitor::radius
+ \brief holds the radius of the area to be monitored, in meters.
+
+ If the specified radius is less than the minimum supported radius, the
+ radius is set to the minimum radius.
+
+ When this property is set, if the center coordinate has already been set and
+ the current position is within the monitored area, areaEntered()
+ is emitted immediately.
+
+ By default, this property is 0.
+
+ Note: Subclass implementations must call the base implementation of
+ setRadius() so that radius() returns the correct value.
+*/
+void QGeoAreaMonitor::setRadius(qreal radius)
+{
+ d->radius = radius;
+}
+
+qreal QGeoAreaMonitor::radius() const
+{
+ return d->radius;
+}
+
+/*!
+ Creates and returns a monitor with the given \a parent that
+ monitors areas using resources on the underlying system.
+
+ Returns 0 if the system has no support for position monitoring.
+
+ Note: Symbian applications will need to have the Location capability
+ otherwise this will return 0.
+*/
+QGeoAreaMonitor *QGeoAreaMonitor::createDefaultMonitor(QObject *parent)
+{
+ // Native Symbian area monitor is temporarily disabled,
+ // see http://bugreports.qt.nokia.com/browse/QTMOBILITY-1059
+//#if defined(Q_OS_SYMBIAN) && defined(QT_LOCATION_S60_MONITORING)
+// QGeoAreaMonitor *ret = NULL;
+// TRAPD(error, ret = QGeoAreaMonitorS60::NewL(parent));
+// return ret;
+//#else
+ QGeoAreaMonitorPolling *ret = NULL;
+ ret = new QGeoAreaMonitorPolling(parent);
+ if (ret && ret->isValid())
+ return ret;
+//#endif
+ return 0;
+}
+
+/*!
+ \fn void QGeoAreaMonitor::areaEntered(const QGeoPositionInfo &update);
+
+ Emitted when the current position has moved from a position outside the
+ monitored area to a position within the monitored area.
+
+ The \a update holds the new position.
+*/
+
+/*!
+ \fn void QGeoAreaMonitor::areaExited(const QGeoPositionInfo &update);
+
+ Emitted when the current position has moved from a position within the
+ monitored area to a position outside the monitored area.
+
+ The \a update holds the new position.
+*/
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeoareamonitor.h b/src/location/qgeoareamonitor.h
new file mode 100644
index 00000000..54737f68
--- /dev/null
+++ b/src/location/qgeoareamonitor.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOAREAMONITOR_H
+#define QGEOAREAMONITOR_H
+
+#include "qmobilityglobal.h"
+#include "qgeocoordinate.h"
+
+#include <QObject>
+
+QT_BEGIN_HEADER
+
+#ifdef Q_QDOC
+//normally we would use macro only but this causes some other compilation issues
+QTM_BEGIN_NAMESPACE
+#else
+namespace QtMobility
+{
+#endif
+
+
+class QGeoPositionInfo;
+class QGeoAreaMonitorPrivate;
+class Q_LOCATION_EXPORT QGeoAreaMonitor : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
+ Q_PROPERTY(qreal radius READ radius WRITE setRadius)
+
+public:
+ explicit QGeoAreaMonitor(QObject *parent);
+ virtual ~QGeoAreaMonitor() = 0;
+
+ virtual void setCenter(const QGeoCoordinate &coordinate);
+ QGeoCoordinate center() const;
+
+ virtual void setRadius(qreal radius);
+ qreal radius() const;
+
+ static QGeoAreaMonitor *createDefaultMonitor(QObject *parent);
+
+Q_SIGNALS:
+ void areaEntered(const QGeoPositionInfo &update);
+ void areaExited(const QGeoPositionInfo &update);
+
+private:
+ Q_DISABLE_COPY(QGeoAreaMonitor)
+ QGeoAreaMonitorPrivate *d;
+};
+
+}
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeoareamonitor_polling.cpp b/src/location/qgeoareamonitor_polling.cpp
new file mode 100644
index 00000000..41080f98
--- /dev/null
+++ b/src/location/qgeoareamonitor_polling.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoareamonitor_polling_p.h"
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+#define UPDATE_INTERVAL_5S 5000
+
+QGeoAreaMonitorPolling::QGeoAreaMonitorPolling(QObject *parent) : QGeoAreaMonitor(parent)
+{
+ insideArea = false;
+ location = QGeoPositionInfoSource::createDefaultSource(this);
+ if (location) {
+ location->setUpdateInterval(UPDATE_INTERVAL_5S);
+ connect(location, SIGNAL(positionUpdated(QGeoPositionInfo)),
+ this, SLOT(positionUpdated(QGeoPositionInfo)));
+ }
+}
+
+QGeoAreaMonitorPolling::~QGeoAreaMonitorPolling()
+{
+ if (location)
+ location->stopUpdates();
+}
+
+void QGeoAreaMonitorPolling::setCenter(const QGeoCoordinate& coordinate)
+{
+ if (coordinate.isValid()) {
+ QGeoAreaMonitor::setCenter(coordinate);
+ checkStartStop();
+ }
+}
+
+void QGeoAreaMonitorPolling::setRadius(qreal radius)
+{
+ QGeoAreaMonitor::setRadius(radius);
+ checkStartStop();
+}
+
+void QGeoAreaMonitorPolling::connectNotify(const char *signal)
+{
+ if (signal == SIGNAL(areaEntered(QGeoPositionInfo)) ||
+ signal == SIGNAL(areaExited(QGeoPositionInfo)))
+ checkStartStop();
+}
+
+void QGeoAreaMonitorPolling::disconnectNotify(const char *signal)
+{
+ if (signal == SIGNAL(areaEntered(QGeoPositionInfo)) ||
+ signal == SIGNAL(areaExited(QGeoPositionInfo)))
+ checkStartStop();
+}
+
+void QGeoAreaMonitorPolling::checkStartStop()
+{
+ if (!location) return;
+
+ if ((QObject::receivers(SIGNAL(areaEntered(QGeoPositionInfo))) > 0 ||
+ QObject::receivers(SIGNAL(areaExited(QGeoPositionInfo))) > 0) &&
+ QGeoAreaMonitor::center().isValid() &&
+ QGeoAreaMonitor::radius() > qreal(0.0)) {
+ location->startUpdates();
+ } else {
+ location->stopUpdates();
+ }
+}
+
+void QGeoAreaMonitorPolling::positionUpdated(const QGeoPositionInfo &info)
+{
+ double distance = info.coordinate().distanceTo(QGeoAreaMonitor::center());
+
+ if (distance <= QGeoAreaMonitor::radius()) {
+ if (!insideArea)
+ emit areaEntered(info);
+ insideArea = true;
+ } else if (insideArea) {
+ emit areaExited(info);
+ insideArea = false;
+ }
+}
+
+#include "moc_qgeoareamonitor_polling_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeoareamonitor_polling_p.h b/src/location/qgeoareamonitor_polling_p.h
new file mode 100644
index 00000000..1a63a454
--- /dev/null
+++ b/src/location/qgeoareamonitor_polling_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOAREAMONITORPOLLING_H
+#define QGEOAREAMONITORPOLLING_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeoareamonitor.h"
+#include "qgeopositioninfosource.h"
+
+QTM_BEGIN_NAMESPACE
+
+/**
+ * QGeoAreaMonitorPolling
+ *
+ */
+class QGeoAreaMonitorPolling : public QGeoAreaMonitor
+{
+ Q_OBJECT
+
+public :
+ QGeoAreaMonitorPolling(QObject *parent = 0);
+ ~QGeoAreaMonitorPolling();
+ void setCenter(const QGeoCoordinate &coordinate);
+ void setRadius(qreal radius);
+
+ inline bool isValid() { return location; }
+
+private slots:
+ void positionUpdated(const QGeoPositionInfo &info);
+
+private:
+ bool insideArea;
+ QGeoPositionInfoSource *location;
+
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+
+ void checkStartStop();
+};
+
+QTM_END_NAMESPACE
+#endif // QGEOAREAMONITORPOLLING_H
diff --git a/src/location/qgeoareamonitor_s60.cpp b/src/location/qgeoareamonitor_s60.cpp
new file mode 100644
index 00000000..8878be97
--- /dev/null
+++ b/src/location/qgeoareamonitor_s60.cpp
@@ -0,0 +1,289 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "qgeoareamonitor_s60_p.h"
+#include "qgeopositioninfo.h"
+#include "qmlbackendmonitorinfo_s60_p.h"
+#include "qmlbackendmonitorcreatetriggerao_s60_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+TInt QGeoAreaMonitorS60::refCount = 0;
+
+QGeoAreaMonitorS60* QGeoAreaMonitorS60::NewL(QObject *aParent)
+{
+ RProcess thisProcess;
+ if (!thisProcess.HasCapability(ECapabilityLocation)) {
+ qWarning() << "QGeoAreaMonitor::createDefaultMonitor() requires the Symbian Location capability to succeed on the Symbian platform.";
+ return 0;
+ }
+
+ QGeoAreaMonitorS60 *self = QGeoAreaMonitorS60::NewLC(aParent);
+ CleanupStack::Pop();
+ if (!self->isValid()) {
+ delete self;
+ self = NULL;
+ }
+ return self;
+}
+
+//creates an entry and exit trigger based on the aCoordinate and
+//aRadius values passed as argument
+void QGeoAreaMonitorS60::setMonitoredArea(const QGeoCoordinate & aCoordinate, qreal aRadius)
+{
+ TCoordinate coord;
+
+ TInt ret1 = QCoordinateToTCoordinate(aCoordinate, coord);
+
+ TInt ret2 = iTriggerCreateAO->getRadius(aRadius);
+
+ if (ret2 == KErrNone)
+ QGeoAreaMonitor::setRadius(aRadius);
+
+ if ((ret1 != KErrNone) || (ret2 != KErrNone))
+ return;
+
+ //Initialize the trigger and enable the trigger if atleast one slot is connected to the areaEntered
+ //signal
+ if ((iTriggerCreateAO->InitializeTrigger(this, EntryTrigger, coord, aRadius)) &&
+ (receivers(SIGNAL(areaEntered(const QGeoPositionInfo&))) > 0)) {
+ iTriggerCreateAO->SetTriggerState(this, EntryTrigger, true);
+ iTriggerAO->NotifyFiredEvent();
+ }
+
+ //Initialize the trigger and enable the trigger if atleast one slot is connected to the areaExited
+ //signal
+ if ((iTriggerCreateAO->InitializeTrigger(this, ExitTrigger, coord, aRadius)) &&
+ (receivers(SIGNAL(areaExited(const QGeoPositionInfo&))) > 0)) {
+ iTriggerCreateAO->SetTriggerState(this, ExitTrigger, true);
+ iTriggerAO->NotifyFiredEvent();
+ }
+
+ //request for the trigger change notification events
+ iNotifyTriggerAO->NotifyChangeEvent();
+}
+
+//virtual function sets the Center of the monitoring area to coordinate
+void QGeoAreaMonitorS60::setCenter(const QGeoCoordinate& coordinate)
+{
+ if (coordinate.isValid())
+ QGeoAreaMonitor::setCenter(coordinate);
+ else
+ return;
+
+ if (QGeoAreaMonitor::radius() != 0) //if radius is not initialised
+ setMonitoredArea(coordinate, QGeoAreaMonitor::radius());
+}
+
+//virtual function sets the radius of the monitorijng area to the radius
+void QGeoAreaMonitorS60::setRadius(qreal radius)
+{
+ setMonitoredArea(QGeoAreaMonitor::center(), radius);
+}
+
+//callback from the QMLBackendMonitorAO object for the entry/exit event
+void QGeoAreaMonitorS60::handleTriggerEvent(TPositionInfo aPosInfo, enTriggerType aStatus)
+{
+ QGeoPositionInfo posInfo;
+
+ TPositionInfoToQGeoPositionInfo(aPosInfo, posInfo);
+
+ if (!posInfo.isValid())
+ return;
+
+ switch (aStatus) {
+ case EntryTrigger : //emit areaEntered trigger
+ emit areaEntered(posInfo);
+ break;
+ case ExitTrigger : //emit areaExited trigger
+ emit areaExited(posInfo);
+ break;
+ case NotifyChangesTrigger:
+ case InvalidTrigger:
+ break;
+ }
+
+}
+
+
+
+//destructor cleaning up the resources
+QGeoAreaMonitorS60::~QGeoAreaMonitorS60()
+{
+
+ if (iTriggerAO || iNotifyTriggerAO || iTriggerCreateAO) {
+ QMLBackendMonitorAO::DeleteAO(this);
+ iTriggerAO = NULL;
+ QMLBackendTriggerChangeAO::DeleteAO();
+ iNotifyTriggerAO = NULL;
+ delete iTriggerCreateAO;
+ iTriggerCreateAO = NULL;
+ }
+ if (connectedLbt) {
+ --refCount;
+ if (refCount == 0) {
+ lbtServ.Close();
+ }
+ }
+}
+
+QGeoAreaMonitorS60* QGeoAreaMonitorS60::NewLC(QObject* aParent)
+{
+ QGeoAreaMonitorS60 *self = new(ELeave) QGeoAreaMonitorS60(aParent);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+//second level construction : creating the QMLBackendMonitorAO : for
+//monitoring the trigger fired event,QMLBackendMonitorCreateTriggerAO:
+//instance object for creating the trigger and QMLBackendTriggerChangeAO :
+//for monitoring the changes to the trigger properties
+void QGeoAreaMonitorS60::ConstructL()
+{
+ if (lbtServ.Connect() == KErrNone) {
+ CleanupClosePushL(lbtServ);
+
+ connectedLbt = true;
+ ++refCount;
+
+ iTriggerAO = QMLBackendMonitorAO::NewL(lbtServ);
+
+ if (!iTriggerAO)
+ return;
+
+ iTriggerCreateAO = QMLBackendMonitorCreateTriggerAO::NewL(this, lbtServ);
+
+ if (!iTriggerCreateAO)
+ return;
+
+ iNotifyTriggerAO = QMLBackendTriggerChangeAO::NewL(lbtServ);
+
+ CleanupStack::Pop(1);
+ } else {
+ connectedLbt = false;
+ }
+}
+
+//constructor initializing the default values
+QGeoAreaMonitorS60::QGeoAreaMonitorS60(QObject* aParent) : QGeoAreaMonitor(aParent),
+ iTriggerAO(NULL), iNotifyTriggerAO(NULL)
+{
+
+}
+
+//convert a symbian-TPositionInfo value to corresponding QT-QGeoPositionInfo
+void QGeoAreaMonitorS60::TPositionInfoToQGeoPositionInfo(TPositionInfo& aPosInfo, QGeoPositionInfo& aQInfo)
+{
+ QGeoCoordinate coord;
+ TPosition pos;
+ aPosInfo.GetPosition(pos);
+
+ coord.setLatitude(pos.Latitude());
+ coord.setLongitude(pos.Longitude());
+ coord.setAltitude(pos.Altitude());
+
+ //store the QGeoCoordinate values
+ aQInfo.setCoordinate(coord);
+
+ TDateTime datetime = pos.Time().DateTime();
+ QDateTime dt(QDate(datetime.Year(), datetime.Month() + 1, datetime.Day() + 1),
+ QTime(datetime.Hour(), datetime.Minute(), datetime.Second(),
+ datetime.MicroSecond() / 1000),
+ Qt::UTC);
+
+ //store the time stamp
+ aQInfo.setTimestamp(dt);
+
+ //store the horizontal accuracy
+ aQInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
+
+ //store the vertical accuracy
+ aQInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy());
+
+}
+
+
+//convert QT-QCoordinate value to Symbian-TCoordinate value
+int QGeoAreaMonitorS60::QCoordinateToTCoordinate(const QGeoCoordinate& aQCoord, TCoordinate& aTCoord)
+{
+ if (!aQCoord.isValid())
+ return KErrGeneral;
+
+ QGeoAreaMonitor::setCenter(aQCoord);
+ aTCoord.SetCoordinate(aQCoord.latitude(), aQCoord.longitude(), aQCoord.altitude());
+ return KErrNone;
+}
+
+//Notification called when a sot is connected to the areaEntered or
+//areaExited signal
+void QGeoAreaMonitorS60::connectNotify(const char* signal)
+{
+ if ((iTriggerCreateAO->isTriggerInitialized(this, EntryTrigger)) && (QLatin1String(signal) == SIGNAL(areaEntered(QGeoPositionInfo))) && (receivers(SIGNAL(areaEntered(const QGeoPositionInfo&))) <= 1)) {
+ iTriggerCreateAO->SetTriggerState(this, EntryTrigger, true);
+ iTriggerAO-> NotifyFiredEvent();
+ }
+
+ if ((iTriggerCreateAO->isTriggerInitialized(this, ExitTrigger)) && (QLatin1String(signal) == SIGNAL(areaExited(QGeoPositionInfo))) && (receivers(SIGNAL(areaExited(const QGeoPositionInfo&))) <= 1)) {
+ iTriggerCreateAO->SetTriggerState(this, ExitTrigger, true);
+ iTriggerAO-> NotifyFiredEvent();
+ }
+}
+
+//Notification called when a sot is disconnected from the areaEntered or
+//areaExited signal
+void QGeoAreaMonitorS60::disconnectNotify(const char* signal)
+{
+ // Disable the trigger, if no slot connected to signal
+ if ((iTriggerCreateAO->isTriggerInitialized(this, EntryTrigger)) && (QLatin1String(signal) == SIGNAL(areaEntered(QGeoPositionInfo))) && (receivers(SIGNAL(areaEntered(const QGeoPositionInfo&))) == 0)) {
+ // iEnterTrigger->NotifyFiredEvent (FALSE);
+ iTriggerCreateAO->SetTriggerState(this, EntryTrigger, FALSE);
+ }
+
+ if ((iTriggerCreateAO->isTriggerInitialized(this, ExitTrigger)) && (QLatin1String(signal) == SIGNAL(areaExited(QGeoPositionInfo))) && (receivers(SIGNAL(areaExited(const QGeoPositionInfo&))) == 0)) {
+ // iExitTrigger->NotifyFiredEvent (FALSE);
+ iTriggerCreateAO->SetTriggerState(this, ExitTrigger, FALSE);
+ }
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeoareamonitor_s60_p.h b/src/location/qgeoareamonitor_s60_p.h
new file mode 100644
index 00000000..a2be5d35
--- /dev/null
+++ b/src/location/qgeoareamonitor_s60_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOAREAMONITOR60_H_
+#define QGEOAREAMONITOR60_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeoareamonitor.h"
+#include "qmlbackendmonitorao_s60_p.h"
+#include "notificationmonitorcallback_s60_p.h"
+#include "qmlbackendtriggerchangeao_s60_p.h"
+#include "qmlbackendmonitorcreatetriggerao_s60_p.h"
+
+#include <lbt.h>
+#include <lbttriggerinfo.h>
+#include <lbttriggerconditionarea.h>
+#include <lbtgeocircle.h>
+
+QTM_BEGIN_NAMESPACE
+
+/**
+ * QGeoAreaMonitorS60
+ *
+ */
+class QGeoAreaMonitorS60 : public INotificationMonitorCallback,
+ public QGeoAreaMonitor
+
+{
+public :
+ static QGeoAreaMonitorS60* NewL(QObject *parent = 0);
+ void setCenter(const QGeoCoordinate &coordinate);
+ void setRadius(qreal radius);
+ void handleTriggerEvent(TPositionInfo aPosInfo, enTriggerType aStatus);
+ ~QGeoAreaMonitorS60();
+
+ /*
+ * checks whether the object is valid
+ */
+ TBool isValid() {
+ if (iTriggerAO && iNotifyTriggerAO && iTriggerCreateAO)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+private:
+ static QGeoAreaMonitorS60* NewLC(QObject* parent);
+
+ void ConstructL();
+ QGeoAreaMonitorS60(QObject* aParent = 0);
+ void setMonitoredArea(const QGeoCoordinate & aCoordinate, qreal aRadius);
+ void TPositionInfoToQGeoPositionInfo(TPositionInfo& aPosInfo, QGeoPositionInfo& aQInfo);
+ int QCoordinateToTCoordinate(const QGeoCoordinate& aQCoord, TCoordinate& aTCoord);
+
+private slots:
+
+ void connectNotify(const char* signal);
+ void disconnectNotify(const char* signal);
+
+private:
+ RLbtServer lbtServ;
+ QMLBackendMonitorAO *iTriggerAO;
+ QMLBackendMonitorCreateTriggerAO* iTriggerCreateAO;
+ QMLBackendTriggerChangeAO *iNotifyTriggerAO;
+ bool connectedLbt;
+ static TInt refCount;
+};
+
+QTM_END_NAMESPACE
+
+#endif /* QGEOAREAMONITORS60_H_ */
diff --git a/src/location/qgeoboundingarea.cpp b/src/location/qgeoboundingarea.cpp
new file mode 100644
index 00000000..1f256be6
--- /dev/null
+++ b/src/location/qgeoboundingarea.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoboundingarea.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoBoundingArea
+ \brief The QGeoBoundingArea class defines a geographic area.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps
+
+ This class is the base class for classes which specify a geographic
+ area.
+
+ For the sake of consistency, subclasses should describe the specific
+ details of the associated areas in terms of QGeoCoordinate instances
+ and distances in metres.
+*/
+
+/*!
+ \enum QGeoBoundingArea::AreaType
+
+ Describes the type of a bounding area.
+
+ \value BoxType A box shaped bounding area.
+
+ \value CircleType A circular bounding area.
+*/
+
+/*!
+ Destroys this bounding area.
+*/
+QGeoBoundingArea::~QGeoBoundingArea() {}
+
+/*!
+\fn virtual QGeoBoundingArea::AreaType QGeoBoundingArea::type() const
+
+Returns the type of this area.
+*/
+
+/*!
+\fn bool QGeoBoundingArea::isValid() const
+
+Returns whether this bounding area is valid.
+
+An area is considered to be invalid if some of the data that is required to
+unambiguously describe the area has not been set or has been set to an
+unsuitable value.
+*/
+
+/*!
+\fn bool QGeoBoundingArea::isEmpty() const
+
+Returns whether this bounding area is empty.
+
+An empty area is a region which has a geometrical area of 0.
+*/
+
+/*!
+\fn bool QGeoBoundingArea::contains(const QGeoCoordinate &coordinate) const
+
+Returns whether the coordinate \a coordinate is contained within this
+area.
+*/
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeoboundingarea.h b/src/location/qgeoboundingarea.h
new file mode 100644
index 00000000..7dd04c15
--- /dev/null
+++ b/src/location/qgeoboundingarea.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOBOUNDINGAREA_H
+#define QGEOBOUNDINGAREA_H
+
+#include "qmobilityglobal.h"
+
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+
+class Q_LOCATION_EXPORT QGeoBoundingArea
+{
+public:
+ enum AreaType {
+ BoxType,
+ CircleType
+ };
+
+ virtual ~QGeoBoundingArea();
+
+ virtual AreaType type() const = 0;
+
+ virtual bool isValid() const = 0;
+ virtual bool isEmpty() const = 0;
+ virtual bool contains(const QGeoCoordinate &coordinate) const = 0;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGEOBOUNDINGAREA_H
diff --git a/src/location/qgeoboundingbox.cpp b/src/location/qgeoboundingbox.cpp
new file mode 100644
index 00000000..7d170ca2
--- /dev/null
+++ b/src/location/qgeoboundingbox.cpp
@@ -0,0 +1,804 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoboundingbox.h"
+#include "qgeoboundingbox_p.h"
+
+#include "qgeocoordinate.h"
+#include "qnumeric.h"
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoBoundingBox
+ \brief The QGeoBoundingBox class defines a rectangular geographic area.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps
+
+ The rectangle is defined in terms of a QGeoCoordinate which specifies the
+ top left coordinate of the rectangle and a QGeoCoordinate which specifies
+ the bottom right coordinate of the rectangle.
+
+ A bounding box is considered invalid if the top left or bottom right
+ coordinates are invalid or if the top left coordinate is south of the
+ bottom right coordinate.
+
+ Bounding boxes can never cross the poles.
+
+ Several methods behave as though the bounding box is defined in terms of a
+ center coordinate, the width of the bounding box in degrees and the height
+ of the bounding box in degrees.
+
+ If the height or center of a bounding box is adjusted such that it would
+ cross one of the poles the height is modified such that the bounding box
+ touches but does not cross the pole and that the center coordinate is still
+ in the center of the bounding box.
+*/
+
+/*!
+ Constructs a new, invalid bounding box.
+*/
+QGeoBoundingBox::QGeoBoundingBox()
+ : d_ptr(new QGeoBoundingBoxPrivate()) {}
+
+/*!
+ Constructs a new bounding box centered at \a center with a
+ width in degrees of \a degreesWidth and a height in degrees of \a degreesHeight.
+
+ If \a degreesHeight would take the bounding box beyond one of the poles,
+ the height of the bounding box will be truncated such that the bounding box
+ only extends up to the pole. The center of the bounding box will be
+ unchanged, and the height will be adjusted such that the center point is at
+ the center of the truncated bounding box.
+*/
+QGeoBoundingBox::QGeoBoundingBox(const QGeoCoordinate &center, double degreesWidth, double degreesHeight)
+ : d_ptr(new QGeoBoundingBoxPrivate(center, center))
+{
+ setWidth(degreesWidth);
+ setHeight(degreesHeight);
+}
+
+/*!
+ Constructs a new bounding box with a top left coordinate \a
+ topLeft and a bottom right coordinate \a bottomRight.
+*/
+QGeoBoundingBox::QGeoBoundingBox(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
+ : d_ptr(new QGeoBoundingBoxPrivate(topLeft, bottomRight)) {}
+
+/*!
+ Constructs a bounding box from the contents of \a other.
+*/
+QGeoBoundingBox::QGeoBoundingBox(const QGeoBoundingBox &other)
+ : QGeoBoundingArea(other),
+ d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys this bounding box.
+*/
+QGeoBoundingBox::~QGeoBoundingBox() {}
+
+/*!
+ Assigns \a other to this bounding box and returns a reference to this
+ bounding box.
+*/
+QGeoBoundingBox& QGeoBoundingBox::operator = (const QGeoBoundingBox & other)
+{
+ QGeoBoundingArea::operator=(other);
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this bounding box is equal to \a other.
+*/
+bool QGeoBoundingBox::operator == (const QGeoBoundingBox &other) const
+{
+ return ((*(d_ptr.constData()) == *(other.d_ptr.constData())));
+}
+
+/*!
+ Returns whether this bounding box is not equal to \a other.
+*/
+bool QGeoBoundingBox::operator != (const QGeoBoundingBox &other) const
+{
+ return !(this->operator==(other));
+}
+
+/*!
+ Returns QGeoBoundingArea::BoxType to identify this as
+ a QGeoBoundingBox instance.
+
+ This function is provided to help find the specific type of
+ aQGeoBoundingArea instance.
+*/
+QGeoBoundingArea::AreaType QGeoBoundingBox::type() const
+{
+ return QGeoBoundingArea::BoxType;
+}
+
+/*!
+ Returns whether this bounding box is valid.
+
+ A valid bounding box has valid top left and bottom right coordinates and
+ has a top left coordinate with latitude greater than or equal to the
+ latitude of the bottom right coordinate.
+*/
+bool QGeoBoundingBox::isValid() const
+{
+ return (d_ptr->topLeft.isValid()
+ && d_ptr->bottomRight.isValid()
+ && d_ptr->topLeft.latitude() >= d_ptr->bottomRight.latitude());
+}
+
+/*!
+ Returns whether this bounding box has a geometrical area of 0.
+
+ Returns true if this bounding box is invalid.
+*/
+bool QGeoBoundingBox::isEmpty() const
+{
+ return (!isValid()
+ || (d_ptr->topLeft.latitude() == d_ptr->bottomRight.latitude())
+ || (d_ptr->topLeft.longitude() == d_ptr->bottomRight.longitude()));
+}
+
+/*!
+ Sets the top left coordinate of this bounding box to \a topLeft.
+*/
+void QGeoBoundingBox::setTopLeft(const QGeoCoordinate &topLeft)
+{
+ d_ptr->topLeft = topLeft;
+}
+
+/*!
+ Returns the top left coordinate of this bounding box.
+*/
+QGeoCoordinate QGeoBoundingBox::topLeft() const
+{
+ return d_ptr->topLeft;
+}
+
+/*!
+ Sets the top right coordinate of this bounding box to \a topRight.
+*/
+void QGeoBoundingBox::setTopRight(const QGeoCoordinate &topRight)
+{
+ d_ptr->topLeft.setLatitude(topRight.latitude());
+ d_ptr->bottomRight.setLongitude(topRight.longitude());
+}
+
+/*!
+ Returns the top right coordinate of this bounding box.
+*/
+QGeoCoordinate QGeoBoundingBox::topRight() const
+{
+ // TODO remove?
+ if (!isValid())
+ return QGeoCoordinate();
+
+ return QGeoCoordinate(d_ptr->topLeft.latitude(), d_ptr->bottomRight.longitude());
+}
+
+/*!
+ Sets the bottom left coordinate of this bounding box to \a bottomLeft.
+*/
+void QGeoBoundingBox::setBottomLeft(const QGeoCoordinate &bottomLeft)
+{
+ d_ptr->bottomRight.setLatitude(bottomLeft.latitude());
+ d_ptr->topLeft.setLongitude(bottomLeft.longitude());
+}
+
+/*!
+ Returns the bottom left coordinate of this bounding box.
+*/
+QGeoCoordinate QGeoBoundingBox::bottomLeft() const
+{
+ // TODO remove?
+ if (!isValid())
+ return QGeoCoordinate();
+
+ return QGeoCoordinate(d_ptr->bottomRight.latitude(), d_ptr->topLeft.longitude());
+}
+
+/*!
+ Sets the bottom right coordinate of this bounding box to \a bottomRight.
+*/
+void QGeoBoundingBox::setBottomRight(const QGeoCoordinate &bottomRight)
+{
+ d_ptr->bottomRight = bottomRight;
+}
+
+/*!
+ Returns the bottom right coordinate of this bounding box.
+*/
+QGeoCoordinate QGeoBoundingBox::bottomRight() const
+{
+ return d_ptr->bottomRight;
+}
+
+/*!
+ Sets the center of this bounding box to \a center.
+
+ If this causes the bounding box to cross on of the poles the height of the
+ bounding box will be truncated such that the bounding box only extends up
+ to the pole. The center of the bounding box will be unchanged, and the
+ height will be adjusted such that the center point is at the center of the
+ truncated bounding box.
+*/
+void QGeoBoundingBox::setCenter(const QGeoCoordinate &center)
+{
+ double width = this->width();
+ double height = this->height();
+
+ double tlLat = center.latitude() + height / 2.0;
+ double tlLon = center.longitude() - width / 2.0;
+ double brLat = center.latitude() - height / 2.0;
+ double brLon = center.longitude() + width / 2.0;
+
+ if (tlLon < -180.0)
+ tlLon += 360.0;
+ if (tlLon > 180.0)
+ tlLon -= 360.0;
+
+ if (brLon < -180.0)
+ brLon += 360.0;
+ if (brLon > 180.0)
+ brLon -= 360.0;
+
+ if (tlLat > 90.0) {
+ brLat = 2* center.latitude() - 90.0;
+ tlLat = 90.0;
+ }
+
+ if (tlLat < -90.0) {
+ brLat = -90.0;
+ tlLat = -90.0;
+ }
+
+ if (brLat > 90.0) {
+ tlLat = 90.0;
+ brLat = 90.0;
+ }
+
+ if (brLat < -90.0) {
+ tlLat = 2 * center.latitude() + 90.0;
+ brLat = -90.0;
+ }
+
+ if (width == 360.0) {
+ tlLon = -180.0;
+ brLon = 180.0;
+ }
+
+ d_ptr->topLeft = QGeoCoordinate(tlLat, tlLon);
+ d_ptr->bottomRight = QGeoCoordinate(brLat, brLon);
+}
+
+/*!
+ Returns the center of this bounding box.
+*/
+QGeoCoordinate QGeoBoundingBox::center() const
+{
+ if (!isValid())
+ return QGeoCoordinate();
+
+ double cLat = (d_ptr->topLeft.latitude() + d_ptr->bottomRight.latitude()) / 2.0;
+
+ double cLon = (d_ptr->bottomRight.longitude() + d_ptr->topLeft.longitude()) / 2.0;
+ if (d_ptr->topLeft.longitude() > d_ptr->bottomRight.longitude()) {
+ cLon = cLon - 180.0;
+ }
+
+ if (cLon < -180.0)
+ cLon += 360.0;
+ if (cLon > 180.0)
+ cLon -= 360.0;
+
+ return QGeoCoordinate(cLat, cLon);
+}
+
+/*!
+ Sets the width of this bounding box in degrees to \a degreesWidth.
+
+ If \a degreesWidth is less than 0.0 or if this bounding box is invalid this
+ function does nothing. To set up the values of an invalid
+ QGeoBoundingBox based on the center, width and height you should use
+ setCenter() first in order to make the QGeoBoundingBox valid.
+
+ If \a degreesWidth is greater than 360.0 then 360.0 is used as the width,
+ the leftmost longitude of the bounding box is set to -180.0 degrees and the
+ rightmost longitude of the bounding box is set to 180.0 degrees.
+*/
+void QGeoBoundingBox::setWidth(double degreesWidth)
+{
+ if (!isValid())
+ return;
+
+ if (degreesWidth < 0.0)
+ return;
+
+ if (degreesWidth >= 360.0) {
+ d_ptr->topLeft.setLongitude(-180.0);
+ d_ptr->bottomRight.setLongitude(180.0);
+ return;
+ }
+
+ double tlLat = d_ptr->topLeft.latitude();
+ double brLat = d_ptr->bottomRight.latitude();
+
+ QGeoCoordinate c = center();
+
+ double tlLon = c.longitude() - degreesWidth / 2.0;
+
+ if (tlLon < -180.0)
+ tlLon += 360.0;
+ if (tlLon > 180.0)
+ tlLon -= 360.0;
+
+ double brLon = c.longitude() + degreesWidth / 2.0;
+
+ if (brLon < -180.0)
+ brLon += 360.0;
+ if (brLon > 180.0)
+ brLon -= 360.0;
+
+ d_ptr->topLeft = QGeoCoordinate(tlLat, tlLon);
+ d_ptr->bottomRight = QGeoCoordinate(brLat, brLon);
+}
+
+/*!
+ Returns the width of this bounding box in degrees.
+
+ The return value is undefined if this bounding box is invalid.
+*/
+double QGeoBoundingBox::width() const
+{
+ if (!isValid())
+ return qQNaN();
+
+ double result = d_ptr->bottomRight.longitude() - d_ptr->topLeft.longitude();
+ if (result < 0.0)
+ result += 360.0;
+ if (result > 360.0)
+ result -= 360.0;
+
+ return result;
+}
+
+/*!
+ Sets the height of this bounding box in degrees to \a degreesHeight.
+
+ If \a degreesHeight is less than 0.0 or if this bounding box is invalid
+ this function does nothing. To set up the values of an invalid
+ QGeoBoundingBox based on the center, width and height you should use
+ setCenter() first in order to make the QGeoBoundingBox valid.
+
+ If the change in height would cause the bounding box to cross a pole
+ the height is adjusted such that the bounding box only touches the pole.
+
+ This changes is done such that the center coordinate is still at the
+ center of the bounding box, which may result in a bounding box with
+ a smaller height than might otherwise be expected.
+
+ If \a degreesHeight is greater than 180.0 then 180.0 is used as the height.
+*/
+void QGeoBoundingBox::setHeight(double degreesHeight)
+{
+ if (!isValid())
+ return;
+
+ if (degreesHeight < 0.0)
+ return;
+
+ if (degreesHeight >= 180.0) {
+ degreesHeight = 180.0;
+ }
+
+ double tlLon = d_ptr->topLeft.longitude();
+ double brLon = d_ptr->bottomRight.longitude();
+
+ QGeoCoordinate c = center();
+
+ double tlLat = c.latitude() + degreesHeight / 2.0;
+ double brLat = c.latitude() - degreesHeight / 2.0;
+
+ if (tlLat > 90.0) {
+ brLat = 2* c.latitude() - 90.0;
+ tlLat = 90.0;
+ }
+
+ if (tlLat < -90.0) {
+ brLat = -90.0;
+ tlLat = -90.0;
+ }
+
+ if (brLat > 90.0) {
+ tlLat = 90.0;
+ brLat = 90.0;
+ }
+
+ if (brLat < -90.0) {
+ tlLat = 2 * c.latitude() + 90.0;
+ brLat = -90.0;
+ }
+
+ d_ptr->topLeft = QGeoCoordinate(tlLat, tlLon);
+ d_ptr->bottomRight = QGeoCoordinate(brLat, brLon);
+}
+
+/*!
+ Returns the height of this bounding box in degrees.
+
+ The return value is undefined if this bounding box is invalid.
+*/
+double QGeoBoundingBox::height() const
+{
+ if (!isValid())
+ return qQNaN();
+
+ double result = d_ptr->topLeft.latitude() - d_ptr->bottomRight.latitude();
+ if (result < 0.0)
+ result = qQNaN();
+ return result;
+}
+
+/*!
+ Returns whether the coordinate \a coordinate is contained within this
+ bounding box.
+*/
+bool QGeoBoundingBox::contains(const QGeoCoordinate &coordinate) const
+{
+
+ if (!isValid() || !coordinate.isValid())
+ return false;
+
+ double left = d_ptr->topLeft.longitude();
+ double right = d_ptr->bottomRight.longitude();
+ double top = d_ptr->topLeft.latitude();
+ double bottom = d_ptr->bottomRight.latitude();
+
+ double lon = coordinate.longitude();
+ double lat = coordinate.latitude();
+
+ if (lat > top)
+ return false;
+ if (lat < bottom)
+ return false;
+
+ if ((lat == 90.0) && (top == 90.0))
+ return true;
+
+ if ((lat == -90.0) && (bottom == -90.0))
+ return true;
+
+ if (left <= right) {
+ if ((lon < left) || (lon > right))
+ return false;
+ } else {
+ if ((lon < left) && (lon > right))
+ return false;
+ }
+
+ return true;
+}
+
+/*!
+ Returns whether the bounding box \a boundingBox is contained within this
+ bounding box.
+*/
+bool QGeoBoundingBox::contains(const QGeoBoundingBox &boundingBox) const
+{
+ return (contains(boundingBox.topLeft())
+ && contains(boundingBox.topRight())
+ && contains(boundingBox.bottomLeft())
+ && contains(boundingBox.bottomRight()));
+}
+
+/*!
+ Returns whether the bounding box \a boundingBox intersects this bounding
+ box.
+
+ If the top or bottom edges of both bounding boxes are at one of the poles
+ the bounding boxes are considered to be intersecting, since the longitude
+ is irrelevant when the edges are at the pole.
+*/
+bool QGeoBoundingBox::intersects(const QGeoBoundingBox &boundingBox) const
+{
+ double left1 = d_ptr->topLeft.longitude();
+ double right1 = d_ptr->bottomRight.longitude();
+ double top1 = d_ptr->topLeft.latitude();
+ double bottom1 = d_ptr->bottomRight.latitude();
+
+ double left2 = boundingBox.d_ptr->topLeft.longitude();
+ double right2 = boundingBox.d_ptr->bottomRight.longitude();
+ double top2 = boundingBox.d_ptr->topLeft.latitude();
+ double bottom2 = boundingBox.d_ptr->bottomRight.latitude();
+
+ if (top1 < bottom2)
+ return false;
+
+ if (bottom1 > top2)
+ return false;
+
+ if ((top1 == 90.0) && (top1 == top2))
+ return true;
+
+ if ((bottom1 == -90.0) && (bottom1 == bottom2))
+ return true;
+
+ if (left1 < right1) {
+ if (left2 < right2) {
+ if ((left1 > right2) || (right1 < left2))
+ return false;
+ } else {
+ if ((left1 > right2) && (right1 < left2))
+ return false;
+ }
+ } else {
+ if (left2 < right2) {
+ if ((left2 > right1) && (right2 < left1))
+ return false;
+ } else {
+ // if both wrap then they have to intersect
+ }
+ }
+
+ return true;
+}
+
+/*!
+ Translates this bounding box by \a degreesLatitude northwards and \a
+ degreesLongitude eastwards.
+
+ Negative values of \a degreesLatitude and \a degreesLongitude correspond to
+ southward and westward translation respectively.
+
+ If the translation would have caused the bounding box to cross a pole the
+ bounding box will be translated until the top or bottom edge of bounding
+ box touches the pole but not further.
+*/
+void QGeoBoundingBox::translate(double degreesLatitude, double degreesLongitude)
+{
+ // TODO handle dlat, dlon larger than 360 degrees
+
+ double tlLat = d_ptr->topLeft.latitude();
+ double tlLon = d_ptr->topLeft.longitude();
+ double brLat = d_ptr->bottomRight.latitude();
+ double brLon = d_ptr->bottomRight.longitude();
+
+ if ((tlLat != 90.0) || (brLat != -90.0)) {
+ tlLat += degreesLatitude;
+ brLat += degreesLatitude;
+ }
+
+ if ( (tlLon != -180.0) || (brLon != 180.0) ) {
+ tlLon += degreesLongitude;
+ brLon += degreesLongitude;
+ }
+
+ if (tlLon < -180.0)
+ tlLon += 360.0;
+ if (tlLon > 180.0)
+ tlLon -= 360.0;
+
+ if (brLon < -180.0)
+ brLon += 360.0;
+ if (brLon > 180.0)
+ brLon -= 360.0;
+
+ if (tlLat > 90.0)
+ tlLat = 90.0;
+
+ if (tlLat < -90.0)
+ tlLat = -90.0;
+
+ if (brLat > 90.0)
+ brLat = 90.0;
+
+ if (brLat < -90.0)
+ brLat = -90.0;
+
+ d_ptr->topLeft = QGeoCoordinate(tlLat, tlLon);
+ d_ptr->bottomRight = QGeoCoordinate(brLat, brLon);
+}
+
+/*!
+ Returns a copy of this bounding box translated by \a degreesLatitude northwards and \a
+ degreesLongitude eastwards.
+
+ Negative values of \a degreesLatitude and \a degreesLongitude correspond to
+ southward and westward translation respectively.
+
+ \sa translate()
+*/
+QGeoBoundingBox QGeoBoundingBox::translated(double degreesLatitude, double degreesLongitude) const
+{
+ QGeoBoundingBox result(*this);
+ result.translate(degreesLatitude, degreesLongitude);
+ return result;
+}
+
+/*!
+ Returns the smallest bounding box which contains both this bounding box and \a boundingBox.
+*/
+QGeoBoundingBox QGeoBoundingBox::united(const QGeoBoundingBox &boundingBox) const
+{
+ QGeoBoundingBox result(*this);
+ result |= boundingBox;
+ return result;
+}
+
+/*!
+ \fn QGeoBoundingBox QGeoBoundingBox::operator | (const QGeoBoundingBox &boundingBox) const
+
+ Returns the smallest bounding box which contains both this bounding box and \a boundingBox.
+*/
+
+/*!
+ Returns the smallest bounding box which contains both this bounding box and \a boundingBox.
+*/
+QGeoBoundingBox& QGeoBoundingBox::operator |= (const QGeoBoundingBox & boundingBox)
+{
+ // If non-intersecting goes for most narrow box
+
+ double left1 = d_ptr->topLeft.longitude();
+ double right1 = d_ptr->bottomRight.longitude();
+ double top1 = d_ptr->topLeft.latitude();
+ double bottom1 = d_ptr->bottomRight.latitude();
+
+ double left2 = boundingBox.d_ptr->topLeft.longitude();
+ double right2 = boundingBox.d_ptr->bottomRight.longitude();
+ double top2 = boundingBox.d_ptr->topLeft.latitude();
+ double bottom2 = boundingBox.d_ptr->bottomRight.latitude();
+
+ double top = qMax(top1, top2);
+ double bottom = qMin(bottom1, bottom2);
+
+ double left = 0.0;
+ double right = 0.0;
+
+ bool wrap1 = (left1 > right1);
+ bool wrap2 = (left2 > right2);
+
+ if ((wrap1 && wrap2) || (!wrap1 && !wrap2)) {
+ left = qMin(left1, left2);
+ right = qMax(right1, right2);
+ } else {
+ double wrapLeft = 0.0;
+ double wrapRight = 0.0;
+ double nonWrapLeft = 0.0;
+ double nonWrapRight = 0.0;
+
+ if (wrap1) {
+ wrapLeft = left1;
+ wrapRight = right1;
+ nonWrapLeft = left2;
+ nonWrapRight = right2;
+ } else {
+ wrapLeft = left2;
+ wrapRight = right2;
+ nonWrapLeft = left1;
+ nonWrapRight = right1;
+ }
+
+ bool joinWrapLeft = (nonWrapRight >= wrapLeft);
+ bool joinWrapRight = (nonWrapLeft <= wrapRight);
+
+ if (joinWrapLeft) {
+ if (joinWrapRight) {
+ left = -180.0;
+ right = 180.0;
+ } else {
+ left = nonWrapLeft;
+ right = wrapRight;
+ }
+ } else {
+ if (joinWrapRight) {
+ left = wrapLeft;
+ right = nonWrapRight;
+ } else {
+ double wrapRightDistance = nonWrapLeft - wrapRight;
+ double wrapLeftDistance = wrapLeft - nonWrapRight;
+
+ if (wrapLeftDistance == wrapRightDistance) {
+ left = -180.0;
+ right = 180.0;
+ } else if (wrapLeftDistance < wrapRightDistance) {
+ left = nonWrapLeft;
+ right = wrapRight;
+ } else {
+ left = wrapLeft;
+ right = nonWrapRight;
+ }
+ }
+ }
+ }
+
+ if (((left1 == -180) && (right1 == 180.0))
+ || ((left2 == -180) && (right2 == 180.0))) {
+ left = -180;
+ right = 180;
+ }
+
+ d_ptr->topLeft = QGeoCoordinate(top, left);
+ d_ptr->bottomRight = QGeoCoordinate(bottom, right);
+
+ return *this;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoBoundingBoxPrivate::QGeoBoundingBoxPrivate()
+ : QSharedData() {}
+
+QGeoBoundingBoxPrivate::QGeoBoundingBoxPrivate(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
+ : QSharedData(),
+ topLeft(topLeft),
+ bottomRight(bottomRight) {}
+
+QGeoBoundingBoxPrivate::QGeoBoundingBoxPrivate(const QGeoBoundingBoxPrivate &other)
+ : QSharedData(),
+ topLeft(other.topLeft),
+ bottomRight(other.bottomRight) {}
+
+QGeoBoundingBoxPrivate::~QGeoBoundingBoxPrivate() {}
+
+QGeoBoundingBoxPrivate& QGeoBoundingBoxPrivate::operator= (const QGeoBoundingBoxPrivate & other)
+{
+ topLeft = other.topLeft;
+ bottomRight = other.bottomRight;
+
+ return *this;
+}
+
+bool QGeoBoundingBoxPrivate::operator== (const QGeoBoundingBoxPrivate &other) const
+{
+ return ((topLeft == other.topLeft) && (bottomRight == other.bottomRight));
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeoboundingbox.h b/src/location/qgeoboundingbox.h
new file mode 100644
index 00000000..ff5e665b
--- /dev/null
+++ b/src/location/qgeoboundingbox.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOBOUNDINGBOX_H
+#define QGEOBOUNDINGBOX_H
+
+#include "qgeoboundingarea.h"
+
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingBoxPrivate;
+
+class Q_LOCATION_EXPORT QGeoBoundingBox : public QGeoBoundingArea
+{
+public:
+ QGeoBoundingBox();
+ QGeoBoundingBox(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
+ QGeoBoundingBox(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
+
+ QGeoBoundingBox(const QGeoBoundingBox &other);
+ ~QGeoBoundingBox();
+
+ QGeoBoundingBox& operator = (const QGeoBoundingBox &other);
+
+ bool operator == (const QGeoBoundingBox &other) const;
+ bool operator != (const QGeoBoundingBox &other) const;
+
+ QGeoBoundingArea::AreaType type() const;
+
+ bool isValid() const;
+ bool isEmpty() const;
+
+ void setTopLeft(const QGeoCoordinate &topLeft);
+ QGeoCoordinate topLeft() const;
+
+ void setTopRight(const QGeoCoordinate &topRight);
+ QGeoCoordinate topRight() const;
+
+ void setBottomLeft(const QGeoCoordinate &bottomLeft);
+ QGeoCoordinate bottomLeft() const;
+
+ void setBottomRight(const QGeoCoordinate &bottomRight);
+ QGeoCoordinate bottomRight() const;
+
+ void setCenter(const QGeoCoordinate &center);
+ QGeoCoordinate center() const;
+
+ void setWidth(double degreesWidth);
+ double width() const;
+
+ void setHeight(double degreesHeight);
+ double height() const;
+
+ bool contains(const QGeoCoordinate &coordinate) const;
+ bool contains(const QGeoBoundingBox &boundingBox) const;
+ bool intersects(const QGeoBoundingBox &boundingBox) const;
+
+ void translate(double degreesLatitude, double degreesLongitude);
+ QGeoBoundingBox translated(double degreesLatitude, double degreesLongitude) const;
+
+ QGeoBoundingBox united(const QGeoBoundingBox &boundingBox) const;
+ QGeoBoundingBox operator | (const QGeoBoundingBox &boundingBox) const;
+ QGeoBoundingBox& operator |= (const QGeoBoundingBox &boundingBox);
+
+private:
+ QSharedDataPointer<QGeoBoundingBoxPrivate> d_ptr;
+};
+
+inline QGeoBoundingBox QGeoBoundingBox::operator | (const QGeoBoundingBox &boundingBox) const
+{
+ return united(boundingBox);
+}
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/location/qgeoboundingbox_p.h b/src/location/qgeoboundingbox_p.h
new file mode 100644
index 00000000..a2af2025
--- /dev/null
+++ b/src/location/qgeoboundingbox_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOBOUNDINGBOX_P_H
+#define QGEOBOUNDINGBOX_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeocoordinate.h"
+
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoBoundingBoxPrivate : public QSharedData
+{
+public:
+ QGeoBoundingBoxPrivate();
+ QGeoBoundingBoxPrivate(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
+ QGeoBoundingBoxPrivate(const QGeoBoundingBoxPrivate &other);
+ ~QGeoBoundingBoxPrivate();
+
+ QGeoBoundingBoxPrivate& operator= (const QGeoBoundingBoxPrivate &other);
+
+ bool operator== (const QGeoBoundingBoxPrivate &other) const;
+
+ QGeoCoordinate topLeft;
+ QGeoCoordinate bottomRight;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeoboundingcircle.cpp b/src/location/qgeoboundingcircle.cpp
new file mode 100644
index 00000000..943e87e1
--- /dev/null
+++ b/src/location/qgeoboundingcircle.cpp
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoboundingcircle.h"
+#include "qgeoboundingcircle_p.h"
+
+#include "qgeocoordinate.h"
+#include "qnumeric.h"
+
+#include <QDebug>
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoBoundingCircle
+ \brief The QGeoBoundingCircle class defines a circular geographic area.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup maps
+
+ The circle is defined in terms of a QGeoCoordinate which specifies the
+ center of the circle and a qreal which specifies the radius of the circle
+ in metres.
+
+ The circle is considered invalid if the center coordinate is invalid
+ or if the radius is less than zero.
+*/
+
+/*!
+ Constructs a new, invalid bounding circle.
+*/
+QGeoBoundingCircle::QGeoBoundingCircle()
+ : d_ptr(new QGeoBoundingCirclePrivate()) {}
+
+/*!
+ Constructs a new bounding circle centered at \a center and with a radius of \a
+ radius metres.
+*/
+QGeoBoundingCircle::QGeoBoundingCircle(const QGeoCoordinate &center, qreal radius)
+ : d_ptr(new QGeoBoundingCirclePrivate(center, radius)) {}
+
+/*!
+ Constructs a new bounding circle from the contents of \a other.
+*/
+QGeoBoundingCircle::QGeoBoundingCircle(const QGeoBoundingCircle &other)
+ : QGeoBoundingArea(other),
+ d_ptr(other.d_ptr) {}
+
+/*!
+ Destroys this bounding circle.
+*/
+QGeoBoundingCircle::~QGeoBoundingCircle() {}
+
+/*!
+ Assigns \a other to this bounding circle and returns a reference to this
+ bounding circle.
+*/
+QGeoBoundingCircle& QGeoBoundingCircle::operator = (const QGeoBoundingCircle & other)
+{
+ QGeoBoundingArea::operator=(other);
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns whether this bounding circle is equal to \a other.
+*/
+bool QGeoBoundingCircle::operator == (const QGeoBoundingCircle &other) const
+{
+ return ((*(d_ptr.constData()) == *(other.d_ptr.constData())));
+}
+
+/*!
+ Returns whether this bounding circle is not equal to \a other.
+*/
+bool QGeoBoundingCircle::operator != (const QGeoBoundingCircle &other) const
+{
+ return !(this->operator==(other));
+}
+
+/*!
+ Returns QGeoBoundingArea::CircleType to identify this as a
+ QGeoBoundingCircle instance.
+
+ This function is provided to help find the specific type of
+ aQGeoBoundingArea instance.
+*/
+QGeoBoundingArea::AreaType QGeoBoundingCircle::type() const
+{
+ return QGeoBoundingArea::CircleType;
+}
+
+/*!
+ Returns whether this bounding circle is valid.
+
+ A valid bounding circle has a valid center coordinate and a radius
+ greater than or equal to zero.
+*/
+bool QGeoBoundingCircle::isValid() const
+{
+ return (d_ptr->center.isValid()
+ && !qIsNaN(d_ptr->radius)
+ && d_ptr->radius >= -1e-7);
+}
+
+/*!
+ Returns whether this bounding circle has a geometrical area of zero.
+
+ Returns true if this bounding circle is invalid.
+*/
+bool QGeoBoundingCircle::isEmpty() const
+{
+ return (!isValid() || (d_ptr->radius <= 1e-7));
+}
+
+/*!
+ Sets the center coordinate of this bounding circle to \a center.
+*/
+void QGeoBoundingCircle::setCenter(const QGeoCoordinate &center)
+{
+ d_ptr->center = center;
+}
+
+/*!
+ Returns the center coordinate of this bounding circle.
+*/
+QGeoCoordinate QGeoBoundingCircle::center() const
+{
+ return d_ptr->center;
+}
+
+/*!
+ Sets the radius in metres of this bounding circle to \a radius.
+*/
+void QGeoBoundingCircle::setRadius(qreal radius)
+{
+ d_ptr->radius = radius;
+}
+
+/*!
+ Returns the radius in meters of this bounding circle.
+*/
+qreal QGeoBoundingCircle::radius() const
+{
+ return d_ptr->radius;
+}
+
+/*!
+ Returns whether the coordinate \a coordinate is contained within this
+ bounding circle.
+*/
+bool QGeoBoundingCircle::contains(const QGeoCoordinate &coordinate) const
+{
+
+ if (!isValid() || !coordinate.isValid())
+ return false;
+
+ if (d_ptr->center.distanceTo(coordinate) <= d_ptr->radius)
+ return true;
+
+ return false;
+}
+
+/*!
+ Translates this bounding circle by \a degreesLatitude northwards and \a
+ degreesLongitude eastwards.
+
+ Negative values of \a degreesLatitude and \a degreesLongitude correspond to
+ southward and westward translation respectively.
+*/
+void QGeoBoundingCircle::translate(double degreesLatitude, double degreesLongitude)
+{
+ // TODO handle dlat, dlon larger than 360 degrees
+
+ double lat = d_ptr->center.latitude();
+ double lon = d_ptr->center.longitude();
+
+ lat += degreesLatitude;
+ lon += degreesLongitude;
+
+ if (lon < -180.0)
+ lon += 360.0;
+ if (lon > 180.0)
+ lon -= 360.0;
+
+ if (lat > 90.0) {
+ lat = 180.0 - lat;
+ if (lon < 0.0)
+ lon = 180.0;
+ else
+ lon -= 180;
+ }
+
+ if (lat < -90.0) {
+ lat = 180.0 + lat;
+ if (lon < 0.0)
+ lon = 180.0;
+ else
+ lon -= 180;
+ }
+
+ d_ptr->center = QGeoCoordinate(lat, lon);
+}
+
+/*!
+ Returns a copy of this bounding circle translated by \a degreesLatitude northwards and \a
+ degreesLongitude eastwards.
+
+ Negative values of \a degreesLatitude and \a degreesLongitude correspond to
+ southward and westward translation respectively.
+
+ \sa translate()
+*/
+QGeoBoundingCircle QGeoBoundingCircle::translated(double degreesLatitude, double degreesLongitude) const
+{
+ QGeoBoundingCircle result(*this);
+ result.translate(degreesLatitude, degreesLongitude);
+ return result;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoBoundingCirclePrivate::QGeoBoundingCirclePrivate()
+ : QSharedData(),
+ radius(-1.0) {}
+
+QGeoBoundingCirclePrivate::QGeoBoundingCirclePrivate(const QGeoCoordinate &center, qreal radius)
+ : QSharedData(),
+ center(center),
+ radius(radius) {}
+
+QGeoBoundingCirclePrivate::QGeoBoundingCirclePrivate(const QGeoBoundingCirclePrivate &other)
+ : QSharedData(),
+ center(other.center),
+ radius(other.radius) {}
+
+QGeoBoundingCirclePrivate::~QGeoBoundingCirclePrivate() {}
+
+QGeoBoundingCirclePrivate& QGeoBoundingCirclePrivate::operator= (const QGeoBoundingCirclePrivate & other)
+{
+ center = other.center;
+ radius = other.radius;
+
+ return *this;
+}
+
+bool QGeoBoundingCirclePrivate::operator== (const QGeoBoundingCirclePrivate &other) const
+{
+ return ((center == other.center) && (radius == other.radius));
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeoboundingcircle.h b/src/location/qgeoboundingcircle.h
new file mode 100644
index 00000000..0c832535
--- /dev/null
+++ b/src/location/qgeoboundingcircle.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOBOUNDINGCIRCLE_H
+#define QGEOBOUNDINGCIRCLE_H
+
+#include "qgeoboundingarea.h"
+
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QGeoBoundingCirclePrivate;
+
+class Q_LOCATION_EXPORT QGeoBoundingCircle : public QGeoBoundingArea
+{
+public:
+ QGeoBoundingCircle();
+ QGeoBoundingCircle(const QGeoCoordinate &center, qreal radius);
+
+ QGeoBoundingCircle(const QGeoBoundingCircle &other);
+ ~QGeoBoundingCircle();
+
+ QGeoBoundingCircle& operator = (const QGeoBoundingCircle &other);
+
+ bool operator == (const QGeoBoundingCircle &other) const;
+ bool operator != (const QGeoBoundingCircle &other) const;
+
+ QGeoBoundingArea::AreaType type() const;
+
+ bool isValid() const;
+ bool isEmpty() const;
+
+ void setCenter(const QGeoCoordinate &center);
+ QGeoCoordinate center() const;
+
+ void setRadius(qreal radius);
+ qreal radius() const;
+
+ bool contains(const QGeoCoordinate &coordinate) const;
+
+ void translate(double degreesLatitude, double degreesLongitude);
+ QGeoBoundingCircle translated(double degreesLatitude, double degreesLongitude) const;
+private:
+ QSharedDataPointer<QGeoBoundingCirclePrivate> d_ptr;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/location/qgeoboundingcircle_p.h b/src/location/qgeoboundingcircle_p.h
new file mode 100644
index 00000000..852c5c92
--- /dev/null
+++ b/src/location/qgeoboundingcircle_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOBOUNDINGCIRCLE_P_H
+#define QGEOBOUNDINGCIRCLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeocoordinate.h"
+
+#include <QSharedData>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoBoundingCirclePrivate : public QSharedData
+{
+public:
+ QGeoBoundingCirclePrivate();
+ QGeoBoundingCirclePrivate(const QGeoCoordinate &center, qreal radius);
+ QGeoBoundingCirclePrivate(const QGeoBoundingCirclePrivate &other);
+ ~QGeoBoundingCirclePrivate();
+
+ QGeoBoundingCirclePrivate& operator= (const QGeoBoundingCirclePrivate &other);
+
+ bool operator== (const QGeoBoundingCirclePrivate &other) const;
+
+ QGeoCoordinate center;
+ qreal radius;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeocoordinate.cpp b/src/location/qgeocoordinate.cpp
new file mode 100644
index 00000000..f6766637
--- /dev/null
+++ b/src/location/qgeocoordinate.cpp
@@ -0,0 +1,638 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgeocoordinate.h"
+#include "qgeocoordinate_p.h"
+#include "qlocationutils_p.h"
+
+#include <QDateTime>
+#include <QHash>
+#include <QDataStream>
+#include <QDebug>
+#include <qnumeric.h>
+
+#include <math.h>
+
+#include <QDebug>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072;
+
+inline static double qgeocoordinate_degToRad(double deg)
+{
+ return deg * M_PI / 180;
+}
+inline static double qgeocoordinate_radToDeg(double rad)
+{
+ return rad * 180 / M_PI;
+}
+
+
+QGeoCoordinatePrivate::QGeoCoordinatePrivate() {
+ lat = qQNaN();
+ lng = qQNaN();
+ alt = qQNaN();
+}
+
+
+/*!
+ \class QGeoCoordinate
+ \brief The QGeoCoordinate class defines a geographical position on the surface of the Earth.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ A QGeoCoordinate is defined by latitude, longitude, and optionally, altitude.
+
+ Use type() to determine whether a coordinate is a 2D coordinate (has
+ latitude and longitude only) or 3D coordinate (has latitude, longitude
+ and altitude). Use distanceTo() and azimuthTo() to calculate the distance
+ and bearing between coordinates.
+
+ The coordinate values should be specified using the WGS84 datum.
+*/
+
+/*!
+ \enum QGeoCoordinate::CoordinateType
+ Defines the types of a coordinate.
+
+ \value InvalidCoordinate An invalid coordinate. A coordinate is invalid if its latitude or longitude values are invalid.
+ \value Coordinate2D A coordinate with valid latitude and longitude values.
+ \value Coordinate3D A coordinate with valid latitude and longitude values, and also an altitude value.
+*/
+
+/*!
+ \enum QGeoCoordinate::CoordinateFormat
+ Defines the possible formatting options for toString().
+
+ \value Degrees Returns a string representation of the coordinates in decimal degrees format.
+ \value DegreesWithHemisphere Returns a string representation of the coordinates in decimal degrees format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
+ \value DegreesMinutes Returns a string representation of the coordinates in degrees-minutes format.
+ \value DegreesMinutesWithHemisphere Returns a string representation of the coordinates in degrees-minutes format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
+ \value DegreesMinutesSeconds Returns a string representation of the coordinates in degrees-minutes-seconds format.
+ \value DegreesMinutesSecondsWithHemisphere Returns a string representation of the coordinates in degrees-minutes-seconds format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
+
+ \sa toString()
+*/
+
+
+/*!
+ Constructs a coordinate. The coordinate will be invalid until
+ setLatitude() and setLongitude() have been called.
+*/
+QGeoCoordinate::QGeoCoordinate()
+ : d(new QGeoCoordinatePrivate)
+{
+}
+
+/*!
+ Constructs a coordinate with the given \a latitude and \a longitude.
+
+ If the latitude is not between -90 to 90 inclusive, or the longitude
+ is not between -180 to 180 inclusive, none of the values are set and
+ the type() will be QGeoCoordinate::InvalidCoordinate.
+
+ \sa isValid()
+*/
+QGeoCoordinate::QGeoCoordinate(double latitude, double longitude)
+ : d(new QGeoCoordinatePrivate)
+{
+ if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
+ d->lat = latitude;
+ d->lng = longitude;
+ }
+}
+
+/*!
+ Constructs a coordinate with the given \a latitude, \a longitude
+ and \a altitude.
+
+ If the latitude is not between -90 to 90 inclusive, or the longitude
+ is not between -180 to 180 inclusive, none of the values are set and
+ the type() will be QGeoCoordinate::InvalidCoordinate.
+
+ Note that \a altitude specifies the metres above sea level.
+
+ \sa isValid()
+*/
+QGeoCoordinate::QGeoCoordinate(double latitude, double longitude, double altitude)
+ : d(new QGeoCoordinatePrivate)
+{
+ if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
+ d->lat = latitude;
+ d->lng = longitude;
+ d->alt = altitude;
+ }
+}
+
+/*!
+ Constructs a coordinate from the contents of \a other.
+*/
+QGeoCoordinate::QGeoCoordinate(const QGeoCoordinate &other)
+ : d(new QGeoCoordinatePrivate)
+{
+ operator=(other);
+}
+
+/*!
+ Destroys the coordinate object.
+*/
+QGeoCoordinate::~QGeoCoordinate()
+{
+ delete d;
+}
+
+/*!
+ Assigns \a other to this coordinate and returns a reference to this
+ coordinate.
+*/
+QGeoCoordinate &QGeoCoordinate::operator=(const QGeoCoordinate & other)
+{
+ if (this == &other)
+ return *this;
+
+ d->lat = other.d->lat;
+ d->lng = other.d->lng;
+ d->alt = other.d->alt;
+
+ return *this;
+}
+
+/*!
+ Returns true if the latitude, longitude and altitude of this
+ coordinate are the same as those of \a other.
+
+ The longitude will be ignored if the latitude is +/- 90 degrees.
+*/
+bool QGeoCoordinate::operator==(const QGeoCoordinate &other) const
+{
+ bool latEqual = (qIsNaN(d->lat) && qIsNaN(other.d->lat))
+ || qFuzzyCompare(d->lat, other.d->lat);
+ bool lngEqual = (qIsNaN(d->lng) && qIsNaN(other.d->lng))
+ || qFuzzyCompare(d->lng, other.d->lng);
+ bool altEqual = (qIsNaN(d->alt) && qIsNaN(other.d->alt))
+ || qFuzzyCompare(d->alt, other.d->alt);
+
+ if (!qIsNaN(d->lat) && ((d->lat == 90.0) || (d->lat == -90.0)))
+ lngEqual = true;
+
+ return (latEqual && lngEqual && altEqual);
+}
+
+/*!
+ \fn bool QGeoCoordinate::operator!=(const QGeoCoordinate &other) const;
+
+ Returns true if the latitude, longitude or altitude of this
+ coordinate are not the same as those of \a other.
+*/
+
+/*!
+ Returns true if the type() is Coordinate2D or Coordinate3D.
+*/
+bool QGeoCoordinate::isValid() const
+{
+ CoordinateType t = type();
+ return t == Coordinate2D || t == Coordinate3D;
+}
+
+/*!
+ Returns the type of this coordinate.
+*/
+QGeoCoordinate::CoordinateType QGeoCoordinate::type() const
+{
+ if (QLocationUtils::isValidLat(d->lat)
+ && QLocationUtils::isValidLong(d->lng)) {
+ if (qIsNaN(d->alt))
+ return Coordinate2D;
+ return Coordinate3D;
+ }
+ return InvalidCoordinate;
+}
+
+
+/*!
+ Returns the latitude, in decimal degrees. The return value is undefined
+ if the latitude has not been set.
+
+ A positive latitude indicates the Northern Hemisphere, and a negative
+ latitude indicates the Southern Hemisphere.
+
+ \sa setLatitude(), type()
+*/
+double QGeoCoordinate::latitude() const
+{
+ return d->lat;
+}
+
+/*!
+ Sets the latitude (in decimal degrees) to \a latitude. The value should
+ be in the WGS84 datum.
+
+ To be valid, the latitude must be between -90 to 90 inclusive.
+
+ \sa latitude()
+*/
+void QGeoCoordinate::setLatitude(double latitude)
+{
+ d->lat = latitude;
+}
+
+/*!
+ Returns the longitude, in decimal degrees. The return value is undefined
+ if the longitude has not been set.
+
+ A positive longitude indicates the Eastern Hemisphere, and a negative
+ longitude indicates the Western Hemisphere.
+
+ \sa setLongitude(), type()
+*/
+double QGeoCoordinate::longitude() const
+{
+ return d->lng;
+}
+
+/*!
+ Sets the longitude (in decimal degrees) to \a longitude. The value should
+ be in the WGS84 datum.
+
+ To be valid, the longitude must be between -180 to 180 inclusive.
+
+ \sa longitude()
+*/
+void QGeoCoordinate::setLongitude(double longitude)
+{
+ d->lng = longitude;
+}
+
+/*!
+ Returns the altitude (meters above sea level).
+
+ The return value is undefined if the altitude has not been set.
+
+ \sa setAltitude(), type()
+*/
+double QGeoCoordinate::altitude() const
+{
+ return d->alt;
+}
+
+/*!
+ Sets the altitude (meters above sea level) to \a altitude.
+
+ \sa altitude()
+*/
+void QGeoCoordinate::setAltitude(double altitude)
+{
+ d->alt = altitude;
+}
+
+/*!
+ Returns the distance (in meters) from this coordinate to the coordinate
+ specified by \a other. Altitude is not used in the calculation.
+
+ This calculation returns the great-circle distance between the two
+ coordinates, with an assumption that the Earth is spherical for the
+ purpose of this calculation.
+
+ Returns 0 if the type of this coordinate or the type of \a other is
+ QGeoCoordinate::InvalidCoordinate.
+*/
+qreal QGeoCoordinate::distanceTo(const QGeoCoordinate &other) const
+{
+ if (type() == QGeoCoordinate::InvalidCoordinate
+ || other.type() == QGeoCoordinate::InvalidCoordinate) {
+ return 0;
+ }
+
+ // Haversine formula
+ double dlat = qgeocoordinate_degToRad(other.d->lat - d->lat);
+ double dlon = qgeocoordinate_degToRad(other.d->lng - d->lng);
+ double haversine_dlat = sin(dlat / 2.0);
+ haversine_dlat *= haversine_dlat;
+ double haversine_dlon = sin(dlon / 2.0);
+ haversine_dlon *= haversine_dlon;
+ double y = haversine_dlat
+ + cos(qgeocoordinate_degToRad(d->lat))
+ * cos(qgeocoordinate_degToRad(other.d->lat))
+ * haversine_dlon;
+ double x = 2 * asin(sqrt(y));
+ return qreal(x * qgeocoordinate_EARTH_MEAN_RADIUS * 1000);
+}
+
+/*!
+ Returns the azimuth (or bearing) in degrees from this coordinate to the
+ coordinate specified by \a other. Altitude is not used in the calculation.
+
+ The bearing returned is the bearing from the origin to \a other along the
+ great-circle between the two coordinates. There is an assumption that the
+ Earth is spherical for the purpose of this calculation.
+
+ Returns 0 if the type of this coordinate or the type of \a other is
+ QGeoCoordinate::InvalidCoordinate.
+*/
+qreal QGeoCoordinate::azimuthTo(const QGeoCoordinate &other) const
+{
+ if (type() == QGeoCoordinate::InvalidCoordinate
+ || other.type() == QGeoCoordinate::InvalidCoordinate) {
+ return 0;
+ }
+
+ double dlon = qgeocoordinate_degToRad(other.d->lng - d->lng);
+ double lat1Rad = qgeocoordinate_degToRad(d->lat);
+ double lat2Rad = qgeocoordinate_degToRad(other.d->lat);
+
+ double y = sin(dlon) * cos(lat2Rad);
+ double x = cos(lat1Rad) * sin(lat2Rad) - sin(lat1Rad) * cos(lat2Rad) * cos(dlon);
+
+ double whole;
+ double fraction = modf(qgeocoordinate_radToDeg(atan2(y, x)), &whole);
+ return qreal((int(whole + 360) % 360) + fraction);
+}
+
+void QGeoCoordinatePrivate::atDistanceAndAzimuth(const QGeoCoordinate &coord,
+ qreal distance, qreal azimuth,
+ double *lon, double *lat)
+{
+ double latRad = qgeocoordinate_degToRad(coord.d->lat);
+ double lonRad = qgeocoordinate_degToRad(coord.d->lng);
+ double cosLatRad = cos(latRad);
+ double sinLatRad = sin(latRad);
+
+ double azimuthRad = qgeocoordinate_degToRad(azimuth);
+
+ double ratio = (distance / (qgeocoordinate_EARTH_MEAN_RADIUS * 1000.0));
+ double cosRatio = cos(ratio);
+ double sinRatio = sin(ratio);
+
+ double resultLatRad = asin(sinLatRad * cosRatio
+ + cosLatRad * sinRatio * cos(azimuthRad));
+ double resultLonRad = lonRad
+ + atan2(sin(azimuthRad) * sinRatio * cosLatRad,
+ cosRatio - sinLatRad * sin(resultLatRad));
+
+ *lat = qgeocoordinate_radToDeg(resultLatRad);
+ *lon = qgeocoordinate_radToDeg(resultLonRad);
+}
+
+/*!
+ Returns the coordinate that is reached by traveling \a distance metres
+ from the current coordinate at \a azimuth (or bearing) along a great-circle.
+ There is an assumption that the Earth is spherical for the purpose of this
+ calculation.
+
+ The altitude will have \a distanceUp added to it.
+
+ Returns an invalid coordinate if this coordinate is invalid.
+*/
+QGeoCoordinate QGeoCoordinate::atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp) const
+{
+ if (!isValid())
+ return QGeoCoordinate();
+
+ double resultLon, resultLat;
+ QGeoCoordinatePrivate::atDistanceAndAzimuth(*this, distance, azimuth,
+ &resultLon, &resultLat);
+
+ if (resultLon > 180.0)
+ resultLon -= 360.0;
+ else if (resultLon < -180.0)
+ resultLon += 360.0;
+
+ double resultAlt = d->alt + distanceUp;
+ return QGeoCoordinate(resultLat, resultLon, resultAlt);
+}
+
+/*!
+ Returns this coordinate as a string in the specified \a format.
+
+ For example, if this coordinate has a latitude of -27.46758, a longitude
+ of 153.027892 and an altitude of 28.1, these are the strings
+ returned depending on \a format:
+
+ \table
+ \header
+ \o \a format value
+ \o Returned string
+ \row
+ \o \l Degrees
+ \o -27.46758\unicode{0xB0}, 153.02789\unicode{0xB0}, 28.1m
+ \row
+ \o \l DegreesWithHemisphere
+ \o 27.46758\unicode{0xB0} S, 153.02789\unicode{0xB0} E, 28.1m
+ \row
+ \o \l DegreesMinutes
+ \o -27\unicode{0xB0} 28.054', 153\unicode{0xB0} 1.673', 28.1m
+ \row
+ \o \l DegreesMinutesWithHemisphere
+ \o 27\unicode{0xB0} 28.054 S', 153\unicode{0xB0} 1.673' E, 28.1m
+ \row
+ \o \l DegreesMinutesSeconds
+ \o -27\unicode{0xB0} 28' 3.2", 153\unicode{0xB0} 1' 40.4", 28.1m
+ \row
+ \o \l DegreesMinutesSecondsWithHemisphere
+ \o 27\unicode{0xB0} 28' 3.2" S, 153\unicode{0xB0} 1' 40.4" E, 28.1m
+ \endtable
+
+ The altitude field is omitted if no altitude is set.
+
+ If the coordinate is invalid, an empty string is returned.
+*/
+QString QGeoCoordinate::toString(CoordinateFormat format) const
+{
+ if (type() == QGeoCoordinate::InvalidCoordinate)
+ return QString();
+
+ QString latStr;
+ QString longStr;
+
+ double absLat = qAbs(d->lat);
+ double absLng = qAbs(d->lng);
+ QChar symbol(0x00B0); // degrees symbol
+
+ switch (format) {
+ case Degrees:
+ case DegreesWithHemisphere: {
+ latStr = QString::number(absLat, 'f', 5) + symbol;
+ longStr = QString::number(absLng, 'f', 5) + symbol;
+ break;
+ }
+ case DegreesMinutes:
+ case DegreesMinutesWithHemisphere: {
+ double latMin = (absLat - int(absLat)) * 60;
+ double lngMin = (absLng - int(absLng)) * 60;
+ latStr = QString("%1%2 %3'")
+ .arg(QString::number(int(absLat)))
+ .arg(symbol)
+ .arg(QString::number(latMin, 'f', 3));
+ longStr = QString("%1%2 %3'")
+ .arg(QString::number(int(absLng)))
+ .arg(symbol)
+ .arg(QString::number(lngMin, 'f', 3));
+ break;
+ }
+ case DegreesMinutesSeconds:
+ case DegreesMinutesSecondsWithHemisphere: {
+ double latMin = (absLat - int(absLat)) * 60;
+ double lngMin = (absLng - int(absLng)) * 60;
+ double latSec = (latMin - int(latMin)) * 60;
+ double lngSec = (lngMin - int(lngMin)) * 60;
+
+ latStr = QString("%1%2 %3' %4\"")
+ .arg(QString::number(int(absLat)))
+ .arg(symbol)
+ .arg(QString::number(int(latMin)))
+ .arg(QString::number(latSec, 'f', 1));
+ longStr = QString("%1%2 %3' %4\"")
+ .arg(QString::number(int(absLng)))
+ .arg(symbol)
+ .arg(QString::number(int(lngMin)))
+ .arg(QString::number(lngSec, 'f', 1));
+ break;
+ }
+ }
+
+ // now add the "-" to the start, or append the hemisphere char
+ switch (format) {
+ case Degrees:
+ case DegreesMinutes:
+ case DegreesMinutesSeconds: {
+ if (d->lat < 0)
+ latStr.insert(0, "-");
+ if (d->lng < 0)
+ longStr.insert(0, "-");
+ break;
+ }
+ case DegreesWithHemisphere:
+ case DegreesMinutesWithHemisphere:
+ case DegreesMinutesSecondsWithHemisphere: {
+ if (d->lat < 0)
+ latStr.append(" S");
+ else if (d->lat > 0)
+ latStr.append(" N");
+ if (d->lng < 0)
+ longStr.append(" W");
+ else if (d->lng > 0)
+ longStr.append(" E");
+ break;
+ }
+ }
+
+ if (qIsNaN(d->alt))
+ return QString("%1, %2").arg(latStr, longStr);
+ return QString("%1, %2, %3m").arg(latStr, longStr, QString::number(d->alt));
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QGeoCoordinate &coord)
+{
+ double lat = coord.latitude();
+ double lng = coord.longitude();
+
+ dbg.nospace() << "QGeoCoordinate(";
+ if (qIsNaN(lat))
+ dbg.nospace() << '?';
+ else
+ dbg.nospace() << lat;
+ dbg.nospace() << ", ";
+ if (qIsNaN(lng))
+ dbg.nospace() << '?';
+ else
+ dbg.nospace() << lng;
+ if (coord.type() == QGeoCoordinate::Coordinate3D) {
+ dbg.nospace() << ", ";
+ dbg.nospace() << coord.altitude();
+ }
+ dbg.nospace() << ')';
+ return dbg;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QGeoCoordinate &coordinate)
+
+ \relates QGeoCoordinate
+
+ Writes the given \a coordinate to the specified \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QGeoCoordinate &coordinate)
+{
+ stream << coordinate.latitude();
+ stream << coordinate.longitude();
+ stream << coordinate.altitude();
+ return stream;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QGeoCoordinate &coordinate)
+ \relates QGeoCoordinate
+
+ Reads a coordinate from the specified \a stream into the given
+ \a coordinate.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator>>(QDataStream &stream, QGeoCoordinate &coordinate)
+{
+ double value;
+ stream >> value;
+ coordinate.setLatitude(value);
+ stream >> value;
+ coordinate.setLongitude(value);
+ stream >> value;
+ coordinate.setAltitude(value);
+ return stream;
+}
+#endif
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeocoordinate.h b/src/location/qgeocoordinate.h
new file mode 100644
index 00000000..5f696732
--- /dev/null
+++ b/src/location/qgeocoordinate.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOCOORDINATE_H
+#define QGEOCOORDINATE_H
+
+#include "qmobilityglobal.h"
+
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+class QDataStream;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinatePrivate;
+class Q_LOCATION_EXPORT QGeoCoordinate
+{
+public:
+ enum CoordinateType {
+ InvalidCoordinate,
+ Coordinate2D,
+ Coordinate3D
+ };
+
+ enum CoordinateFormat {
+ Degrees,
+ DegreesWithHemisphere,
+ DegreesMinutes,
+ DegreesMinutesWithHemisphere,
+ DegreesMinutesSeconds,
+ DegreesMinutesSecondsWithHemisphere
+ };
+
+ QGeoCoordinate();
+ QGeoCoordinate(double latitude, double longitude);
+ QGeoCoordinate(double latitude, double longitude, double altitude);
+ QGeoCoordinate(const QGeoCoordinate &other);
+ ~QGeoCoordinate();
+
+ QGeoCoordinate &operator=(const QGeoCoordinate &other);
+
+ bool operator==(const QGeoCoordinate &other) const;
+ inline bool operator!=(const QGeoCoordinate &other) const {
+ return !operator==(other);
+ }
+
+ bool isValid() const;
+ CoordinateType type() const;
+
+ void setLatitude(double latitude);
+ double latitude() const;
+
+ void setLongitude(double longitude);
+ double longitude() const;
+
+ void setAltitude(double altitude);
+ double altitude() const;
+
+ qreal distanceTo(const QGeoCoordinate &other) const;
+ qreal azimuthTo(const QGeoCoordinate &other) const;
+
+ QGeoCoordinate atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp = 0.0) const;
+
+ QString toString(CoordinateFormat format = DegreesMinutesSecondsWithHemisphere) const;
+
+private:
+ QGeoCoordinatePrivate *d;
+
+ friend class QGeoCoordinatePrivate;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_LOCATION_EXPORT QDebug operator<<(QDebug, const QGeoCoordinate &);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoCoordinate &coordinate);
+Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoCoordinate &coordinate);
+#endif
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeocoordinate_p.h b/src/location/qgeocoordinate_p.h
new file mode 100644
index 00000000..45b94768
--- /dev/null
+++ b/src/location/qgeocoordinate_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOCOORDINATE_P_H
+#define QGEOCOORDINATE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoCoordinatePrivate
+{
+public:
+ QGeoCoordinatePrivate();
+
+ double lat;
+ double lng;
+ double alt;
+
+ static void atDistanceAndAzimuth(const QGeoCoordinate &coord,
+ qreal distance, qreal azimuth,
+ double *lon, double *lat);
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOCOORDINATE_P_H
diff --git a/src/location/qgeoinfothread_wince.cpp b/src/location/qgeoinfothread_wince.cpp
new file mode 100644
index 00000000..84bf3ef2
--- /dev/null
+++ b/src/location/qgeoinfothread_wince.cpp
@@ -0,0 +1,409 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QMetaType>
+
+#include "qgeoinfothread_wince_p.h"
+
+Q_DECLARE_METATYPE(GPS_POSITION);
+
+QTM_BEGIN_NAMESPACE
+
+// ========== QGeoInfoValidator ==========
+
+QGeoInfoValidator::QGeoInfoValidator() {}
+
+QGeoInfoValidator::~QGeoInfoValidator() {}
+
+// ========== QGeoInfoThreadWinCE ==========
+
+
+// This QGeoInfoThreadWinCE instance takes ownership of the validator, and must delete it before
+// it is destructed.
+QGeoInfoThreadWinCE::QGeoInfoThreadWinCE(QGeoInfoValidator *validator, bool timeoutsForPeriodicUpdates, QObject *parent)
+ : QThread(parent),
+ validator(validator),
+ timeoutsForPeriodicUpdates(timeoutsForPeriodicUpdates),
+ requestScheduled(false),
+ requestInterval(0),
+ updatesScheduled(false),
+ updatesInterval(0),
+ stopping(false),
+ hasLastPosition(false),
+ invalidDataReceived(false),
+ updateTimeoutTriggered(false)
+{
+ qRegisterMetaType<GPS_POSITION>();
+ m_newDataEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_gpsStateChange = CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_wakeUpEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+}
+
+QGeoInfoThreadWinCE::~QGeoInfoThreadWinCE()
+{
+ // Let/make the thread finish...
+
+ mutex.lock();
+
+ updatesScheduled = false;
+ requestScheduled = false;
+ stopping = true;
+
+ mutex.unlock();
+
+ wakeUp();
+
+ wait();
+
+ // ...then clean up.
+
+ delete validator;
+
+ CloseHandle(m_newDataEvent);
+ CloseHandle(m_gpsStateChange);
+ CloseHandle(m_wakeUpEvent);
+}
+
+// TODO - just need to add the WinCE line from QTime::currentTime to QDateTime::currentDateTime
+// and we can scrap this method
+QDateTime QGeoInfoThreadWinCE::currentDateTime()
+{
+ QDate d = QDate::currentDate();
+ QTime t = QTime::currentTime();
+
+ // just in case we past midnight in between the last two calls
+ if (d != QDate::currentDate()) {
+ d = QDate::currentDate();
+ t = QTime::currentTime();
+ }
+
+ return QDateTime(d, t);
+}
+
+int QGeoInfoThreadWinCE::msecsTo(QDateTime from, QDateTime to)
+{
+ int MSECS_PER_DAY = 86400000;
+ return (from.date().daysTo(to.date()) * MSECS_PER_DAY) + from.time().msecsTo(to.time());
+}
+
+void QGeoInfoThreadWinCE::requestUpdate(int timeout)
+{
+ QMutexLocker locker(&mutex);
+
+ if (!requestScheduled) {
+ requestScheduled = true;
+
+ if (timeout == 0)
+ timeout = DefaultRequestTimeout;
+
+ requestInterval = timeout;
+ requestNextTime = currentDateTime().addMSecs(requestInterval);
+
+ locker.unlock();
+ wakeUp();
+ }
+}
+
+void QGeoInfoThreadWinCE::startUpdates()
+{
+ QMutexLocker locker(&mutex);
+ if (!updatesScheduled) {
+ updatesScheduled = true;
+ updateTimeoutTriggered = false;
+ hasLastPosition = false;
+
+ if (updatesInterval != 0)
+ updatesNextTime = currentDateTime().addMSecs(updatesInterval);
+
+ locker.unlock();
+ wakeUp();
+ }
+}
+
+void QGeoInfoThreadWinCE::stopUpdates()
+{
+ QMutexLocker locker(&mutex);
+ if (updatesScheduled) {
+ updatesScheduled = false;
+ locker.unlock();
+ wakeUp();
+ }
+}
+
+void QGeoInfoThreadWinCE::setUpdateInterval(int interval)
+{
+ QMutexLocker locker(&mutex);
+
+ if (interval == updatesInterval)
+ return;
+
+ int oldInterval = updatesInterval;
+ updatesInterval = interval;
+
+ if (updatesScheduled) {
+ QDateTime now = currentDateTime();
+
+ // The periodic update interval has been changed and updates are still ocurring.
+
+ if (oldInterval != 0) {
+ if (updatesInterval != 0) {
+ // If we are changing fixed intervals we update the scheduled time for the next
+ // periodic update, making sure that it is scheduled in the future.
+ updatesNextTime = updatesNextTime.addMSecs(updatesInterval - oldInterval);
+ while (msecsTo(now, updatesNextTime) < 0)
+ updatesNextTime = updatesNextTime.addMSecs(updatesInterval);
+ } else {
+ // If we now want to emit updates as the data arrives we invalidate the scheduled
+ // time for the next update, just to be on the safe side.
+ updatesNextTime = now;
+ }
+ } else {
+ // If we were previously emitting updates as the data arrived we set the scheduled time
+ // for the next periodic update.
+ updatesNextTime = now.addMSecs(updatesInterval);
+ }
+
+ locker.unlock();
+ wakeUp();
+ }
+}
+
+void QGeoInfoThreadWinCE::wakeUp()
+{
+ SetEvent(m_wakeUpEvent);
+ statusUpdated.wakeAll();
+}
+
+// We try to keep the GPS turned off as much as we can to preserve battery life.
+// When run() is called we turn on the GPS device and we leave it on
+// until the request is satisfied or periodic updates are stopped.
+// The methods requestUpdate() and startUpdates() will call start() if required.
+void QGeoInfoThreadWinCE::run()
+{
+ mutex.lock();
+ gpsReachedOnState = false;
+ m_gps = NULL;
+
+ const int handleCount = 3;
+ HANDLE handles[handleCount] = { m_newDataEvent, m_gpsStateChange, m_wakeUpEvent };
+
+ if (updatesScheduled || requestScheduled) {
+ m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0);
+ }
+
+ while (true) {
+
+ if (stopping)
+ break;
+
+ if (!updatesScheduled && !requestScheduled) {
+ if (m_gps != NULL) {
+ GPSCloseDevice(m_gps);
+ m_gps = NULL;
+ }
+ statusUpdated.wait(&mutex);
+ if (updatesScheduled || requestScheduled) {
+ gpsReachedOnState = false;
+ m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0);
+ }
+ }
+
+ // If the periodic update is 0 then updates are returned as available.
+ // If this is not the case then the next timeout will be set for whichever of
+ // the request and periodic updates that is due next.
+
+ // We cap the amount of time we spend waiting for updates.
+ DWORD timeout = MaximumMainLoopWaitTime;
+
+ QDateTime now = currentDateTime();
+
+ if (requestScheduled) {
+ if (!updatesScheduled || (updatesInterval == 0)
+ || (msecsTo(requestNextTime, updatesNextTime) >= 0)) {
+ timeout = msecsTo(now, requestNextTime) + 100;
+ } else {
+ if (updatesInterval != 0)
+ timeout = msecsTo(now, updatesNextTime) + 100;
+ }
+ } else {
+ // updatesScheduled has to be true or we wouldn't still be in the larger while loop.
+ if (updatesInterval != 0)
+ timeout = msecsTo(now, updatesNextTime) + 100;
+ }
+
+ if (timeout > MaximumMainLoopWaitTime)
+ timeout = MaximumMainLoopWaitTime;
+
+ mutex.unlock();
+ DWORD dwRet = WaitForMultipleObjects(handleCount, handles, FALSE, timeout);
+ mutex.lock();
+
+ // The GPS data has been updated.
+ if (dwRet == WAIT_OBJECT_0) {
+ // The other options are:
+ // dwRet == WAIT_OBJECT_0 + 1
+ // => The GPS state has been updated.
+ // dwRet == WAIT_OBJECT_0 + 2
+ // => We called QGeoInfoThreadWinCE::wakeUp().
+ // dwRet == WAIT_TIMEOUT
+ // => WaitForMultipleObjects() timed out.
+
+ GPS_POSITION posn;
+ posn.dwVersion = GPS_VERSION_1;
+ posn.dwSize = sizeof(posn);
+
+ dwRet = GPSGetPosition(m_gps, &posn, timeout, 0);
+
+ if (dwRet == ERROR_SUCCESS) {
+ if (!validator->valid(posn)) {
+ invalidDataReceived = true;
+ } else {
+ m_lastPosition = posn;
+ hasLastPosition = true;
+ updateTimeoutTriggered = false;
+
+ // A request and a periodic update could both be satisfied at once.
+ // We use this flag to prevent a double update.
+ bool emitDataUpdated = false;
+
+ // If a request is in process we emit the dataUpdated signal.
+ if (requestScheduled) {
+ emitDataUpdated = true;
+ requestScheduled = false;
+ }
+
+ // If we are updating as data becomes available or if the update period has elapsed
+ // we emit the dataUpdated signal.
+ if (updatesScheduled) {
+ QDateTime now = currentDateTime();
+ if (updatesInterval == 0) {
+ emitDataUpdated = true;
+ } else if (msecsTo(now, updatesNextTime) < 0) {
+ while (msecsTo(now, updatesNextTime) < 0)
+ updatesNextTime = updatesNextTime.addMSecs(updatesInterval);
+ emitDataUpdated = true;
+ }
+ }
+
+ if (emitDataUpdated) {
+ hasLastPosition = false;
+ mutex.unlock();
+ emit dataUpdated(m_lastPosition);
+ mutex.lock();
+ }
+ }
+ }
+ }
+ if (dwRet != WAIT_OBJECT_0 || invalidDataReceived) {
+ invalidDataReceived = false;
+
+ // Third party apps may have the ability to turn off the gps hardware independently of
+ // the Microsoft GPS API.
+ // This checks for an unexpected power down and turns the hardware back on.
+
+ // The GPS state has been updated.
+
+ if (dwRet == WAIT_OBJECT_0 + 1) {
+ GPS_DEVICE device;
+ device.dwVersion = GPS_VERSION_1;
+ device.dwSize = sizeof(device);
+
+ dwRet = GPSGetDeviceState(&device);
+
+ if (device.dwDeviceState == SERVICE_STATE_ON) {
+ gpsReachedOnState = true;
+ } else if ((device.dwDeviceState == SERVICE_STATE_OFF) && gpsReachedOnState) {
+ // We do not want to mess with devices that are slow starting up, so we only
+ // turn on devices that have previously reached the "On" state.
+ gpsReachedOnState = false;
+ m_gps = GPSOpenDevice(m_newDataEvent, m_gpsStateChange, NULL, 0);
+ }
+ }
+
+ // We reach this point if the gps state has changed, if the wake up event has been
+ // triggered, if we received data we were not interested in from the GPS,
+ // or if a timeout occurred while waiting for gps data.
+ //
+ // In all of these cases we should check for request and periodic update timeouts.
+
+ QDateTime now = currentDateTime();
+
+ bool emitUpdateTimeout = false;
+
+ // Check for request timeouts.
+ if (requestScheduled && msecsTo(now, requestNextTime) < 0) {
+ requestScheduled = false;
+ emitUpdateTimeout = true;
+ }
+
+ // Check to see if a periodic update is due.
+ if (updatesScheduled && updatesInterval != 0 && (msecsTo(now, updatesNextTime) < 0)) {
+ while (msecsTo(now, updatesNextTime) < 0)
+ updatesNextTime = updatesNextTime.addMSecs(updatesInterval);
+ if (hasLastPosition) {
+ hasLastPosition = false;
+ mutex.unlock();
+ emit dataUpdated(m_lastPosition);
+ mutex.lock();
+ } else {
+ if (timeoutsForPeriodicUpdates && !updateTimeoutTriggered) {
+ updateTimeoutTriggered = true;
+ emitUpdateTimeout = true;
+ }
+ }
+ }
+
+ if (emitUpdateTimeout) {
+ mutex.unlock();
+ emit updateTimeout();
+ mutex.lock();
+ }
+ }
+ }
+
+ if (m_gps != NULL)
+ GPSCloseDevice(m_gps);
+
+ mutex.unlock();
+}
+
+#include "moc_qgeoinfothread_wince_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeoinfothread_wince_p.h b/src/location/qgeoinfothread_wince_p.h
new file mode 100644
index 00000000..49f1b76b
--- /dev/null
+++ b/src/location/qgeoinfothread_wince_p.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOINFOTHREAD_WINCE_P_H
+#define QGEOINFOTHREAD_WINCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
+#include <QDateTime>
+
+#include <windows.h>
+
+// including requires <windows.h>
+#include <gpsapi.h>
+
+// including requires <windows.h>
+// included here rather than in the cpp file to make sure it is included after <windows.h>
+#include <service.h> // used for SERVICE_STATE_ constants
+
+QTM_BEGIN_NAMESPACE
+
+// Used to determine if the dataUpdated signal should be emitted by a QGeoInfoThreadWinCE instance.
+// If valid() returns false the QGeoInfoThreadWinCE instance will ignore the data.
+// This is subclassed in order to filter for valid position or satellite data in GPS_POSITION
+// structs.
+class QGeoInfoValidator
+{
+public:
+ QGeoInfoValidator();
+ virtual ~QGeoInfoValidator();
+ virtual bool valid(const GPS_POSITION &data) const = 0;
+};
+
+class QGeoInfoThreadWinCE : public QThread
+{
+ Q_OBJECT
+
+public:
+ enum {
+ // The default timeout for requests if none is specified.
+ DefaultRequestTimeout = 10000,
+ // The maximum time to spend waiting for GPS events in the main loop of the thread.
+ MaximumMainLoopWaitTime = 5000
+ };
+
+ QGeoInfoThreadWinCE(QGeoInfoValidator *validator, bool timeoutsForPeriodicUpdates, QObject *parent = 0);
+ ~QGeoInfoThreadWinCE();
+
+//public slots:
+ void requestUpdate(int timeout = 5000);
+ void startUpdates();
+ void stopUpdates();
+ void setUpdateInterval(int updateInterval);
+
+signals:
+ void dataUpdated(GPS_POSITION data);
+ void updateTimeout();
+
+protected:
+ void run();
+
+private:
+ void wakeUp();
+
+ QDateTime currentDateTime();
+ int msecsTo(QDateTime from, QDateTime to);
+
+ QGeoInfoValidator *validator;
+ bool timeoutsForPeriodicUpdates;
+
+ bool requestScheduled;
+ qint32 requestInterval;
+ QDateTime requestNextTime;
+
+ bool updatesScheduled;
+ qint32 updatesInterval;
+ QDateTime updatesNextTime;
+
+ bool stopping;
+
+ bool gpsReachedOnState;
+
+ bool hasLastPosition;
+ bool invalidDataReceived;
+ bool updateTimeoutTriggered;
+ GPS_POSITION m_lastPosition;
+
+ QMutex mutex;
+ QWaitCondition statusUpdated;
+
+ HANDLE m_gps;
+ HANDLE m_newDataEvent;
+ HANDLE m_gpsStateChange;
+ HANDLE m_wakeUpEvent;
+};
+
+QTM_END_NAMESPACE
+
+#endif //#ifndef QGEOINFOTHREAD_WINCE_P_H
diff --git a/src/location/qgeoplace.cpp b/src/location/qgeoplace.cpp
new file mode 100644
index 00000000..0fa76757
--- /dev/null
+++ b/src/location/qgeoplace.cpp
@@ -0,0 +1,269 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoplace.h"
+#include "qgeoplace_p.h"
+#include "qlandmark.h"
+
+#ifdef QGEOPLACE_DEBUG
+#include <QDebug>
+#endif
+
+#if !defined(Q_CC_MWERKS)
+template<> QTM_PREPEND_NAMESPACE(QGeoPlacePrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QGeoPlacePrivate)>::clone()
+{
+ return d->clone();
+}
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoPlace
+ \brief The QGeoPlace class represents basic information about a place.
+
+ \inmodule QtLocation
+ \since 1.1
+
+ \ingroup location
+
+ A QGeoPlace contains a coordinate and the corresponding address, along
+ with an optional bounding box describing the minimum viewport necessary
+ to display the entirety of the place.
+
+ A QGeoPlace may contain an QLandmark instance. The isLandmark() function
+ can be used to determine if this is the case, and the
+ QLandmark(const QGeoPlace &place) constructor can be used to restore
+ access to the landmark data.
+
+ For example:
+ \code
+ QGeoPlace p;
+ QLandmark l;
+ ...
+ if (p.isLandmark())
+ l = QLandmark(p)
+ \endcode
+*/
+
+/*!
+ Constructs an empty place object.
+*/
+QGeoPlace::QGeoPlace()
+ : d_ptr(new QGeoPlacePrivate())
+{
+}
+
+/*!
+ \internal
+*/
+QGeoPlace::QGeoPlace(QGeoPlacePrivate *dd)
+ : d_ptr(dd) {}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QGeoPlace::QGeoPlace(const QGeoPlace &other)
+ : d_ptr(other.d_ptr)
+{
+}
+
+/*!
+ Destroys this place.
+*/
+QGeoPlace::~QGeoPlace()
+{
+}
+
+/*!
+ Assigns \a other to this place and returns a reference
+ to this place.
+*/
+QGeoPlace &QGeoPlace::operator= (const QGeoPlace & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+inline QGeoPlacePrivate* QGeoPlace::d_func()
+{
+ return reinterpret_cast<QGeoPlacePrivate*>(d_ptr.data());
+}
+
+inline const QGeoPlacePrivate* QGeoPlace::d_func() const
+{
+ return reinterpret_cast<const QGeoPlacePrivate*>(d_ptr.constData());
+}
+
+/*!
+ Returns true if \a other is equal to this place,
+ otherwise returns false.
+*/
+bool QGeoPlace::operator== (const QGeoPlace &other) const
+{
+ return ( *(d_ptr.constData()) == *(other.d_ptr.constData()));
+}
+
+/*!
+ Returns true if \a other is not equal to this place,
+ otherwise returns false.
+*/
+bool QGeoPlace::operator!= (const QGeoPlace &other) const
+{
+ return (!this->operator ==(other));
+}
+
+/*!
+ This function returns whether this QGeoPlace instance contain all of the
+ information required to construct a QLandmark instance.
+
+ If so, the QLandmark(const QGeoPlace &place) constructor can be used to
+ restore access to the landmark data.
+*/
+bool QGeoPlace::isLandmark() const
+{
+ return (d_ptr->type == QGeoPlacePrivate::LandmarkType);
+}
+
+/*!
+ Returns the viewport associated with this place.
+
+ The viewport is a suggestion for a size and position of a map window
+ which aims to view this palce.
+*/
+QGeoBoundingBox QGeoPlace::viewport() const
+{
+ Q_D(const QGeoPlace);
+ return d->viewport;
+}
+
+/*!
+ Sets the viewport associated with this place to \a viewport.
+
+ The viewport is a suggestion for a size and position of a map window
+ which aims to view this palce.
+*/
+void QGeoPlace::setViewport(const QGeoBoundingBox &viewport)
+{
+ Q_D(QGeoPlace);
+ d->viewport = viewport;
+}
+
+/*!
+ Returns the coordinate that this place is located at.
+*/
+QGeoCoordinate QGeoPlace::coordinate() const
+{
+ Q_D(const QGeoPlace);
+ return d->coordinate;
+}
+
+/*!
+ Sets the \a coordinate that this place is located at.
+*/
+void QGeoPlace::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ Q_D(QGeoPlace);
+ d->coordinate = coordinate;
+}
+
+/*!
+ Returns the address of this place.
+*/
+QGeoAddress QGeoPlace::address() const
+{
+ Q_D(const QGeoPlace);
+ return d->address;
+}
+
+/*!
+ Sets the \a address of this place.
+*/
+void QGeoPlace::setAddress(const QGeoAddress &address)
+{
+ Q_D(QGeoPlace);
+ d->address = address;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QGeoPlacePrivate::QGeoPlacePrivate()
+ : QSharedData(),
+ type(QGeoPlacePrivate::GeoPlaceType) {}
+
+QGeoPlacePrivate::QGeoPlacePrivate(const QGeoPlacePrivate &other)
+ : QSharedData(other),
+ type(other.type),
+ viewport(other.viewport),
+ coordinate(other.coordinate),
+ address(other.address) {}
+
+QGeoPlacePrivate::~QGeoPlacePrivate() {}
+
+QGeoPlacePrivate& QGeoPlacePrivate::operator= (const QGeoPlacePrivate & other)
+{
+ type = other.type;
+ viewport = other.viewport;
+ coordinate = other.coordinate;
+ address = other.address;
+
+ return *this;
+}
+
+bool QGeoPlacePrivate::operator== (const QGeoPlacePrivate &other) const
+{
+
+#ifdef QGEOPLACE_DEBUG
+ qDebug() << "typoe" << (type == other.type);
+ qDebug() << "viewport" << (viewport == other.viewport);
+ qDebug() << "coordinate:" << (coordinate == other.coordinate);
+ qDebug() << "address:" << (address == other.address);
+#endif
+
+ return ((type == other.type)
+ && (viewport == other.viewport)
+ && (coordinate == other.coordinate)
+ && (address == other.address));
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeoplace.h b/src/location/qgeoplace.h
new file mode 100644
index 00000000..3919b1ee
--- /dev/null
+++ b/src/location/qgeoplace.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPLACE_H
+#define QGEOPLACE_H
+
+#include "qmobilityglobal.h"
+#include <QSharedDataPointer>
+
+#include "qgeoaddress.h"
+#include "qgeoboundingbox.h"
+#include "qgeocoordinate.h"
+
+class QString;
+
+QTM_BEGIN_NAMESPACE
+
+class QLandmark;
+
+class QGeoPlacePrivate;
+
+class Q_LOCATION_EXPORT QGeoPlace
+{
+public:
+ QGeoPlace();
+ QGeoPlace(const QGeoPlace &other);
+ virtual ~QGeoPlace();
+
+ QGeoPlace& operator=(const QGeoPlace &other);
+
+ bool operator==(const QGeoPlace &other) const;
+ bool operator!=(const QGeoPlace &other) const;
+
+ bool isLandmark() const;
+
+ QGeoBoundingBox viewport() const;
+ void setViewport(const QGeoBoundingBox &viewport);
+
+ QGeoCoordinate coordinate() const;
+ void setCoordinate(const QGeoCoordinate &coordinate);
+
+ QGeoAddress address() const;
+ void setAddress(const QGeoAddress &address);
+
+protected:
+ QGeoPlace(QGeoPlacePrivate *dd);
+
+ QSharedDataPointer<QGeoPlacePrivate> d_ptr;
+
+private:
+ QGeoPlacePrivate* d_func();
+ const QGeoPlacePrivate* d_func() const;
+ friend class QLandmark;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeoplace_p.h b/src/location/qgeoplace_p.h
new file mode 100644
index 00000000..d9aef402
--- /dev/null
+++ b/src/location/qgeoplace_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPLACE_P_H
+#define QGEOPLACE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QRectF>
+#include <QSharedData>
+
+#include "qgeoplace.h"
+#include "qgeoaddress.h"
+#include "qgeoboundingbox.h"
+#include "qgeocoordinate.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPlacePrivate : public QSharedData
+{
+public:
+ enum PlaceType {
+ GeoPlaceType,
+ LandmarkType
+ };
+
+ QGeoPlacePrivate();
+ QGeoPlacePrivate(const QGeoPlacePrivate &other);
+ virtual ~QGeoPlacePrivate();
+
+ QGeoPlacePrivate& operator= (const QGeoPlacePrivate &other);
+
+ virtual bool operator== (const QGeoPlacePrivate &other) const;
+
+ virtual QGeoPlacePrivate* clone() const { return new QGeoPlacePrivate(*this); }
+ PlaceType type;
+ QGeoBoundingBox viewport;
+ QGeoCoordinate coordinate;
+ QGeoAddress address;
+};
+
+QTM_END_NAMESPACE
+
+#if defined(Q_CC_MWERKS)
+// This results in multiple symbol definition errors on all other compilers
+// but not having a definition here results in an attempt to use the unspecialized
+// clone (which fails because of the pure virtuals above)
+template<> QTM_PREPEND_NAMESPACE(QGeoPlacePrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QGeoPlacePrivate)>::clone()
+{
+ return d->clone();
+}
+#else
+template<> QTM_PREPEND_NAMESPACE(QGeoPlacePrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QGeoPlacePrivate)>::clone();
+#endif
+
+#endif
+
diff --git a/src/location/qgeopositioninfo.cpp b/src/location/qgeopositioninfo.cpp
new file mode 100644
index 00000000..3d8e2780
--- /dev/null
+++ b/src/location/qgeopositioninfo.cpp
@@ -0,0 +1,332 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgeopositioninfo.h"
+
+#include <QHash>
+#include <QDebug>
+#include <QDataStream>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoPrivate
+{
+public:
+ QDateTime timestamp;
+ QGeoCoordinate coord;
+ QHash<int, qreal> doubleAttribs;
+};
+
+/*!
+ \class QGeoPositionInfo
+ \brief The QGeoPositionInfo class contains information gathered on a global position, direction and velocity at a particular point in time.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ A QGeoPositionInfo contains, at a minimum, a geographical coordinate and
+ a timestamp. It may also have heading and speed measurements as well as
+ estimates of the accuracy of the provided data.
+
+ \sa QGeoPositionInfoSource
+*/
+
+/*!
+ \enum QGeoPositionInfo::Attribute
+ Defines the attributes for positional information.
+
+ \value Direction The bearing to true north from the direction of travel, in degrees.
+ \value GroundSpeed The ground speed, in metres/sec.
+ \value VerticalSpeed The vertical speed, in metres/sec.
+ \value MagneticVariation The angle between the horizontal component of the magnetic field and true north, in degrees. Also known as magnetic declination. A positive value indicates a clockwise direction from true north and a negative value indicates a counter-clockwise direction.
+ \value HorizontalAccuracy The accuracy of the provided latitude-longitude value, in metres.
+ \value VerticalAccuracy The accuracy of the provided altitude value, in metres.
+*/
+
+/*!
+ Creates an invalid QGeoPositionInfo object.
+
+ \sa isValid()
+*/
+QGeoPositionInfo::QGeoPositionInfo()
+ : d(new QGeoPositionInfoPrivate)
+{
+}
+
+/*!
+ Creates a QGeoPositionInfo for the given \a coordinate and \a timestamp.
+*/
+QGeoPositionInfo::QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime &timestamp)
+ : d(new QGeoPositionInfoPrivate)
+{
+ d->timestamp = timestamp;
+ d->coord = coordinate;
+}
+
+/*!
+ Creates a QGeoPositionInfo with the values of \a other.
+*/
+QGeoPositionInfo::QGeoPositionInfo(const QGeoPositionInfo &other)
+ : d(new QGeoPositionInfoPrivate)
+{
+ operator=(other);
+}
+
+/*!
+ Destroys a QGeoPositionInfo object.
+*/
+QGeoPositionInfo::~QGeoPositionInfo()
+{
+ delete d;
+}
+
+/*!
+ Assigns the values from \a other to this QGeoPositionInfo.
+*/
+QGeoPositionInfo &QGeoPositionInfo::operator=(const QGeoPositionInfo & other)
+{
+ if (this == &other)
+ return *this;
+
+ d->timestamp = other.d->timestamp;
+ d->coord = other.d->coord;
+ d->doubleAttribs = other.d->doubleAttribs;
+
+ return *this;
+}
+
+/*!
+ Returns true if all of this object's values are the same as those of
+ \a other.
+*/
+bool QGeoPositionInfo::operator==(const QGeoPositionInfo &other) const
+{
+ return d->timestamp == other.d->timestamp
+ && d->coord == other.d->coord
+ && d->doubleAttribs == other.d->doubleAttribs;
+}
+
+/*!
+ \fn bool QGeoPositionInfo::operator!=(const QGeoPositionInfo &other) const
+
+ Returns true if any of this object's values are not the same as those of
+ \a other.
+*/
+
+/*!
+ Returns true if the timestamp() and coordinate() values are both valid.
+
+ \sa QGeoCoordinate::isValid(), QDateTime::isValid()
+*/
+bool QGeoPositionInfo::isValid() const
+{
+ return d->timestamp.isValid() && d->coord.isValid();
+}
+
+/*!
+ Sets the date and time at which this position was reported to \a timestamp.
+
+ The \a timestamp must be in UTC time.
+
+ \sa timestamp()
+*/
+void QGeoPositionInfo::setTimestamp(const QDateTime &timestamp)
+{
+ d->timestamp = timestamp;
+}
+
+/*!
+ Returns the date and time at which this position was reported, in UTC time.
+
+ Returns an invalid QDateTime if no date/time value has been set.
+
+ \sa setTimestamp()
+*/
+QDateTime QGeoPositionInfo::timestamp() const
+{
+ return d->timestamp;
+}
+
+/*!
+ Sets the coordinate for this position to \a coordinate.
+
+ \sa coordinate()
+*/
+void QGeoPositionInfo::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ d->coord = coordinate;
+}
+
+/*!
+ Returns the coordinate for this position.
+
+ Returns an invalid coordinate if no coordinate has been set.
+
+ \sa setCoordinate()
+*/
+QGeoCoordinate QGeoPositionInfo::coordinate() const
+{
+ return d->coord;
+}
+
+/*!
+ Sets the value for \a attribute to \a value.
+
+ \sa attribute()
+*/
+void QGeoPositionInfo::setAttribute(Attribute attribute, qreal value)
+{
+ d->doubleAttribs[int(attribute)] = value;
+}
+
+/*!
+ Returns the value of the specified \a attribute as a qreal value.
+
+ Returns -1 if the value has not been set, although this may also
+ be a legitimate value for some attributes.
+
+ The function hasAttribute() should be used to determine whether or
+ not a value has been set for an attribute.
+
+ \sa hasAttribute(), setAttribute()
+*/
+qreal QGeoPositionInfo::attribute(Attribute attribute) const
+{
+ if (d->doubleAttribs.contains(int(attribute)))
+ return d->doubleAttribs[int(attribute)];
+ return -1;
+}
+
+/*!
+ Removes the specified \a attribute and its value.
+*/
+void QGeoPositionInfo::removeAttribute(Attribute attribute)
+{
+ d->doubleAttribs.remove(int(attribute));
+}
+
+/*!
+ Returns true if the specified \a attribute is present for this
+ QGeoPositionInfo object.
+*/
+bool QGeoPositionInfo::hasAttribute(Attribute attribute) const
+{
+ return d->doubleAttribs.contains(int(attribute));
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info)
+{
+ dbg.nospace() << "QGeoPositionInfo(" << info.d->timestamp;
+ dbg.nospace() << ", ";
+ dbg.nospace() << info.d->coord;
+
+ QList<int> attribs = info.d->doubleAttribs.keys();
+ for (int i = 0; i < attribs.count(); i++) {
+ dbg.nospace() << ", ";
+ switch (attribs[i]) {
+ case QGeoPositionInfo::Direction:
+ dbg.nospace() << "Direction=";
+ break;
+ case QGeoPositionInfo::GroundSpeed:
+ dbg.nospace() << "GroundSpeed=";
+ break;
+ case QGeoPositionInfo::VerticalSpeed:
+ dbg.nospace() << "VerticalSpeed=";
+ break;
+ case QGeoPositionInfo::MagneticVariation:
+ dbg.nospace() << "MagneticVariation=";
+ break;
+ case QGeoPositionInfo::HorizontalAccuracy:
+ dbg.nospace() << "HorizontalAccuracy=";
+ break;
+ case QGeoPositionInfo::VerticalAccuracy:
+ dbg.nospace() << "VerticalAccuracy=";
+ break;
+ }
+ dbg.nospace() << info.d->doubleAttribs[attribs[i]];
+ }
+ dbg.nospace() << ')';
+ return dbg;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info)
+ \relates QGeoPositionInfo
+
+ Writes the given \a info to the specified \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info)
+{
+ stream << info.d->timestamp;
+ stream << info.d->coord;
+ stream << info.d->doubleAttribs;
+ return stream;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info)
+ \relates QGeoPositionInfo
+
+ Reads a coordinate from the specified \a stream into the given
+ \a info.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info)
+{
+ stream >> info.d->timestamp;
+ stream >> info.d->coord;
+ stream >> info.d->doubleAttribs;
+ return stream;
+}
+#endif
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfo.h b/src/location/qgeopositioninfo.h
new file mode 100644
index 00000000..79ef9ad1
--- /dev/null
+++ b/src/location/qgeopositioninfo.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOPOSITIONINFO_H
+#define QGEOPOSITIONINFO_H
+
+#include "qmobilityglobal.h"
+#include "qgeocoordinate.h"
+
+#include <QDateTime>
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+class QDataStream;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoPrivate;
+class Q_LOCATION_EXPORT QGeoPositionInfo
+{
+public:
+ enum Attribute {
+ Direction,
+ GroundSpeed,
+ VerticalSpeed,
+ MagneticVariation,
+ HorizontalAccuracy,
+ VerticalAccuracy
+ };
+
+ QGeoPositionInfo();
+ QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime &updateTime);
+ QGeoPositionInfo(const QGeoPositionInfo &other);
+ ~QGeoPositionInfo();
+
+ QGeoPositionInfo &operator=(const QGeoPositionInfo &other);
+
+ bool operator==(const QGeoPositionInfo &other) const;
+ inline bool operator!=(const QGeoPositionInfo &other) const {
+ return !operator==(other);
+ }
+
+ bool isValid() const;
+
+ void setTimestamp(const QDateTime &timestamp);
+ QDateTime timestamp() const;
+
+ void setCoordinate(const QGeoCoordinate &coordinate);
+ QGeoCoordinate coordinate() const;
+
+ void setAttribute(Attribute attribute, qreal value);
+ qreal attribute(Attribute attribute) const;
+ void removeAttribute(Attribute attribute);
+ bool hasAttribute(Attribute attribute) const;
+
+private:
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info);
+#endif
+#ifndef QT_NO_DATASTREAM
+ friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info);
+ friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info);
+#endif
+ QGeoPositionInfoPrivate *d;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info);
+Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info);
+#endif
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeopositioninfosource.cpp b/src/location/qgeopositioninfosource.cpp
new file mode 100644
index 00000000..ea03a0d6
--- /dev/null
+++ b/src/location/qgeopositioninfosource.cpp
@@ -0,0 +1,551 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qgeopositioninfosource.h>
+#include "qgeopositioninfosourcefactory.h"
+
+#include <QPluginLoader>
+#include <QStringList>
+#include <QSettings>
+#include <QCryptographicHash>
+#include "qmobilitypluginsearch.h"
+
+#if defined(Q_OS_SYMBIAN)
+# include "qgeopositioninfosource_s60_p.h"
+#elif defined(QT_SIMULATOR)
+# include "qgeopositioninfosource_simulator_p.h"
+#elif defined(Q_OS_WINCE)
+# include "qgeopositioninfosource_wince_p.h"
+#elif defined(Q_WS_MAEMO_6)
+# include "qgeopositioninfosource_maemo_p.h"
+#elif defined(Q_WS_MAEMO_5)
+# include "qgeopositioninfosource_maemo5_p.h"
+#endif
+
+#if defined (Q_WS_MEEGO)
+#include "qgeopositioninfosource_maemo_p.h"
+#if defined (GEOCLUE_MASTER_AVAILABLE)
+#include "qgeopositioninfosource_geocluemaster_p.h"
+#endif
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoPositionInfoSource
+ \brief The QGeoPositionInfoSource class is an abstract base class for the distribution of positional updates.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ The static function QGeoPositionInfoSource::createDefaultSource() creates a default
+ position source that is appropriate for the platform, if one is available.
+ Otherwise, QGeoPositionInfoSource will check for available plugins that
+ implement the QGeoPositionInfoSourceFactory interface.
+
+ Users of a QGeoPositionInfoSource subclass can request the current position using
+ requestUpdate(), or start and stop regular position updates using
+ startUpdates() and stopUpdates(). When an update is available,
+ positionUpdated() is emitted. The last known position can be accessed with
+ lastKnownPosition().
+
+ If regular position updates are required, setUpdateInterval() can be used
+ to specify how often these updates should be emitted. If no interval is
+ specified, updates are simply provided whenever they are available.
+ For example:
+
+ \code
+ // Emit updates every 10 seconds if available
+ QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0);
+ if (source)
+ source->setUpdateInterval(10000);
+ \endcode
+
+ To remove an update interval that was previously set, call
+ setUpdateInterval() with a value of 0.
+
+ Note that the position source may have a minimum value requirement for
+ update intervals, as returned by minimumUpdateInterval().
+
+ \warning On Windows CE it is not possible to detect if a device is GPS enabled.
+ The default position source on a Windows CE device without GPS support will never provide any position data.
+
+ \warning On Symbian it is currently only possible to instantiate and use the position sources in the main thread
+ of the application.
+
+*/
+
+/*!
+ \enum QGeoPositionInfoSource::PositioningMethod
+ Defines the types of positioning methods.
+
+ \value SatellitePositioningMethods Satellite-based positioning methods such as GPS.
+ \value NonSatellitePositioningMethods Other positioning methods.
+ \value AllPositioningMethods A flag that matches all positioning methods.
+*/
+
+class QGeoPositionInfoSourcePrivate
+{
+public:
+ int interval;
+ QGeoPositionInfoSource::PositioningMethods methods;
+
+ static QList<QGeoPositionInfoSourceFactory*> pluginsSorted();
+ static QHash<QString, QGeoPositionInfoSourceFactory*> plugins(bool reload = false);
+ static void loadDynamicPlugins(QHash<QString, QGeoPositionInfoSourceFactory*> &plugins);
+ static void loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory*> &plugins);
+};
+
+QHash<QString, QGeoPositionInfoSourceFactory*> QGeoPositionInfoSourcePrivate::plugins(bool reload)
+{
+ static QHash<QString, QGeoPositionInfoSourceFactory*> plugins;
+ static bool alreadyDiscovered = false;
+
+ if (reload == true)
+ alreadyDiscovered = false;
+
+ if (!alreadyDiscovered) {
+ loadStaticPlugins(plugins);
+ loadDynamicPlugins(plugins);
+ alreadyDiscovered = true;
+ }
+ return plugins;
+}
+
+static bool pluginComparator(const QGeoPositionInfoSourceFactory *p1, const QGeoPositionInfoSourceFactory *p2)
+{
+ return (p1->sourcePriority() > p2->sourcePriority());
+}
+
+QList<QGeoPositionInfoSourceFactory*> QGeoPositionInfoSourcePrivate::pluginsSorted()
+{
+ QList<QGeoPositionInfoSourceFactory*> list = plugins().values();
+ qStableSort(list.begin(), list.end(), pluginComparator);
+ return list;
+}
+
+void QGeoPositionInfoSourcePrivate::loadDynamicPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
+{
+ QStringList paths;
+ paths << mobilityPlugins(QLatin1String("position"));
+
+ QPluginLoader qpl;
+ QString blockName;
+
+ QSettings settings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat"));
+ QVariant value = settings.value("position.plugin.operator.whitelist");
+ if (value.isValid()) {
+ QStringList parts = value.toString().split(",");
+ if (parts.size() == 4) {
+ QFile file(parts.at(1));
+ file.open(QIODevice::ReadOnly);
+
+ QCryptographicHash hash(QCryptographicHash::Sha1);
+ while (!file.atEnd()) {
+ QByteArray data = file.read(4096);
+ hash.addData(data);
+ }
+ file.close();
+
+ QByteArray hexHash = hash.result().toHex();
+
+ bool loadIt = true;
+ if (QString::number(file.size()) != parts.at(3)) {
+ qCritical("Position info plugin: bad plugin size for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ loadIt = false;
+ }
+
+ if (hexHash != parts.at(2).toLatin1()) {
+ qCritical("Position info plugin: bad plugin hash for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ loadIt = false;
+ }
+
+ if (loadIt) {
+ qpl.setFileName(parts.at(1));
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance());
+
+ if (f) {
+ QString name = f->sourceName();
+ if (name == parts.at(0)) {
+ plugins.insert(name, f);
+ } else {
+ qCritical("Position info plugin: bad plugin name for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ }
+ }
+ }
+
+ // still set blockName to ensure the plugin doesn't load
+ blockName = parts.at(1);
+ } else {
+ qWarning("Position plugin whitelist: invalid format -- should be key,filename,hash,size");
+ }
+ }
+
+ for (int i = 0; i < paths.count(); ++i) {
+ if (paths.at(i) != blockName) {
+ qpl.setFileName(paths.at(i));
+
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance());
+ if (f) {
+ QString name = f->sourceName();
+
+ #if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+ if (showDebug)
+ qDebug("Dynamic: found a service provider plugin with name %s", qPrintable(name));
+ #endif
+ plugins.insertMulti(name, f);
+ }
+ }
+ }
+}
+
+void QGeoPositionInfoSourcePrivate::loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
+{
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+#endif
+
+ QObjectList staticPlugins = QPluginLoader::staticInstances();
+ for (int i = 0; i < staticPlugins.count(); ++i) {
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(staticPlugins.at(i));
+
+ if (f) {
+ QString name = f->sourceName();
+
+#if !defined QT_NO_DEBUG
+ if (showDebug)
+ qDebug("Static: found a service provider plugin with name %s", qPrintable(name));
+#endif
+ if (!name.isEmpty()) {
+ plugins.insertMulti(name, f);
+ }
+ }
+
+ }
+}
+
+/*!
+ Creates a position source with the specified \a parent.
+*/
+
+QGeoPositionInfoSource::QGeoPositionInfoSource(QObject *parent)
+ : QObject(parent),
+ d(new QGeoPositionInfoSourcePrivate)
+{
+ d->interval = 0;
+ d->methods = 0;
+}
+
+/*!
+ Destroys the position source.
+*/
+QGeoPositionInfoSource::~QGeoPositionInfoSource()
+{
+ delete d;
+}
+
+/*!
+ \property QGeoPositionInfoSource::updateInterval
+ \brief This property holds the requested interval in milliseconds between each update.
+
+ If the update interval is not set (or is set to 0) the
+ source will provide updates as often as necessary.
+
+ If the update interval is set, the source will provide updates at an
+ interval as close to the requested interval as possible. If the requested
+ interval is less than the minimumUpdateInterval(),
+ the minimum interval is used instead.
+
+ Changes to the update interval will happen as soon as is practical, however the
+ time the change takes may vary between implementations. Whether or not the elapsed
+ time from the previous interval is counted as part of the new interval is also
+ implementation dependent.
+
+ The default value for this property is 0.
+
+ Note: Subclass implementations must call the base implementation of
+ setUpdateInterval() so that updateInterval() returns the correct value.
+*/
+void QGeoPositionInfoSource::setUpdateInterval(int msec)
+{
+ d->interval = msec;
+}
+
+int QGeoPositionInfoSource::updateInterval() const
+{
+ return d->interval;
+}
+
+/*!
+ Sets the preferred positioning methods for this source to \a methods.
+
+ If \a methods includes a method that is not supported by the source, the
+ unsupported method will be ignored.
+
+ If \a methods does not include any methods supported by the source, the
+ preferred methods will be set to the set of methods which the source supports.
+
+ \bold {Note:} When reimplementing this method, subclasses must call the
+ base method implementation to ensure preferredPositioningMethods() returns the correct value.
+
+ \sa supportedPositioningMethods()
+*/
+void QGeoPositionInfoSource::setPreferredPositioningMethods(PositioningMethods methods)
+{
+ d->methods = methods & supportedPositioningMethods();
+ if (d->methods == 0) {
+ d->methods = supportedPositioningMethods();
+ }
+}
+
+/*!
+ Returns the positioning methods set by setPreferredPositioningMethods().
+*/
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSource::preferredPositioningMethods() const
+{
+ return d->methods;
+}
+
+/*!
+ Creates and returns a position source with the given \a parent that
+ reads from the system's default sources of location data, or the plugin
+ with the highest available priority.
+
+ Returns 0 if the system has no default position source and no valid plugins
+ could be found.
+
+ Note: Symbian applications will need to have the Location capability
+ otherwise this will return 0.
+*/
+
+QGeoPositionInfoSource *QGeoPositionInfoSource::createDefaultSource(QObject *parent)
+{
+ QSettings pluginSettings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat"));
+ QVariant value = pluginSettings.value("position.plugin.operator.whitelist");
+ if (value.isValid()) {
+ QStringList parts = value.toString().split(",");
+ if (parts.size() == 4) {
+ QGeoPositionInfoSource *source = createSource(parts.at(0), parent);
+ if (source)
+ return source;
+ }
+ }
+
+#if defined(Q_OS_SYMBIAN)
+ QGeoPositionInfoSource *ret = NULL;
+ TRAPD(error, QT_TRYCATCH_LEAVING(ret = CQGeoPositionInfoSourceS60::NewL(parent)));
+ if (error == KErrNone)
+ return ret;
+#elif defined(QT_SIMULATOR)
+ return new QGeoPositionInfoSourceSimulator(parent);
+#elif defined(Q_OS_WINCE)
+ return new QGeoPositionInfoSourceWinCE(parent);
+#elif (defined(Q_WS_MAEMO_6)) || (defined(Q_WS_MAEMO_5))
+ QGeoPositionInfoSourceMaemo *source = new QGeoPositionInfoSourceMaemo(parent);
+ int status = source->init();
+ if (status != -1)
+ return source;
+ else
+ delete source;
+#elif defined(Q_WS_MEEGO)
+ // Use Maemo6 backend if its available, otherwise use Geoclue backend
+ QSettings maemo6Settings(QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSatMaemo6"));
+ if (!maemo6Settings.value("maemo6positioningavailable").isValid()) {
+ QGeoPositionInfoSourceMaemo* maemo6Source = new QGeoPositionInfoSourceMaemo(parent);
+ int status = maemo6Source->init();
+ if (status == -1) {
+ delete maemo6Source;
+ maemo6Source = 0;
+ maemo6Settings.setValue("maemo6positioningavailable", false);
+ } else {
+ return maemo6Source;
+ }
+ }
+#ifdef GEOCLUE_MASTER_AVAILABLE
+ QGeoPositionInfoSourceGeoclueMaster *geoclueSource = new QGeoPositionInfoSourceGeoclueMaster(parent);
+ int status = geoclueSource->init();
+ if (status >= 0)
+ return geoclueSource;
+ delete geoclueSource;
+#endif // GEOCLUE_MASTER_AVAILABLE
+#endif
+ // no good platform source, try plugins
+ foreach (QGeoPositionInfoSourceFactory *f, QGeoPositionInfoSourcePrivate::pluginsSorted()) {
+ QGeoPositionInfoSource *src = f->positionInfoSource(parent);
+ if (src)
+ return src;
+ }
+
+ return 0;
+}
+
+
+/*!
+ Creates and returns a position source with the given \a parent,
+ by loading the plugin named \a sourceName.
+
+ Returns 0 if the plugin cannot be found.
+*/
+QGeoPositionInfoSource *QGeoPositionInfoSource::createSource(const QString &sourceName, QObject *parent)
+{
+ QGeoPositionInfoSourceFactory *f = QGeoPositionInfoSourcePrivate::plugins().value(sourceName);
+ if (f) {
+ QGeoPositionInfoSource *src = f->positionInfoSource(parent);
+ if (src)
+ return src;
+ }
+ return 0;
+}
+
+
+/*!
+ Returns a list of available source plugins. Note that this list does not
+ include the default platform backend, if one is available.
+*/
+QStringList QGeoPositionInfoSource::availableSources()
+{
+ return QGeoPositionInfoSourcePrivate::plugins().keys();
+}
+
+/*!
+ \fn QGeoPositionInfo QGeoPositionInfoSource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0;
+
+ Returns an update containing the last known position, or a null update
+ if none is available.
+
+ If \a fromSatellitePositioningMethodsOnly is true, this returns the last
+ known position received from a satellite positioning method; if none
+ is available, a null update is returned.
+*/
+
+/*!
+ \fn virtual PositioningMethods QGeoPositionInfoSource::supportedPositioningMethods() const = 0;
+
+ Returns the positioning methods available to this source.
+
+ \sa setPreferredPositioningMethods()
+*/
+
+
+/*!
+ \property QGeoPositionInfoSource::minimumUpdateInterval
+ \brief This property holds the minimum time (in milliseconds) required to retrieve a position update.
+
+ This is the minimum value accepted by setUpdateInterval() and
+ requestUpdate().
+*/
+
+
+/*!
+ \fn virtual void QGeoPositionInfoSource::startUpdates() = 0;
+
+ Starts emitting updates at regular intervals as specified by setUpdateInterval().
+
+ If setUpdateInterval() has not been called, the source will emit updates
+ as soon as they become available.
+
+ An updateTimout() signal will be emitted if this QGeoPositionInfoSource subclass determines
+ that it will not be able to provide regular updates. This could happen if a satellite fix is
+ lost or if a hardware error is detected. Position updates will recommence if the data becomes
+ available later on. The updateTimout() signal will not be emitted again until after the
+ periodic updates resume.
+*/
+
+/*!
+ \fn virtual void QGeoPositionInfoSource::stopUpdates() = 0;
+
+ Stops emitting updates at regular intervals.
+*/
+
+/*!
+ \fn virtual void QGeoPositionInfoSource::requestUpdate(int timeout = 0);
+
+ Attempts to get the current position and emit positionUpdated() with
+ this information. If the current position cannot be found within the given \a timeout
+ (in milliseconds) or if \a timeout is less than the value returned by
+ minimumUpdateInterval(), updateTimeout() is emitted.
+
+ If the timeout is zero, the timeout defaults to a reasonable timeout
+ period as appropriate for the source.
+
+ This does nothing if another update request is in progress. However
+ it can be called even if startUpdates() has already been called and
+ regular updates are in progress.
+
+ If the source uses multiple positioning methods, it tries to gets the
+ current position from the most accurate positioning method within the
+ given timeout.
+*/
+
+/*!
+ \fn void QGeoPositionInfoSource::positionUpdated(const QGeoPositionInfo &update);
+
+ If startUpdates() or requestUpdate() is called, this signal is emitted
+ when an update becomes available.
+
+ The \a update value holds the value of the new update.
+*/
+
+/*!
+ \fn void QGeoPositionInfoSource::updateTimeout();
+
+ If requestUpdate() was called, this signal will be emitted if the current position could not
+ be retrieved within the specified timeout.
+
+ If startUpdates() has been called, this signal will be emitted if this QGeoPositionInfoSource
+ subclass determines that it will not be able to provide further regular updates. This signal
+ will not be emitted again until after the regular updates resume.
+*/
+
+#include "moc_qgeopositioninfosource.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosource.h b/src/location/qgeopositioninfosource.h
new file mode 100644
index 00000000..d5997488
--- /dev/null
+++ b/src/location/qgeopositioninfosource.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOPOSITIONINFOSOURCE_H
+#define QGEOPOSITIONINFOSOURCE_H
+
+#include "qmobilityglobal.h"
+#include "qgeopositioninfo.h"
+
+#include <QObject>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoSourcePrivate;
+class Q_LOCATION_EXPORT QGeoPositionInfoSource : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval)
+ Q_PROPERTY(int minimumUpdateInterval READ minimumUpdateInterval)
+
+public:
+ enum PositioningMethod {
+ SatellitePositioningMethods = 0x000000ff,
+ NonSatellitePositioningMethods = 0xffffff00,
+ AllPositioningMethods = 0xffffffff
+ };
+ Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)
+
+ explicit QGeoPositionInfoSource(QObject *parent);
+ virtual ~QGeoPositionInfoSource();
+
+ virtual void setUpdateInterval(int msec);
+ int updateInterval() const;
+
+ virtual void setPreferredPositioningMethods(PositioningMethods methods);
+ PositioningMethods preferredPositioningMethods() const;
+
+ virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0;
+
+ virtual PositioningMethods supportedPositioningMethods() const = 0;
+ virtual int minimumUpdateInterval() const = 0;
+
+ static QGeoPositionInfoSource *createDefaultSource(QObject *parent);
+ static QGeoPositionInfoSource *createSource(const QString &sourceName, QObject *parent);
+ static QStringList availableSources();
+
+public Q_SLOTS:
+ virtual void startUpdates() = 0;
+ virtual void stopUpdates() = 0;
+
+ virtual void requestUpdate(int timeout = 0) = 0;
+
+Q_SIGNALS:
+ void positionUpdated(const QGeoPositionInfo &update);
+ void updateTimeout();
+
+private:
+ Q_DISABLE_COPY(QGeoPositionInfoSource)
+ QGeoPositionInfoSourcePrivate *d;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoPositionInfoSource::PositioningMethods)
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeopositioninfosource_geocluemaster.cpp b/src/location/qgeopositioninfosource_geocluemaster.cpp
new file mode 100644
index 00000000..8fba770f
--- /dev/null
+++ b/src/location/qgeopositioninfosource_geocluemaster.cpp
@@ -0,0 +1,556 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+#include <QDebug>
+#endif
+
+#include "qgeopositioninfosource_geocluemaster_p.h"
+#include <gconf/gconf-client.h>
+
+QTM_BEGIN_NAMESPACE
+
+#define MINIMUM_UPDATE_INTERVAL 1000
+#define UPDATE_TIMEOUT_COLD_START 120000
+
+// Callback for position-changed -signal
+static void position_changed (GeocluePosition *position,
+ GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy,
+ gpointer userdata) // Ptr to this
+{
+ Q_UNUSED(position);
+ if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
+ fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) {
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->regularUpdateFailed();
+ } else {
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->regularUpdateSucceeded(
+ fields, timestamp, latitude, longitude, altitude, accuracy);
+ }
+}
+
+// Callback for velocity-changed -signal
+static void velocity_changed (GeoclueVelocity *velocity,
+ GeoclueVelocityFields fields,
+ int timestamp,
+ double speed,
+ double direction,
+ double climb,
+ gpointer userdata) // Ptr to this
+{
+ Q_UNUSED(velocity)
+ Q_UNUSED(timestamp)
+ Q_UNUSED(direction)
+ Q_UNUSED(climb)
+ if (!(fields & GEOCLUE_VELOCITY_FIELDS_SPEED)) {
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->velocityUpdateFailed();
+ return;
+ }
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->velocityUpdateSucceeded(speed);
+}
+
+// Callback for single async update
+static void position_callback (GeocluePosition *pos,
+ GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy,
+ GError *error,
+ gpointer userdata)
+{
+ Q_UNUSED(pos);
+ Q_UNUSED(accuracy);
+
+ if (error)
+ g_error_free (error);
+ if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
+ fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) {
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->singleUpdateFailed();
+
+ } else {
+ static_cast<QGeoPositionInfoSourceGeoclueMaster*>(userdata)->singleUpdateSucceeded(
+ fields, timestamp, latitude, longitude, altitude, accuracy);
+ }
+}
+
+QGeoPositionInfoSourceGeoclueMaster::QGeoPositionInfoSourceGeoclueMaster(QObject *parent)
+ : QGeoPositionInfoSource(parent), m_updateInterval(0), m_preferredResources(GEOCLUE_RESOURCE_ALL),
+ m_preferredAccuracy(GEOCLUE_ACCURACY_LEVEL_NONE),
+ m_client(0), m_pos(0), m_vel(0), m_lastPositionIsFresh(false), m_lastVelocityIsFresh(false),
+ m_lastVelocity(0), m_lastPositionFromSatellite(false), m_methods(AllPositioningMethods)
+{
+ m_requestTimer.setSingleShot(true);
+ QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestUpdateTimeout()));
+ QObject::connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(startUpdatesTimeout()));
+}
+
+QGeoPositionInfoSourceGeoclueMaster::~QGeoPositionInfoSourceGeoclueMaster()
+{
+ if (m_pos)
+ g_object_unref (m_pos);
+ if (m_vel)
+ g_object_unref(m_vel);
+ if (m_client)
+ g_object_unref (m_client);
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::velocityUpdateFailed()
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster velocity update failed.";
+#endif
+ // Set the velocitydata non-fresh.
+ m_lastVelocityIsFresh = false;
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::velocityUpdateSucceeded(double speed)
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster velocity update succeeded, speed: " << speed;
+#endif
+ // Store the velocity and mark it as fresh. Simple but hopefully adequate.
+ m_lastVelocity = speed * 0.514444; // convert knots to m/s
+ m_lastVelocityIsFresh = true;
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::singleUpdateFailed()
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster single update failed (requestUpdate)";
+#endif
+ if (m_requestTimer.isActive())
+ m_requestTimer.stop();
+ // Send timeout even if time wasn't up yet, because we are not trying again
+ emit updateTimeout();
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::singleUpdateSucceeded(GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy)
+{
+ QGeoPositionInfo info = geoclueToPositionInfo(fields, timestamp, latitude, longitude, altitude, accuracy);
+ m_lastPosition = info;
+ if (m_requestTimer.isActive())
+ m_requestTimer.stop();
+ if (m_lastVelocityIsFresh)
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, m_lastVelocity); // assume groundspeed
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster single update succeeded: ";
+ qDebug() << "Lat, lon, alt, speed:" << info.coordinate().latitude() << info.coordinate().longitude() << info.coordinate().altitude() << info.attribute(QGeoPositionInfo::GroundSpeed);
+#endif
+ emit positionUpdated(info);
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::regularUpdateFailed()
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster regular update failed.";
+#endif
+ // Emit timeout and keep on listening in case error condition clears.
+ // Currently this is emitted each time an error occurs, and thereby it assumes
+ // that there does not come many erroneous updates from position source.
+ // This assumption may be invalid.
+ m_lastVelocityIsFresh = false;
+ m_lastPositionIsFresh = false;
+ if (m_updateTimer.isActive())
+ emit updateTimeout();
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::regularUpdateSucceeded(GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy)
+{
+ m_lastPosition = geoclueToPositionInfo(fields, timestamp, latitude, longitude, altitude, accuracy);
+ m_lastPositionIsFresh = true;
+ if (m_lastVelocityIsFresh) {
+ m_lastPosition.setAttribute(QGeoPositionInfo::GroundSpeed, m_lastVelocity); // assume groundspeed
+ m_lastVelocityIsFresh = false;
+ }
+ // If a non-intervalled startUpdates has been issued, send an update.
+ if (!m_updateTimer.isActive()) {
+ m_lastPositionIsFresh = false;
+ emit positionUpdated(m_lastPosition);
+ }
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster regular update succeeded: ";
+ qDebug() << "Lat, lon, alt, speed:" << m_lastPosition.coordinate().latitude() << m_lastPosition.coordinate().longitude() << m_lastPosition.coordinate().altitude() << m_lastPosition.attribute(QGeoPositionInfo::GroundSpeed);
+#endif
+}
+
+bool QGeoPositionInfoSourceGeoclueMaster::tryGPS()
+{
+ // Check if the gconf value is set properly
+ GConfClient* client;
+ gchar* device_name;
+ client = gconf_client_get_default();
+ device_name = gconf_client_get_string(client, "/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice", NULL);
+ QString deviceName(QString::fromAscii(device_name));
+ g_object_unref(client);
+ g_free(device_name);
+
+ if (deviceName.isEmpty()) {
+ return false;
+ } else {
+ // Check if the device exists (does nothing if a bluetooth address)
+ if (deviceName.trimmed().at(0) == '/' && QFile::exists(deviceName.trimmed())) {
+ return true;
+ }
+ return false;
+ }
+}
+
+int QGeoPositionInfoSourceGeoclueMaster::init()
+{
+ g_type_init ();
+ // Check if there is sense to try GPS
+ if (tryGPS()) {
+ m_preferredResources = GEOCLUE_RESOURCE_GPS;
+ m_preferredAccuracy = GEOCLUE_ACCURACY_LEVEL_DETAILED;
+ if (configurePositionSource() != -1) {
+ return 0;
+ } else {
+ // If not successful, try to get any resource
+ m_preferredResources = GEOCLUE_RESOURCE_ALL;
+ m_preferredAccuracy = GEOCLUE_ACCURACY_LEVEL_NONE;
+ return configurePositionSource();
+ }
+ } else {
+ return configurePositionSource();
+ }
+}
+
+int QGeoPositionInfoSourceGeoclueMaster::configurePositionSource()
+{
+ GeoclueMaster *master(0);
+ GError *error = 0;
+ // Free potential previous sources, because new requirements can't be set for the client
+ // (creating a position object after changing requirements seems to fail).
+ if (m_client) {
+ g_object_unref (m_client);
+ m_client = 0;
+ }
+ if (m_pos) {
+ g_object_unref(m_pos);
+ m_pos = 0;
+ }
+ if (m_vel) {
+ g_object_unref(m_vel);
+ m_vel = 0;
+ }
+
+ master = geoclue_master_get_default ();
+ if (!master) {
+ qCritical ("QGeoPositionInfoSourceGeoclueMaster error creating GeoclueMaster");
+ return -1;
+ }
+
+ m_client = geoclue_master_create_client (master, NULL, &error);
+ g_object_unref (master);
+
+ if (!m_client) {
+ qCritical ("QGeoPositionInfoSourceGeoclueMaster error creating GeoclueMasterClient.");
+ if (error) {
+ qCritical (error->message);
+ g_error_free (error);
+ }
+ return -1;
+ }
+
+ if (!geoclue_master_client_set_requirements (m_client,
+ m_preferredAccuracy, // min_accuracy
+ 0, // min_time
+ TRUE, // require_updates (signals)
+ m_preferredResources,
+ &error)){
+ qCritical ("QGeoPositionInfoSourceGeoclueMaster geoclue set_requirements failed.");
+ if (error) {
+ qCritical (error->message);
+ g_error_free (error);
+ }
+ g_object_unref (m_client);
+ m_client = 0;
+ return -1;
+ }
+ m_pos = geoclue_master_client_create_position (m_client, NULL);
+ if (!m_pos) {
+ qCritical("QGeoPositionInfoSourceGeoclueMaster failed to get a position object");
+ g_object_unref (m_client);
+ m_client = 0;
+ return -1;
+ }
+ // Succeeding velocity is not mandatory. Master does not provide abstraction
+ // for velocity provider, hence request Gypsy provider directly.
+ m_vel = geoclue_velocity_new("org.freedesktop.Geoclue.Providers.Gypsy",
+ "/org/freedesktop/Geoclue/Providers/Gypsy");
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ if (m_vel == NULL)
+ qDebug("QGeoPositionInfoSourceGeoclueMaster velocity provider (Gypsy) not available.");
+#endif
+ return 0;
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::setUpdateInterval(int msec)
+{
+ msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+ m_updateInterval = msec;
+ // If update timer is running, set the new interval
+ if (m_updateTimer.isActive()) {
+ m_updateTimer.setInterval(msec);
+ }
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::setPreferredPositioningMethods(PositioningMethods methods)
+{
+ if (methods == m_methods)
+ return;
+ m_methods = methods;
+
+ switch (methods) {
+ case SatellitePositioningMethods:
+ m_preferredResources = GEOCLUE_RESOURCE_GPS;
+ m_preferredAccuracy = GEOCLUE_ACCURACY_LEVEL_DETAILED;
+ break;
+ case NonSatellitePositioningMethods:
+ m_preferredResources = (GeoclueResourceFlags)(GEOCLUE_RESOURCE_CELL | GEOCLUE_RESOURCE_NETWORK);
+ m_preferredAccuracy = GEOCLUE_ACCURACY_LEVEL_NONE;
+ break;
+ case AllPositioningMethods:
+ m_preferredResources = GEOCLUE_RESOURCE_ALL;
+ m_preferredAccuracy = GEOCLUE_ACCURACY_LEVEL_NONE;
+ break;
+ default:
+ qWarning("GeoPositionInfoSourceGeoClueMaster unknown preferred method.");
+ return;
+ }
+ QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster requested to set methods to, and set them to: " << methods << m_preferredResources;
+#endif
+ m_lastPositionIsFresh = false;
+ m_lastVelocityIsFresh = false;
+ int status = configurePositionSource();
+
+ // If updates ongoing, connect to the new objects
+ if (m_updateTimer.isActive()) {
+ if (status != -1) {
+ g_signal_connect (G_OBJECT (m_pos), "position-changed",
+ G_CALLBACK (position_changed),this);
+ if (m_vel) {
+ g_signal_connect (G_OBJECT (m_vel), "velocity-changed",
+ G_CALLBACK (velocity_changed),this);
+ }
+ } else {
+ // Changing source failed and there was active reques
+ m_updateTimer.stop();
+ emit updateTimeout();
+ }
+ }
+ // If a request ongoing, ask it from new object
+ if (m_requestTimer.isActive()) {
+ if ( status != -1) {
+ geoclue_position_get_position_async (m_pos,
+ (GeocluePositionCallback)position_callback,
+ this);
+ } else {
+ // Changing source failed and there was active reques
+ m_requestTimer.stop();
+ emit updateTimeout();
+ }
+ }
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceGeoclueMaster::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ if (fromSatellitePositioningMethodsOnly) {
+ if (m_lastPositionFromSatellite)
+ return m_lastPosition;
+ else
+ return QGeoPositionInfo();
+ }
+ return m_lastPosition;
+}
+
+QGeoPositionInfoSourceGeoclueMaster::PositioningMethods QGeoPositionInfoSourceGeoclueMaster::supportedPositioningMethods() const
+{
+ // There is no really knowing which methods the GeoClue master supports.
+ return AllPositioningMethods;
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::startUpdates()
+{
+ if (m_updateTimer.isActive()) {
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster timer was active, ignoring startUpdates: " << m_updateInterval;
+#endif
+ return;
+ }
+ if (!m_pos) {
+ // May happen if source has been changed unsuccesfully
+ emit updateTimeout();
+ return;
+ }
+ if (m_updateInterval > 0) {
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster startUpdates with interval: " << m_updateInterval;
+#endif
+ m_updateTimer.start(m_updateInterval);
+ }
+ g_signal_connect (G_OBJECT (m_pos), "position-changed",
+ G_CALLBACK (position_changed),this);
+ if (m_vel) {
+ g_signal_connect (G_OBJECT (m_vel), "velocity-changed",
+ G_CALLBACK (velocity_changed),this);
+ }
+}
+
+int QGeoPositionInfoSourceGeoclueMaster::minimumUpdateInterval() const {
+ return MINIMUM_UPDATE_INTERVAL;
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::stopUpdates()
+{
+ if (m_updateTimer.isActive())
+ m_updateTimer.stop();
+ if (m_pos) {
+ g_signal_handlers_disconnect_by_func(G_OBJECT(m_pos), (void*)position_changed, this);
+ } if (m_vel) {
+ g_signal_handlers_disconnect_by_func(G_OBJECT(m_vel), (void*)velocity_changed, this);
+ }
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::requestUpdate(int timeout)
+{
+ if ((timeout < minimumUpdateInterval() && timeout != 0) || !m_pos) {
+ emit updateTimeout();
+ return;
+ }
+ if (m_requestTimer.isActive()) {
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster request timer was active, ignoring startUpdates.";
+#endif
+ return;
+ }
+ // Create better logic for timeout value (specs leave it impl dependant).
+ // Especially if there are active updates ongoing, there is no point of waiting
+ // for whole cold start time.
+ if (timeout == 0)
+ m_requestTimer.start(UPDATE_TIMEOUT_COLD_START);
+ else
+ m_requestTimer.start(timeout);
+ geoclue_position_get_position_async (m_pos, (GeocluePositionCallback)position_callback,this);
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::requestUpdateTimeout()
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster requestUpdate timeout occurred.";
+#endif
+ // If we end up here, there has not been valid position update.
+ emit updateTimeout();
+}
+
+void QGeoPositionInfoSourceGeoclueMaster::startUpdatesTimeout()
+{
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster startUpdates timeout occurred.";
+#endif
+ // Check if there are position updates since last positionUpdated().
+ // Do not however send timeout, that's reserved for signaling errors.
+ if (m_lastPositionIsFresh) {
+ emit positionUpdated(m_lastPosition);
+ m_lastPositionIsFresh = false;
+ m_lastVelocityIsFresh = false;
+ }
+}
+
+// Helper function to convert data into a QGeoPositionInfo
+QGeoPositionInfo QGeoPositionInfoSourceGeoclueMaster::geoclueToPositionInfo(
+ GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy* accuracy)
+{
+ QGeoCoordinate coordinate(latitude, longitude);
+ QDateTime dateTime = QDateTime();
+ dateTime.setTime_t(timestamp);
+ if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) {
+ coordinate.setAltitude(altitude);
+ }
+ QGeoPositionInfo info(coordinate, dateTime);
+ if (accuracy) {
+ double horizontalAccuracy;
+ double verticalAccuracy;
+ GeoclueAccuracyLevel accuracyLevel;
+ geoclue_accuracy_get_details(accuracy, &accuracyLevel, &horizontalAccuracy, &verticalAccuracy);
+#ifdef Q_LOCATION_GEOCLUE_DEBUG
+ qDebug() << "QGeoPositionInfoSourceGeoclueMaster::accuracy horizontal vertical level: " << horizontalAccuracy << verticalAccuracy << accuracyLevel;
+#endif
+ if (accuracyLevel & GEOCLUE_ACCURACY_LEVEL_DETAILED)
+ m_lastPositionFromSatellite = true;
+ else
+ m_lastPositionFromSatellite = false;
+ if (accuracyLevel != GEOCLUE_ACCURACY_LEVEL_NONE) {
+ info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, horizontalAccuracy);
+ info.setAttribute(QGeoPositionInfo::VerticalAccuracy, verticalAccuracy);
+ }
+ }
+ return info;
+}
+
+#include "moc_qgeopositioninfosource_geocluemaster_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosource_geocluemaster_p.h b/src/location/qgeopositioninfosource_geocluemaster_p.h
new file mode 100644
index 00000000..a02cdb5d
--- /dev/null
+++ b/src/location/qgeopositioninfosource_geocluemaster_p.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCE_GEOCLUEMASTER_H
+#define QGEOPOSITIONINFOSOURCE_GEOCLUEMASTER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qgeopositioninfosource.h>
+#include <geoclue/geoclue-master.h>
+#include <geoclue/geoclue-velocity.h>
+#include <QTimer>
+
+//#define Q_LOCATION_GEOCLUE_DEBUG
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoSourceGeoclueMaster : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+public:
+ void positionChanged(GeocluePosition *position,
+ GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy);
+ QGeoPositionInfoSourceGeoclueMaster(QObject *parent = 0);
+ ~QGeoPositionInfoSourceGeoclueMaster();
+
+ // From QGeoPositionInfoSource
+ void setUpdateInterval(int msec);
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
+ void setPreferredPositioningMethods(PositioningMethods methods);
+ int minimumUpdateInterval() const;
+ int init();
+
+ void singleUpdateFailed();
+ void singleUpdateSucceeded(GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy);
+ void regularUpdateFailed();
+ void regularUpdateSucceeded(GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy);
+ void velocityUpdateFailed();
+ void velocityUpdateSucceeded(double speed);
+
+public slots:
+ virtual void startUpdates();
+ virtual void stopUpdates();
+ virtual void requestUpdate(int timeout = 5000);
+
+private slots:
+ void requestUpdateTimeout();
+ void startUpdatesTimeout();
+
+private:
+ bool tryGPS();
+ int configurePositionSource();
+ QGeoPositionInfo geoclueToPositionInfo(GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy* accuracy);
+private:
+ int m_updateInterval;
+ GeoclueResourceFlags m_preferredResources;
+ GeoclueAccuracyLevel m_preferredAccuracy;
+ GeoclueMasterClient *m_client;
+ GeocluePosition *m_pos;
+ GeoclueVelocity* m_vel;
+ QTimer m_updateTimer;
+ QTimer m_requestTimer;
+ bool m_lastPositionIsFresh;
+ bool m_lastVelocityIsFresh;
+ double m_lastVelocity;
+ bool m_lastPositionFromSatellite;
+ QGeoPositionInfo m_lastPosition;
+ PositioningMethods m_methods;
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOPOSITIONINFOSOURCE_GEOCLUEMASTER_H
diff --git a/src/location/qgeopositioninfosource_maemo.cpp b/src/location/qgeopositioninfosource_maemo.cpp
new file mode 100644
index 00000000..fb6d07e8
--- /dev/null
+++ b/src/location/qgeopositioninfosource_maemo.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_maemo_p.h"
+#include <iostream>
+#include <QDateTime>
+
+using namespace std;
+
+QTM_BEGIN_NAMESPACE
+
+QGeoPositionInfoSourceMaemo::QGeoPositionInfoSourceMaemo(QObject *parent): QGeoPositionInfoSource(parent)
+{
+ requestTimer = new QTimer(this);
+ QObject::connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimerExpired()));
+ locationOngoing = false;
+}
+
+
+int QGeoPositionInfoSourceMaemo::init()
+{
+ dbusComm = new DBusComm(this);
+ int status = dbusComm->init();
+
+ if (status == 0) {
+ QObject::connect(dbusComm, SIGNAL(receivedPositionUpdate(const QGeoPositionInfo &)),
+ this, SLOT(newPositionUpdate(const QGeoPositionInfo &)));
+ QObject::connect(dbusComm, SIGNAL(serviceConnected()),
+ this, SLOT(onServiceConnect()));
+ QObject::connect(dbusComm, SIGNAL(serviceDisconnected()),
+ this, SLOT(onServiceDisconnect()));
+ }
+ return status;
+}
+
+void QGeoPositionInfoSourceMaemo::onServiceDisconnect()
+{
+ //
+}
+
+void QGeoPositionInfoSourceMaemo::onServiceConnect()
+{
+ DBusComm::Command command =
+ (DBusComm::Command)
+ ( DBusComm::CommandSetInterval |
+ DBusComm::CommandSetMethods );
+
+ int interval = QGeoPositionInfoSource::updateInterval();
+ QGeoPositionInfoSource::PositioningMethods method;
+ method = QGeoPositionInfoSource::preferredPositioningMethods();
+
+ if (locationOngoing) {
+ command = (DBusComm::Command) ( command | DBusComm::CommandStart );
+ dbusComm->sendConfigRequest(command, method, interval);
+ } else {
+ dbusComm->sendConfigRequest(command, method, interval);
+ }
+}
+
+void QGeoPositionInfoSourceMaemo::newPositionUpdate(const QGeoPositionInfo &update)
+{
+ if(update.isValid()) {
+ emit positionUpdated(update);
+ if ( requestTimer->isActive() )
+ shutdownRequestSession();
+ } else {
+ if ( !requestTimer->isActive() )
+ emit updateTimeout();
+ }
+}
+
+
+QGeoPositionInfo QGeoPositionInfoSourceMaemo::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ QGeoPositionInfo update = dbusComm->requestLastKnownPosition(fromSatellitePositioningMethodsOnly);
+
+ return update;
+}
+
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceMaemo::supportedPositioningMethods() const
+{
+ return dbusComm->availableMethods();
+}
+
+
+void QGeoPositionInfoSourceMaemo::setUpdateInterval(int msec)
+{
+ qint32 min = dbusComm->minimumInterval();
+ msec = (msec < min) ? min : msec;
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+
+ dbusComm->sendConfigRequest(dbusComm->CommandSetInterval, 0, msec);
+}
+
+
+void QGeoPositionInfoSourceMaemo::setPreferredPositioningMethods(PositioningMethods sources)
+{
+ QGeoPositionInfoSource::setPreferredPositioningMethods(sources);
+ dbusComm->sendConfigRequest(dbusComm->CommandSetMethods, sources, 0);
+}
+
+
+int QGeoPositionInfoSourceMaemo::minimumUpdateInterval() const
+{
+ return dbusComm->minimumInterval();
+}
+
+
+void QGeoPositionInfoSourceMaemo::startUpdates()
+{
+ locationOngoing = true;
+ if ( !requestTimer->isActive() )
+ dbusComm->sendConfigRequest(DBusComm::CommandStart, 0, 0);
+}
+
+
+void QGeoPositionInfoSourceMaemo::stopUpdates()
+{
+ locationOngoing = false;
+ if ( !requestTimer->isActive() )
+ dbusComm->sendConfigRequest(dbusComm->CommandStop, 0, 0);
+}
+
+
+void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout)
+{
+ if ( QGeoPositionInfoSource::updateInterval() !=
+ dbusComm->minimumInterval() )
+ dbusComm->sendConfigRequest(dbusComm->CommandSetInterval, 0,
+ dbusComm->minimumInterval());
+
+ if ( !QGeoPositionInfoSource::preferredPositioningMethods().testFlag(QGeoPositionInfoSource::AllPositioningMethods) )
+ dbusComm->sendConfigRequest(dbusComm->CommandSetMethods,
+ QGeoPositionInfoSource::AllPositioningMethods, 0);
+
+ if ( !locationOngoing )
+ dbusComm->sendConfigRequest(dbusComm->CommandStart, 0, 0);
+
+ requestTimer->start(timeout);
+}
+
+void QGeoPositionInfoSourceMaemo::requestTimerExpired()
+{
+ emit updateTimeout();
+ shutdownRequestSession();
+}
+
+void QGeoPositionInfoSourceMaemo::shutdownRequestSession()
+{
+ requestTimer->stop();
+
+ if ( !locationOngoing )
+ dbusComm->sendConfigRequest(dbusComm->CommandStop, 0, 0);
+
+ if ( QGeoPositionInfoSource::updateInterval() !=
+ dbusComm->minimumInterval() )
+ dbusComm->sendConfigRequest(dbusComm->CommandSetInterval, 0,
+ QGeoPositionInfoSource::updateInterval());
+
+ if ( !QGeoPositionInfoSource::preferredPositioningMethods().testFlag(QGeoPositionInfoSource::AllPositioningMethods) )
+ dbusComm->sendConfigRequest(dbusComm->CommandSetMethods,
+ QGeoPositionInfoSource::preferredPositioningMethods(), 0);
+}
+
+#include "moc_qgeopositioninfosource_maemo_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeopositioninfosource_maemo5.cpp b/src/location/qgeopositioninfosource_maemo5.cpp
new file mode 100644
index 00000000..d9227d31
--- /dev/null
+++ b/src/location/qgeopositioninfosource_maemo5.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_maemo5_p.h"
+#include "liblocationwrapper_p.h"
+#include <qnumeric.h>
+
+using namespace std;
+
+QTM_BEGIN_NAMESPACE
+
+QGeoPositionInfoSourceMaemo::QGeoPositionInfoSourceMaemo(QObject *parent)
+ : QGeoPositionInfoSource(parent)
+{
+ // default values
+ timerInterval = DEFAULT_UPDATE_INTERVAL;
+ updateTimer = new QTimer(this);
+ updateTimer->setSingleShot(true);
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeoutElapsed()));
+
+ requestTimer = new QTimer(this);
+ requestTimer->setSingleShot(true);
+ connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed()));
+
+ connect(LiblocationWrapper::instance(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPositionUpdate(QGeoPositionInfo)));
+
+ errorOccurred = false;
+ errorSent = false;
+
+ positionInfoState = QGeoPositionInfoSourceMaemo::Undefined;
+}
+
+int QGeoPositionInfoSourceMaemo::init()
+{
+ if (LiblocationWrapper::instance()->inited()) {
+ connect(LiblocationWrapper::instance(), SIGNAL(error()), this, SLOT(error()));
+ return INIT_OK;
+ } else {
+ return INIT_FAILED;
+ }
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceMaemo::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ return (LiblocationWrapper::instance()->lastKnownPosition(fromSatellitePositioningMethodsOnly));
+}
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceMaemo::supportedPositioningMethods() const
+{
+ QGeoPositionInfoSource::PositioningMethods methods;
+
+ if (!GConfItem("/system/nokia/location/gps-disabled").value().toBool())
+ methods |= SatellitePositioningMethods;
+ if (!GConfItem("/system/nokia/location/network-disabled").value().toBool())
+ methods |= NonSatellitePositioningMethods;
+ if (methods.testFlag(SatellitePositioningMethods) && methods.testFlag(NonSatellitePositioningMethods))
+ methods |= AllPositioningMethods;
+
+ return methods;
+}
+
+void QGeoPositionInfoSourceMaemo::setUpdateInterval(int msec)
+{
+ bool updateTimerInterval = false;
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive)
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
+ updateTimerInterval = true;
+
+ if (!msec) {
+ timerInterval = MINIMUM_UPDATE_INTERVAL;
+ QGeoPositionInfoSource::setUpdateInterval(0);
+ } else {
+ timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec;
+ QGeoPositionInfoSource::setUpdateInterval(timerInterval);
+ }
+
+ if (timerInterval >= POWERSAVE_THRESHOLD)
+ positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive;
+ else
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive;
+
+ // If powersave has been active when new update interval has been set,
+ // ensure that timer is started.
+ if (updateTimerInterval)
+ startLocationDaemon();
+
+ // Ensure that new timer interval is taken into use immediately.
+ activateTimer();
+}
+
+void QGeoPositionInfoSourceMaemo::setPreferredPositioningMethods(PositioningMethods methods)
+{
+ QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
+}
+
+int QGeoPositionInfoSourceMaemo::minimumUpdateInterval() const
+{
+ return MINIMUM_UPDATE_INTERVAL;
+}
+
+// public slots:
+void QGeoPositionInfoSourceMaemo::startUpdates()
+{
+ startLocationDaemon();
+
+ // Ensure that powersave is selected, if stopUpdates() has been called,
+ // but selected update interval is still greater than POWERSAVE_THRESHOLD.
+ if (timerInterval >= POWERSAVE_THRESHOLD)
+ positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive;
+
+ activateTimer();
+}
+
+void QGeoPositionInfoSourceMaemo::stopUpdates()
+{
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive;
+
+ if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)) {
+ updateTimer->stop();
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+ }
+
+ errorOccurred = false;
+ errorSent = false;
+
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started;
+ positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped;
+}
+
+void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout)
+{
+ int timeoutForRequest = 0;
+
+ if (!timeout) {
+ if (LiblocationWrapper::instance()->isActive())
+ // If GPS is active, assume quick fix.
+ timeoutForRequest = DEFAULT_UPDATE_INTERVAL;
+ else
+ // Otherwise reserve longer time to get a fix.
+ timeoutForRequest = POWERSAVE_POWERON_PERIOD;
+ } else if (timeout < MINIMUM_UPDATE_INTERVAL) {
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)
+ return;
+
+ emit updateTimeout();
+ return;
+ } else {
+ timeoutForRequest = timeout;
+ }
+
+ positionInfoState |= QGeoPositionInfoSourceMaemo::RequestActive;
+
+ if (!(LiblocationWrapper::instance()->isActive()))
+ LiblocationWrapper::instance()->start();
+
+ activateTimer();
+ requestTimer->start(timeoutForRequest);
+}
+
+void QGeoPositionInfoSourceMaemo::newPositionUpdate(const QGeoPositionInfo &position)
+{
+ /*
+ Invalid fixes have NaN for horizontal accuracy regardless of
+ whether they come from satellite or non-satellite position methods.
+
+ Satellite fixes always have LOCATION_GPS_DEVICE_TIME_SET.
+ If this is not set and we have a numeric value for horizontal
+ accuracy then we are dealing with a non-satellite based positioning
+ method.
+
+ Since QGeoPositionInfo instances are only considered valid if
+ they have a valid coordinate and a valid timestamp, we use
+ the current date and time as the timestamp for the network based
+ positioning. This will help in the case where someone wants to
+ reply a journey from a log file.
+
+ Based on some logging it looks like satellite and non-satellite
+ methods can be distinguished (after the initial fix) by whether
+ the time has been set and / or whether the horizontal accuracy
+ is above or below around 500 metres. Using the timestamp
+ appears to be more definitive than using the accuracy.
+ */
+
+ const bool horizontalAccuracyDefined = !qIsNaN(position.attribute(QGeoPositionInfo::HorizontalAccuracy));
+ const bool hasTimeStamp = !position.timestamp().isNull();
+
+ if (horizontalAccuracyDefined) {
+ if (hasTimeStamp) {
+ //Valid satellite fix
+ lastUpdateFromSatellite = position;
+ } else {
+ //Valid non-satellite fix
+ QGeoPositionInfo networkPosition(position);
+ networkPosition.setTimestamp(QDateTime::currentDateTime());
+ lastUpdateFromNetwork = networkPosition;
+ }
+ } else {
+ //Invalid position update
+ if (hasTimeStamp) {
+ lastUpdateFromSatellite = QGeoPositionInfo();
+ } else {
+ lastUpdateFromNetwork = QGeoPositionInfo();
+ }
+ }
+}
+
+void QGeoPositionInfoSourceMaemo::updateTimeoutElapsed()
+{
+ QGeoPositionInfo position;
+
+ QGeoPositionInfoSource::PositioningMethods methods = preferredPositioningMethods();
+
+ if (methods.testFlag(AllPositioningMethods)) {
+ methods |= SatellitePositioningMethods;
+ methods |= NonSatellitePositioningMethods;
+ }
+
+ if (methods.testFlag(SatellitePositioningMethods) && !methods.testFlag(NonSatellitePositioningMethods)) {
+ //only SatellitePositioningMethods preferred
+ position = lastUpdateFromSatellite;
+ } else if (methods.testFlag(NonSatellitePositioningMethods) && !methods.testFlag(SatellitePositioningMethods)) {
+ //only NonSatellitePositioningMethods preferred
+ position = lastUpdateFromNetwork;
+ } else {
+ //AllPositioningMethods or none preferred
+ if (lastUpdateFromSatellite.isValid())
+ position = lastUpdateFromSatellite;
+ else
+ position = lastUpdateFromNetwork;
+ }
+
+ if (position.isValid()) {
+ errorOccurred = false;
+ errorSent = false;
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) {
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive;
+ requestTimer->stop();
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+
+ // Ensure that requested position fix is emitted even though
+ // powersave is active and GPS would normally be off.
+ if ((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) &&
+ (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)) {
+ emit positionUpdated(position);
+ }
+ }
+
+ // Make sure that if update is triggered when waking up, there
+ // is no false position update.
+ if (!((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) &&
+ (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)))
+ emit positionUpdated(position);
+ } else {
+ // if an error occurs when we are updating periodically and we haven't
+ // sent an error since the last fix...
+ if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) &&
+ errorOccurred && !errorSent) {
+ errorSent = true;
+ // we need to emit the updateTimeout signal
+ emit updateTimeout();
+ }
+ }
+ activateTimer();
+}
+
+void QGeoPositionInfoSourceMaemo::requestTimeoutElapsed()
+{
+ updateTimer->stop();
+ emit updateTimeout();
+
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive;
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+
+ activateTimer();
+}
+
+void QGeoPositionInfoSourceMaemo::error()
+{
+ errorOccurred = true;
+}
+
+void QGeoPositionInfoSourceMaemo::activateTimer()
+{
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) {
+ updateTimer->start(MINIMUM_UPDATE_INTERVAL);
+ return;
+ }
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) {
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) {
+ // Cannot call stopUpdates() here since we want to keep powersave
+ // active.
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+ updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD);
+ errorOccurred = false;
+ errorSent = false;
+
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started;
+ positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped;
+ } else if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) {
+ startLocationDaemon();
+ updateTimer->start(POWERSAVE_POWERON_PERIOD);
+ }
+ return;
+ }
+
+ if (positionInfoState & QGeoPositionInfoSourceMaemo::Started)
+ updateTimer->start(timerInterval);
+}
+
+void QGeoPositionInfoSourceMaemo::startLocationDaemon()
+{
+ if (!(LiblocationWrapper::instance()->isActive()))
+ LiblocationWrapper::instance()->start();
+ positionInfoState |= QGeoPositionInfoSourceMaemo::Started;
+ positionInfoState &= ~QGeoPositionInfoSourceMaemo::Stopped;
+}
+
+#include "moc_qgeopositioninfosource_maemo5_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeopositioninfosource_maemo5_p.h b/src/location/qgeopositioninfosource_maemo5_p.h
new file mode 100644
index 00000000..0bbc8bc1
--- /dev/null
+++ b/src/location/qgeopositioninfosource_maemo5_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCEMAEMO5_H
+#define QGEOPOSITIONINFOSOURCEMAEMO5_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QTimer>
+#include "qgeopositioninfosource.h"
+
+#define INIT_OK 0
+#define INIT_FAILED -1
+#define MINIMUM_UPDATE_INTERVAL 1000
+#define DEFAULT_UPDATE_INTERVAL 5000
+#define POWERSAVE_THRESHOLD 180000
+#define POWERSAVE_POWERON_PERIOD 120000
+
+QTM_BEGIN_NAMESPACE
+
+class LiblocationWrapper;
+
+class QGeoPositionInfoSourceMaemo : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+
+public:
+
+ QGeoPositionInfoSourceMaemo(QObject *parent = 0);
+
+ int init();
+
+ virtual void setUpdateInterval(int interval);
+ virtual void setPreferredPositioningMethods(PositioningMethods methods);
+ virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ virtual PositioningMethods supportedPositioningMethods() const;
+ virtual int minimumUpdateInterval() const;
+
+private:
+ bool positionInited;
+ QTimer *updateTimer;
+ QTimer *requestTimer;
+ int timerInterval;
+ bool errorOccurred;
+ bool errorSent;
+
+ void activateTimer();
+ void startLocationDaemon();
+
+ enum PositionInfoState {
+ Undefined = 0,
+ Started = 1,
+ Stopped = 2,
+ RequestActive = 4,
+ PowersaveActive = 8
+ };
+ int positionInfoState;
+
+ QGeoPositionInfo lastUpdateFromSatellite;
+ QGeoPositionInfo lastUpdateFromNetwork;
+
+signals:
+ void positionUpdated(const QGeoPositionInfo &update);
+
+public slots:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = DEFAULT_UPDATE_INTERVAL);
+
+private slots:
+ void requestTimeoutElapsed();
+ void error();
+ void newPositionUpdate(const QGeoPositionInfo &position);
+ void updateTimeoutElapsed();
+
+private:
+ Q_DISABLE_COPY(QGeoPositionInfoSourceMaemo)
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOPOSITIONINFOSOURCEMAEMO5_H
diff --git a/src/location/qgeopositioninfosource_maemo_p.h b/src/location/qgeopositioninfosource_maemo_p.h
new file mode 100644
index 00000000..76646a3b
--- /dev/null
+++ b/src/location/qgeopositioninfosource_maemo_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCEMAEMO_H
+#define QGEOPOSITIONINFOSOURCEMAEMO_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeopositioninfosource.h"
+#include "dbuscomm_maemo_p.h"
+
+#ifdef Q_WS_MAEMO_5
+#include "qgeocoordinate.h"
+
+extern "C"
+{
+#include <glib.h>
+#include <location/location-gpsd-control.h>
+#include <location/location-gps-device.h>
+#include <location/location-misc.h>
+#include <location/location-distance-utils.h>
+}
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+class DBusComm;
+class QGeoPositionInfoSourceMaemo : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+
+public:
+ QGeoPositionInfoSourceMaemo(QObject *parent = 0);
+ int init();
+
+ virtual void setUpdateInterval(int interval);
+ virtual void setPreferredPositioningMethods(PositioningMethods sources);
+ virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ virtual PositioningMethods supportedPositioningMethods() const;
+ virtual int minimumUpdateInterval() const;
+
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 5000);
+
+private:
+ DBusComm* dbusComm;
+ QTimer* requestTimer;
+ bool locationOngoing;
+
+ void shutdownRequestSession();
+
+private Q_SLOTS:
+ void newPositionUpdate(const QGeoPositionInfo &update);
+ void onServiceConnect();
+ void onServiceDisconnect();
+ void requestTimerExpired();
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qgeopositioninfosource_s60.cpp b/src/location/qgeopositioninfosource_s60.cpp
new file mode 100644
index 00000000..e1a7d204
--- /dev/null
+++ b/src/location/qgeopositioninfosource_s60.cpp
@@ -0,0 +1,954 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QDateTime>
+#include <QDebug>
+#include <limits.h>
+#include "qgeopositioninfosource_s60_p.h"
+#include "qgeopositioninfosource.h"
+#include "qmlbackendao_s60_p.h"
+
+
+
+QTM_BEGIN_NAMESPACE
+
+// constructor
+CQGeoPositionInfoSourceS60::CQGeoPositionInfoSourceS60(QObject* aParent) : QGeoPositionInfoSource(aParent),
+ mCurrentModuleId(TUid::Null()),
+ mReqModuleId(TUid::Null()),
+ mDevStatusUpdateAO(NULL),
+ mReqUpdateAO(NULL),
+ mRegUpdateAO(NULL),
+ mSupportedMethods(PositioningMethod(0)),
+ mCurrentMethod(PositioningMethod(0)),
+ mListSize(0),
+ mMinUpdateInterval(100),
+ mStartUpdates(FALSE),
+ mRegularUpdateTimedOut(FALSE),
+ mModuleFlags(0)
+{
+ memset(mList, 0 , MAX_SIZE * sizeof(CPosMethodInfo));
+}
+
+// destructor
+CQGeoPositionInfoSourceS60::~CQGeoPositionInfoSourceS60()
+{
+ if (mReqUpdateAO)
+ delete mReqUpdateAO;
+
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+
+ if (mDevStatusUpdateAO)
+ delete mDevStatusUpdateAO;
+
+
+}
+
+// static function NewLC
+CQGeoPositionInfoSourceS60* CQGeoPositionInfoSourceS60::NewLC(QObject* aParent)
+{
+ CQGeoPositionInfoSourceS60* self =
+ new(ELeave) CQGeoPositionInfoSourceS60(aParent);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+// static function NewL
+CQGeoPositionInfoSourceS60* CQGeoPositionInfoSourceS60::NewL(QObject * aParent)
+{
+ RProcess thisProcess;
+ if (!thisProcess.HasCapability(ECapabilityLocation)) {
+ qWarning() << "QGeoPositionInfoSource::createDefaultSource() requires the Symbian Location capability to succeed on the Symbian platform.";
+ return 0;
+ }
+
+ CQGeoPositionInfoSourceS60* self = CQGeoPositionInfoSourceS60::NewLC(aParent);
+ CleanupStack::Pop();
+
+ //check if the second phase construction is successful
+ if (!self->isValid()) {
+ delete self;
+ self = NULL;
+ }
+
+ return self;
+}
+
+// 2nd phase constructor
+void CQGeoPositionInfoSourceS60::ConstructL()
+{
+ TInt error = mPositionServer.Connect();
+
+ if (error == KErrNone) {
+ CleanupClosePushL(mPositionServer);
+
+ mDevStatusUpdateAO = CQMLBackendAO::NewL(this, DeviceStatus);
+
+ if (mDevStatusUpdateAO == NULL) {
+ CleanupStack::Pop(1);
+
+ return;
+ }
+
+ //update the list array with the available method initially
+ updateDeviceStatus();
+
+ // Set the PreferredPositioningMethods based on Supported methods
+ QGeoPositionInfoSource::setPreferredPositioningMethods(mSupportedMethods);
+
+ //devStatusUpdateAO->NotifyDeviceStatus(mStatusEvent);
+
+ CleanupStack::PushL(mDevStatusUpdateAO);
+
+ if (mCurrentModuleId != TUid::Null()) {
+ mRegUpdateAO = CQMLBackendAO::NewL(this, RegularUpdate, mCurrentModuleId);
+ mRegUpdateAO->setUpdateInterval(updateInterval());
+ }
+ CleanupStack::Pop(2);
+ }
+
+}
+
+QGeoPositionInfo CQGeoPositionInfoSourceS60::lastKnownPosition(bool aFromSatellitePositioningMethodsOnly) const
+{
+
+ QGeoPositionInfo posUpdate;
+ TPosition pos;
+ TInt error = KErrNone;
+ RPositioner iLastKnownpositioner;
+ TRequestStatus status;
+
+ error = iLastKnownpositioner.Open(*const_cast<RPositionServer*>(&mPositionServer));
+ //request for lastknown position update and wait for the request to complete
+ if (error == KErrNone) {
+
+ TPositionInfo posInfo;
+
+ iLastKnownpositioner.SetRequestor(CRequestor::ERequestorService ,
+ CRequestor::EFormatApplication, _L("QTmobility_Location"));
+
+
+ iLastKnownpositioner.GetLastKnownPosition(posInfo, status);
+
+ User::WaitForRequest(status);
+
+ error = status.Int();
+
+ iLastKnownpositioner.Close();
+
+ if ((error == KErrNone) || (error == KPositionPartialUpdate)) {
+
+ TPositionModuleInfo modInfo;
+ mPositionServer.GetModuleInfoById(posInfo.ModuleId(), modInfo);
+
+ if (!aFromSatellitePositioningMethodsOnly || (aFromSatellitePositioningMethodsOnly && (modInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite))) {
+ QGeoCoordinate coord;
+
+ posInfo.GetPosition(pos);
+
+ coord.setLatitude(pos.Latitude());
+ coord.setLongitude(pos.Longitude());
+ coord.setAltitude(pos.Altitude());
+
+ //store the QGeoCoordinate values
+ posUpdate.setCoordinate(coord);
+
+ TDateTime datetime = pos.Time().DateTime();
+ QDateTime dt(QDate(datetime.Year(), datetime.Month() + 1, datetime.Day() + 1),
+ QTime(datetime.Hour(), datetime.Minute(), datetime.Second(),
+ datetime.MicroSecond() / 1000),
+ Qt::UTC);
+
+ //store the time stamp
+ posUpdate.setTimestamp(dt);
+
+ //store the horizontal accuracy
+ posUpdate.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
+
+ //store the vertical accuracy
+ posUpdate.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy());
+
+ }
+ }
+ }
+
+ return posUpdate;
+}
+
+//
+int CQGeoPositionInfoSourceS60::minimumUpdateInterval() const
+{
+ if (mCurrentModuleId == TUid::Null())
+ return 0;
+
+ return mMinUpdateInterval;
+}
+
+
+
+//private function : to derive the supported positioning methods
+void CQGeoPositionInfoSourceS60::updateAvailableTypes()
+{
+ PositioningMethods types;
+
+ for (TInt i = 0; i < mListSize ; i++) {
+ //check only for the available module without any device errors
+ if (mList[i].mIsAvailable &&
+ (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown) &&
+ (mList[i].mStatus != TPositionModuleStatus::EDeviceError)) {
+ types |= mList[i].mPosMethod;
+
+ }
+
+ //if both SatellitePositioningMethods and NonSatellitePositioningMethods return
+ if (types.testFlag(AllPositioningMethods))
+ break;
+ }
+
+ //update the supported methods based on types value, derived from the above steps
+ mSupportedMethods = types;
+}
+
+//private function : to retrieve the index of the supplied module id from the mList array
+TInt CQGeoPositionInfoSourceS60::checkModule(TPositionModuleId aId)//const
+{
+
+ TInt i;
+ for (i = 0; i < mListSize; i++)
+ if (mList[i].mUid == aId) {
+ return i;
+ }
+
+ return -1;
+}
+
+//private function : get the index of the mList that supports the preferred method if
+//available,else returns the index of the default module
+TInt CQGeoPositionInfoSourceS60::getIndexPositionModule(TUint8 aBits, PositioningMethods aPosMethods) const
+{
+ TInt index, error;
+
+ TPositionModuleId modID;
+
+ //get the default module Id, whose index is returned if the preferred methods are not
+ //available
+ error = mPositionServer.GetDefaultModuleId(modID);
+
+ if (error != KErrNone)
+ modID = TUid::Null();
+
+ //index = -1 : no methods available in the mList that supports preferred methods
+ index = -1;
+
+
+ for (TInt i = 0; i < mListSize ; i++) {
+ //check the module properties to select the preferred method,search should not
+ //not select an unavailable method,error device or index matching aLastIndex
+ if (mList[i].mIsAvailable && aPosMethods.testFlag(mList[i].mPosMethod)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))) {
+ return i;
+ }
+
+ //store the index of the default module
+ if ((modID == mList[i].mUid) && ((aBits >> i) & 1))
+ index = i;
+ }
+
+
+ return index;
+}
+
+//private function : to get the index of the positioning method with time to first fix
+//lesser than timeout
+TInt CQGeoPositionInfoSourceS60::getMoreAccurateMethod(TInt aTimeout, TUint8 aBits)
+{
+ TInt index = -1;
+ double temp = -1.0;
+ PositioningMethods posMethods;
+ TTimeIntervalMicroSeconds microSeconds;
+
+ posMethods = preferredPositioningMethods();
+
+ //convert the timeout --> micro seconds
+ microSeconds = aTimeout * 1000;
+
+ for (TInt i = 0 ; i < mListSize; i++) {
+ if (mList[i].mIsAvailable
+ && posMethods.testFlag(mList[i].mPosMethod)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))
+ && (mList[i].mTimeToFirstFix < microSeconds)) {
+ if ((temp == -1.0) || (mList[i].mHorizontalAccuracy < temp)) {
+ index = i;
+ temp = mList[i].mHorizontalAccuracy;
+ }
+ }
+ }
+
+ if (index != -1) {
+ return index;
+ }
+
+ bool minSet = false;
+ microSeconds = 0;
+
+ for (TInt i = 0 ; i < mListSize; i++) {
+ if (mList[i].mIsAvailable
+ && posMethods.testFlag(mList[i].mPosMethod)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))) {
+ if (!minSet || (mList[i].mTimeToFirstFix < microSeconds)) {
+ index = i;
+ minSet = true;
+ microSeconds = mList[i].mTimeToFirstFix;
+ }
+ }
+ }
+
+ return index;
+}
+
+//private function : to update the mList array
+void CQGeoPositionInfoSourceS60::updateStatus(TPositionModuleInfo &aModInfo, TInt aStatus)
+{
+
+ TInt i, index;
+ TPositionModuleId id;
+ PositioningMethod method;
+ TBool available;
+ TReal32 accuracy;
+ TTimeIntervalMicroSeconds time_to_first_fix, time_to_next_fix;
+ TPositionQuality quality;
+ CQMLBackendAO *temp = NULL;
+
+ //query for the following parameters
+ id = aModInfo.ModuleId();
+
+ //module with a satellite capability is assumed to be provided satellite based positioning
+ //method
+ method = (aModInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite) ?
+ SatellitePositioningMethods : NonSatellitePositioningMethods;
+
+ //gets the device availability based on the user settings
+ available = aModInfo.IsAvailable();
+
+ //quality : holds the required metrics
+ aModInfo.GetPositionQuality(quality);
+
+ //Accuracy
+ accuracy = quality.HorizontalAccuracy();
+
+ //time taken for the first fix
+ time_to_first_fix = quality.TimeToFirstFix();
+
+ //time taken for the subsequent fix
+ time_to_next_fix = quality.TimeToNextFix();
+
+
+
+ if ((i = checkModule(id)) == -1) {
+ //update the properties of the module
+ QMutexLocker lLocker(&m_mutex);
+
+ //TPositionModuleId of the module
+ mList[mListSize].mUid = id;
+
+ //positioning method method type
+ mList[mListSize].mPosMethod = method;
+
+ //status of the device
+ mList[mListSize].mStatus = aStatus;
+
+ //availablility of the module
+ mList[mListSize].mIsAvailable = available;
+
+ //horizontal accuracy of the module
+ mList[mListSize].mHorizontalAccuracy = accuracy;
+
+ //time required to get the first fix
+ mList[mListSize].mTimeToFirstFix = time_to_first_fix;
+
+ //time required for subsequent fix
+ mList[mListSize].mTimeToNextFix = time_to_next_fix;
+
+ //count on the mList array size
+ mListSize++;
+
+ //update the supported source types based on the device status
+ updateAvailableTypes();
+
+ //store the correct method in use from the mCurrentModuleId retireved earlier
+ if (id == mCurrentModuleId) {
+ mCurrentMethod = method;
+ mMinUpdateInterval = mList[mListSize-1].mTimeToNextFix.Int64() / 1000;
+ }
+ lLocker.unlock();
+ } else {
+
+ QMutexLocker lLocker(&m_mutex);
+ //module's status has changed
+ if (mList[i].mStatus != aStatus)
+ mList[i].mStatus = aStatus;
+
+ //module's availability has changed
+ if (mList[i].mIsAvailable != available)
+ mList[i].mIsAvailable = available;
+
+ //module's horizontal accuracy has changed
+ if (mList[i].mHorizontalAccuracy != accuracy)
+ mList[i].mHorizontalAccuracy = accuracy;
+
+ //module's time to first fix has changed
+ if (mList[i].mTimeToFirstFix != time_to_first_fix)
+ mList[i].mTimeToFirstFix = time_to_first_fix;
+
+ //module's time to subsequent fix has changed
+ if (mList[i].mTimeToNextFix != time_to_next_fix)
+ mList[i].mTimeToFirstFix = time_to_next_fix;
+
+ //update the supported source types based on the device status
+ updateAvailableTypes();
+
+ lLocker.unlock();
+
+ //if the mCurrentModuleId is NULL, try updating the reg update with the available
+ //positioning method
+ if (mCurrentModuleId == TUid::Null() && (available == TRUE) &&
+ (aStatus != TPositionModuleStatus::EDeviceUnknown) &&
+ (aStatus != TPositionModuleStatus::EDeviceError)) {
+ TInt interval;
+
+ interval = QGeoPositionInfoSource::updateInterval();
+
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[i].mUid)));
+
+ QMutexLocker lRegLocker_interval(&m_mutex_interval);
+ mMinUpdateInterval = interval;
+ lRegLocker_interval.unlock();
+
+ if ((ret == KErrNone) && (temp != NULL)) {
+ temp->setUpdateInterval(interval);
+
+ QMutexLocker lRegLocker(&m_mutex_RegUpAO);
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+ mRegUpdateAO = temp;
+ lRegLocker.unlock();
+
+ //to be uncommented when startUpdates are done
+
+ if (mStartUpdates)
+ mRegUpdateAO->startUpdates();
+
+ QMutexLocker lRegLocker_interval1(&m_mutex_interval);
+ mCurrentModuleId = mList[i].mUid;
+ mMinUpdateInterval = mList[i].mTimeToNextFix.Int64() / 1000;
+
+ mCurrentMethod = mList[i].mPosMethod;
+ lRegLocker_interval1.unlock();
+
+ }
+ }
+
+ //check if the status of the currently used modules for regular update or
+ //request update has changed
+ if (((id == mCurrentModuleId) || (id == mReqModuleId)) &&
+ ((aStatus == TPositionModuleStatus::EDeviceUnknown) ||
+ (aStatus == TPositionModuleStatus::EDeviceError) ||
+ (available == FALSE))) {
+ //if the change happened for regular update
+ if (id == mCurrentModuleId) {
+ TInt interval;
+
+ TUint8 bits;
+
+ interval = QGeoPositionInfoSource::updateInterval();
+
+ QMutexLocker lRegLocker1(&m_mutex_RegUpAO);
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+ lRegLocker1.unlock();
+
+ bits = mModuleFlags;
+
+ do {
+ //error = Get the index of the positioning module based on
+ //the preferred method if available , else get the default
+ //position module
+ index = getIndexPositionModule(bits);
+
+ if (index >= 0) {
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[index].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL))
+ break;
+
+ bits = bits & (0XFF ^(1 << index));
+ }
+ } while (index >= 0);
+
+
+ if (temp != NULL) {
+ //successful in creating the subsession for the required
+ //method
+
+ QMutexLocker lRegLocker2(&m_mutex_RegUpAO);
+ mRegUpdateAO = temp;
+ lRegLocker2.unlock();
+
+ QMutexLocker lRegLocker_interval2(&m_mutex_interval);
+ mCurrentModuleId = mList[index].mUid;
+ mCurrentMethod = mList[index].mPosMethod;
+ mMinUpdateInterval = mList[index].mTimeToNextFix.Int64() / 1000;
+ lRegLocker_interval2.unlock();
+
+ mRegUpdateAO->setUpdateInterval(interval);
+
+ //to be uncommented when startUpdates are done
+
+ if (mStartUpdates)
+ mRegUpdateAO->startUpdates();
+
+ } else {
+ //no methods available,clean up the resources
+ QMutexLocker lRegLocker3(&m_mutex_RegUpAO);
+ mRegUpdateAO = NULL;
+ lRegLocker3.unlock();
+
+ QMutexLocker lRegLocker_interval3(&m_mutex_interval);
+ mCurrentModuleId = TUid::Null();
+ mMinUpdateInterval = interval;
+ mCurrentMethod = PositioningMethod(0);
+ lRegLocker_interval3.unlock();
+
+ emit updateTimeout();
+ }
+
+ }
+
+ //check if device status of the request update module changed
+ if (id == mReqModuleId) {
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ if (mRegUpdateAO)
+ delete mReqUpdateAO;
+ mReqUpdateAO = NULL;
+ mReqModuleId = TUid::Null();
+ lReqLocker.unlock();
+
+ emit updateTimeout();
+ }
+
+ }
+
+ } //end else
+
+}
+
+
+// Notification methods from active object. Notifies device status changes
+void CQGeoPositionInfoSourceS60::updateDeviceStatus(void)
+{
+ TPositionModuleStatus moduleStatus;
+ TPositionModuleInfo moduleInfo;
+ TInt error;
+
+ //mListSize = 0 : called updateDeviceStatus() first time to initialise the array
+ if (mListSize == 0) {
+ TUint modCount;
+
+ //count on the modules currently supported by the device
+ mPositionServer.GetNumModules(modCount);
+
+ //module ID of the default module
+ error = mPositionServer.GetDefaultModuleId(mCurrentModuleId);
+
+ if (error != KErrNone)
+ mCurrentModuleId = TUid::Null();
+
+ for (TUint i = 0; i < modCount; i++) {
+ //get module information
+ mPositionServer.GetModuleInfoByIndex(i, moduleInfo);
+
+ //get module status
+ mPositionServer.GetModuleStatus(moduleStatus, moduleInfo.ModuleId());
+
+ //update the properties of the module in the mList array
+ updateStatus(moduleInfo, moduleStatus.DeviceStatus());
+
+ mModuleFlags |= (1 << i);
+ }
+ } else {
+ //UpdateDeviceStatus() called after registering for NotifyModuleStatusEvent
+
+ //get the module id from the status event
+ TPositionModuleId id = mStatusEvent.ModuleId();
+
+ //get module information
+ mPositionServer.GetModuleInfoById(id, moduleInfo);
+
+ //get current status of the module
+ mStatusEvent.GetModuleStatus(moduleStatus);
+
+ //update the properties of the module in the mList array
+ updateStatus(moduleInfo, moduleStatus.DeviceStatus());
+
+
+ }
+
+ //register for next NotifyModuleStatusEvent
+ mDevStatusUpdateAO->notifyDeviceStatus(mStatusEvent);
+
+}
+
+//
+void CQGeoPositionInfoSourceS60::TPositionInfo2QGeoPositionInfo(
+ HPositionGenericInfo *aPosInfo1, QGeoPositionInfo& aPosInfo2)
+{
+ TPosition pos;
+ QGeoCoordinate coord;
+ float val;
+
+ aPosInfo1->GetPosition(pos);
+
+
+ coord.setLatitude(pos.Latitude());
+ coord.setLongitude(pos.Longitude());
+ coord.setAltitude(pos.Altitude());
+
+ //store the QGeoCoordinate values
+ aPosInfo2.setCoordinate(coord);
+
+ TDateTime datetime = pos.Time().DateTime();
+ QDateTime dt(QDate(datetime.Year() , datetime.Month() + 1, datetime.Day() + 1),
+ QTime(datetime.Hour() , datetime.Minute(), datetime.Second(),
+ datetime.MicroSecond() / 1000),
+ Qt::UTC);
+
+ //store the time stamp
+ aPosInfo2.setTimestamp(dt);
+
+ //store the horizontal accuracy
+ aPosInfo2.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
+
+ //store the vertical accuracy
+ aPosInfo2.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy());
+
+ //check for the horizontal speed
+ if (aPosInfo1->IsFieldAvailable(EPositionFieldHorizontalSpeed)) {
+ aPosInfo1->GetValue(EPositionFieldHorizontalSpeed, val);
+ aPosInfo2.setAttribute(QGeoPositionInfo::GroundSpeed, val);
+ }
+
+ //check for the vertcal speed
+ if (aPosInfo1->IsFieldAvailable(EPositionFieldVerticalSpeed)) {
+ aPosInfo1->GetValue(EPositionFieldVerticalSpeed, val);
+ aPosInfo2.setAttribute(QGeoPositionInfo::VerticalSpeed, val);
+ }
+
+ //check for the magnetic variation
+ if (aPosInfo1->IsFieldAvailable(EPositionFieldMagneticCourseError)) {
+ aPosInfo1->GetValue(EPositionFieldMagneticCourseError, val);
+ aPosInfo2.setAttribute(QGeoPositionInfo::MagneticVariation, val);
+ }
+
+ //check for the heading
+ if (aPosInfo1->IsFieldAvailable(EPositionFieldHeading)) {
+ aPosInfo1->GetValue(EPositionFieldHeading, val);
+ aPosInfo2.setAttribute(QGeoPositionInfo::Direction, val);
+ }
+}
+//
+void CQGeoPositionInfoSourceS60::updatePosition(HPositionGenericInfo *aPosInfo, int aError)
+{
+ QGeoPositionInfo posInfo;
+
+ if (aError == KErrNone && aPosInfo) {
+ //fill posUpdate
+ TPositionInfo2QGeoPositionInfo(aPosInfo, posInfo);
+
+ mRegularUpdateTimedOut = false;
+
+ //emit posUpdate
+ emit positionUpdated(posInfo);
+ } else if (aError == KErrTimedOut) {
+ //request has timed out
+ if (mStartUpdates) {
+ if (!mRegularUpdateTimedOut) {
+ mRegularUpdateTimedOut = true;
+ emit updateTimeout();
+ }
+ } else {
+ emit updateTimeout();
+ }
+ } else {
+ //posiitoning module is unable to return any position information
+ emit updateTimeout();
+ }
+}
+
+// Returns the PositionServer handle
+RPositionServer& CQGeoPositionInfoSourceS60:: getPositionServer()
+{
+ return mPositionServer;
+}
+
+
+// for request update
+void CQGeoPositionInfoSourceS60::requestUpdate(int aTimeout)
+{
+ TInt index = -1;
+ TUint8 bits;
+
+ CQMLBackendAO *temp = NULL;
+
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit updateTimeout();
+ return;
+ }
+
+ //return if already a request update is pending
+ if (mReqUpdateAO && mReqUpdateAO->isRequestPending())
+ return;
+
+ if (aTimeout < 0 || (aTimeout != 0 && aTimeout < minimumUpdateInterval())) {
+ emit updateTimeout();
+ return;
+ }
+
+ if (aTimeout == 0)
+ aTimeout = 20000;
+
+ bits = mModuleFlags;
+
+ do {
+
+ //index of the more accurate method in the array
+ index = getMoreAccurateMethod(aTimeout, bits);
+
+ //no positioning method method available : emit updateTimeout
+ if (index < 0) {
+ emit updateTimeout();
+ break;
+ }
+ //if the selected module for request update is same as the previous one reuse the request
+ if (mList[index].mUid == mReqModuleId) {
+ if (mReqUpdateAO) {
+ mReqUpdateAO->requestUpdate(aTimeout);
+ return;
+ }
+ }
+
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, OnceUpdate, mList[index].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL)) {
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ //delete the old reqest update
+ if (mReqUpdateAO)
+ delete mReqUpdateAO;
+
+ //set the requestAO to the newly created AO
+ mReqUpdateAO = temp;
+ //set the request module ID
+ mReqModuleId = mList[index].mUid;
+ lReqLocker.unlock();
+
+ //start the update
+ mReqUpdateAO->requestUpdate(aTimeout);
+
+ return;
+ }
+
+ bits = bits & (0XFF ^(1 << index));
+
+ } while (index >= 0);
+
+ //cleanup resources if the invalid requpdate is still stored
+ if (mReqUpdateAO) {
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ delete mReqUpdateAO;
+ mReqUpdateAO = NULL;
+ mReqModuleId = TUid::Null();
+ lReqLocker.unlock();
+ }
+
+}
+
+// starts the regular updates
+void CQGeoPositionInfoSourceS60::startUpdates()
+{
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit updateTimeout();
+ return;
+ }
+
+ if (receivers(SIGNAL(positionUpdated(QGeoPositionInfo))) > 0 && !mStartUpdates)
+ mRegUpdateAO->startUpdates();
+ mRegularUpdateTimedOut = false;
+ mStartUpdates = true;
+}
+
+// stops the regular updates
+void CQGeoPositionInfoSourceS60::stopUpdates()
+{
+ mStartUpdates = false;
+
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit updateTimeout();
+ return;
+ }
+
+ mRegUpdateAO->cancelUpdate();
+}
+
+void CQGeoPositionInfoSourceS60::setPreferredPositioningMethods(PositioningMethods aMethods)
+{
+
+
+ QGeoPositionInfoSource::setPreferredPositioningMethods(aMethods);
+
+ PositioningMethods preferredMethod(PositioningMethods(0));
+ TInt index = -1;
+ // the poistioning methods are not supported
+ // if the preferred positioning method is the current poistioning
+
+ if (!(mSupportedMethods & aMethods) || (aMethods == PositioningMethods(AllPositioningMethods)) ||
+ (aMethods == PositioningMethods(mCurrentMethod)))
+
+ return;
+
+ //TPositionModuleId moduleId = getPreferredPoistionModuleId(methods);
+
+ //if(moduleId == TUid::Null())
+ //return;
+ CQMLBackendAO *temp = NULL;
+ TUint8 bits;
+ bits = mModuleFlags;
+ do {
+ //index = Get the index of the positioning module based on
+ //the preferred method if available , else get the default
+ //position module
+ index = getIndexPositionModule(bits, aMethods);
+
+ if (index == -1)
+ return;
+
+ if (index >= 0) {
+
+ TRAPD(error, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[index].mUid)));
+ if ((temp != NULL) && (error == KErrNone))
+ break;
+
+ bits = bits & (0XFF ^(1 << index));
+ }
+ } while (index >= 0);
+
+
+
+ if (temp != NULL) {
+ // this is needed as the previous setupdateinterval value should not be lost
+ int updateInterval = QGeoPositionInfoSource::updateInterval();
+ QMutexLocker lRegLocker(&m_mutex_RegUpAO);
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+ mRegUpdateAO = temp;
+
+ mCurrentModuleId = mList[index].mUid ;
+ lRegLocker.unlock();
+
+ index = checkModule(mCurrentModuleId);
+
+ if (index >= 0 && index < mListSize) {
+ QMutexLocker lRegLocker_interval(&m_mutex_interval);
+ mCurrentMethod = mList[index].mPosMethod ;
+ mMinUpdateInterval = mList[index].mTimeToNextFix.Int64() / 1000;
+ lRegLocker_interval.unlock();
+ }
+
+ int value = mRegUpdateAO->setUpdateInterval(updateInterval);
+ //as the positioning module has changed,
+ //possibility of the minimumupdateinterval being changed
+ if (value != updateInterval)
+ QGeoPositionInfoSource::setUpdateInterval(value);
+
+ }
+
+}
+
+void CQGeoPositionInfoSourceS60::setUpdateInterval(int aMilliSec)
+{
+
+
+ if (mRegUpdateAO) {
+ int interval = mRegUpdateAO->setUpdateInterval(aMilliSec);
+ // as the above set value can be minimum value so
+ // assigning to the base class data member
+ QGeoPositionInfoSource::setUpdateInterval(interval);
+ }
+}
+
+void CQGeoPositionInfoSourceS60::connectNotify(const char *aSignal)
+{
+ // start update if it already connected
+ if (mStartUpdates && mRegUpdateAO && QLatin1String(aSignal) == SIGNAL(positionUpdated(QGeoPositionInfo)))
+ mRegUpdateAO->startUpdates();
+
+}
+
+void CQGeoPositionInfoSourceS60::disconnectNotify(const char *aSignal)
+{
+ // Cancel updates if slot is disconnected for the positionUpdate() signal.
+
+ if ((mRegUpdateAO) && (QLatin1String(aSignal) == SIGNAL(positionUpdated(QGeoPositionInfo))) && receivers(SIGNAL(positionUpdated(QGeoPositionInfo))) == 0)
+ mRegUpdateAO->cancelUpdate();
+
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosource_s60_p.h b/src/location/qgeopositioninfosource_s60_p.h
new file mode 100644
index 00000000..c0076e94
--- /dev/null
+++ b/src/location/qgeopositioninfosource_s60_p.h
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCES60_H
+#define QGEOPOSITIONINFOSOURCES60_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <lbs.h>
+#include <qmutex.h>
+#include "qgeopositioninfosource.h"
+#include "qmlbackendao_s60_p.h"
+#include "notificationcallback_s60_p.h"
+
+#define MAX_SIZE 25
+
+QTM_BEGIN_NAMESPACE
+
+// CLASS DECLARATION
+//forward declaration
+class CQMLBackendAO;
+
+class CPosMethodInfo
+{
+public:
+ // A unique id for the positioning module
+ TPositionModuleId mUid;
+
+ // Positioning Module (satellite/ non-satellite)
+ QGeoPositionInfoSource::PositioningMethod mPosMethod;
+
+ //
+ int mStatus;
+
+ // time to first and next fix from the location server
+ TTimeIntervalMicroSeconds mTimeToFirstFix;
+ TTimeIntervalMicroSeconds mTimeToNextFix;
+
+ // Accuracy
+ double mHorizontalAccuracy;
+
+ // Flags whether the positioning technology is currently available or not.
+ bool mIsAvailable;
+};
+
+
+/**
+ * CQGeoPositionInfoSourceS60
+ *
+ */
+class CQGeoPositionInfoSourceS60 : public INotificationCallback,
+ public QGeoPositionInfoSource
+
+{
+public:
+ // Constructors and destructor
+ /**
+ * Destructor.
+ */
+ ~CQGeoPositionInfoSourceS60();
+
+ /**
+ * Two-phased constructor.
+ */
+ static CQGeoPositionInfoSourceS60* NewL(QObject* aParent);
+
+ /**
+ * Two-phased constructor.
+ */
+ static CQGeoPositionInfoSourceS60* NewLC(QObject* aParent);
+
+ /**
+ * returns the last known position
+ */
+ QGeoPositionInfo lastKnownPosition(bool aFromSatellitePositioningMethodsOnly = false) const;
+
+ /**
+ * returns the minimum update interval
+ */
+ int minimumUpdateInterval() const;
+
+ /**
+ * Sets the preferred PositioningMethod, if available
+ * otherwise sets the default poistioning mmethod
+ */
+ void setPreferredPositioningMethods(PositioningMethods aMethods);
+
+ /**
+ * Sets the interval for the regular position notifications
+ */
+ void setUpdateInterval(int aMilliSec);
+
+ /**
+ * Returns the supported Positioning Methods
+ */
+ PositioningMethods supportedPositioningMethods() const {
+ return mSupportedMethods;
+ }
+
+
+ //Applications using qt api's should avoid calling below methods as it is
+ //used internally by CQGeoPositionInfoSourceS60 for maintaining different states
+
+ /**
+ * Notification methods from active object.
+ * Notifies device status, position value, and status
+ */
+ void updateDeviceStatus(void) ;
+
+ /**
+ * Update the position info
+ */
+ void updatePosition(HPositionGenericInfo* aPosInfo, int aError);
+
+
+ /**
+ * Gets the handle of the PositionServer
+ */
+ RPositionServer& getPositionServer();
+
+ /*
+ * checks whether the object is valid
+ */
+ inline TBool isValid() {
+ if (mDevStatusUpdateAO && mRegUpdateAO)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ inline TPositionModuleId getCurrentPositonModuleID() {
+ return mCurrentModuleId;
+ }
+
+ inline TPositionModuleId getRequestUpdateModuleID() {
+ return mReqModuleId;
+ }
+
+public slots :
+ // for request update
+ void requestUpdate(int timeout = 5000);
+
+ // starts the regular updates
+ virtual void startUpdates();
+
+ // stops the regular updates
+ virtual void stopUpdates();
+
+
+private:
+
+ /**
+ * Constructor for performing 1st stage construction
+ */
+ CQGeoPositionInfoSourceS60(QObject* aParent = 0);
+
+ /**
+ * EPOC default constructor for performing 2nd stage construction
+ */
+ void ConstructL();
+
+ void updateStatus(TPositionModuleInfo &aModInfo, TInt aStatus);
+
+ void updateAvailableTypes(void);
+
+ //get the index of the module in the List array
+ TInt checkModule(TPositionModuleId aId) ;//const;
+
+ //get the index of the position module based on the preferred methods
+ TInt getIndexPositionModule(TUint8 aBits, PositioningMethods aPosMethods = AllPositioningMethods) const;
+
+ //get the more accuarte method with time to first fix < than timeout
+ TInt getMoreAccurateMethod(TInt aTimeout, TUint8 aBits);
+
+ void TPositionInfo2QGeoPositionInfo(HPositionGenericInfo *mPosInfo,
+ QGeoPositionInfo& posUpdate);
+
+protected:
+ void connectNotify(const char *aSignal);
+
+ void disconnectNotify(const char *aSignal);
+
+private:
+ /**
+ * current module ID
+ */
+ TPositionModuleId mCurrentModuleId;
+
+ /**
+ *prvmoduleID
+ */
+ TPositionModuleId mReqModuleId;
+
+ /**
+ * Active object for device status updates
+ */
+ CQMLBackendAO * mDevStatusUpdateAO;
+
+ /**
+ * Active object for requestUpdate
+ */
+ CQMLBackendAO * mReqUpdateAO;
+
+ /**
+ * Active object for regular updates.
+ */
+ CQMLBackendAO * mRegUpdateAO;
+
+ /**
+ * Positioner server
+ */
+ RPositionServer mPositionServer;
+
+ /**
+ * list of supported position methods
+ */
+ CPosMethodInfo mList[MAX_SIZE];
+
+ PositioningMethods mSupportedMethods;
+
+ PositioningMethod mCurrentMethod;
+
+ /**
+ * maintaiss the size of thr CPosMethodInfo array
+ */
+ int mListSize;
+
+ int mMinUpdateInterval;
+
+ /*
+ * query for the status
+ */
+ TPositionModuleStatusEvent mStatusEvent;
+
+ // mutex for making thread safe
+ QMutex m_mutex;
+ QMutex m_mutex_interval;
+
+ // mutex for ReqUpdate Active Ojbect
+ QMutex m_mutex_ReqUpAO;
+
+ // mutex for RegUpdate Active Ojbect
+ QMutex m_mutex_RegUpAO;
+
+ /*
+ * maintain the startUpdates status
+ */
+ TBool mStartUpdates;
+
+ TBool mRegularUpdateTimedOut;
+
+ /*
+ * flags for the modules
+ */
+ TUint8 mModuleFlags;
+};
+
+QTM_END_NAMESPACE
+
+#endif // CQGEOPOSITIONINFOSOURCES60_H
diff --git a/src/location/qgeopositioninfosource_simulator.cpp b/src/location/qgeopositioninfosource_simulator.cpp
new file mode 100644
index 00000000..b40e079f
--- /dev/null
+++ b/src/location/qgeopositioninfosource_simulator.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_simulator_p.h"
+#include "qlocationdata_simulator_p.h"
+#include "mobilitysimulatorglobal.h"
+#include "qlocationconnection_simulator_p.h"
+#include <mobilityconnection_p.h>
+
+#include <private/qsimulatordata_p.h>
+#include <QtCore/QDebug>
+#include <QtCore/QTimer>
+#include <QtCore/QDataStream>
+
+#include <QtNetwork/QLocalSocket>
+
+QTM_BEGIN_NAMESPACE
+
+using namespace QtSimulatorPrivate;
+
+namespace Simulator
+{
+ QGeoPositionInfo toPositionInfo(const QGeoPositionInfoData &data)
+ {
+ QDateTime timestamp;
+ if (data.dateTime.isValid())
+ timestamp = data.dateTime;
+ else
+ timestamp = QDateTime::currentDateTime();
+ QGeoCoordinate coord(data.latitude, data.longitude, data.altitude);
+ QGeoPositionInfo info(coord, timestamp);
+ info.setAttribute(QGeoPositionInfo::Direction, data.direction);
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, data.groundSpeed);
+ info.setAttribute(QGeoPositionInfo::VerticalSpeed, data.verticalSpeed);
+ info.setAttribute(QGeoPositionInfo::MagneticVariation, data.magneticVariation);
+ info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, data.horizontalAccuracy);
+ info.setAttribute(QGeoPositionInfo::VerticalAccuracy, data.verticalAccuracy);
+ return info;
+ }
+} //namespace
+
+// Location API
+
+QGeoPositionInfoSourceSimulator::QGeoPositionInfoSourceSimulator(QObject *parent)
+ : QGeoPositionInfoSource(parent)
+ , timer(new QTimer(this))
+ , requestTimer(new QTimer(this))
+{
+ ensureSimulatorConnection();
+
+ connect(timer, SIGNAL(timeout()), this, SLOT(updatePosition()));
+ requestTimer->setSingleShot(true);
+ connect(requestTimer, SIGNAL(timeout()), this, SLOT(updatePosition()));
+}
+
+QGeoPositionInfoSourceSimulator::~QGeoPositionInfoSourceSimulator()
+{
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceSimulator::lastKnownPosition(bool /*fromSatellitePositioningMethodsOnly*/) const
+{
+ return lastPosition;
+}
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceSimulator::supportedPositioningMethods() const
+{
+ // Is GPS now Satelite or not? Guessing so...
+ return QGeoPositionInfoSource::SatellitePositioningMethods;
+}
+
+void QGeoPositionInfoSourceSimulator::setUpdateInterval(int msec)
+{
+ // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal
+ // to or larger than the minimum update interval.
+ if (msec != 0 && msec < minimumUpdateInterval())
+ msec = minimumUpdateInterval();
+
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+ if (timer->isActive()) {
+ timer->setInterval(msec);
+ timer->start();
+ }
+}
+
+int QGeoPositionInfoSourceSimulator::minimumUpdateInterval() const
+{
+ return qtPositionInfo()->minimumInterval;
+}
+
+void QGeoPositionInfoSourceSimulator::startUpdates()
+{
+ int interval = updateInterval();
+ if (interval < minimumUpdateInterval())
+ interval = minimumUpdateInterval();
+ timer->setInterval(interval);
+ timer->start();
+}
+
+void QGeoPositionInfoSourceSimulator::stopUpdates()
+{
+ timer->stop();
+}
+
+void QGeoPositionInfoSourceSimulator::requestUpdate(int timeout)
+{
+ if (!requestTimer->isActive()) {
+ // Get a single update within timeframe
+ if (timeout < minimumUpdateInterval() && timeout != 0)
+ emit updateTimeout();
+ else {
+ requestTimer->start(timeout * qreal(0.75));
+ }
+ }
+}
+
+void QGeoPositionInfoSourceSimulator::updatePosition()
+{
+ if (qtPositionInfo()->enabled) {
+ lastPosition = Simulator::toPositionInfo(*qtPositionInfo());
+ emit positionUpdated(lastPosition);
+ } else {
+ emit updateTimeout();
+ }
+}
+
+#include "moc_qgeopositioninfosource_simulator_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosource_simulator_p.h b/src/location/qgeopositioninfosource_simulator_p.h
new file mode 100644
index 00000000..3c2a5703
--- /dev/null
+++ b/src/location/qgeopositioninfosource_simulator_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCESIMULATOR_H
+#define QGEOPOSITIONINFOSOURCESIMULATOR_H
+
+#include "qgeopositioninfosource.h"
+#include "qgeopositioninfo.h"
+#include "qlocationdata_simulator_p.h"
+
+QT_BEGIN_HEADER
+
+class QTimer;
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoSourceSimulator : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+public:
+ QGeoPositionInfoSourceSimulator(QObject *parent = 0);
+ ~QGeoPositionInfoSourceSimulator();
+
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
+
+ void setUpdateInterval(int msec);
+ int minimumUpdateInterval() const;
+
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
+
+ void requestUpdate(int timeout = 0);
+
+private slots:
+ void updatePosition();
+private:
+ Q_DISABLE_COPY(QGeoPositionInfoSourceSimulator);
+ QTimer *timer;
+ QTimer *requestTimer;
+ QGeoPositionInfo lastPosition;
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOPOSITIONINFOSOURCESIMULATOR_H
diff --git a/src/location/qgeopositioninfosource_wince.cpp b/src/location/qgeopositioninfosource_wince.cpp
new file mode 100644
index 00000000..19451e60
--- /dev/null
+++ b/src/location/qgeopositioninfosource_wince.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <windows.h>
+#include <gpsapi.h> // including requires <windows.h>
+
+#include "qgeopositioninfosource_wince_p.h"
+#include "qgeoinfothread_wince_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+// ========== QGeoPositionInfoValidator ==========
+
+QGeoPositionInfoValidator::QGeoPositionInfoValidator() : QGeoInfoValidator() {}
+
+QGeoPositionInfoValidator::~QGeoPositionInfoValidator() {}
+
+// Returns true if data contains at least the minimal amount of data we need to produce the
+// QGeoPositionInfoSource positionUpdated signal, otherwise returns false.
+bool QGeoPositionInfoValidator::valid(const GPS_POSITION &data) const
+{
+ if (((data.dwValidFields & GPS_VALID_LATITUDE) == 0)
+ || ((data.dwValidFields & GPS_VALID_LONGITUDE) == 0)
+ || ((data.dwValidFields & GPS_VALID_UTC_TIME) == 0)) {
+ return false;
+ }
+ return true;
+}
+
+// ========== QGeoPositionInfoSourceWinCE ==========
+
+QGeoPositionInfoSourceWinCE::QGeoPositionInfoSourceWinCE(QObject *parent)
+ : QGeoPositionInfoSource(parent)
+{
+ QGeoInfoValidator *validator = new QGeoPositionInfoValidator();
+
+ // The QGeoInfoThreadWinCE instance takes ownership of the validator.
+ infoThread = new QGeoInfoThreadWinCE(validator, true, this);
+ infoThread->start();
+ // QGeoInfoThreadWinCE takes care of registering GPS_POSITION as a metatype.
+ connect(infoThread, SIGNAL(dataUpdated(GPS_POSITION)), this, SLOT(dataUpdated(GPS_POSITION)));
+ connect(infoThread, SIGNAL(updateTimeout()), this, SIGNAL(updateTimeout()));
+}
+
+QGeoPositionInfoSourceWinCE::~QGeoPositionInfoSourceWinCE()
+{
+ delete infoThread;
+}
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinCE::supportedPositioningMethods() const
+{
+ return QGeoPositionInfoSource::SatellitePositioningMethods;
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceWinCE::lastKnownPosition(bool) const
+{
+ return lastPosition;
+}
+
+void QGeoPositionInfoSourceWinCE::setUpdateInterval(int msec)
+{
+ // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal
+ // to or larger than the minimum update interval.
+ if (msec != 0 && msec < MinimumUpdateInterval)
+ msec = MinimumUpdateInterval;
+
+ infoThread->setUpdateInterval(msec);
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+}
+
+int QGeoPositionInfoSourceWinCE::minimumUpdateInterval() const
+{
+ return MinimumUpdateInterval;
+}
+
+void QGeoPositionInfoSourceWinCE::startUpdates()
+{
+ infoThread->startUpdates();
+}
+
+void QGeoPositionInfoSourceWinCE::stopUpdates()
+{
+ infoThread->stopUpdates();
+}
+
+void QGeoPositionInfoSourceWinCE::requestUpdate(int timeout)
+{
+ // A timeout of 0 means to use the default timeout, which is handled by the QGeoInfoThreadWinCE
+ // instance, otherwise if timeout is less than the minimum update interval we emit a
+ // updateTimeout signal
+ if (timeout < minimumUpdateInterval() && timeout != 0)
+ emit updateTimeout();
+ else
+ infoThread->requestUpdate(timeout);
+}
+
+/*
+ This is _only_ called when QGeoPositionInfoValidator::valid() returns true for the position.
+ This means that it is implied that:
+ - (data.dwValidFields & GPS_VALID_LATITUDE) != 0
+ - (data.dwValidFields & GPS_VALID_LONGITUDE) != 0
+ - (data.dwValidFields & GPS_VALID_UTC_TIME) != 0
+
+ This guarantees that the newly created position will be valid.
+ If the code is changed such that this is no longer guaranteed then this method will need to be
+ updated to test for those conditions.
+*/
+void QGeoPositionInfoSourceWinCE::dataUpdated(GPS_POSITION data)
+{
+ QGeoCoordinate coordinate(data.dblLatitude, data.dblLongitude);
+
+ // The altitude is optional in QGeoCoordinate, so we do not strictly require that the
+ // GPS_POSITION structure has valid altitude data in order to trigger an update.
+ if ((data.dwValidFields & GPS_VALID_ALTITUDE_WRT_SEA_LEVEL) != 0)
+ coordinate.setAltitude(data.flAltitudeWRTSeaLevel);
+
+ QDate date(data.stUTCTime.wYear, data.stUTCTime.wMonth, data.stUTCTime.wDay);
+ QTime time(data.stUTCTime.wHour, data.stUTCTime.wMinute, data.stUTCTime.wSecond,
+ data.stUTCTime.wMilliseconds);
+
+ QDateTime dateTime(date, time, Qt::UTC);
+
+ QGeoPositionInfo pos(coordinate, dateTime);
+
+ // The following properties are optional, and so are set if the data is present and valid in
+ // the GPS_POSITION structure.
+ if ((data.dwValidFields & GPS_VALID_SPEED) != 0)
+ pos.setAttribute(QGeoPositionInfo::GroundSpeed, data.flSpeed);
+
+ if ((data.dwValidFields & GPS_VALID_HEADING) != 0)
+ pos.setAttribute(QGeoPositionInfo::Direction, data.flHeading);
+
+ if ((data.dwValidFields & GPS_VALID_MAGNETIC_VARIATION) != 0)
+ pos.setAttribute(QGeoPositionInfo::MagneticVariation, data.dblMagneticVariation);
+
+ lastPosition = pos;
+ emit positionUpdated(pos);
+}
+
+#include "moc_qgeopositioninfosource_wince_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosource_wince_p.h b/src/location/qgeopositioninfosource_wince_p.h
new file mode 100644
index 00000000..c3da32a5
--- /dev/null
+++ b/src/location/qgeopositioninfosource_wince_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCE_WINCE_P_H
+#define QGEOPOSITIONINFOSOURCE_WINCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qgeopositioninfosource.h>
+
+#include "qgeoinfothread_wince_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfoValidator : public QGeoInfoValidator
+{
+public:
+ QGeoPositionInfoValidator();
+ ~QGeoPositionInfoValidator();
+
+ bool valid(const GPS_POSITION &data) const;
+};
+
+class QGeoPositionInfoSourceWinCE : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+
+public:
+ enum {
+ // The minimum acceptable interval for periodic updates.
+ MinimumUpdateInterval = 100
+ };
+
+ explicit QGeoPositionInfoSourceWinCE(QObject *parent = 0);
+ ~QGeoPositionInfoSourceWinCE();
+
+ void setUpdateInterval(int msec);
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
+ int minimumUpdateInterval() const;
+
+public slots:
+ virtual void startUpdates();
+ virtual void stopUpdates();
+ virtual void requestUpdate(int timeout = 0);
+
+private slots:
+ void dataUpdated(GPS_POSITION data);
+
+private:
+ QGeoPositionInfo lastPosition;
+ QGeoInfoThreadWinCE *infoThread;
+};
+
+QTM_END_NAMESPACE
+
+#endif //#ifndef QGEOPOSITIONINFOSOURCE_WINCE_P_H
diff --git a/src/location/qgeopositioninfosourcefactory.cpp b/src/location/qgeopositioninfosourcefactory.cpp
new file mode 100644
index 00000000..3feae137
--- /dev/null
+++ b/src/location/qgeopositioninfosourcefactory.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosourcefactory.h"
+
+QTM_BEGIN_NAMESPACE
+
+/*!
+ \class QGeoPositionInfoSourceFactory
+
+ \brief The QGeoPositionInfoSourceFactory class is a factory class used
+ as the plugin interface for external providers of positioning data.
+
+ \inmodule QtLocation
+
+ \ingroup location
+ \since 1.2
+
+ Implementers must provide a unique combination of sourceName() and
+ sourceVersion() per plugin.
+
+ The other functions must be overridden by all plugins, other than
+ sourcePriority() which defaults to returning 0. Higher values of
+ priority will be preferred to lower ones.
+
+ \section1 Default plugins
+
+ Normally, the platform default position source will always overrule any
+ plugin-based position source during a call to createDefaultSource().
+ However, a limited measure is available where needed to change this behaviour,
+ using a system-wide configuration file.
+
+ The configuration file is in the system's default QSettings format, under
+ \c Nokia/QtLocationPosAndSat (for example, on most Linux variants this is
+ \c /etc/xdg/Nokia/QtLocationPosAndSat.conf). To set a default plugin source,
+ set the value \c position.plugin.operator.whitelist to a string of the format
+ \c "name,filename,hash,size" where \a name is the same as returned by the
+ plugin's \c sourceName() function, \a size is the size of the shared library
+ and \a hash is the library's SHA1 hash in hex format.
+ */
+
+/*!
+ \fn QGeoPositionInfoSource *QGeoPositionInfoSourceFactory::positionInfoSource(QObject *parent)
+
+ Returns a new QGeoPositionInfoSource associated with this plugin
+ with parent \a parent . Can also return 0, in which case the factory
+ with the next highest priority will be used instead.
+ */
+
+/*!
+ \fn QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactory::satelliteInfoSource(QObject *parent)
+
+ Returns a new QGeoSatelliteInfoSource associated with this plugin
+ with parent \a parent. Can also return 0, in which case the factory
+ with the next highest priority will be used instead.
+ */
+
+/*!
+ \fn QString QGeoPositionInfoSourceFactory::sourceName() const
+
+ Returns the string used to identify the position provider behind this
+ implementation.
+
+ The combination of sourceName() and sourceVersion() should be unique
+ amongst the plugins.
+ */
+
+/*!
+ \fn int QGeoPositionInfoSourceFactory::sourceVersion() const
+
+ Returns the version of the plugin.
+
+ The combination of sourceName() and sourceVersion() should be unique
+ amongst the plugins.
+ */
+
+/*!
+ Returns the priority of this factory in the list of available
+ factories. Factories with higher values of priority will be preferred
+ to those with lower values.
+ */
+int QGeoPositionInfoSourceFactory::sourcePriority() const
+{
+ return 0;
+}
+
+/*!
+ Destroys the position info source factory.
+*/
+QGeoPositionInfoSourceFactory::~QGeoPositionInfoSourceFactory()
+{}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeopositioninfosourcefactory.h b/src/location/qgeopositioninfosourcefactory.h
new file mode 100644
index 00000000..5940828f
--- /dev/null
+++ b/src/location/qgeopositioninfosourcefactory.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCEFACTORY_H
+#define QGEOPOSITIONINFOSOURCEFACTORY_H
+
+#include "qmobilityglobal.h"
+#include "qgeopositioninfosource.h"
+#include "qgeosatelliteinfosource.h"
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+class Q_LOCATION_EXPORT QGeoPositionInfoSourceFactory
+{
+public:
+ virtual ~QGeoPositionInfoSourceFactory();
+
+ virtual QString sourceName() const = 0;
+ virtual int sourceVersion() const = 0;
+ virtual int sourcePriority() const;
+
+ virtual QGeoPositionInfoSource *positionInfoSource(QObject *parent) = 0;
+ virtual QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent) = 0;
+};
+
+QTM_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+#define QT_POSITION_SOURCE_INTERFACE "com.nokia.qt.mobility.position.sourcefactory/1.0"
+Q_DECLARE_INTERFACE(QtMobility::QGeoPositionInfoSourceFactory, QT_POSITION_SOURCE_INTERFACE);
+QT_END_NAMESPACE
+
+#endif // QGEOPOSITIONINFOSOURCEFACTORY_H
diff --git a/src/location/qgeosatelliteinfo.cpp b/src/location/qgeosatelliteinfo.cpp
new file mode 100644
index 00000000..96dbac9d
--- /dev/null
+++ b/src/location/qgeosatelliteinfo.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgeosatelliteinfo.h"
+
+#include <QHash>
+#include <QDebug>
+#include <QDataStream>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoPrivate
+{
+public:
+ int prn;
+ int signal;
+ QHash<int, qreal> doubleAttribs;
+};
+
+
+/*!
+ \class QGeoSatelliteInfo
+ \brief The QGeoSatelliteInfo class contains basic information about a satellite.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ \sa QGeoSatelliteInfoSource
+*/
+
+/*!
+ \enum QGeoSatelliteInfo::Attribute
+ Defines the attributes for the satellite information.
+
+ \value Elevation The elevation of the satellite, in degrees.
+ \value Azimuth The azimuth to true north, in degrees.
+*/
+
+
+/*!
+ Creates a satellite information object.
+*/
+QGeoSatelliteInfo::QGeoSatelliteInfo()
+ : d(new QGeoSatelliteInfoPrivate)
+{
+ d->prn = -1;
+ d->signal = -1;
+}
+
+/*!
+ Creates a satellite information object with the values of \a other.
+*/
+
+QGeoSatelliteInfo::QGeoSatelliteInfo(const QGeoSatelliteInfo &other)
+ : d(new QGeoSatelliteInfoPrivate)
+{
+ operator=(other);
+}
+
+/*!
+ Destroys a satellite information object.
+*/
+QGeoSatelliteInfo::~QGeoSatelliteInfo()
+{
+ delete d;
+}
+
+/*!
+ Assigns the values from \a other to this object.
+*/
+QGeoSatelliteInfo &QGeoSatelliteInfo::operator=(const QGeoSatelliteInfo & other)
+{
+ if (this == &other)
+ return *this;
+
+ d->prn = other.d->prn;
+ d->signal = other.d->signal;
+ d->doubleAttribs = other.d->doubleAttribs;
+ return *this;
+}
+
+/*!
+ Returns true if all the information for this satellite
+ are the same as those of \a other.
+*/
+bool QGeoSatelliteInfo::operator==(const QGeoSatelliteInfo &other) const
+{
+ return d->prn == other.d->prn
+ && d->signal == other.d->signal
+ && d->doubleAttribs == other.d->doubleAttribs;
+}
+
+/*!
+ \fn bool QGeoSatelliteInfo::operator!=(const QGeoSatelliteInfo &other) const;
+
+ Returns true if any of the information for this satellite
+ are not the same as those of \a other.
+*/
+
+/*!
+ Sets the PRN (Pseudo-random noise) number to \a prn.
+
+ The PRN number can be used to identify a satellite.
+*/
+void QGeoSatelliteInfo::setPrnNumber(int prn)
+{
+ d->prn = prn;
+}
+
+/*!
+ Returns the PRN (Pseudo-random noise) number, or -1 if the value has not been set.
+*/
+
+int QGeoSatelliteInfo::prnNumber() const
+{
+ return d->prn;
+}
+
+/*!
+ Sets the signal strength to \a signalStrength, in decibels.
+*/
+void QGeoSatelliteInfo::setSignalStrength(int signalStrength)
+{
+ d->signal = signalStrength;
+}
+
+/*!
+ Returns the signal strength, or -1 if the value has not been set.
+*/
+int QGeoSatelliteInfo::signalStrength() const
+{
+ return d->signal;
+}
+
+/*!
+ Sets the value for \a attribute to \a value.
+*/
+void QGeoSatelliteInfo::setAttribute(Attribute attribute, qreal value)
+{
+ d->doubleAttribs[int(attribute)] = value;
+}
+
+/*!
+ Returns the value of the specified \a attribute as a qreal value.
+
+ Returns -1 if the value has not been set.
+
+ \sa hasAttribute(), setAttribute()
+*/
+qreal QGeoSatelliteInfo::attribute(Attribute attribute) const
+{
+ if (d->doubleAttribs.contains(int(attribute)))
+ return d->doubleAttribs[int(attribute)];
+ return -1;
+}
+
+/*!
+ Removes the specified \a attribute and its value.
+*/
+void QGeoSatelliteInfo::removeAttribute(Attribute attribute)
+{
+ d->doubleAttribs.remove(int(attribute));
+}
+
+/*!
+ Returns true if the specified \a attribute is present in this update.
+*/
+bool QGeoSatelliteInfo::hasAttribute(Attribute attribute) const
+{
+ return d->doubleAttribs.contains(int(attribute));
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info)
+{
+ dbg.nospace() << "QGeoSatelliteInfo(PRN=" << info.d->prn;
+ dbg.nospace() << ", signal-strength=";
+ dbg.nospace() << info.d->signal;
+
+ QList<int> attribs = info.d->doubleAttribs.keys();
+ for (int i = 0; i < attribs.count(); i++) {
+ dbg.nospace() << ", ";
+ switch (attribs[i]) {
+ case QGeoSatelliteInfo::Elevation:
+ dbg.nospace() << "Elevation=";
+ break;
+ case QGeoSatelliteInfo::Azimuth:
+ dbg.nospace() << "Azimuth=";
+ break;
+ }
+ dbg.nospace() << info.d->doubleAttribs[attribs[i]];
+ }
+ dbg.nospace() << ')';
+ return dbg;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info)
+ \relates QGeoSatelliteInfo
+
+ Writes the given \a info to the specified \a stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info)
+{
+ stream << info.d->prn;
+ stream << info.d->signal;
+ stream << info.d->doubleAttribs;
+ return stream;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info)
+ \relates QGeoSatelliteInfo
+
+ Reads satellite information from the specified \a stream into the given
+ \a info.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+
+QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info)
+{
+ stream >> info.d->prn;
+ stream >> info.d->signal;
+ stream >> info.d->doubleAttribs;
+ return stream;
+}
+#endif
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeosatelliteinfo.h b/src/location/qgeosatelliteinfo.h
new file mode 100644
index 00000000..bce8dfb1
--- /dev/null
+++ b/src/location/qgeosatelliteinfo.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOSATELLITEINFO_H
+#define QGEOSATELLITEINFO_H
+
+#include "qmobilityglobal.h"
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+class QDataStream;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoPrivate;
+class Q_LOCATION_EXPORT QGeoSatelliteInfo
+{
+public:
+ enum Attribute {
+ Elevation,
+ Azimuth
+ };
+
+ QGeoSatelliteInfo();
+ QGeoSatelliteInfo(const QGeoSatelliteInfo &other);
+ ~QGeoSatelliteInfo();
+
+ QGeoSatelliteInfo &operator=(const QGeoSatelliteInfo &other);
+
+ bool operator==(const QGeoSatelliteInfo &other) const;
+ inline bool operator!=(const QGeoSatelliteInfo &other) const {
+ return !operator==(other);
+ }
+
+ void setPrnNumber(int prn);
+ int prnNumber() const;
+
+ void setSignalStrength(int signalStrength);
+ int signalStrength() const;
+
+ void setAttribute(Attribute attribute, qreal value);
+ qreal attribute(Attribute attribute) const;
+ void removeAttribute(Attribute attribute);
+
+ bool hasAttribute(Attribute attribute) const;
+
+private:
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info);
+#endif
+#ifndef QT_NO_DATASTREAM
+ friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info);
+ friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info);
+#endif
+ QGeoSatelliteInfoPrivate *d;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info);
+Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info);
+#endif
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeosatelliteinfosource.cpp b/src/location/qgeosatelliteinfosource.cpp
new file mode 100644
index 00000000..b68b2a63
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource.cpp
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qgeosatelliteinfosource.h>
+#include "qgeopositioninfosourcefactory.h"
+#include <QPluginLoader>
+#include <QStringList>
+#include <QCryptographicHash>
+#include <QSettings>
+#include "qmobilitypluginsearch.h"
+
+#if defined(Q_OS_SYMBIAN)
+# include "qgeosatelliteinfosource_s60_p.h"
+#elif defined(QT_SIMULATOR)
+# include "qgeosatelliteinfosource_simulator_p.h"
+#elif defined(Q_OS_WINCE)
+# include "qgeosatelliteinfosource_wince_p.h"
+#elif defined(Q_WS_MAEMO_6)
+# include "qgeosatelliteinfosource_maemo_p.h"
+#elif defined(Q_WS_MAEMO_5)
+# include "qgeosatelliteinfosource_maemo5_p.h"
+#endif
+
+#if defined(Q_WS_MEEGO)
+#include "qgeosatelliteinfosource_maemo_p.h"
+#if defined(GYPSY_AVAILABLE)
+#include "qgeosatelliteinfosource_gypsy_p.h"
+#endif
+#endif
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoSourcePrivate
+{
+public:
+ static QList<QGeoPositionInfoSourceFactory*> pluginsSorted();
+ static QHash<QString, QGeoPositionInfoSourceFactory*> plugins(bool reload = false);
+ static void loadDynamicPlugins(QHash<QString, QGeoPositionInfoSourceFactory*> &plugins);
+ static void loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory*> &plugins);
+};
+
+QHash<QString, QGeoPositionInfoSourceFactory*> QGeoSatelliteInfoSourcePrivate::plugins(bool reload)
+{
+ static QHash<QString, QGeoPositionInfoSourceFactory*> plugins;
+ static bool alreadyDiscovered = false;
+
+ if (reload == true)
+ alreadyDiscovered = false;
+
+ if (!alreadyDiscovered) {
+ loadStaticPlugins(plugins);
+ loadDynamicPlugins(plugins);
+ alreadyDiscovered = true;
+ }
+ return plugins;
+}
+
+static bool pluginComparator(const QGeoPositionInfoSourceFactory *p1, const QGeoPositionInfoSourceFactory *p2)
+{
+ return (p1->sourcePriority() > p2->sourcePriority());
+}
+
+QList<QGeoPositionInfoSourceFactory*> QGeoSatelliteInfoSourcePrivate::pluginsSorted()
+{
+ QList<QGeoPositionInfoSourceFactory*> list = plugins().values();
+ qStableSort(list.begin(), list.end(), pluginComparator);
+ return list;
+}
+
+void QGeoSatelliteInfoSourcePrivate::loadDynamicPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
+{
+ QStringList paths;
+ paths << mobilityPlugins(QLatin1String("position"));
+
+ QPluginLoader qpl;
+ QString blockName;
+
+ QSettings settings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat"));
+ QVariant value = settings.value("position.plugin.operator.whitelist");
+ if (value.isValid()) {
+ QStringList parts = value.toString().split(",");
+ if (parts.size() == 4) {
+ QFile file(parts.at(1));
+ file.open(QIODevice::ReadOnly);
+
+ QCryptographicHash hash(QCryptographicHash::Sha1);
+ while (!file.atEnd()) {
+ QByteArray data = file.read(4096);
+ hash.addData(data);
+ }
+ file.close();
+
+ QByteArray hexHash = hash.result().toHex();
+
+ bool loadIt = true;
+ if (QString::number(file.size()) != parts.at(3)) {
+ qCritical("Position info plugin: bad plugin size for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ loadIt = false;
+ }
+
+ if (hexHash != parts.at(2).toLatin1()) {
+ qCritical("Position info plugin: bad plugin hash for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ loadIt = false;
+ }
+
+ if (loadIt) {
+ qpl.setFileName(parts.at(1));
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance());
+
+ if (f) {
+ QString name = f->sourceName();
+ if (name == parts.at(0)) {
+ plugins.insert(name, f);
+ } else {
+ qCritical("Position info plugin: bad plugin name for %s",
+ qPrintable(parts.at(1)));
+ qWarning("Will fall back to platform default");
+ }
+ }
+ }
+
+ // still set blockName to ensure the plugin doesn't load
+ blockName = parts.at(1);
+ } else {
+ qWarning("Position plugin whitelist: invalid format -- should be key,filename,hash,size");
+ }
+ }
+
+ for (int i = 0; i < paths.count(); ++i) {
+ if (paths.at(i) != blockName) {
+ qpl.setFileName(paths.at(i));
+
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance());
+ if (f) {
+ QString name = f->sourceName();
+
+ #if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+ if (showDebug)
+ qDebug("Dynamic: found a service provider plugin with name %s", qPrintable(name));
+ #endif
+ plugins.insertMulti(name, f);
+ }
+ }
+ }
+}
+
+void QGeoSatelliteInfoSourcePrivate::loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
+{
+#if !defined QT_NO_DEBUG
+ const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
+#endif
+
+ QObjectList staticPlugins = QPluginLoader::staticInstances();
+ for (int i = 0; i < staticPlugins.count(); ++i) {
+ QGeoPositionInfoSourceFactory *f =
+ qobject_cast<QGeoPositionInfoSourceFactory*>(staticPlugins.at(i));
+
+ if (f) {
+ QString name = f->sourceName();
+
+#if !defined QT_NO_DEBUG
+ if (showDebug)
+ qDebug("Static: found a service provider plugin with name %s", qPrintable(name));
+#endif
+ if (!name.isEmpty()) {
+ plugins.insertMulti(name, f);
+ }
+ }
+
+ }
+}
+
+/*!
+ \class QGeoSatelliteInfoSource
+ \brief The QGeoSatelliteInfoSource class is an abstract base class for the distribution of satellite information updates.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ The static function QGeoSatelliteInfoSource::createDefaultSource() creates a default
+ satellite data source that is appropriate for the platform, if one is
+ available. Otherwise, available QGeoPositionInfoSourceFactory plugins will
+ be checked for one that has a satellite data source available.
+
+ Call startUpdates() and stopUpdates() to start and stop regular updates,
+ or requestUpdate() to request a single update.
+ When an update is available, satellitesInViewUpdated() and/or
+ satellitesInUseUpdated() will be emitted.
+
+ \warning On Windows CE it is not possible to detect if a device is GPS enabled.
+ The default satellite source on a Windows CE device without GPS support will never provide any satellite data.
+
+ \warning On Symbian it is currently only possible to instantiate and use the satellite sources in the main thread
+ of the application.
+*/
+
+/*!
+ Creates a source with the specified \a parent.
+*/
+QGeoSatelliteInfoSource::QGeoSatelliteInfoSource(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ Creates and returns a source with the specified \a parent that reads
+ from the system's default source of satellite update information, or the
+ highest priority available plugin.
+
+ Returns 0 if the system has no default source and no valid plugins
+ could be found.
+
+ Note: Symbian applications will need to have the Location capability
+ otherwise this will return 0.
+*/
+QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent)
+{
+ QSettings pluginSettings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat"));
+ QVariant value = pluginSettings.value("position.plugin.operator.whitelist");
+ if (value.isValid()) {
+ QStringList parts = value.toString().split(",");
+ if (parts.size() == 4) {
+ QGeoSatelliteInfoSource *source = createSource(parts.at(0), parent);
+ if (source)
+ return source;
+ }
+ }
+
+#if defined(Q_OS_SYMBIAN)
+ CQGeoSatelliteInfoSourceS60 *ret = NULL;
+ TRAPD(error, QT_TRYCATCH_LEAVING(ret = CQGeoSatelliteInfoSourceS60::NewL(parent)));
+ if (error == KErrNone)
+ return ret;
+#elif defined(Q_OS_WINCE)
+ return new QGeoSatelliteInfoSourceWinCE(parent);
+#elif (defined(Q_WS_MAEMO_6)) || (defined(Q_WS_MAEMO_5))
+ QGeoSatelliteInfoSourceMaemo *source = new QGeoSatelliteInfoSourceMaemo(parent);
+ int status = source->init();
+
+ if (status != -1)
+ return source;
+ else
+ delete source;
+#elif defined(QT_SIMULATOR)
+ return new QGeoSatelliteInfoSourceSimulator(parent);
+#elif defined(Q_WS_MEEGO)
+ // Use Maemo6 backend if available, otherwise use Gypsy backend
+ QSettings maemo6Settings(QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSatMaemo6"));
+ if (!maemo6Settings.value("maemo6satelliteavailable").isValid()) {
+ QGeoSatelliteInfoSourceMaemo *maemoSource = new QGeoSatelliteInfoSourceMaemo(parent);
+ int status = maemoSource->init();
+ if (status == -1) {
+ delete maemoSource;
+ maemoSource = 0;
+ maemo6Settings.setValue("maemo6satelliteavailable", false);
+ } else {
+ return maemoSource;
+ }
+ }
+#ifdef GYPSY_AVAILABLE
+ QGeoSatelliteInfoSourceGypsy* gypsySource = new QGeoSatelliteInfoSourceGypsy(parent);
+ int status = gypsySource->init();
+ if (status >= 0)
+ return gypsySource;
+ delete gypsySource;
+#endif // GYPSY_AVAILABLE
+#endif
+ foreach (QGeoPositionInfoSourceFactory *f, QGeoSatelliteInfoSourcePrivate::pluginsSorted()) {
+ QGeoSatelliteInfoSource *src = f->satelliteInfoSource(parent);
+ if (src)
+ return src;
+ }
+
+ return 0;
+}
+
+/*!
+ Creates and returns a source with the given \a parent,
+ by loading the plugin named \a sourceName.
+
+ Returns 0 if the plugin cannot be found.
+*/
+QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createSource(const QString &sourceName, QObject *parent)
+{
+ QGeoPositionInfoSourceFactory *f = QGeoSatelliteInfoSourcePrivate::plugins().value(sourceName);
+ if (f) {
+ QGeoSatelliteInfoSource *src = f->satelliteInfoSource(parent);
+ if (src)
+ return src;
+ }
+ return 0;
+}
+
+/*!
+ Returns a list of available source plugins. Note that this does not
+ include the default system backend, if one is available.
+*/
+QStringList QGeoSatelliteInfoSource::availableSources()
+{
+ return QGeoSatelliteInfoSourcePrivate::plugins().keys();
+}
+
+/*!
+ \fn void QGeoSatelliteInfoSource::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+ If startUpdates() or requestUpdate() is called, this signal is emitted
+ when an update is available on the satellites that are
+ currently in view.
+
+ The \a satellites parameter holds the satellites currently in view.
+*/
+
+/*!
+ \fn void QGeoSatelliteInfoSource::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+ If startUpdates() or requestUpdate() is called, this signal is emitted
+ when an update is available on the number of satellites that are
+ currently in use.
+
+ These are the satellites that are used to get a "fix" - that
+ is, those used to determine the current position.
+
+ The \a satellites parameter holds the satellites currently in use.
+*/
+
+/*!
+ \fn virtual void QGeoSatelliteInfoSource::startUpdates() = 0;
+
+ Starts emitting updates at regular intervals. The updates will be
+ provided whenever new satellite information becomes available.
+
+ \sa satellitesInViewUpdated(), satellitesInUseUpdated()
+*/
+
+/*!
+ \fn virtual void QGeoSatelliteInfoSource::stopUpdates() = 0;
+
+ Stops emitting updates at regular intervals.
+*/
+
+/*!
+ \fn virtual void QGeoSatelliteInfoSource::requestUpdate(int timeout = 0);
+
+ Attempts to get the current satellite information and emit
+ satellitesInViewUpdated() and satellitesInUseUpdated() with this
+ information. If the current position cannot be found
+ within the given \a timeout (in milliseconds), requestTimeout() is
+ emitted.
+
+ If the timeout is zero, the timeout defaults to a reasonable timeout
+ period as appropriate for the source.
+
+ This does nothing if another update request is in progress. However
+ it can be called even if startUpdates() has already been called and
+ regular updates are in progress.
+*/
+
+/*!
+ \fn void QGeoSatelliteInfoSource::requestTimeout();
+
+ Emitted if requestUpdate() was called and the current satellite
+ information could not be retrieved within the specified timeout.
+*/
+
+#include "moc_qgeosatelliteinfosource.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/qgeosatelliteinfosource.h b/src/location/qgeosatelliteinfosource.h
new file mode 100644
index 00000000..8ab2bf6e
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOSATELLITEINFOSOURCE_H
+#define QGEOSATELLITEINFOSOURCE_H
+
+#include "qmobilityglobal.h"
+#include "qgeosatelliteinfo.h"
+
+#include <QObject>
+#include <QList>
+
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoSourcePrivate;
+class Q_LOCATION_EXPORT QGeoSatelliteInfoSource : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QGeoSatelliteInfoSource(QObject *parent);
+
+ static QGeoSatelliteInfoSource *createDefaultSource(QObject *parent);
+ static QGeoSatelliteInfoSource *createSource(const QString &sourceName, QObject *parent);
+ static QStringList availableSources();
+
+public Q_SLOTS:
+ virtual void startUpdates() = 0;
+ virtual void stopUpdates() = 0;
+
+ virtual void requestUpdate(int timeout = 0) = 0;
+
+Q_SIGNALS:
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void requestTimeout();
+
+private:
+ Q_DISABLE_COPY(QGeoSatelliteInfoSource)
+ QGeoSatelliteInfoSourcePrivate *d;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qgeosatelliteinfosource_gypsy.cpp b/src/location/qgeosatelliteinfosource_gypsy.cpp
new file mode 100644
index 00000000..9550f4d8
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_gypsy.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosatelliteinfosource_gypsy_p.h"
+
+#ifdef Q_LOCATION_GYPSY_DEBUG
+#include <QDebug>
+#endif
+#include <QFile>
+
+QTM_BEGIN_NAMESPACE
+
+#define UPDATE_TIMEOUT_COLD_START 120000
+
+
+// Callback function for 'satellites-changed' -signal
+static void satellites_changed (GypsySatellite *satellite,
+ GPtrArray *satellites,
+ gpointer userdata)
+{
+#ifdef Q_LOCATION_GYPSY_DEBUG
+ qDebug() << "QGeoSatelliteInfoSourceGypsy Gypsy satellites-changed -signal received.";
+#endif
+ ((QGeoSatelliteInfoSourceGypsy*)userdata)->satellitesChanged(satellite, satellites);
+}
+
+SatelliteGypsyEngine::SatelliteGypsyEngine(QGeoSatelliteInfoSource* parent) :
+ m_owner(parent)
+{
+}
+SatelliteGypsyEngine::~SatelliteGypsyEngine()
+{
+}
+
+// Glib symbols
+gulong SatelliteGypsyEngine::eng_g_signal_connect(gpointer instance,
+ const gchar* detailed_signal,
+ GCallback c_handler,
+ gpointer data)
+{
+ return ::g_signal_connect(instance, detailed_signal, c_handler, data);
+}
+guint SatelliteGypsyEngine::eng_g_signal_handlers_disconnect_by_func (gpointer instance,
+ gpointer func,
+ gpointer data)
+{
+ return ::g_signal_handlers_disconnect_by_func(instance, func, data);
+}
+
+void SatelliteGypsyEngine::eng_g_free(gpointer mem)
+{
+ return ::g_free(mem);
+}
+// Gypsy symbols
+GypsyControl* SatelliteGypsyEngine::eng_gypsy_control_get_default (void)
+{
+ return ::gypsy_control_get_default();
+}
+char *SatelliteGypsyEngine::eng_gypsy_control_create (GypsyControl *control, const char*device_name, GError **error)
+{
+ return ::gypsy_control_create(control, device_name, error);
+}
+GypsyDevice *SatelliteGypsyEngine::eng_gypsy_device_new (const char *object_path)
+{
+ return ::gypsy_device_new(object_path);
+}
+GypsySatellite *SatelliteGypsyEngine::eng_gypsy_satellite_new (const char *object_path)
+{
+ return ::gypsy_satellite_new (object_path);
+}
+gboolean SatelliteGypsyEngine::eng_gypsy_device_start (GypsyDevice *device, GError **error)
+{
+ return ::gypsy_device_start(device, error);
+}
+gboolean SatelliteGypsyEngine::eng_gypsy_device_stop (GypsyDevice *device, GError **error)
+{
+ // Unfortunately this cannot be done; calling this will stop the GPS device
+ // (basically makes gypsy-daemon unusable for anyone), regardless of applications
+ // using it (see bug http://bugs.meego.com/show_bug.cgi?id=11707).
+ Q_UNUSED(device);
+ Q_UNUSED(error);
+ return true;
+ //return ::gypsy_device_stop (device, error);
+}
+GypsyDeviceFixStatus SatelliteGypsyEngine::eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error)
+{
+ return ::gypsy_device_get_fix_status (device, error);
+}
+GPtrArray *SatelliteGypsyEngine::eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error)
+{
+ return ::gypsy_satellite_get_satellites (satellite, error);
+}
+void SatelliteGypsyEngine::eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites)
+{
+ return ::gypsy_satellite_free_satellite_array(satellites);
+}
+// GConf symbols (mockability due to X11 requirement)
+GConfClient* SatelliteGypsyEngine::eng_gconf_client_get_default(void)
+{
+ return ::gconf_client_get_default();
+}
+gchar* SatelliteGypsyEngine::eng_gconf_client_get_string(GConfClient* client, const gchar* key, GError** err)
+{
+ return ::gconf_client_get_string(client, key, err);
+}
+
+QGeoSatelliteInfoSourceGypsy::QGeoSatelliteInfoSourceGypsy(QObject *parent) : QGeoSatelliteInfoSource(parent),
+ m_engine(0), m_satellite(0), m_device(0), m_updatesOngoing(false), m_requestOngoing(false)
+{
+ m_requestTimer.setSingleShot(true);
+ QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestUpdateTimeout()));
+}
+
+void QGeoSatelliteInfoSourceGypsy::createEngine()
+{
+ if (m_engine)
+ delete m_engine;
+ m_engine = new SatelliteGypsyEngine(this);
+}
+
+QGeoSatelliteInfoSourceGypsy::~QGeoSatelliteInfoSourceGypsy()
+{
+ GError* error = NULL;
+ if (m_device) {
+ m_engine->eng_gypsy_device_stop (m_device, &error);
+ g_object_unref(m_device);
+ }
+ if (m_satellite)
+ g_object_unref(m_satellite);
+ if (error)
+ g_error_free(error);
+ if (m_engine)
+ delete m_engine;
+}
+
+void QGeoSatelliteInfoSourceGypsy::satellitesChanged(GypsySatellite* satellite,
+ GPtrArray* satellites)
+{
+ if (!satellite || !satellites)
+ return;
+ // We have satellite data and assume it is valid.
+ // If a single updateRequest was active, send signals right away.
+ // If a periodic timer was running (meaning that the client wishes
+ // to have updates at defined intervals), store the data for later sending.
+ QList<QtMobility::QGeoSatelliteInfo> lastSatellitesInView;
+ QList<QtMobility::QGeoSatelliteInfo> lastSatellitesInUse;
+
+ unsigned int i;
+ for (i = 0; i < satellites->len; i++) {
+ GypsySatelliteDetails *details = (GypsySatelliteDetails*)satellites->pdata[i];
+ QGeoSatelliteInfo info;
+ info.setAttribute(QGeoSatelliteInfo::Elevation, details->elevation);
+ info.setAttribute(QGeoSatelliteInfo::Azimuth, details->azimuth);
+ info.setPrnNumber(details->satellite_id);
+ info.setSignalStrength(details->snr);
+ if (details->in_use)
+ lastSatellitesInUse.append(info);
+ lastSatellitesInView.append(info);
+ }
+ bool sendUpdates(false);
+ // If a single updateRequest() has been issued:
+ if (m_requestOngoing) {
+ sendUpdates = true;
+ m_requestTimer.stop();
+ m_requestOngoing = false;
+ // If there is no regular updates ongoing, disconnect now.
+ if (!m_updatesOngoing) {
+ m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void*)satellites_changed, this);
+ }
+ }
+ // If regular updates are to be delivered as they come:
+ if (m_updatesOngoing)
+ sendUpdates = true;
+
+ if (sendUpdates) {
+ emit satellitesInUseUpdated(lastSatellitesInUse);
+ emit satellitesInViewUpdated(lastSatellitesInView);
+ }
+}
+
+int QGeoSatelliteInfoSourceGypsy::init()
+{
+ GError *error = NULL;
+ char *path;
+ GConfClient* client;
+ gchar* device_name;
+
+ g_type_init ();
+ createEngine();
+
+ client = m_engine->eng_gconf_client_get_default();
+ if (!client) {
+ qWarning ("QGeoSatelliteInfoSourceGypsy client creation failed.");
+ return -1;
+ }
+ device_name = m_engine->eng_gconf_client_get_string(client, "/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice", NULL);
+ g_object_unref(client);
+ QString deviceName(QString::fromAscii(device_name));
+ if (deviceName.isEmpty() ||
+ (deviceName.trimmed().at(0) == '/' && !QFile::exists(deviceName.trimmed()))) {
+ qWarning ("QGeoSatelliteInfoSourceGypsy Empty/nonexistent GPS device name detected.");
+ qWarning ("Use gconftool-2 to set it, e.g. on terminal: ");
+ qWarning ("gconftool-2 -t string -s /apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice /dev/ttyUSB0");
+ m_engine->eng_g_free(device_name);
+ return -1;
+ }
+ GypsyControl *control = NULL;
+ control = m_engine->eng_gypsy_control_get_default();
+ if (!control) {
+ qWarning("QGeoSatelliteInfoSourceGypsy unable to create Gypsy control.");
+ m_engine->eng_g_free(device_name);
+ return -1;
+ }
+ // (path is the DBus path)
+ path = m_engine->eng_gypsy_control_create (control, device_name, &error);
+ m_engine->eng_g_free(device_name);
+ g_object_unref(control);
+ if (!path) {
+ qWarning ("QGeoSatelliteInfoSourceGypsy error creating client.");
+ if (error) {
+ qWarning ("error message: %s", error->message);
+ g_error_free (error);
+ }
+ return -1;
+ }
+ m_device = m_engine->eng_gypsy_device_new (path);
+ m_satellite = m_engine->eng_gypsy_satellite_new (path);
+ m_engine->eng_g_free(path);
+ if (!m_device || !m_satellite) {
+ qWarning ("QGeoSatelliteInfoSourceGypsy error creating satellite device.");
+ qWarning ("Is GPS device set correctly? If not, use gconftool-2 to set it, e.g.: ");
+ qWarning ("gconftool-2 -t string -s /apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice /dev/ttyUSB0");
+ if (m_device)
+ g_object_unref(m_device);
+ if (m_satellite)
+ g_object_unref(m_satellite);
+ return -1;
+ }
+ m_engine->eng_gypsy_device_start (m_device, &error);
+ if (error) {
+ qWarning ("QGeoSatelliteInfoSourceGypsy error starting device: %s ",
+ error->message);
+ g_error_free(error);
+ g_object_unref(m_device);
+ g_object_unref(m_satellite);
+ return -1;
+ }
+ return 0;
+}
+
+void QGeoSatelliteInfoSourceGypsy::startUpdates()
+{
+ if (m_updatesOngoing)
+ return;
+ // If there is a request timer ongoing, we've connected to the signal already
+ if (!m_requestTimer.isActive()) {
+ m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
+ G_CALLBACK (satellites_changed), this);
+ }
+ m_updatesOngoing = true;
+}
+
+void QGeoSatelliteInfoSourceGypsy::stopUpdates()
+{
+ if (!m_updatesOngoing)
+ return;
+ m_updatesOngoing = false;
+ // Disconnect only if there is no single update request ongoing. Once single update request
+ // is completed and it notices that there is no active update ongoing, it will disconnect
+ // the signal.
+ if (!m_requestTimer.isActive())
+ m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void*)satellites_changed, this);
+}
+
+void QGeoSatelliteInfoSourceGypsy::requestUpdate(int timeout)
+{
+ if (m_requestOngoing)
+ return;
+ if (timeout < 0) {
+ emit requestTimeout();
+ return;
+ }
+ m_requestOngoing = true;
+ GError *error = 0;
+ // If GPS has a fix a already, request current data.
+ GypsyDeviceFixStatus fixStatus = m_engine->eng_gypsy_device_get_fix_status(m_device, &error);
+ if (!error && (fixStatus != GYPSY_DEVICE_FIX_STATUS_INVALID &&
+ fixStatus != GYPSY_DEVICE_FIX_STATUS_NONE)) {
+#ifdef Q_LOCATION_GYPSY_DEBUG
+ qDebug() << "QGeoSatelliteInfoSourceGypsy fix available, requesting current satellite data";
+#endif
+ GPtrArray* satelliteData = m_engine->eng_gypsy_satellite_get_satellites(m_satellite, &error);
+ if (!error) {
+ // The fix was available and we have satellite data to deliver right away.
+ satellitesChanged(m_satellite, satelliteData);
+ m_engine->eng_gypsy_satellite_free_satellite_array(satelliteData);
+ return;
+ }
+ }
+ // No fix is available. If updates are not ongoing already, start them.
+ m_requestTimer.setInterval(timeout == 0? UPDATE_TIMEOUT_COLD_START: timeout);
+ if (!m_updatesOngoing) {
+ m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
+ G_CALLBACK (satellites_changed), this);
+ }
+ m_requestTimer.start();
+ if (error) {
+#ifdef Q_LOCATION_GYPSY_DEBUG
+ qDebug() << "QGeoSatelliteInfoSourceGypsy error asking fix status or satellite data: " << error->message;
+#endif
+ g_error_free(error);
+ }
+}
+
+void QGeoSatelliteInfoSourceGypsy::requestUpdateTimeout()
+{
+#ifdef Q_LOCATION_GYPSY_DEBUG
+ qDebug("QGeoSatelliteInfoSourceGypsy request update timeout occurred.");
+#endif
+ // If we end up here, there has not been valid satellite update.
+ // Emit timeout and disconnect from signal if regular updates are not
+ // ongoing (as we were listening just for one single requestUpdate).
+ if (!m_updatesOngoing) {
+ m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void*)satellites_changed, this);
+ }
+ m_requestOngoing = false;
+ emit requestTimeout();
+}
+
+#include "moc_qgeosatelliteinfosource_gypsy_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeosatelliteinfosource_gypsy_p.h b/src/location/qgeosatelliteinfosource_gypsy_p.h
new file mode 100644
index 00000000..4b9b0a6f
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_gypsy_p.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE_GYPSY_H
+#define QGEOSATELLITEINFOSOURCE_GYPSY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeosatelliteinfosource.h"
+#include "qgeosatelliteinfo.h"
+#include <gypsy/gypsy-satellite.h>
+#include <gypsy/gypsy-control.h>
+#include <gypsy/gypsy-device.h>
+#include <gconf/gconf-client.h>
+#include <QTimer>
+
+// #define Q_LOCATION_GYPSY_DEBUG
+
+QTM_BEGIN_NAMESPACE
+
+// An engine that encapsulates all symbols we want
+// to be able to mock (for unit/autotest purposes).
+class SatelliteGypsyEngine
+{
+public:
+ SatelliteGypsyEngine(QGeoSatelliteInfoSource* parent = 0);
+ virtual ~SatelliteGypsyEngine();
+ // Glib symbols
+ virtual gulong eng_g_signal_connect(gpointer instance,
+ const gchar* detailed_signal,
+ GCallback c_handler,
+ gpointer data);
+ virtual guint eng_g_signal_handlers_disconnect_by_func(gpointer instance,
+ gpointer func,
+ gpointer data);
+ virtual void eng_g_free(gpointer mem);
+ // Gypsy symbols
+ virtual GypsyControl* eng_gypsy_control_get_default (void);
+ virtual char *eng_gypsy_control_create (GypsyControl *control, const char*device_name, GError **error);
+ virtual GypsyDevice *eng_gypsy_device_new (const char *object_path);
+ virtual GypsySatellite *eng_gypsy_satellite_new (const char *object_path);
+ virtual gboolean eng_gypsy_device_start (GypsyDevice *device, GError **error);
+ virtual gboolean eng_gypsy_device_stop (GypsyDevice *device, GError **error);
+ virtual GypsyDeviceFixStatus eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error);
+ virtual GPtrArray *eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error);
+ virtual void eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites);
+ // GConf symbols (mockability due to X11 requirement)
+ virtual GConfClient* eng_gconf_client_get_default(void);
+ virtual gchar* eng_gconf_client_get_string(GConfClient* client, const gchar* key, GError** err);
+protected:
+ QGeoSatelliteInfoSource* m_owner;
+};
+
+class QGeoSatelliteInfoSourceGypsy : public QGeoSatelliteInfoSource
+ {
+ Q_OBJECT
+
+public:
+ explicit QGeoSatelliteInfoSourceGypsy(QObject *parent = 0);
+ ~QGeoSatelliteInfoSourceGypsy();
+ int init();
+
+public slots:
+ virtual void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 5000);
+ void satellitesChanged(GypsySatellite* satellite, GPtrArray* satellites);
+
+signals:
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+
+private slots:
+ void requestUpdateTimeout();
+
+protected:
+ // Creates an engine which encapsulates all used symbols
+ // that we want to be also able to mock.
+ virtual void createEngine();
+ SatelliteGypsyEngine* m_engine;
+
+private:
+ Q_DISABLE_COPY(QGeoSatelliteInfoSourceGypsy)
+ GypsySatellite* m_satellite;
+ GypsyDevice* m_device;
+ QTimer m_requestTimer;
+ bool m_updatesOngoing;
+ bool m_requestOngoing;
+ };
+
+QTM_END_NAMESPACE
+
+#endif // QGEOSATELLITEINFOSOURCE_GYPSY_H
diff --git a/src/location/qgeosatelliteinfosource_maemo.cpp b/src/location/qgeosatelliteinfosource_maemo.cpp
new file mode 100644
index 00000000..a1c203c4
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_maemo.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosatelliteinfosource_maemo_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent) : QGeoSatelliteInfoSource(parent),
+ running(false), satInViewSeen(false)
+{
+ requestTimer = new QTimer(this);
+ QObject::connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimerExpired()));
+}
+
+
+int QGeoSatelliteInfoSourceMaemo::init()
+{
+ dbusComm = new DBusComm(this);
+ int status = dbusComm->init();
+
+ if (status == 0) {
+ QObject::connect(dbusComm, SIGNAL(receivedSatellitesInView(const QList<QGeoSatelliteInfo> &)),
+ this, SLOT(newSatellitesInView(const QList<QGeoSatelliteInfo> &)));
+ QObject::connect(dbusComm, SIGNAL(receivedSatellitesInUse(const QList<QGeoSatelliteInfo> &)),
+ this, SLOT(newSatellitesInUse(const QList<QGeoSatelliteInfo> &)));
+ QObject::connect(dbusComm, SIGNAL(serviceConnected()),
+ this, SLOT(onServiceConnect()));
+ QObject::connect(dbusComm, SIGNAL(serviceDisconnected()),
+ this, SLOT(onServiceDisconnect()));
+ }
+
+ return status;
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::startUpdates()
+{
+ if ( !requestTimer->isActive() )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0);
+ running = true;
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::stopUpdates()
+{
+ if ( !requestTimer->isActive() )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0);
+ running = false;
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout)
+{
+ if ( !running )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0);
+
+ requestTimer->start(timeout);
+ satInViewSeen = false;
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::newSatellitesInView(const QList<QGeoSatelliteInfo> &update)
+{
+ if ( requestTimer->isActive() && satInViewSeen ) {
+ requestTimer->stop();
+ if ( !running )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0);
+ else
+ emit satellitesInViewUpdated(update);
+ } else {
+ emit satellitesInViewUpdated(update);
+ }
+
+ satInViewSeen = true;
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::newSatellitesInUse(const QList<QGeoSatelliteInfo> &update)
+{
+ if ( requestTimer->isActive() ) {
+ requestTimer->stop();
+ if ( !running )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0);
+ }
+
+ emit satellitesInUseUpdated(update);
+}
+
+void QGeoSatelliteInfoSourceMaemo::requestTimerExpired()
+{
+ requestTimer->stop();
+
+ if ( !running )
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStop, 0, 0);
+
+ emit requestTimeout();
+}
+
+void QGeoSatelliteInfoSourceMaemo::onServiceDisconnect()
+{
+ //
+}
+
+
+void QGeoSatelliteInfoSourceMaemo::onServiceConnect()
+{
+ if (running) {
+ dbusComm->sendConfigRequest(DBusComm::CommandSatStart, 0, 0);
+ }
+}
+
+
+#include "moc_qgeosatelliteinfosource_maemo_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeosatelliteinfosource_maemo5.cpp b/src/location/qgeosatelliteinfosource_maemo5.cpp
new file mode 100644
index 00000000..f0edb292
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_maemo5.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosatelliteinfosource_maemo5_p.h"
+#include "liblocationwrapper_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent)
+ : QGeoSatelliteInfoSource(parent)
+{
+ client_id_ = -1;
+ timerInterval = DEFAULT_UPDATE_INTERVAL;
+ updateTimer = new QTimer(this);
+ updateTimer->setSingleShot(true);
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(satelliteStatus()));
+
+ requestTimer = new QTimer(this);
+ requestTimer->setSingleShot(true);
+ connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed()));
+
+ satelliteInfoState = QGeoSatelliteInfoSourceMaemo::Undefined;
+}
+
+int QGeoSatelliteInfoSourceMaemo::init()
+{
+ if (LiblocationWrapper::instance()->inited())
+ return INIT_OK;
+ else
+ return INIT_FAILED;
+}
+
+void QGeoSatelliteInfoSourceMaemo::setUpdateInterval(int msec)
+{
+ bool updateTimerInterval = false;
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive)
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)
+ updateTimerInterval = true;
+
+ timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec;
+
+ if (timerInterval >= POWERSAVE_THRESHOLD)
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive;
+ else
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive;
+
+ // If powersave has been active when new update interval has been set,
+ // ensure that timer is started.
+ if (updateTimerInterval)
+ startLocationDaemon();
+
+ // Ensure that new timer interval is taken into use immediately.
+ activateTimer();
+}
+
+void QGeoSatelliteInfoSourceMaemo::startUpdates()
+{
+ startLocationDaemon();
+
+ // Ensure that powersave is selected, if stopUpdates() has been called,
+ // but selected update interval is still greater than POWERSAVE_THRESHOLD.
+ if (timerInterval >= POWERSAVE_THRESHOLD)
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive;
+
+ activateTimer();
+}
+
+void QGeoSatelliteInfoSourceMaemo::stopUpdates()
+{
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive;
+
+ if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)) {
+ updateTimer->stop();
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+ }
+
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started;
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped;
+}
+
+void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout)
+{
+ int timeoutForRequest = 0;
+
+ if (!timeout) {
+ if (LiblocationWrapper::instance()->isActive())
+ // If GPS is active, assume quick fix.
+ timeoutForRequest = DEFAULT_UPDATE_INTERVAL;
+ else
+ // Otherwise reserve longer time to get a fix.
+ timeoutForRequest = POWERSAVE_POWERON_PERIOD;
+ } else if (timeout < MINIMUM_UPDATE_INTERVAL) {
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)
+ return;
+
+ emit requestTimeout();
+ return;
+ } else {
+ timeoutForRequest = timeout;
+ }
+
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestActive;
+
+ if (!(LiblocationWrapper::instance()->isActive()))
+ LiblocationWrapper::instance()->start();
+
+ activateTimer();
+ requestTimer->start(timeoutForRequest);
+}
+
+void QGeoSatelliteInfoSourceMaemo::satelliteStatus()
+{
+ QList<QGeoSatelliteInfo> satellitesInView =
+ LiblocationWrapper::instance()->satellitesInView();
+ QList<QGeoSatelliteInfo> satellitesInUse =
+ LiblocationWrapper::instance()->satellitesInUse();
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) {
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive;
+
+ requestTimer->stop();
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) {
+ if (LiblocationWrapper::instance()->isActive()) {
+ LiblocationWrapper::instance()->stop();
+ }
+ }
+
+ // Ensure that requested satellite info is emitted even though
+ // powersave is active and GPS would normally be off.
+ if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) &&
+ (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)) {
+ if (satellitesInView.length()) {
+ emit satellitesInViewUpdated(satellitesInView);
+ emit satellitesInUseUpdated(satellitesInUse);
+ }
+ }
+ }
+
+ // Make sure that if update is triggered when waking up, there
+ // is no false position update.
+ if (!((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) &&
+ (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped))) {
+ if (satellitesInView.length()) {
+ emit satellitesInViewUpdated(satellitesInView);
+ emit satellitesInUseUpdated(satellitesInUse);
+ }
+ }
+
+ activateTimer();
+}
+
+void QGeoSatelliteInfoSourceMaemo::requestTimeoutElapsed()
+{
+ updateTimer->stop();
+ emit requestTimeout();
+
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive;
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+
+ activateTimer();
+}
+
+void QGeoSatelliteInfoSourceMaemo::activateTimer()
+{
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) {
+ updateTimer->start(MINIMUM_UPDATE_INTERVAL);
+ return;
+ }
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) {
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) {
+ // Cannot call stopUpdates() here since we want to keep powersave
+ // active.
+ if (LiblocationWrapper::instance()->isActive())
+ LiblocationWrapper::instance()->stop();
+ updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD);
+
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started;
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped;
+ } else if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) {
+ startLocationDaemon();
+ updateTimer->start(POWERSAVE_POWERON_PERIOD);
+ }
+ return;
+ }
+
+ if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started)
+ updateTimer->start(timerInterval);
+}
+
+void QGeoSatelliteInfoSourceMaemo::startLocationDaemon()
+{
+ if (!(LiblocationWrapper::instance()->isActive()))
+ LiblocationWrapper::instance()->start();
+ satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Started;
+ satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Stopped;
+}
+
+#include "moc_qgeosatelliteinfosource_maemo5_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeosatelliteinfosource_maemo5_p.h b/src/location/qgeosatelliteinfosource_maemo5_p.h
new file mode 100644
index 00000000..0cb8be4e
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_maemo5_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE_MAEMO5_H
+#define QGEOSATELLITEINFOSOURCE_MAEMO5_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QTimer>
+#include "qgeosatelliteinfosource.h"
+#include "qgeosatelliteinfo.h"
+
+#define INIT_OK 0
+#define INIT_FAILED -1
+#define MINIMUM_UPDATE_INTERVAL 1000
+#define DEFAULT_UPDATE_INTERVAL 5000
+#define POWERSAVE_THRESHOLD 180000
+#define POWERSAVE_POWERON_PERIOD 120000
+
+QTM_BEGIN_NAMESPACE
+
+class LiblocationWrapper;
+
+class QGeoSatelliteInfoSourceMaemo : public QGeoSatelliteInfoSource
+{
+ Q_OBJECT
+
+public:
+ explicit QGeoSatelliteInfoSourceMaemo(QObject *parent = 0);
+
+ int init();
+
+private:
+ int client_id_;
+ void setUpdateInterval(int interval);
+ QTimer *updateTimer;
+ QTimer *requestTimer;
+ int timerInterval;
+ void activateTimer();
+ void startLocationDaemon();
+
+ enum SatelliteInfoState {
+ Undefined = 0,
+ Started = 1,
+ Stopped = 2,
+ RequestActive = 4,
+ PowersaveActive = 8
+ };
+ int satelliteInfoState;
+
+public slots:
+ virtual void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 5000);
+ void satelliteStatus();
+
+signals:
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void requestTimeout();
+
+private slots:
+ void requestTimeoutElapsed();
+
+private:
+ Q_DISABLE_COPY(QGeoSatelliteInfoSourceMaemo)
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOSATELLITEINFOSOURCE_MAEMO5_H
+
diff --git a/src/location/qgeosatelliteinfosource_maemo_p.h b/src/location/qgeosatelliteinfosource_maemo_p.h
new file mode 100644
index 00000000..b8f8e72f
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_maemo_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE_MAEMO_H
+#define QGEOSATELLITEINFOSOURCE_MAEMO_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgeosatelliteinfosource.h"
+#include "qgeosatelliteinfo.h"
+#include "dbuscomm_maemo_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoSourceMaemo : public QGeoSatelliteInfoSource
+{
+ Q_OBJECT
+public:
+ explicit QGeoSatelliteInfoSourceMaemo(QObject *parent = 0);
+ int init();
+
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 5000);
+
+Q_SIGNALS:
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
+ void requestTimeout();
+
+private Q_SLOTS:
+ void newSatellitesInView(const QList<QGeoSatelliteInfo> &update);
+ void newSatellitesInUse(const QList<QGeoSatelliteInfo> &update);
+ void onServiceDisconnect();
+ void onServiceConnect();
+ void requestTimerExpired();
+
+private:
+ DBusComm* dbusComm;
+ bool running;
+ bool satInViewSeen;
+ QTimer* requestTimer;
+ Q_DISABLE_COPY(QGeoSatelliteInfoSourceMaemo)
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/src/location/qgeosatelliteinfosource_s60.cpp b/src/location/qgeosatelliteinfosource_s60.cpp
new file mode 100644
index 00000000..dae038b2
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_s60.cpp
@@ -0,0 +1,708 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QObject>
+#include <QDateTime>
+#include <QDebug>
+#include <limits.h>
+#include "qgeopositioninfosource_s60_p.h"
+#include "qgeosatelliteinfosource_s60_p.h"
+#include "qgeosatelliteinfosource.h"
+#include "qgeosatelliteinfo.h"
+
+#include <QList>
+
+QTM_BEGIN_NAMESPACE
+
+// constructor
+CQGeoSatelliteInfoSourceS60::CQGeoSatelliteInfoSourceS60(QObject* aParent) : QGeoSatelliteInfoSource(aParent),
+ mCurrentModuleId(TUid::Null()),
+ mReqModuleId(TUid::Null()),
+ mDevStatusUpdateAO(NULL),
+ mReqUpdateAO(NULL),
+ mRegUpdateAO(NULL),
+ mListSize(0),
+ mMinUpdateInterval(0),
+ mStartUpdates(FALSE),
+ mModuleFlags(0)
+{
+ memset(mList, 0 , MAX_SIZE * sizeof(CSatMethodInfo));
+}
+
+// destructor
+CQGeoSatelliteInfoSourceS60::~CQGeoSatelliteInfoSourceS60()
+{
+ if (mReqUpdateAO)
+ delete mReqUpdateAO;
+
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+
+ if (mDevStatusUpdateAO)
+ delete mDevStatusUpdateAO;
+}
+
+// static function NewLC
+CQGeoSatelliteInfoSourceS60* CQGeoSatelliteInfoSourceS60::NewLC(QObject* aParent)
+{
+ CQGeoSatelliteInfoSourceS60* self =
+ new(ELeave) CQGeoSatelliteInfoSourceS60(aParent);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+// static function NewL
+CQGeoSatelliteInfoSourceS60* CQGeoSatelliteInfoSourceS60::NewL(QObject * aParent)
+{
+ RProcess thisProcess;
+ if (!thisProcess.HasCapability(ECapabilityLocation)) {
+ qWarning() << "QGeoSatelliteInfoSource::createDefaultSource() requires the Symbian Location capability to succeed on the Symbian platform.";
+ return 0;
+ }
+
+ CQGeoSatelliteInfoSourceS60* self = CQGeoSatelliteInfoSourceS60::NewLC(aParent);
+ CleanupStack::Pop();
+
+ //check if the second phase construction is successful
+ if (!self->isValid()) {
+ delete self;
+ self = NULL;
+ }
+
+ return self;
+}
+
+// 2nd phase constructor
+void CQGeoSatelliteInfoSourceS60::ConstructL()
+{
+ TInt error = mPositionServer.Connect();
+
+ if (error == KErrNone) {
+ CleanupClosePushL(mPositionServer);
+
+ mDevStatusUpdateAO = CQMLBackendAO::NewL(this, DeviceStatus);
+
+ if (mDevStatusUpdateAO == NULL) {
+ CleanupStack::Pop(1);
+
+ return;
+ }
+
+ //update the list array with the available method initially
+ updateDeviceStatus();
+
+ CleanupStack::PushL(mDevStatusUpdateAO);
+
+ /*
+ if(mCurrentModuleId != TUid::Null())
+ mRegUpdateAO = CQMLBackendAOSatellite::NewL(this,RegularUpdate,mCurrentModuleId);
+ */
+ TUint8 bits;
+ TInt index = -1;
+
+ CQMLBackendAO *temp = NULL;
+
+ bits = mModuleFlags;
+
+ do {
+ //error = Get the index of the positioning module based on
+ //priority position module providing the satellite fix
+ index = getIndexPositionModule(bits);
+
+ if (index >= 0) {
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[index].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL))
+ break;
+
+ bits = bits & (0XFF ^(1 << index));
+ }
+ } while (index >= 0);
+
+ if (index >= 0) {
+ mRegUpdateAO = temp;
+ mRegUpdateAO->setUpdateInterval(0);
+ mCurrentModuleId = mList[index].mUid;
+ } else {
+ delete temp;
+ }
+
+ CleanupStack::Pop(2);
+ }
+
+}
+
+//private function : to retrieve the index of the supplied module id from the mList array
+TInt CQGeoSatelliteInfoSourceS60::checkModule(TPositionModuleId aId)//const
+{
+ QMutexLocker locker(&m_mutex);
+ TInt i;
+ for (i = 0; i < mListSize; i++)
+ if (mList[i].mUid == aId)
+ return i;
+ return -1;
+}
+
+//
+int CQGeoSatelliteInfoSourceS60::minimumUpdateInterval() const
+{
+ if (mCurrentModuleId == TUid::Null())
+ return 0;
+
+ return mMinUpdateInterval;
+
+ /*TInt i = checkModule(mCurrentModuleId);
+ if (i != -1)
+ return mList[i].mTimeToNextFix.Int64() / 1000; //divide by 1000, to convert microsecond to milisecond
+ return 0;*/
+}
+
+//private function : get the index of the mList that supports the preferred method if
+//available,else returns the index of the default module
+TInt CQGeoSatelliteInfoSourceS60::getIndexPositionModule(TUint8 aBits) const
+{
+ TInt index;
+
+ TPositionModuleId modID = TUid::Null();
+
+ //index = -1 : no methods available in the mList that supports preferred methods
+ index = -1;
+
+ for (TInt i = 0; i < mListSize ; i++) {
+ //check the module properties to select the preferred method,search should not
+ //not select an unavailable method,error device or index matching aLastIndex
+ if ((mList[i].mIsAvailable)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))) {
+ return i;
+ }
+ }
+
+ return index;
+}
+
+//private function : to get the index of the positioning method with time to first fix
+//lesser than timeout
+TInt CQGeoSatelliteInfoSourceS60::getMoreAccurateMethod(TInt aTimeout, TUint8 aBits)
+{
+ TInt index = -1;
+ double temp = -1.0;
+
+ TTimeIntervalMicroSeconds microSeconds;
+
+ //convert the timeout --> micro seconds
+ microSeconds = aTimeout * 1000;
+
+ if (microSeconds == 0)
+ microSeconds = INT_MAX;
+
+ for (TInt i = 0 ; i < mListSize; i++) {
+ if (mList[i].mIsAvailable
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))
+ && (mList[i].mTimeToFirstFix < microSeconds)) {
+ if ((temp == -1.0) || (mList[i].mHorizontalAccuracy < temp)) {
+ index = i;
+ temp = mList[i].mHorizontalAccuracy;
+ }
+ }
+ }
+
+ if (index != -1)
+ return index;
+
+ bool minSet = false;
+ microSeconds = 0;
+
+ for (TInt i = 0 ; i < mListSize; i++) {
+ if (mList[i].mIsAvailable
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceUnknown)
+ && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
+ && (((aBits >> i) & 1))) {
+ if (!minSet || (mList[i].mTimeToFirstFix < microSeconds)) {
+ index = i;
+ minSet = true;
+ microSeconds = mList[i].mTimeToFirstFix;
+ }
+ }
+ }
+
+ return index;
+}
+
+//private function : to update the mList array
+void CQGeoSatelliteInfoSourceS60::updateStatus(TPositionModuleInfo &aModInfo, TInt aStatus)
+{
+
+ TInt i, index;
+ TPositionModuleId id;
+ TBool available;
+ TReal32 accuracy;
+ TTimeIntervalMicroSeconds time_to_first_fix, time_to_next_fix;
+ TPositionQuality quality;
+ CQMLBackendAO *temp = NULL;
+
+ //query for the following parameters
+ id = aModInfo.ModuleId();
+
+ //gets the device availability based on the user settings
+ available = aModInfo.IsAvailable();
+
+ //quality : holds the required metrics
+ aModInfo.GetPositionQuality(quality);
+
+ //Accuracy
+ accuracy = quality.HorizontalAccuracy();
+
+ //time taken for the first fix
+ time_to_first_fix = quality.TimeToFirstFix();
+
+ //time taken for the subsequent fix
+ time_to_next_fix = quality.TimeToNextFix();
+
+ if ((i = checkModule(id)) == -1) {
+ //update the properties of the module
+ QMutexLocker lLocker(&m_mutex);
+
+ //TPositionModuleId of the module
+ mList[mListSize].mUid = id;
+
+ //status of the device
+ mList[mListSize].mStatus = aStatus;
+
+ //availablility of the module
+ mList[mListSize].mIsAvailable = available;
+
+ //horizontal accuracy of the module
+ mList[mListSize].mHorizontalAccuracy = accuracy;
+
+ //time required to get the first fix
+ mList[mListSize].mTimeToFirstFix = time_to_first_fix;
+
+ //time required for subsequent fix
+ mList[mListSize].mTimeToNextFix = time_to_next_fix;
+
+ //count on the mList array size
+ mListSize++;
+
+ mMinUpdateInterval = mList[mListSize-1].mTimeToNextFix.Int64() / 1000;
+ lLocker.unlock();
+ } else {
+
+ QMutexLocker lLocker(&m_mutex);
+
+ //module's status has changed
+ if (mList[i].mStatus != aStatus)
+ mList[i].mStatus = aStatus;
+
+ //module's availability has changed
+ if (mList[i].mIsAvailable != available)
+ mList[i].mIsAvailable = available;
+
+ //module's horizontal accuracy has changed
+ if (mList[i].mHorizontalAccuracy != accuracy)
+ mList[i].mHorizontalAccuracy = accuracy;
+
+ //module's time to first fix has changed
+ if (mList[i].mTimeToFirstFix != time_to_first_fix)
+ mList[i].mTimeToFirstFix = time_to_first_fix;
+
+ //module's time to subsequent fix has changed
+ if (mList[i].mTimeToNextFix != time_to_next_fix)
+ mList[i].mTimeToFirstFix = time_to_next_fix;
+
+ lLocker.unlock();
+
+ //if the mCurrentModuleId is NULL, try updating the reg update with the available
+ //positioning method
+ if (mCurrentModuleId == TUid::Null() && (available == TRUE) &&
+ (aStatus != TPositionModuleStatus::EDeviceUnknown) &&
+ (aStatus != TPositionModuleStatus::EDeviceError)) {
+ TInt interval = 0;
+
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[i].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL)) {
+ temp->setUpdateInterval(interval);
+
+ QMutexLocker lRegLocker(&m_mutex_RegUpAO);
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+ mRegUpdateAO = temp;
+
+ //to be uncommented when startUpdates are done
+
+ if (mStartUpdates)
+ mRegUpdateAO->startUpdates();
+
+
+ mCurrentModuleId = mList[i].mUid;
+ mMinUpdateInterval = mList[i].mTimeToNextFix.Int64() / 1000;
+ lRegLocker.unlock();
+
+ }
+ }
+
+ //check if the status of the currently used modules for regular update or
+ //request update has changed
+ if (((id == mCurrentModuleId) || (id == mReqModuleId)) &&
+ ((aStatus == TPositionModuleStatus::EDeviceUnknown) ||
+ (aStatus == TPositionModuleStatus::EDeviceError) ||
+ (available == FALSE))) {
+ //if the change happened for regular update
+ if (id == mCurrentModuleId) {
+ TInt interval = 0;
+
+ TUint8 bits;
+
+ QMutexLocker lRegLocker1(&m_mutex_RegUpAO);
+ if (mRegUpdateAO)
+ delete mRegUpdateAO;
+ lRegLocker1.unlock();
+
+ bits = mModuleFlags;
+
+ do {
+ //error = Get the index of the positioning module based on
+ //priority position module providing the satellite fix
+ index = getIndexPositionModule(bits);
+
+ if (index >= 0) {
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, RegularUpdate,
+ mList[index].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL))
+ break;
+
+ bits = bits & (0XFF ^(1 << index));
+ }
+ } while (index >= 0);
+
+
+ if (temp != NULL) {
+ //successful in creating the subsession for the required
+ //method
+ QMutexLocker lRegLocker2(&m_mutex_RegUpAO);
+ mRegUpdateAO = temp;
+
+ mCurrentModuleId = mList[index].mUid;
+ mMinUpdateInterval = mList[i].mTimeToNextFix.Int64() / 1000;
+ lRegLocker2.unlock();
+
+ mRegUpdateAO->setUpdateInterval(interval);
+
+ if (mStartUpdates)
+ mRegUpdateAO->startUpdates();
+
+ } else {
+ //no methods available,clean up the resources
+ QMutexLocker lRegLocker3(&m_mutex_RegUpAO);
+ mRegUpdateAO = NULL;
+ mCurrentModuleId = TUid::Null();
+ mMinUpdateInterval = interval;
+ lRegLocker3.unlock();
+ }
+
+ }
+
+ //check if device status of the request update module changed
+ if (id == mReqModuleId) {
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ if (mRegUpdateAO)
+ delete mReqUpdateAO;
+ mReqUpdateAO = NULL;
+ mReqModuleId = TUid::Null();
+ lReqLocker.unlock();
+ emit requestTimeout();
+ }
+
+ }
+
+ } //end else
+
+}
+
+
+// Notification methods from active object. Notifies device status changes
+void CQGeoSatelliteInfoSourceS60::updateDeviceStatus(void)
+{
+ TPositionModuleStatus moduleStatus;
+ TPositionModuleInfo moduleInfo;
+
+ //mListSize = 0 : called updateDeviceStatus() first time to initialise the array
+ if (mListSize == 0) {
+ TUint modCount;
+
+ //count on the modules currently supported by the device
+ mPositionServer.GetNumModules(modCount);
+
+ for (TUint i = 0; i < modCount; i++) {
+ //get module information
+ mPositionServer.GetModuleInfoByIndex(i, moduleInfo);
+
+ if (moduleInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite) {
+ //get module status
+ mPositionServer.GetModuleStatus(moduleStatus, moduleInfo.ModuleId());
+
+ //update the properties of the module in the mList array
+ updateStatus(moduleInfo, moduleStatus.DeviceStatus());
+
+ mModuleFlags |= (1 << i);
+ }
+ }
+ } else {
+ //UpdateDeviceStatus() called afetr registering for NotifyModuleStatusEvent
+
+ //get the module id from the status event
+ TPositionModuleId id = mStatusEvent.ModuleId();
+
+ //get module information
+ mPositionServer.GetModuleInfoById(id, moduleInfo);
+
+ if (moduleInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite) {
+ //get current status of the module
+ mStatusEvent.GetModuleStatus(moduleStatus);
+
+ //update the properties of the module in the mList array
+ updateStatus(moduleInfo, moduleStatus.DeviceStatus());
+ }
+
+ }
+
+ //register for next NotifyModuleStatusEvent
+ mDevStatusUpdateAO->notifyDeviceStatus(mStatusEvent);
+
+}
+
+//
+void CQGeoSatelliteInfoSourceS60::TPositionSatelliteInfo2QGeoSatelliteInfo(
+ TPositionSatelliteInfo &aSatInfo, QList<QGeoSatelliteInfo> &qListSatInView,
+ QList<QGeoSatelliteInfo> &qListSatInUse)
+{
+ TInt satInView = aSatInfo.NumSatellitesInView();
+ TSatelliteData satData;
+ QGeoSatelliteInfo qInfo;
+
+ for (TInt i = 0; i < satInView; i++) {
+ aSatInfo.GetSatelliteData(i, satData);
+ qInfo.setSignalStrength(satData.SignalStrength());
+ qInfo.setPrnNumber(satData.SatelliteId());
+ qInfo.setAttribute(QGeoSatelliteInfo::Elevation, satData.Elevation());
+ qInfo.setAttribute(QGeoSatelliteInfo::Azimuth, satData.Azimuth());
+ if (satData.IsUsed() == TRUE) {
+ qListSatInUse.append(qInfo);
+ }
+ qListSatInView.append(qInfo);
+ }
+}
+//
+void CQGeoSatelliteInfoSourceS60::updatePosition(TPositionSatelliteInfo &aSatInfo,
+ int aError, bool isStartUpdate)
+{
+ QList<QGeoSatelliteInfo> qListSatInUse;
+ QList<QGeoSatelliteInfo> qListSatInView;
+ if (aError == KErrNone) {
+ //fill posUpdate
+ TPositionSatelliteInfo2QGeoSatelliteInfo(aSatInfo, qListSatInView,
+ qListSatInUse);
+ if ((receivers(SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&))) > 0)) {
+ if ((isStartUpdate == FALSE) || (mqListSatInView != qListSatInView)) {
+ emit satellitesInViewUpdated(qListSatInView);
+ mqListSatInView = qListSatInView;
+ }
+ }
+
+ if ((receivers(SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&))) > 0)) {
+ if ((isStartUpdate == FALSE) || (mqListSatInUse != qListSatInUse)) {
+ emit satellitesInUseUpdated(qListSatInUse);
+ mqListSatInUse = qListSatInUse;
+ }
+ }
+ }
+
+ else if (aError == KErrTimedOut) {
+ //request has timed out
+ emit requestTimeout();
+ }
+
+ else {
+ //request has resulted in an error. could be changed to emit error signal when available.
+ emit requestTimeout();
+ }
+}
+
+// for request update
+void CQGeoSatelliteInfoSourceS60::requestUpdate(int aTimeout)
+{
+ TInt index = -1;
+ TUint8 bits;
+
+ CQMLBackendAO *temp = NULL;
+
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit requestTimeout();
+ return;
+ }
+
+ //requestupdate
+ //return if already a request update is pending
+ if (mReqUpdateAO && mReqUpdateAO->isRequestPending())
+ return;
+
+ if (aTimeout < 0) {
+ emit requestTimeout();
+ return;
+ }
+
+ bits = mModuleFlags;
+
+ do {
+
+ //index of the more accurate method in the array
+ index = getMoreAccurateMethod(aTimeout, bits);
+
+ //no positioning method method available : emit requestTimeout
+ if (index < 0) {
+ emit requestTimeout();
+ break;
+ }
+ //if the selected module for request update is same as the previous one reuse the request
+ if (mList[index].mUid == mReqModuleId) {
+ if (mReqUpdateAO) {
+ mReqUpdateAO->requestUpdate(aTimeout);
+ return;
+ }
+ }
+
+ TRAPD(ret, QT_TRYCATCH_LEAVING(temp = CQMLBackendAO::NewL(this, OnceUpdate, mList[index].mUid)));
+
+ if ((ret == KErrNone) && (temp != NULL)) {
+
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ //delete the old reqest update
+ if (mReqUpdateAO)
+ delete mReqUpdateAO;
+
+ //set the requestAO to the newly created AO
+ mReqUpdateAO = temp;
+
+ //set the request module ID
+ mReqModuleId = mList[index].mUid;
+ lReqLocker.unlock();
+
+ //start the update
+ mReqUpdateAO->requestUpdate(aTimeout);
+
+ return;
+ }
+
+ bits = bits & (0XFF ^(1 << index));
+
+ } while (index >= 0);
+
+ //cleanup resources if the invalid requpdate is still stored
+ if (mReqUpdateAO) {
+ QMutexLocker lReqLocker(&m_mutex_ReqUpAO);
+ delete mReqUpdateAO;
+ mReqUpdateAO = NULL;
+ lReqLocker.unlock();
+ mReqModuleId = TUid::Null();
+ }
+
+}
+
+// starts the regular updates
+void CQGeoSatelliteInfoSourceS60::startUpdates()
+{
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit requestTimeout();
+ return;
+ }
+
+ if (mRegUpdateAO && ((receivers(SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&))) > 0) ||
+ (receivers(SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&))) > 0)))
+ mRegUpdateAO->startUpdates();
+
+ mStartUpdates = true;
+}
+
+// stops the regular updates
+void CQGeoSatelliteInfoSourceS60::stopUpdates()
+{
+ mStartUpdates = false;
+
+ if (mRegUpdateAO == NULL || mCurrentModuleId == TUid::Null()) {
+ emit requestTimeout();
+ return;
+ }
+
+ if (mReqUpdateAO)
+ mRegUpdateAO->cancelUpdate();
+}
+
+
+void CQGeoSatelliteInfoSourceS60::connectNotify(const char *aSignal)
+{
+ // start update if it already connected
+ if (mStartUpdates && mRegUpdateAO && ((QLatin1String(aSignal) == SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&))) ||
+ (QLatin1String(aSignal) == SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)))))
+ mRegUpdateAO->startUpdates();
+
+}
+
+void CQGeoSatelliteInfoSourceS60::disconnectNotify(const char *aSignal)
+{
+ // Cancel updates if slot is disconnected for the positionUpdate() signal.
+
+ if ((mRegUpdateAO) && (QLatin1String(aSignal) == SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&))) && (receivers(SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&))) == 0) &&
+ (QLatin1String(aSignal) == SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&))) && (receivers(SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&))) == 0))
+ mRegUpdateAO->cancelUpdate();
+
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeosatelliteinfosource_s60_p.h b/src/location/qgeosatelliteinfosource_s60_p.h
new file mode 100644
index 00000000..36aef4e8
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_s60_p.h
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE60_H_
+#define QGEOSATELLITEINFOSOURCE60_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <lbs.h>
+#include <qmutex.h>
+#include "qgeosatelliteinfosource.h"
+#include "notificationsatellitecallback_s60_p.h"
+
+#define MAX_SIZE 25
+
+QTM_BEGIN_NAMESPACE
+
+// CLASS DECLARATION
+//forward declaration
+class CQMLBackendAO;
+
+class CSatMethodInfo
+{
+public:
+ // A unique id for the positioning module
+ TPositionModuleId mUid;
+
+ // current status of the module
+ int mStatus;
+
+ // time to first and next fix from the location server
+ TTimeIntervalMicroSeconds mTimeToFirstFix;
+ TTimeIntervalMicroSeconds mTimeToNextFix;
+
+ // Accuracy
+ double mHorizontalAccuracy;
+
+ // Flags whether the positioning technology is currently available or not.
+ bool mIsAvailable;
+};
+
+
+/**
+ * CQGeoSatelliteInfoSourceS60
+ *
+ */
+class CQGeoSatelliteInfoSourceS60 : public INotificationSatelliteCallback,
+ public QGeoSatelliteInfoSource
+
+{
+public:
+ // Constructors and destructor
+ /**
+ * Destructor.
+ */
+ ~CQGeoSatelliteInfoSourceS60();
+
+ /**
+ * Two-phased constructor.
+ */
+ static CQGeoSatelliteInfoSourceS60* NewL(QObject* aParent);
+
+ /**
+ * Two-phased constructor.
+ */
+ static CQGeoSatelliteInfoSourceS60* NewLC(QObject* aParent);
+
+ /**
+ * Notification methods from active object.
+ * Notifies device status, position value, and status
+ */
+ void updateDeviceStatus(void) ;
+
+ /**
+ * Update the position info
+ */
+ void updatePosition(TPositionSatelliteInfo &aPosSatInfo, int aError , bool isStartUpdate);
+
+
+ /**
+ * Gets the handle of the PositionServer
+ */
+ RPositionServer& getPositionServer() {
+ return mPositionServer;
+ }
+
+ int minimumUpdateInterval() const;
+
+ /*
+ * checks whether the object is valid
+ */
+ inline TBool isValid() {
+ if (mDevStatusUpdateAO && mRegUpdateAO)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ inline TPositionModuleId getCurrentPositonModuleID() {
+ return mCurrentModuleId;
+ }
+
+ inline TPositionModuleId getRequestUpdateModuleID() {
+ return mReqModuleId;
+ }
+
+public slots :
+ // for request update
+ void requestUpdate(int timeout = 5000);
+
+ // starts the regular updates
+ virtual void startUpdates();
+
+ // stops the regular updates
+ virtual void stopUpdates();
+
+
+private:
+
+ /**
+ * Constructor for performing 1st stage construction
+ */
+ CQGeoSatelliteInfoSourceS60(QObject* aParent = 0);
+
+ /**
+ * EPOC default constructor for performing 2nd stage construction
+ */
+ void ConstructL();
+
+ void updateStatus(TPositionModuleInfo &aModInfo, TInt aStatus);
+
+ //get the index of the module in the List array
+ TInt checkModule(TPositionModuleId aId) ;//const;
+
+ //get the index of the position module based on the preferred methods
+ TInt getIndexPositionModule(TUint8 aBits) const;
+
+ //get the more accuarte method with time to first fix < than timeout
+ TInt getMoreAccurateMethod(TInt aTimeout, TUint8 aBits);
+
+ void TPositionSatelliteInfo2QGeoSatelliteInfo(TPositionSatelliteInfo &aSatInfo,
+ QList<QGeoSatelliteInfo> &qListSatInView,
+ QList<QGeoSatelliteInfo> &qListSatInUse);
+
+
+protected:
+ void connectNotify(const char *aSignal);
+
+ void disconnectNotify(const char *aSignal);
+
+private:
+ /**
+ * current module ID
+ */
+ TPositionModuleId mCurrentModuleId;
+
+ /**
+ *prvmoduleID
+ */
+ TPositionModuleId mReqModuleId;
+
+ /**
+ * Active object for device status updates
+ */
+ CQMLBackendAO * mDevStatusUpdateAO;
+
+ /**
+ * Active object for requestUpdate
+ */
+ CQMLBackendAO * mReqUpdateAO;
+
+ /**
+ * Active object for regular updates.
+ */
+ CQMLBackendAO * mRegUpdateAO;
+
+ /**
+ * Positioner server
+ */
+ RPositionServer mPositionServer;
+
+
+ /*
+ * Number of Satellites in View
+ */
+ QList<QGeoSatelliteInfo> mqListSatInView;
+
+ /*
+ * Numberof Satellites in Use
+ */
+ QList<QGeoSatelliteInfo> mqListSatInUse;
+
+ /**
+ * list of supported position methods
+ */
+ CSatMethodInfo mList[MAX_SIZE];
+
+ /**
+ * maintaiss the size of thr CPosMethodInfo array
+ */
+ int mListSize;
+
+ int mMinUpdateInterval;
+
+ /*
+ * query for the status
+ */
+ TPositionModuleStatusEvent mStatusEvent;
+
+ // mutex for making thread safe
+ QMutex m_mutex;
+ // mutex for ReqUpdate Active Ojbect
+ QMutex m_mutex_ReqUpAO;
+ // mutex for RegUpdate Active Ojbect
+ QMutex m_mutex_RegUpAO;
+
+ /*
+ * maintain the startUpdates status
+ */
+ TBool mStartUpdates;
+
+ /*
+ * flags for the modules
+ */
+ TUint8 mModuleFlags;
+};
+
+QTM_END_NAMESPACE
+
+#endif /* QGEOSATELLITEINFOSOURCE60_H_ */
diff --git a/src/location/qgeosatelliteinfosource_simulator.cpp b/src/location/qgeosatelliteinfosource_simulator.cpp
new file mode 100644
index 00000000..e0fdc24c
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_simulator.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeosatelliteinfosource_simulator_p.h"
+#include "qlocationconnection_simulator_p.h"
+#include "qlocationdata_simulator_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+QGeoSatelliteInfoSourceSimulator::QGeoSatelliteInfoSourceSimulator(QObject *parent)
+ : QGeoSatelliteInfoSource(parent)
+ , timer(new QTimer(this))
+ , requestTimer(new QTimer(this))
+{
+ ensureSimulatorConnection();
+
+ timer->setInterval(5000);
+ connect(timer, SIGNAL(timeout()), this, SLOT(updateData()));
+ requestTimer->setSingleShot(true);
+ connect(requestTimer, SIGNAL(timeout()), this, SLOT(updateData()));
+}
+
+void QGeoSatelliteInfoSourceSimulator::startUpdates()
+{
+ timer->start();
+}
+
+void QGeoSatelliteInfoSourceSimulator::stopUpdates()
+{
+ timer->stop();
+}
+
+void QGeoSatelliteInfoSourceSimulator::requestUpdate(int timeout)
+{
+ if (!requestTimer->isActive()) {
+ // Get a single update within timeframe
+ if (timeout < 0)
+ emit requestTimeout();
+ else {
+ requestTimer->start(timeout * qreal(0.75));
+ }
+ }
+}
+
+void QGeoSatelliteInfoSourceSimulator::updateData()
+{
+ QList<QGeoSatelliteInfo> satellitesInUse;
+ QList<QGeoSatelliteInfo> satellitesInView;
+
+ QGeoSatelliteInfoData *data = qtSatelliteInfo();
+ for(int i = 0; i < data->satellites.count(); i++) {
+ QGeoSatelliteInfoData::SatelliteInfo info = data->satellites.at(i);
+ QGeoSatelliteInfo satInfo;
+ satInfo.setPrnNumber(info.prn);
+ satInfo.setAttribute(QGeoSatelliteInfo::Azimuth, info.azimuth);
+ satInfo.setAttribute(QGeoSatelliteInfo::Elevation, info.elevation);
+ satInfo.setSignalStrength(info.signalStrength);
+ satellitesInView.append(satInfo);
+ if (info.inUse)
+ satellitesInUse.append(satInfo);
+ }
+ emit satellitesInViewUpdated(satellitesInView);
+ emit satellitesInUseUpdated(satellitesInUse);
+}
+
+#include "moc_qgeosatelliteinfosource_simulator_p.cpp"
+QTM_END_NAMESPACE
+
diff --git a/src/location/qgeosatelliteinfosource_simulator_p.h b/src/location/qgeosatelliteinfosource_simulator_p.h
new file mode 100644
index 00000000..5b13c4a8
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_simulator_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE_SIMULATOR_H
+#define QGEOSATELLITEINFOSOURCE_SIMULATOR_H
+
+#include <QTimer>
+#include "qgeosatelliteinfosource.h"
+#include "qgeosatelliteinfo.h"
+
+#define MINIMUM_UPDATE_INTERVAL 1000
+#define DEFAULT_UPDATE_INTERVAL 5000
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoSourceSimulator : public QGeoSatelliteInfoSource
+{
+ Q_OBJECT
+
+public:
+ explicit QGeoSatelliteInfoSourceSimulator(QObject *parent = 0);
+
+public slots:
+ virtual void startUpdates();
+ virtual void stopUpdates();
+ virtual void requestUpdate(int timeout = 5000);
+
+private slots:
+ void updateData();
+
+private:
+ Q_DISABLE_COPY(QGeoSatelliteInfoSourceSimulator)
+ QTimer *timer;
+ QTimer *requestTimer;
+};
+
+QTM_END_NAMESPACE
+
+#endif // QGEOSATELLITEINFOSOURCE_SIMULATOR_H
+
diff --git a/src/location/qgeosatelliteinfosource_wince.cpp b/src/location/qgeosatelliteinfosource_wince.cpp
new file mode 100644
index 00000000..5b5ae48c
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_wince.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QList>
+#include <QHash>
+
+#include <qgeosatelliteinfo.h>
+
+#include "qgeosatelliteinfosource_wince_p.h"
+#include "qgeoinfothread_wince_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+// ========== QGeoSatelliteInfoValidator ==========
+
+QGeoSatelliteInfoValidator::QGeoSatelliteInfoValidator() : QGeoInfoValidator() {}
+
+QGeoSatelliteInfoValidator::~QGeoSatelliteInfoValidator() {}
+
+// Returns true if data contains at least the minimal amount of data we need to produce one of the
+// QGeoSatelliteInfoSource signals, otherwise returns false.
+bool QGeoSatelliteInfoValidator::valid(const GPS_POSITION &data) const
+{
+ if (((data.dwValidFields & GPS_VALID_SATELLITE_COUNT) == 0)
+ || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) == 0)
+ || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_PRNS) == 0)
+ || ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_SIGNAL_TO_NOISE_RATIO) == 0)) {
+ return false;
+ }
+ return true;
+}
+
+// ========== QGeoSatelliteInfoSourceWinCE ==========
+
+QGeoSatelliteInfoSourceWinCE::QGeoSatelliteInfoSourceWinCE(QObject *parent) : QGeoSatelliteInfoSource(parent)
+{
+ QGeoSatelliteInfoValidator *validator = new QGeoSatelliteInfoValidator();
+
+ // The QGeoInfoThreadWinCE instance takes ownership of the validator.
+ infoThread = new QGeoInfoThreadWinCE(validator, false, this);
+ infoThread->setUpdateInterval(DefaultUpdateInterval);
+ infoThread->start();
+
+ // QGeoInfoThreadWinCE takes care of registering GPS_POSITION as a metatype.
+ connect(infoThread, SIGNAL(dataUpdated(GPS_POSITION)), this, SLOT(dataUpdated(GPS_POSITION)));
+ connect(infoThread, SIGNAL(updateTimeout()), this, SIGNAL(requestTimeout()));
+}
+
+QGeoSatelliteInfoSourceWinCE::~QGeoSatelliteInfoSourceWinCE()
+{
+ delete infoThread;
+}
+
+void QGeoSatelliteInfoSourceWinCE::startUpdates()
+{
+ infoThread->startUpdates();
+}
+
+void QGeoSatelliteInfoSourceWinCE::stopUpdates()
+{
+ infoThread->stopUpdates();
+}
+
+void QGeoSatelliteInfoSourceWinCE::requestUpdate(int timeout)
+{
+ if (timeout < 0)
+ emit requestTimeout();
+ else
+ infoThread->requestUpdate(timeout);
+}
+
+/*
+ This is _only_ called when QGeoSatelliteInfoValidator::valid() returns true for the position.
+ This means that it is implied that:
+ - (data.dwValidFields & GPS_VALID_SATELLITE_COUNT) != 0
+ - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0
+ - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_PRNS) != 0
+ - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_SIGNAL_TO_NOISE_RATIO) != 0
+
+ This guarantees that the newly created position will be valid.
+ If the code is changed such that this is no longer guaranteed then this method will need to be
+ updated to test for those conditions.
+*/
+void QGeoSatelliteInfoSourceWinCE::dataUpdated(GPS_POSITION data)
+{
+ // Satellites in view are hashed on the PRN values since the PRN value is how we
+ // determine which of the satellites are in use.
+ QHash<int, QGeoSatelliteInfo> satellitesInView;
+
+ for (unsigned int i = 0; i < data.dwSatellitesInView; ++i) {
+ QGeoSatelliteInfo satellite;
+
+ satellite.setPrnNumber(data.rgdwSatellitesInViewPRNs[i]);
+ satellite.setSignalStrength(data.rgdwSatellitesInViewSignalToNoiseRatio[i]);
+
+ // The following properties are optional, and so are set if the data is present and valid
+ // in the GPS_POSITION structure.
+ if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_AZIMUTH) != 0) {
+ satellite.setAttribute(QGeoSatelliteInfo::Azimuth,
+ data.rgdwSatellitesInViewAzimuth[i]);
+ }
+
+ if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_ELEVATION) != 0) {
+ satellite.setAttribute(QGeoSatelliteInfo::Elevation,
+ data.rgdwSatellitesInViewElevation[i]);
+ }
+
+ satellitesInView.insert(satellite.prnNumber(), satellite);
+ }
+
+ emit satellitesInViewUpdated(satellitesInView.values());
+
+ // If the PRN data for the satellites which were used is unavailable we are done...
+ if ((data.dwValidFields & GPS_VALID_SATELLITES_USED_PRNS) == 0)
+ return;
+
+ // ...otherwise we construct the list of satellites which are in use and emit the appropriate
+ // signal
+ QList<QGeoSatelliteInfo> satellitesInUse;
+
+ for (unsigned int i = 0; i < data.dwSatelliteCount; ++i) {
+ int inUsePRN = data.rgdwSatellitesUsedPRNs[i];
+ if (satellitesInView.contains(inUsePRN))
+ satellitesInUse << satellitesInView.value(inUsePRN);
+ }
+
+ emit satellitesInUseUpdated(satellitesInUse);
+}
+
+#include "moc_qgeosatelliteinfosource_wince_p.cpp"
+QTM_END_NAMESPACE
diff --git a/src/location/qgeosatelliteinfosource_wince_p.h b/src/location/qgeosatelliteinfosource_wince_p.h
new file mode 100644
index 00000000..8fc1bd28
--- /dev/null
+++ b/src/location/qgeosatelliteinfosource_wince_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSATELLITEINFOSOURCE_WINCE_P_H
+#define QGEOSATELLITEINFOSOURCE_WINCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qgeosatelliteinfosource.h>
+
+#include "qgeoinfothread_wince_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoSatelliteInfoValidator : public QGeoInfoValidator
+{
+public:
+ QGeoSatelliteInfoValidator();
+ ~QGeoSatelliteInfoValidator();
+
+ bool valid(const GPS_POSITION &data) const;
+};
+
+class QGeoSatelliteInfoSourceWinCE : public QGeoSatelliteInfoSource
+{
+ Q_OBJECT
+
+public:
+ enum {
+ // The interval at which the periodic updates will occur.
+ DefaultUpdateInterval = 5000
+ };
+
+ explicit QGeoSatelliteInfoSourceWinCE(QObject *parent = 0);
+ ~QGeoSatelliteInfoSourceWinCE();
+
+public slots:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 0);
+
+private slots:
+ void dataUpdated(GPS_POSITION data);
+
+private:
+ QGeoInfoThreadWinCE *infoThread;
+};
+
+QTM_END_NAMESPACE
+
+#endif //#ifndef QGEOSATELLITEINFOSOURCE_WINCE_P_H
diff --git a/src/location/qlocationconnection_simulator.cpp b/src/location/qlocationconnection_simulator.cpp
new file mode 100644
index 00000000..08ba7727
--- /dev/null
+++ b/src/location/qlocationconnection_simulator.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlocationconnection_simulator_p.h"
+#include "qgeopositioninfosource_simulator_p.h"
+#include "qlocationdata_simulator_p.h"
+#include "mobilitysimulatorglobal.h"
+
+#include <private/qsimulatordata_p.h>
+#include <QtCore/QDebug>
+#include <QtCore/QTimer>
+#include <QtCore/QDataStream>
+
+#include <QtNetwork/QLocalSocket>
+
+QTM_BEGIN_NAMESPACE
+
+using namespace QtSimulatorPrivate;
+
+namespace Simulator
+{
+ LocationConnection::LocationConnection(MobilityConnection *mobilityCon)
+ : QObject(mobilityCon)
+ , mConnection(mobilityCon)
+ , mInitialDataReceived(false)
+ {
+ qt_registerLocationTypes();
+ mobilityCon->addMessageHandler(this);
+ }
+
+
+ void LocationConnection::getInitialData()
+ {
+ RemoteMetacall<void>::call(mConnection->sendSocket(), NoSync, "setRequestsLocationInfo");
+
+ while (!mInitialDataReceived) {
+ mConnection->receiveSocket()->waitForReadyRead(100);
+ mConnection->onReadyRead();
+ }
+ }
+
+ void LocationConnection::initialLocationDataSent()
+ {
+ mInitialDataReceived = true;
+ }
+
+ void LocationConnection::setLocationData(const QGeoPositionInfoData &data)
+ {
+ *qtPositionInfo() = data;
+ }
+
+ void LocationConnection::setSatelliteData(const QGeoSatelliteInfoData &data)
+ {
+ *qtSatelliteInfo() = data;
+ }
+
+#include "moc_qlocationconnection_simulator_p.cpp"
+
+} // namespace
+
+
+void ensureSimulatorConnection()
+{
+ using namespace Simulator;
+
+ static bool connected = false;
+ if (connected)
+ return;
+
+ connected = true;
+ MobilityConnection *connection = MobilityConnection::instance();
+ LocationConnection *locationConnection = new LocationConnection(connection);
+ locationConnection->getInitialData();
+}
+
+QGeoPositionInfoData *qtPositionInfo()
+{
+ static QGeoPositionInfoData *positionInfo = 0;
+ if (!positionInfo) {
+ positionInfo = new QGeoPositionInfoData;
+ }
+
+ return positionInfo;
+}
+
+QGeoSatelliteInfoData *qtSatelliteInfo()
+{
+ static QGeoSatelliteInfoData *satelliteInfo;
+ if (!satelliteInfo) {
+ satelliteInfo = new QGeoSatelliteInfoData;
+ }
+
+ return satelliteInfo;
+}
+
+
+QTM_END_NAMESPACE
diff --git a/src/location/qlocationconnection_simulator_p.h b/src/location/qlocationconnection_simulator_p.h
new file mode 100644
index 00000000..33dc09bd
--- /dev/null
+++ b/src/location/qlocationconnection_simulator_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLOCATIONCONNECTION_H
+#define QLOCATIONCONNECTION_H
+
+#include "qlocationdata_simulator_p.h"
+#include <mobilityconnection_p.h>
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+namespace Simulator
+{
+ class LocationConnection : public QObject
+ {
+ Q_OBJECT
+ public:
+ LocationConnection(MobilityConnection *mobilityCon);
+ virtual ~LocationConnection() {}
+
+ void getInitialData();
+
+ private slots:
+ void setLocationData(const QtMobility::QGeoPositionInfoData &);
+ void setSatelliteData(const QtMobility::QGeoSatelliteInfoData &);
+ void initialLocationDataSent();
+
+ private:
+ MobilityConnection *mConnection;
+ bool mInitialDataReceived;
+ };
+} // end namespace Simulator
+
+void ensureSimulatorConnection();
+QGeoPositionInfoData *qtPositionInfo();
+QGeoSatelliteInfoData *qtSatelliteInfo();
+
+QTM_END_NAMESPACE
+
+#endif // QLOCATIONCONNECTION_H
diff --git a/src/location/qlocationdata_simulator.cpp b/src/location/qlocationdata_simulator.cpp
new file mode 100644
index 00000000..1e84de4d
--- /dev/null
+++ b/src/location/qlocationdata_simulator.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlocationdata_simulator_p.h"
+
+#include <QtCore/QDataStream>
+
+QTM_BEGIN_NAMESPACE
+
+void qt_registerLocationTypes()
+{
+ qRegisterMetaTypeStreamOperators<QGeoPositionInfoData>("QtMobility::QGeoPositionInfoData");
+ qRegisterMetaTypeStreamOperators<QGeoSatelliteInfoData>("QtMobility::QGeoSatelliteInfoData");
+ qRegisterMetaTypeStreamOperators<QGeoSatelliteInfoData::SatelliteInfo>("QtMobility::QGeoSatelliteInfoData::SatelliteInfo");
+}
+
+QDataStream &operator<<(QDataStream &out, const QGeoPositionInfoData &s)
+{
+ out << s.latitude << s.longitude << s.altitude;
+ out << s.direction << s.groundSpeed << s.verticalSpeed << s.magneticVariation << s.horizontalAccuracy << s.verticalAccuracy;
+ out << s.dateTime;
+ out << s.minimumInterval << s.enabled;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QGeoPositionInfoData &s)
+{
+ in >> s.latitude >> s.longitude >> s.altitude;
+ in >> s.direction >> s.groundSpeed >> s.verticalSpeed >> s.magneticVariation >> s.horizontalAccuracy >> s.verticalAccuracy;
+ in >> s.dateTime;
+ in >> s.minimumInterval >> s.enabled;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData &s)
+{
+ out << s.satellites;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData &s)
+{
+ in >> s.satellites;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData::SatelliteInfo &s)
+{
+ out << s.prn << s.azimuth << s.elevation << s.signalStrength << s.inUse;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData::SatelliteInfo &s)
+{
+ in >> s.prn >> s.azimuth >> s.elevation >> s.signalStrength >> s.inUse;
+ return in;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qlocationdata_simulator_p.h b/src/location/qlocationdata_simulator_p.h
new file mode 100644
index 00000000..9878578e
--- /dev/null
+++ b/src/location/qlocationdata_simulator_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFODATA_SIMULATOR_P_H
+#define QGEOPOSITIONINFODATA_SIMULATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+#include <QtCore/QMetaType>
+#include <QtCore/QDateTime>
+#include <QtCore/QList>
+
+QT_BEGIN_HEADER
+QTM_BEGIN_NAMESPACE
+
+struct QGeoPositionInfoData
+{
+ // Coordinate information
+ double latitude;
+ double longitude;
+ double altitude;
+
+ // Attributes
+ // ### transmit whether attributes are set or not
+ qreal direction;
+ qreal groundSpeed;
+ qreal verticalSpeed;
+ qreal magneticVariation;
+ qreal horizontalAccuracy;
+ qreal verticalAccuracy;
+
+ // DateTime info
+ QDateTime dateTime;
+
+ int minimumInterval;
+ bool enabled;
+};
+
+struct QGeoSatelliteInfoData
+{
+ struct SatelliteInfo
+ {
+ int prn;
+ qreal azimuth;
+ qreal elevation;
+ int signalStrength;
+ bool inUse;
+ };
+
+ QList<SatelliteInfo> satellites;
+};
+
+void qt_registerLocationTypes();
+
+QTM_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QtMobility::QGeoPositionInfoData)
+Q_DECLARE_METATYPE(QtMobility::QGeoSatelliteInfoData)
+Q_DECLARE_METATYPE(QtMobility::QGeoSatelliteInfoData::SatelliteInfo)
+
+QT_END_HEADER
+
+#endif // QGEOPOSITIONINFODATA_SIMULATOR_P_H
diff --git a/src/location/qlocationutils.cpp b/src/location/qlocationutils.cpp
new file mode 100644
index 00000000..8b9bb912
--- /dev/null
+++ b/src/location/qlocationutils.cpp
@@ -0,0 +1,354 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qlocationutils_p.h"
+#include "qgeopositioninfo.h"
+
+#include <QTime>
+#include <QList>
+#include <QByteArray>
+#include <QDebug>
+
+#include <math.h>
+
+QTM_BEGIN_NAMESPACE
+
+// converts e.g. 15306.0235 from NMEA sentence to 153.100392
+static double qlocationutils_nmeaDegreesToDecimal(double nmeaDegrees)
+{
+ double deg;
+ double min = 100.0 * modf(nmeaDegrees / 100.0, &deg);
+ return deg + (min / 60.0);
+}
+
+static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ QByteArray sentence(data, size);
+ QList<QByteArray> parts = sentence.split(',');
+ QGeoCoordinate coord;
+
+ if (hasFix && parts.count() > 6 && parts[6].count() > 0)
+ *hasFix = parts[6].toInt() > 0;
+
+ if (parts.count() > 1 && parts[1].count() > 0) {
+ QTime time;
+ if (QLocationUtils::getNmeaTime(parts[1], &time))
+ info->setTimestamp(QDateTime(QDate(), time, Qt::UTC));
+ }
+
+ if (parts.count() > 5 && parts[3].count() == 1 && parts[5].count() == 1) {
+ double lat;
+ double lng;
+ if (QLocationUtils::getNmeaLatLong(parts[2], parts[3][0], parts[4], parts[5][0], &lat, &lng)) {
+ coord.setLatitude(lat);
+ coord.setLongitude(lng);
+ }
+ }
+
+ if (parts.count() > 9 && parts[9].count() > 0) {
+ bool hasAlt = false;
+ double alt = parts[9].toDouble(&hasAlt);
+ if (hasAlt)
+ coord.setAltitude(alt);
+ }
+
+ if (coord.type() != QGeoCoordinate::InvalidCoordinate)
+ info->setCoordinate(coord);
+}
+
+static void qlocationutils_readGll(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ QByteArray sentence(data, size);
+ QList<QByteArray> parts = sentence.split(',');
+ QGeoCoordinate coord;
+
+ if (hasFix && parts.count() > 6 && parts[6].count() > 0)
+ *hasFix = (parts[6][0] == 'A');
+
+ if (parts.count() > 5 && parts[5].count() > 0) {
+ QTime time;
+ if (QLocationUtils::getNmeaTime(parts[5], &time))
+ info->setTimestamp(QDateTime(QDate(), time, Qt::UTC));
+ }
+
+ if (parts.count() > 4 && parts[2].count() == 1 && parts[4].count() == 1) {
+ double lat;
+ double lng;
+ if (QLocationUtils::getNmeaLatLong(parts[1], parts[2][0], parts[3], parts[4][0], &lat, &lng)) {
+ coord.setLatitude(lat);
+ coord.setLongitude(lng);
+ }
+ }
+
+ if (coord.type() != QGeoCoordinate::InvalidCoordinate)
+ info->setCoordinate(coord);
+}
+
+static void qlocationutils_readRmc(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ QByteArray sentence(data, size);
+ QList<QByteArray> parts = sentence.split(',');
+ QGeoCoordinate coord;
+ QDate date;
+ QTime time;
+
+ if (hasFix && parts.count() > 2 && parts[2].count() > 0)
+ *hasFix = (parts[2][0] == 'A');
+
+ if (parts.count() > 9 && parts[9].count() == 6) {
+ date = QDate::fromString(parts[9], "ddMMyy");
+ if (date.isValid())
+ date = date.addYears(100); // otherwise starts from 1900
+ else
+ date = QDate();
+ }
+
+ if (parts.count() > 1 && parts[1].count() > 0)
+ QLocationUtils::getNmeaTime(parts[1], &time);
+
+ if (parts.count() > 6 && parts[4].count() == 1 && parts[6].count() == 1) {
+ double lat;
+ double lng;
+ if (QLocationUtils::getNmeaLatLong(parts[3], parts[4][0], parts[5], parts[6][0], &lat, &lng)) {
+ coord.setLatitude(lat);
+ coord.setLongitude(lng);
+ }
+ }
+
+ bool parsed = false;
+ double value = 0.0;
+ if (parts.count() > 7 && parts[7].count() > 0) {
+ value = parts[7].toDouble(&parsed);
+ if (parsed)
+ info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value * 1.852 / 3.6)); // knots -> m/s
+ }
+ if (parts.count() > 8 && parts[8].count() > 0) {
+ value = parts[8].toDouble(&parsed);
+ if (parsed)
+ info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
+ }
+ if (parts.count() > 11 && parts[11].count() == 1
+ && (parts[11][0] == 'E' || parts[11][0] == 'W')) {
+ value = parts[10].toDouble(&parsed);
+ if (parsed) {
+ if (parts[11][0] == 'W')
+ value *= -1;
+ info->setAttribute(QGeoPositionInfo::MagneticVariation, qreal(value));
+ }
+ }
+
+ if (coord.type() != QGeoCoordinate::InvalidCoordinate)
+ info->setCoordinate(coord);
+
+ info->setTimestamp(QDateTime(date, time, Qt::UTC));
+}
+
+static void qlocationutils_readVtg(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ if (hasFix)
+ *hasFix = false;
+
+ QByteArray sentence(data, size);
+ QList<QByteArray> parts = sentence.split(',');
+
+ bool parsed = false;
+ double value = 0.0;
+ if (parts.count() > 1 && parts[1].count() > 0) {
+ value = parts[1].toDouble(&parsed);
+ if (parsed)
+ info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
+ }
+ if (parts.count() > 7 && parts[7].count() > 0) {
+ value = parts[7].toDouble(&parsed);
+ if (parsed)
+ info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value / 3.6)); // km/h -> m/s
+ }
+}
+
+static void qlocationutils_readZda(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ if (hasFix)
+ *hasFix = false;
+
+ QByteArray sentence(data, size);
+ QList<QByteArray> parts = sentence.split(',');
+ QDate date;
+ QTime time;
+
+ if (parts.count() > 1 && parts[1].count() > 0)
+ QLocationUtils::getNmeaTime(parts[1], &time);
+
+ if (parts.count() > 4 && parts[2].count() > 0 && parts[3].count() > 0
+ && parts[4].count() == 4) { // must be full 4-digit year
+ int day = parts[2].toUInt();
+ int month = parts[3].toUInt();
+ int year = parts[4].toUInt();
+ if (day > 0 && month > 0 && year > 0)
+ date.setDate(year, month, day);
+ }
+
+ info->setTimestamp(QDateTime(date, time, Qt::UTC));
+}
+
+bool QLocationUtils::getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+{
+ if (!info)
+ return false;
+
+ if (hasFix)
+ *hasFix = false;
+ if (size < 6 || data[0] != '$' || !hasValidNmeaChecksum(data, size))
+ return false;
+
+ if (data[3] == 'G' && data[4] == 'G' && data[5] == 'A') {
+ // "$--GGA" sentence.
+ qlocationutils_readGga(data, size, info, hasFix);
+ return true;
+ }
+
+ if (data[3] == 'G' && data[4] == 'L' && data[5] == 'L') {
+ // "$--GLL" sentence.
+ qlocationutils_readGll(data, size, info, hasFix);
+ return true;
+ }
+
+ if (data[3] == 'R' && data[4] == 'M' && data[5] == 'C') {
+ // "$--RMC" sentence.
+ qlocationutils_readRmc(data, size, info, hasFix);
+ return true;
+ }
+
+ if (data[3] == 'V' && data[4] == 'T' && data[5] == 'G') {
+ // "$--VTG" sentence.
+ qlocationutils_readVtg(data, size, info, hasFix);
+ return true;
+ }
+
+ if (data[3] == 'Z' && data[4] == 'D' && data[5] == 'A') {
+ // "$--ZDA" sentence.
+ qlocationutils_readZda(data, size, info, hasFix);
+ return true;
+ }
+
+ return false;
+}
+
+bool QLocationUtils::hasValidNmeaChecksum(const char *data, int size)
+{
+ int asteriskIndex = -1;
+ for (int i = 0; i < size; i++) {
+ if (data[i] == '*') {
+ asteriskIndex = i;
+ break;
+ }
+ }
+
+ const int CSUM_LEN = 2;
+ if (asteriskIndex < 0 || asteriskIndex + CSUM_LEN >= size)
+ return false;
+
+ // XOR byte value of all characters between '$' and '*'
+ int result = 0;
+ for (int i = 1; i < asteriskIndex; i++)
+ result ^= data[i];
+ /*
+ char calc[CSUM_LEN + 1];
+ ::snprintf(calc, CSUM_LEN + 1, "%02x", result);
+ return ::strncmp(calc, &data[asteriskIndex+1], 2) == 0;
+ */
+
+ QString s;
+ s.sprintf("%02x", result);
+ return s.toAscii() == QByteArray(&data[asteriskIndex+1], 2);
+}
+
+bool QLocationUtils::getNmeaTime(const QByteArray &bytes, QTime *time)
+{
+ int dotIndex = bytes.indexOf('.');
+ QTime tempTime;
+
+ if (dotIndex < 0) {
+ tempTime = QTime::fromString(bytes, "hhmmss");
+ } else {
+ tempTime = QTime::fromString(bytes.mid(0, dotIndex), "hhmmss");
+ bool hasMsecs = false;
+ int midLen = qMin(3, bytes.size() - dotIndex - 1);
+ int msecs = bytes.mid(dotIndex + 1, midLen).toUInt(&hasMsecs);
+ if (hasMsecs)
+ tempTime = tempTime.addMSecs(msecs);
+ }
+
+ if (tempTime.isValid()) {
+ *time = tempTime;
+ return true;
+ }
+ return false;
+}
+
+bool QLocationUtils::getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lng)
+{
+ if ((latDirection != 'N' && latDirection != 'S')
+ || (lngDirection != 'E' && lngDirection != 'W')) {
+ return false;
+ }
+
+ bool hasLat = false;
+ bool hasLong = false;
+ double tempLat = latString.toDouble(&hasLat);
+ double tempLng = lngString.toDouble(&hasLong);
+ if (hasLat && hasLong) {
+ tempLat = qlocationutils_nmeaDegreesToDecimal(tempLat);
+ if (latDirection == 'S')
+ tempLat *= -1;
+ tempLng = qlocationutils_nmeaDegreesToDecimal(tempLng);
+ if (lngDirection == 'W')
+ tempLng *= -1;
+
+ if (isValidLat(tempLat) && isValidLong(tempLng)) {
+ *lat = tempLat;
+ *lng = tempLng;
+ return true;
+ }
+ }
+ return false;
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qlocationutils_p.h b/src/location/qlocationutils_p.h
new file mode 100644
index 00000000..2c39aba0
--- /dev/null
+++ b/src/location/qlocationutils_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QLOCATIONUTILS_P_H
+#define QLOCATIONUTILS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+QT_BEGIN_NAMESPACE
+class QTime;
+class QByteArray;
+QT_END_NAMESPACE
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoPositionInfo;
+class QLocationUtils
+{
+public:
+ inline static bool isValidLat(double lat) {
+ return lat >= -90 && lat <= 90;
+ }
+ inline static bool isValidLong(double lng) {
+ return lng >= -180 && lng <= 180;
+ }
+
+ /*
+ Creates a QGeoPositionInfo from a GGA, GLL, RMC, VTG or ZDA sentence.
+
+ Note:
+ - GGA and GLL sentences have time but not date so the update's
+ QDateTime object will have an invalid date.
+ - RMC reports date with a two-digit year so in this case the year
+ is assumed to be after the year 2000.
+ */
+ QM_AUTOTEST_EXPORT static bool getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix = 0);
+
+ /*
+ Returns true if the given NMEA sentence has a valid checksum.
+ */
+ QM_AUTOTEST_EXPORT static bool hasValidNmeaChecksum(const char *data, int size);
+
+ /*
+ Returns time from a string in hhmmss or hhmmss.z+ format.
+ */
+ QM_AUTOTEST_EXPORT static bool getNmeaTime(const QByteArray &bytes, QTime *time);
+
+ /*
+ Accepts e.g. ("2734.7964", 'S', "15306.0124", 'E') and returns the
+ lat-long values. Fails if lat or long fail isValidLat() or isValidLong().
+ */
+ QM_AUTOTEST_EXPORT static bool getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lon);
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/location/qmlbackendao_s60.cpp b/src/location/qmlbackendao_s60.cpp
new file mode 100644
index 00000000..8674f37e
--- /dev/null
+++ b/src/location/qmlbackendao_s60.cpp
@@ -0,0 +1,478 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_s60_p.h"
+#include "qgeosatelliteinfosource_s60_p.h"
+#include "qmlbackendao_s60_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+//The name of the requestor //Added by PM
+//_LIT(KRequestor,"QTMobility Location");
+
+// constructor
+CQMLBackendAO::CQMLBackendAO() :
+ CActive(EPriorityStandard), // Standard priority
+ mPosInfo(NULL),
+ mRequester(NULL),
+ mRequesterSatellite(NULL),
+ mRequestType(RequestType(0))
+{
+}
+
+//
+//
+//
+CQMLBackendAO* CQMLBackendAO::NewLC(QObject *aRequester,
+ RequestType aRequestType, TPositionModuleId aModId)
+{
+ CQMLBackendAO* self = new(ELeave) CQMLBackendAO();
+ CleanupStack::PushL(self);
+ self->ConstructL(aRequester, aRequestType, aModId);
+ return self;
+}
+
+//
+//
+//
+CQMLBackendAO* CQMLBackendAO::NewL(QObject *aRequester,
+ RequestType aRequestType, TPositionModuleId aModId)
+{
+ CQMLBackendAO* self = CQMLBackendAO::NewLC(aRequester, aRequestType, aModId);
+ CleanupStack::Pop(); // self;
+ return self;
+}
+
+//
+//
+//
+TInt CQMLBackendAO::ConstructL(QObject *aRequester, RequestType aRequestType,
+ TPositionModuleId aModId)
+{
+ TInt error = KErrNone;
+ RPositionServer PosServer;
+
+ if (aRequester->inherits("QGeoSatelliteInfoSource"))
+ mRequesterSatellite = static_cast<CQGeoSatelliteInfoSourceS60*>(aRequester);
+ else
+ mRequester = static_cast<CQGeoPositionInfoSourceS60*>(aRequester);
+
+ mRequestType = aRequestType;
+
+ if ((mRequestType == RegularUpdate) || (mRequestType == OnceUpdate)) {
+ if (aRequester->inherits("QGeoSatelliteInfoSource"))
+ PosServer = mRequesterSatellite->getPositionServer();
+ else
+ PosServer = mRequester->getPositionServer();
+
+ error = mPositioner.Open(PosServer, aModId);
+
+ if (error != KErrNone)
+ return error;
+
+ CleanupClosePushL(mPositioner);
+
+ error = mPositioner.SetRequestor(CRequestor::ERequestorService ,
+ CRequestor::EFormatApplication, _L("QTmobility_Location"));
+
+ CleanupStack::Pop(1);
+
+ if (error != KErrNone)
+ return error;
+
+ }
+
+ CActiveScheduler::Add(this); // Add to scheduler
+
+ return error;
+}
+
+//
+CQMLBackendAO::~CQMLBackendAO()
+{
+ Cancel();
+
+ if ((mRequestType == OnceUpdate) || (mRequestType == RegularUpdate)) {
+ //close the subsession
+ mPositioner.Close();
+
+ if (mPosInfo) {
+ mPosInfo->ClearRequestedFields();
+
+ mPosInfo->ClearPositionData();
+ //delete the HPositionGenericInfo
+ delete mPosInfo;
+ }
+ } else if (mRequestType == DeviceStatus) {
+ RPositionServer posServer;
+
+ //done only by the position server Active Object
+ if (mRequester)
+ posServer = mRequester->getPositionServer();
+ else
+ posServer = mRequesterSatellite->getPositionServer();
+
+ posServer.Close();
+ }
+}
+
+//
+void CQMLBackendAO::DoCancel()
+{
+ CancelAll();
+}
+
+
+//
+void CQMLBackendAO::RunL()
+{
+ switch (mRequestType) {
+ case DeviceStatus :
+ handleDeviceNotification(iStatus.Int());
+ break;
+ case RegularUpdate :
+ case OnceUpdate:
+ handlePosUpdateNotification(iStatus.Int());
+ break;
+ default :
+ break;
+ }
+}
+
+//
+TInt CQMLBackendAO::RunError(TInt aError)
+{
+ return aError;
+}
+
+
+// checks any pending request in activeobject
+bool CQMLBackendAO::isRequestPending()
+{
+ if (IsActive())
+ return true;
+ else
+ return false;
+}
+
+
+
+// Async call to get notifications about device status.
+void CQMLBackendAO::notifyDeviceStatus(TPositionModuleStatusEventBase &aStatusEvent)
+{
+ RPositionServer PosServ;
+
+ if (mRequester)
+ PosServ = mRequester->getPositionServer();
+ else
+ PosServ = mRequesterSatellite->getPositionServer();
+
+ //register for device status events
+ TPositionModuleStatusEventBase::TModuleEvent RequestedEvents(
+ TPositionModuleStatusEventBase::EEventDeviceStatus);
+
+ aStatusEvent.SetRequestedEvents(RequestedEvents);
+
+ PosServ.NotifyModuleStatusEvent(aStatusEvent, iStatus);
+
+ SetActive();
+
+}
+
+void CQMLBackendAO::CancelAll()
+{
+
+ RPositionServer PosServer;
+ if (mRequestType == DeviceStatus) {
+ if (mRequester)
+ PosServer = mRequester->getPositionServer();
+ else
+ PosServer = mRequesterSatellite->getPositionServer();
+
+ PosServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
+ } else if ((mRequestType == OnceUpdate) || (mRequestType == RegularUpdate)) {
+ mPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
+ }
+
+}
+
+//Initialize the posInfo with appropriate fields
+bool CQMLBackendAO::initializePosInfo()
+{
+ if (!mPosInfo) {
+ mPosInfo = HPositionGenericInfo::New();
+
+ if (mPosInfo == NULL)
+ return FALSE;
+ } else {
+ mPosInfo->ClearRequestedFields();
+
+ mPosInfo->ClearPositionData();
+ }
+ RPositionServer posServer;
+ TPositionModuleInfo moduleInfo;
+ TInt error = KErrNone;
+
+ //get the posiiton server
+ posServer = mRequester->getPositionServer();
+
+ //retrieve the module id used by the posiitoner
+ if (mRequestType == RegularUpdate)
+ error = posServer.GetModuleInfoById(mRequester->getCurrentPositonModuleID(), moduleInfo);
+ else
+ error = posServer.GetModuleInfoById(mRequester->getRequestUpdateModuleID(), moduleInfo);
+
+ if (error == KErrNone) {
+
+ //get capabilities of the module
+ TPositionModuleInfo::TCapabilities caps = moduleInfo.Capabilities();
+
+ if (caps & TPositionModuleInfo::ECapabilitySatellite) {
+ mPosInfo->SetRequestedField(EPositionFieldSatelliteNumInView);
+ mPosInfo->SetRequestedField(EPositionFieldSatelliteNumUsed);
+ }
+
+ if (caps & TPositionModuleInfo::ECapabilitySpeed) {
+ mPosInfo->SetRequestedField(EPositionFieldHorizontalSpeed);
+ mPosInfo->SetRequestedField(EPositionFieldVerticalSpeed);
+ }
+ if (caps & TPositionModuleInfo::ECapabilityCompass) {
+ mPosInfo->SetRequestedField(EPositionFieldMagneticCourseError);
+ mPosInfo->SetRequestedField(EPositionFieldHeading);
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//requestUpdate : request for position update once
+void CQMLBackendAO::requestUpdate(int aTimeout)
+{
+ TPositionUpdateOptions aPosOption;
+
+ mPositioner.GetUpdateOptions(aPosOption);
+
+ aPosOption.SetUpdateInterval(TTimeIntervalMicroSeconds(0));
+
+ aPosOption.SetUpdateTimeOut(TTimeIntervalMicroSeconds(aTimeout * 1000));
+
+ mPositioner.SetUpdateOptions(aPosOption);
+
+ startUpdates();
+}
+
+
+//
+void CQMLBackendAO::cancelUpdate()
+{
+ Cancel();
+
+}
+
+
+//
+void CQMLBackendAO::handleDeviceNotification(int aError)
+{
+ switch (aError) {
+ //NotifyPositionModulestatusEvent successfully completed
+ case KErrNone :
+
+ //module not found
+ case KErrNotFound :
+ if (mRequester)
+ mRequester->updateDeviceStatus();
+ else
+ mRequesterSatellite->updateDeviceStatus();
+ break;
+
+ //request has been successfully cancelled
+ case KErrCancel :
+ break;
+
+ //unrecoverabe errors
+ default :
+ break;
+ }
+}
+
+
+//
+void CQMLBackendAO::handlePosUpdateNotification(int aError)
+{
+
+ HPositionGenericInfo *positionInfo = NULL;
+
+ TPositionSatelliteInfo satInfo;
+ switch (aError) {
+ //NotifyPositionUpdate successfully completed
+ case KErrNone :
+
+
+ //requested information could not be retrieved within the maximum peroid
+ case KErrTimedOut:
+
+
+
+ if (mRequester) {
+ positionInfo = HPositionGenericInfo::New();
+
+ if (positionInfo == NULL)
+ return;
+
+ //copy the buffer contents into a new HPositionGenericInfo buffer,to be used
+ //for creating QGeoPositionInfo object later
+ memcpy(positionInfo , mPosInfo , mPosInfo->BufferSize());
+ } else {
+ satInfo = mPosSatInfo;
+ }
+
+ //if regUpdateAO, request for the next update
+ if (mRequestType == RegularUpdate) {
+ if (mRequester) {
+ initializePosInfo();
+ mPositioner.NotifyPositionUpdate(*mPosInfo, iStatus);
+ } else {
+ mPosSatInfo.ClearSatellitesInView();
+ mPositioner.NotifyPositionUpdate(mPosSatInfo, iStatus);
+ }
+
+ SetActive();
+ }
+
+ if (mRequester) {
+ mRequester->updatePosition(positionInfo, aError);
+ delete positionInfo;
+ } else {
+ if ((aError != KErrTimedOut) || (mRequestType != RegularUpdate)) {
+ mRequesterSatellite->updatePosition(satInfo, aError, (mRequestType == RegularUpdate));
+ }
+ }
+
+ break;
+
+ default :
+ if (mRequester) {
+ mRequester->updatePosition(positionInfo, aError); // positionInfo will be NULL
+ } else {
+ mRequesterSatellite->updatePosition(satInfo, aError, (mRequestType == RegularUpdate));
+ }
+ break;
+
+ }
+}
+
+//////////////////////////////////////////////////////////////
+// Sets the interval for getting the regular notification //
+// the time interval set is in milli seconds //
+//////////////////////////////////////////////////////////////
+int CQMLBackendAO::setUpdateInterval(int aMilliSec)
+{
+ int minimumUpdateInterval = 0;
+ TInt64 mUpdateInterval = 0 ;
+
+
+ if (mRequester)
+ minimumUpdateInterval = mRequester->minimumUpdateInterval();
+ else
+ minimumUpdateInterval = mRequesterSatellite->minimumUpdateInterval();
+
+ if (minimumUpdateInterval < 0)
+ minimumUpdateInterval = 100;
+ // if the current requesttype is regular updates
+ // then set the updateinterval otherwise ignore
+ //if(mRequestType != REQ_REG_UPDATE)
+ // return;
+
+ TPositionUpdateOptions aPosOption;
+
+ TInt error = mPositioner.GetUpdateOptions(aPosOption);
+
+ // TTimeIntervalMicroSeconds is converted seconds
+ TInt currentUpdateInterval = aPosOption.UpdateInterval().Int64() / 1000;
+
+ // If msec is not 0 and is less than the value returned by minimumUpdateInterval(),
+ // the interval will be set to the minimum interval.
+ // if (aMilliSec != 0 && aMilliSec <= minimumUpdateInterval) {
+ // workaround, not accepting zero as value, see QTMOBILITY-995
+ if (aMilliSec <= minimumUpdateInterval) {
+ mUpdateInterval = minimumUpdateInterval;
+ } else {
+ mUpdateInterval = aMilliSec;
+ }
+
+ // if the same value is being set then just ignore it.
+ if (currentUpdateInterval == mUpdateInterval) {
+ return mUpdateInterval;
+ }
+
+ // will set Either zero, minimum or +ve value
+ // seconds converted to TTimeIntervalMicroSeconds
+ aPosOption.SetUpdateInterval(TTimeIntervalMicroSeconds(mUpdateInterval * 1000));
+ // set the timeout to the smaller of 150% of interval or update interval + 10 seconds
+ TInt64 mUpdateTimeout = (mUpdateInterval * 3) / 2;
+ if (mUpdateTimeout > mUpdateInterval + 10000)
+ mUpdateTimeout = mUpdateInterval + 10000;
+
+ if (aMilliSec > 0)
+ aPosOption.SetUpdateTimeOut(TTimeIntervalMicroSeconds(mUpdateTimeout * 1000));
+
+ error = mPositioner.SetUpdateOptions(aPosOption);
+
+ return mUpdateInterval;
+}
+
+void CQMLBackendAO::startUpdates()
+{
+ if (!IsActive()) {
+ if (mRequester) {
+ initializePosInfo();
+ mPositioner.NotifyPositionUpdate(*mPosInfo , iStatus);
+ } else {
+ mPosSatInfo.ClearSatellitesInView();
+ mPositioner.NotifyPositionUpdate(mPosSatInfo , iStatus);
+ }
+
+ SetActive();
+
+ }
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qmlbackendao_s60_p.h b/src/location/qmlbackendao_s60_p.h
new file mode 100644
index 00000000..a9618886
--- /dev/null
+++ b/src/location/qmlbackendao_s60_p.h
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QMLBACKENDAO_H
+#define QMLBACKENDAO_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+#include <lbscommon.h>
+#include <lbssatellite.h>
+#include "qgeopositioninfosource.h"
+//#include "qgeopositioninfosources60.h"
+
+QTM_BEGIN_NAMESPACE
+
+class CQGeoPositionInfoSourceS60 ;
+class CQGeoSatelliteInfoSourceS60;
+
+// Types of request
+enum RequestType {
+ RegularUpdate = 1, // Regular updates
+ OnceUpdate, // request update
+ DeviceStatus // device updates
+};
+
+//
+class CQMLBackendAO : public CActive
+{
+public:
+ // Cancel and destroy
+ ~CQMLBackendAO();
+
+ // Two-phased constructor.
+ static CQMLBackendAO* NewL(QObject *aRequester,
+ RequestType aRequestType, TPositionModuleId aModId = TUid::Uid(0)
+ );
+
+ // Two-phased constructor.
+ static CQMLBackendAO* NewLC(QObject *aRequester,
+ RequestType aRequestType, TPositionModuleId aModID);
+
+ // checks any pending request in activeobject
+ bool isRequestPending();
+
+ // Async call to get notifications about device status.
+ void notifyDeviceStatus(TPositionModuleStatusEventBase &aStatusEvent) ;
+
+ // requesting for position update once
+ void requestUpdate(int aTimeout);
+
+ // cancels an outstanding update request
+ void cancelUpdate();
+
+ // Sets an interval in millisecs for regular notifications
+ int setUpdateInterval(int aMilliSec);
+
+ void startUpdates();
+
+
+
+private:
+ // C++ constructor
+ CQMLBackendAO();
+
+ // Second-phase constructor
+ TInt ConstructL(QObject *aRequester, RequestType aRequestType,
+ TPositionModuleId aModId);
+
+ // Device Notifications are handled
+ void handleDeviceNotification(int aError);
+
+ // regular position notifications are handled
+ void handlePosUpdateNotification(int aError);
+
+ void CancelAll();
+
+ bool initializePosInfo();
+
+private:
+ // From CActive
+ // Handle completion
+ void RunL();
+
+ // How to cancel me
+ void DoCancel();
+
+ // Override to handle leaves from RunL(). Default implementation causes
+ // the active scheduler to panic.
+ int RunError(int aError);
+
+private:
+
+ HPositionGenericInfo *mPosInfo;
+
+ // Request is a device or a regular
+ CQGeoPositionInfoSourceS60 *mRequester;
+
+ //Request is a device for Satellite update only
+ CQGeoSatelliteInfoSourceS60 *mRequesterSatellite;
+
+ // Request type once, regular, device
+ RequestType mRequestType;
+
+ // Positioning Information
+ RPositioner mPositioner;
+
+
+ TPositionSatelliteInfo mPosSatInfo;
+};
+
+QTM_END_NAMESPACE
+
+#endif // QMLBACKENDAO_H
diff --git a/src/location/qmlbackendmonitorao_s60.cpp b/src/location/qmlbackendmonitorao_s60.cpp
new file mode 100644
index 00000000..809f404c
--- /dev/null
+++ b/src/location/qmlbackendmonitorao_s60.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlbackendmonitorao_s60_p.h"
+#include "qgeoareamonitor_s60_p.h"
+#include "qmlbackendmonitorinfo_s60_p.h"
+
+#include <lbtsessiontrigger.h>
+#include <lbtgeocircle.h>
+#include <lbttriggerconditionarea.h>
+#include <lbttriggerentry.h>
+
+QTM_BEGIN_NAMESPACE
+
+
+//static member of the QMLBackendMonitorAO object holding the address of the object
+QMLBackendMonitorAO* QMLBackendMonitorAO::iBackendMonitorAO = NULL;
+
+//static member of the QMLBackendMonitorAO object maintaining the reference count
+TInt QMLBackendMonitorAO::refCount = 0;
+
+//request for notification of the trigger fired events
+void QMLBackendMonitorAO::NotifyFiredEvent()
+{
+ if (!IsActive()) {
+ iLbt.NotifyTriggerFired(iTriggerInfo, iStatus);
+ SetActive();
+ }
+}
+
+//static function called prior to the destruction of the
+//singleton QMLBackendMonitorAO object
+void QMLBackendMonitorAO::DeleteAO(QGeoAreaMonitorS60* aParent)
+{
+ //decrement the reference count
+ refCount--;
+ if (refCount == 0) {
+ delete iBackendMonitorAO;
+ iBackendMonitorAO = NULL;
+ }
+}
+
+QMLBackendMonitorAO::~QMLBackendMonitorAO()
+{
+ Cancel();
+ delete iTriggerMonitorInfo; //deletes the CBackendMonitorInfo object holding the linked list
+ iLbt.Close(); //closes the subsession
+}
+
+
+void QMLBackendMonitorAO::DoCancel()
+{
+ if (IsActive()) { //if request is still active,cancel the CancelNotifyTriggerFired request
+ iLbt.CancelNotifyTriggerFired();
+ }
+}
+
+void QMLBackendMonitorAO::RunL()
+{
+ CMonitorTriggerInfo *triggerInfo = NULL;
+ switch (iStatus.Int()) {
+ case KErrNone :
+ //retrieve the triggerInfo corresponding to iTriggerInfo.iTriggerId
+ triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ iTriggerInfo.iTriggerId);
+ if (triggerInfo) {
+ //callback called only if generated for the current AO - Trigger ID
+ (triggerInfo->iParent)->handleTriggerEvent(iTriggerInfo.iFiredPositionInfo ,
+ triggerInfo->iType);
+ }
+ break;
+ default :
+ break;
+ }
+
+ //request for any trigger fired event, for any triggers owned by the client
+ NotifyFiredEvent();
+}
+
+QMLBackendMonitorAO* QMLBackendMonitorAO::NewL(RLbtServer &aLbt)
+{
+ //increment the reference count
+ refCount++;
+ if (!iBackendMonitorAO) {
+ iBackendMonitorAO = QMLBackendMonitorAO::NewLC(aLbt);
+ CleanupStack::Pop();
+ }
+ return iBackendMonitorAO;
+}
+
+QMLBackendMonitorAO* QMLBackendMonitorAO::NewLC(RLbtServer &aLbtServer)
+{
+ QMLBackendMonitorAO *self = new(ELeave) QMLBackendMonitorAO;
+ CleanupStack::PushL(self);
+ self->ConstructL(aLbtServer);
+ if (!self->isValid()) {
+ delete self;
+ self = NULL;
+ }
+ return self;
+}
+
+void QMLBackendMonitorAO::ConstructL(RLbtServer &aLbtServ)
+{
+ if (iLbt.Open(aLbtServ) == KErrNone) { //opens the subsession
+ subsessionCreated = TRUE;
+ iTriggerMonitorInfo = CBackendMonitorInfo::NewL();
+ }
+}
+
+QMLBackendMonitorAO::QMLBackendMonitorAO()
+ : CActive(EPriorityStandard), // Standard priority
+ subsessionCreated(FALSE)
+{
+ CActiveScheduler::Add(this);
+}
+
+QTM_END_NAMESPACE
+
diff --git a/src/location/qmlbackendmonitorao_s60_p.h b/src/location/qmlbackendmonitorao_s60_p.h
new file mode 100644
index 00000000..2a73a41e
--- /dev/null
+++ b/src/location/qmlbackendmonitorao_s60_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBACKENDMONITORAO_H_
+#define QMLBACKENDMONITORAO_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+#include <lbscommon.h>
+#include <lbt.h>
+#include <lbtsessiontrigger.h>
+
+#include "qgeoareamonitor.h"
+
+QTM_BEGIN_NAMESPACE
+
+class CBackendMonitorInfo;
+
+enum enTriggerType { EntryTrigger,
+ ExitTrigger,
+ NotifyChangesTrigger,
+ InvalidTrigger = -1
+ };
+
+class QGeoAreaMonitorS60;
+
+class QMLBackendMonitorAO : public CActive
+{
+public :
+ static QMLBackendMonitorAO* NewL(RLbtServer &aLbtServer);
+
+ static void DeleteAO(QGeoAreaMonitorS60* aParent);
+
+ void NotifyFiredEvent();
+
+ void DoCancel();
+
+ void RunL();
+
+
+private :
+ QMLBackendMonitorAO();
+
+ ~QMLBackendMonitorAO();
+
+ static QMLBackendMonitorAO* NewLC(RLbtServer &aLbt);
+
+ void ConstructL(RLbtServer &aLbtServ);
+
+ bool isValid() {
+ return subsessionCreated && (iTriggerMonitorInfo != NULL);
+ }
+private:
+ //Design change
+ static QMLBackendMonitorAO* iBackendMonitorAO; //single instance for access from all the QGeoAreaMonitorS60 objects
+
+ CBackendMonitorInfo* iTriggerMonitorInfo; //single instance of the CBackendMonitorInfo object
+
+ static TInt refCount; //count : number of monitors created by the clients
+
+ TLbtTriggerFireInfo iTriggerInfo; //info of the fired event
+
+ bool subsessionCreated; //check for the successful creation of the subsession
+
+ RLbt iLbt; //subsession
+
+};
+QTM_END_NAMESPACE
+
+#endif /* QMLBACKENDMONITORAO_H_ */
diff --git a/src/location/qmlbackendmonitorcreatetriggerao_s60.cpp b/src/location/qmlbackendmonitorcreatetriggerao_s60.cpp
new file mode 100644
index 00000000..9a6514ff
--- /dev/null
+++ b/src/location/qmlbackendmonitorcreatetriggerao_s60.cpp
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlbackendmonitorao_s60_p.h"
+#include "qgeoareamonitor_s60_p.h"
+#include "qmlbackendmonitorinfo_s60_p.h"
+#include "qmlbackendmonitorcreatetriggerao_s60_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+//Sets the radius of the monitoring area, to aRadius.If the Radius is less than the MinimumTriggerAreaSize(),
+//then aRadius will be set to MinimumTriggerAreaSize() supported by the LBT implementation.If the aRadius is
+//greater than the MinimumTriggerAreaSize() it is unaltered.
+TInt QMLBackendMonitorCreateTriggerAO::getRadius(qreal& aRadius)
+{
+ TInt ret = KErrNone;
+
+ qreal minimumRadius;
+
+ TLbtTriggeringSystemSettings triggerSettings;
+
+ //gets the triggering System Setting
+ TRAP(ret, iLbt.GetTriggeringSystemSettingsL(triggerSettings));
+
+ if (ret != KErrNone)
+ return ret;
+
+ minimumRadius = triggerSettings.MinimumTriggerAreaSize();
+
+ if (aRadius < minimumRadius)
+ aRadius = minimumRadius;
+
+ return ret;
+}
+
+//creates a trigger of type aType(EntryTrigger/ExitTrigger), with the coordinates and radius as
+//supplied in the argument
+bool QMLBackendMonitorCreateTriggerAO::InitializeTrigger(QGeoAreaMonitorS60* aParent ,
+ enTriggerType aType,
+ TCoordinate& aCoordinate,
+ qreal& aRadius)
+{
+ TInt ret = KErrGeneral;
+
+ TLbtTriggerId triggerID = NULL;
+
+ //try retrieving the trigger information from the linked list corresponding to the aParent and aType
+ CMonitorTriggerInfo* triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo(aParent, aType);
+
+ //if no triggerinfo available in the linked list
+ if (triggerInfo == NULL) {
+ //Define the triggering area
+ CLbtGeoCircle* trigArea = NULL;
+
+ TRAP(ret, trigArea = CLbtGeoCircle::NewL(
+ aCoordinate ,//center coordinate
+ aRadius //radius in meters. If
+ //NaN is used, Location
+ //Triggering Server will
+ //use minimal size of trigger
+ //area as the radius of the
+ //trigger
+ ));
+
+ if ((ret != KErrNone) || !trigArea)
+ return FALSE;
+
+ CleanupStack::PushL(trigArea);
+
+ CLbtTriggerConditionArea* cond = NULL;
+
+ if (aType == EntryTrigger) {
+ //2: Construct a entry type of trigger condition
+ TRAP(ret, cond = CLbtTriggerConditionArea::NewL(
+ trigArea,
+ CLbtTriggerConditionArea::EFireOnEnter
+ ));
+ } else if (aType == ExitTrigger) {
+ TRAP(ret, cond = CLbtTriggerConditionArea::NewL(
+ trigArea,
+ CLbtTriggerConditionArea::EFireOnExit
+ ));
+ }
+
+
+ if ((ret != KErrNone) || !cond) {
+ CleanupStack::PopAndDestroy(trigArea);
+ return FALSE;
+ }
+
+ CleanupStack::Pop(trigArea); //ownership of trigArea is transferred.
+
+ CleanupStack::PushL(cond);
+
+ RRequestorStack reqStack;
+
+ CleanupClosePushL(reqStack);
+
+ //trigger name.
+ _LIT(KMyTriggerName, "EntryTrigger");
+ TDesC triggerName(KMyTriggerName);
+
+ if (aType == ExitTrigger) {
+ _LIT(KMyTriggerName, "ExitTrigger");
+ triggerName = KMyTriggerName;
+ }
+
+ //Construct requestor
+ _LIT(KMyRequestorName, "QTLBTBackend"); //Application name used as requestor identifier
+
+ CRequestor *req = NULL;
+
+ TRAP(ret, req = CRequestor::NewL(
+ CRequestorBase::ERequestorService,
+ CRequestorBase::EFormatApplication,
+ KMyRequestorName
+ ));
+
+ if ((ret != KErrNone) || !req) {
+ CleanupStack::PopAndDestroy(&reqStack);
+ CleanupStack::PopAndDestroy(cond);
+ return FALSE;
+ }
+
+ CleanupStack::PushL(req);
+
+ TRAP(ret, reqStack.AppendL(req));
+
+ CleanupStack::Pop(req);
+
+ if (ret != KErrNone) {
+ CleanupStack::PopAndDestroy(&reqStack);
+ CleanupStack::PopAndDestroy(cond);
+ return FALSE;
+ }
+
+ TUid managerUid = TUid::Uid(0);
+
+ CLbtSessionTrigger* trig = NULL;
+
+ TRAP(ret, trig = CLbtSessionTrigger::NewL(
+ triggerName,
+ CLbtTriggerEntry::EStateDisabled,
+ reqStack,
+ managerUid,
+ cond
+ ));
+
+ CleanupStack::PopAndDestroy(&reqStack);
+
+ CleanupStack::Pop(cond);
+
+ trig->SetTimeToRearm(0);
+
+ if ((ret != KErrNone) || (!trig)) {
+ CleanupStack::PopAndDestroy(cond);
+ return FALSE;
+ }
+
+ CleanupStack::PushL(trig);
+
+ //iLbt.CreateTrigger(*trig, triggerID, ETrue, iStatus);
+
+ //CleanupStack::PopAndDestroy(trig );
+
+ TRAP(ret, iActiveSchedulerwait = new(ELeave) CActiveSchedulerWait);
+
+ if ((ret != KErrNone) || !iActiveSchedulerwait) {
+ CleanupStack::PopAndDestroy(trig);
+ return FALSE;
+ }
+
+ iTriggerCreation = FALSE;
+
+ //create a trigger asynchronously
+ iLbt.CreateTrigger(*trig, triggerID, ETrue, iStatus);
+
+ SetActive();
+
+ //wait till the iActiveSchedularwait->AsyncStop() is called in RunL
+ iActiveSchedulerwait->Start();
+
+ delete iActiveSchedulerwait;
+
+ CleanupStack::PopAndDestroy(trig);
+
+ //if the trigger creation is successful, add the triggerinfo to the linked list
+ if (iTriggerCreation == TRUE)
+ iTriggerMonitorInfo->addMonitorTriggerInfo(aParent, triggerID, aType);
+
+ delete req;
+
+ return iTriggerCreation;
+ } else { //triggerinfo available in the linked list
+
+ CLbtSessionTrigger* trig = NULL;
+
+ //Define the triggering area
+ CLbtGeoCircle* trigArea = NULL;
+
+ TRAP(ret, trigArea = CLbtGeoCircle::NewL(
+ aCoordinate , //center coordinate
+ aRadius //radius in meters. If
+ //NaN is used, Location
+ //Triggering Server will
+ //use minimal size of trigger
+ //area as the radius of the
+ //trigger
+ ));
+
+ if ((ret != KErrNone) || (!trigArea)) {
+
+ return FALSE;
+ }
+
+ CleanupStack::PushL(trigArea);
+
+ //2: Construct a entry type of trigger condition
+ CLbtTriggerConditionArea* cond = NULL;
+
+ if (aType == EntryTrigger) {
+ //2: Construct a entry type of trigger condition
+ TRAP(ret, cond = CLbtTriggerConditionArea::NewL(
+ trigArea,
+ CLbtTriggerConditionArea::EFireOnEnter
+ ));
+ } else if (aType == ExitTrigger) {
+ TRAP(ret, cond = CLbtTriggerConditionArea::NewL(
+ trigArea,
+ CLbtTriggerConditionArea::EFireOnExit
+ ));
+ }
+
+
+ if ((ret != KErrNone) || !cond) {
+ CleanupStack::PopAndDestroy(trigArea);
+ return FALSE;
+ }
+
+ CleanupStack::Pop(trigArea); //ownership of trigArea is transferred.
+
+ CleanupStack::PushL(cond);
+
+ //create a session trigger
+ TRAP(ret, trig = CLbtSessionTrigger::NewL());
+
+ if ((ret != KErrNone) || (!trig)) {
+ CleanupStack::PopAndDestroy(cond);
+ return FALSE;
+ }
+
+ //set the condition for the trigger
+ trig->SetCondition(cond);
+
+ CleanupStack::Pop(cond);
+
+ CleanupStack::PushL(trig);
+
+ //set the trigger ID
+ trig->SetId(triggerInfo->iTriggerID);
+
+ iLbt.SetTriggerStateL(triggerInfo->iTriggerID, CLbtTriggerEntry::EStateDisabled, ELbtTrue);
+
+ //update the trigger with the new condition in LBT server
+ TRAP(ret, iLbt.UpdateTriggerL(*trig, CLbtTriggerEntry::EAttributeCondition, ELbtTrue));
+
+ CleanupStack::PopAndDestroy(trig);
+
+
+ if (ret != KErrNone) {
+ return FALSE;;
+ }
+
+ return TRUE;
+ }
+}
+
+
+QMLBackendMonitorCreateTriggerAO::~QMLBackendMonitorCreateTriggerAO()
+{
+ Cancel();
+ iLbt.Close(); //closes the subsession
+}
+
+
+void QMLBackendMonitorCreateTriggerAO::DoCancel()
+{
+ if (!IsActive()) {
+ iActiveSchedulerwait->AsyncStop();
+ }
+}
+
+void QMLBackendMonitorCreateTriggerAO::RunL()
+{
+ switch (iStatus.Int()) {
+ case KErrNone :
+ iTriggerCreation = TRUE;
+ break;
+ default :
+ break;
+ }
+ //stops the AO, waiting in the iActiveSchedulerwait->Start()
+ iActiveSchedulerwait->AsyncStop();
+}
+
+QMLBackendMonitorCreateTriggerAO* QMLBackendMonitorCreateTriggerAO::NewL(QGeoAreaMonitorS60* aParent , RLbtServer &aLbt)
+{
+
+ QMLBackendMonitorCreateTriggerAO* self = QMLBackendMonitorCreateTriggerAO::
+ NewLC(aParent, aLbt);
+ CleanupStack::Pop();
+
+ return self;
+}
+
+QMLBackendMonitorCreateTriggerAO* QMLBackendMonitorCreateTriggerAO::NewLC(QGeoAreaMonitorS60* aParent , RLbtServer &aLbtServer)
+{
+ QMLBackendMonitorCreateTriggerAO *self = new(ELeave) QMLBackendMonitorCreateTriggerAO;
+ CleanupStack::PushL(self);
+ self->ConstructL(aLbtServer);
+ if (!self->isValid()) {
+ delete self;
+ self = NULL;
+ }
+ return self;
+}
+
+void QMLBackendMonitorCreateTriggerAO::ConstructL(RLbtServer &aLbtServ)
+{
+ if (iLbt.Open(aLbtServ) == KErrNone) { //opens the subseesion
+ subsessionCreated = TRUE;
+ //get the singleton object of CBackendMonitorInfo class
+ iTriggerMonitorInfo = CBackendMonitorInfo::NewL();
+ }
+}
+
+QMLBackendMonitorCreateTriggerAO::QMLBackendMonitorCreateTriggerAO()
+ : CActive(EPriorityStandard), // Standard priority
+ subsessionCreated(FALSE), iTriggerCreation(FALSE)
+{
+ CActiveScheduler::Add(this); //add AO to the Schedular
+}
+
+//Enables/Disables the trigger state depending on the aStatus
+void QMLBackendMonitorCreateTriggerAO::SetTriggerState(QGeoAreaMonitorS60* aParent, enTriggerType aType, bool aStatus)
+{
+ //retrieve the triggerinfo from the linked list from the supplied aPrent and aType
+ CMonitorTriggerInfo* triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo(aParent, aType);
+
+ if (aStatus == true) {
+ TRAPD(err, iLbt.SetTriggerStateL(triggerInfo->iTriggerID, CLbtTriggerEntry::EStateEnabled, ELbtTrue));
+ } else {
+ TRAPD(err, iLbt.SetTriggerStateL(triggerInfo->iTriggerID, CLbtTriggerEntry::EStateDisabled, ELbtTrue));
+ }
+}
+
+//checks whether trigger is Initialized. The trigger entry corresponding to the aParent and aType is
+//searched in the linked list
+bool QMLBackendMonitorCreateTriggerAO::isTriggerInitialized(QGeoAreaMonitorS60* aParent, enTriggerType aType)
+{
+ CMonitorTriggerInfo* triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo(aParent, aType);
+
+ return (triggerInfo != NULL) ? TRUE : FALSE;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qmlbackendmonitorcreatetriggerao_s60_p.h b/src/location/qmlbackendmonitorcreatetriggerao_s60_p.h
new file mode 100644
index 00000000..a9adc597
--- /dev/null
+++ b/src/location/qmlbackendmonitorcreatetriggerao_s60_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QMLBACKENDMONITORCREATETRIGGER_H_
+#define QMLBACKENDMONITORCREATETRIGGER_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmlbackendmonitorao_s60_p.h"
+#include "qmlbackendmonitorinfo_s60_p.h"
+
+#include <lbtsessiontrigger.h>
+#include <lbtgeocircle.h>
+#include <lbttriggerconditionarea.h>
+#include <lbttriggerentry.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QGeoAreaMonitorS60;
+
+class QMLBackendMonitorCreateTriggerAO : public CActive
+{
+public :
+ static QMLBackendMonitorCreateTriggerAO* NewL(QGeoAreaMonitorS60* aParent , RLbtServer &aLbtServer);
+
+ bool InitializeTrigger(QGeoAreaMonitorS60* aParent, enTriggerType aType, TCoordinate& aCoordinate, qreal& aRadius);
+
+ bool isTriggerInitialized(QGeoAreaMonitorS60* aParent, enTriggerType aType);
+
+ void DoCancel();
+
+ void RunL();
+
+ void SetTriggerState(QGeoAreaMonitorS60* aParent, enTriggerType aType, bool aStatus);
+
+ TInt getRadius(qreal& radius);
+
+ ~QMLBackendMonitorCreateTriggerAO();
+private :
+ QMLBackendMonitorCreateTriggerAO();
+
+ static QMLBackendMonitorCreateTriggerAO* NewLC(QGeoAreaMonitorS60* aParent , RLbtServer &aLbt);
+
+ void ConstructL(RLbtServer &aLbtServ);
+
+ bool isValid() {
+ return subsessionCreated && (iTriggerMonitorInfo != NULL);
+ }
+private:
+
+ CBackendMonitorInfo* iTriggerMonitorInfo; //single instance of the CBackendMonitorInfo object
+
+ CActiveSchedulerWait* iActiveSchedulerwait;
+
+ bool subsessionCreated; //check for the successful creation of the subsession
+
+ bool iTriggerCreation;
+
+ RLbt iLbt; //subsession
+
+};
+
+QTM_END_NAMESPACE
+
+#endif /* QMLBACKENDMONITORCREATETRIGGER_H_ */
diff --git a/src/location/qmlbackendmonitorinfo_s60.cpp b/src/location/qmlbackendmonitorinfo_s60.cpp
new file mode 100644
index 00000000..ede9408c
--- /dev/null
+++ b/src/location/qmlbackendmonitorinfo_s60.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qmlbackendmonitorinfo_s60_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+//singleton class object
+CBackendMonitorInfo* CBackendMonitorInfo::iBackendMonitorInfo = NULL;
+
+CBackendMonitorInfo* CBackendMonitorInfo::NewL()
+{
+ if (!iBackendMonitorInfo)
+ iBackendMonitorInfo = new CBackendMonitorInfo;
+
+ return iBackendMonitorInfo;
+}
+
+//returns the CMonitorTriggerInfo info based on the aTrigID
+CMonitorTriggerInfo* CBackendMonitorInfo::getMonitorTriggerInfo(TLbtTriggerId aTrigID)
+{
+ CMonitorTriggerInfo* currentNode = iMonitorInfo;
+ while (currentNode && (currentNode->iTriggerID != aTrigID)) {
+ currentNode = currentNode->next;
+ }
+ return currentNode;
+}
+
+//returns the CMonitorTriggerInfo info based on the aParent,aType from the linked list
+CMonitorTriggerInfo* CBackendMonitorInfo::getMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, enTriggerType aType)
+{
+ CMonitorTriggerInfo* currentNode = iMonitorInfo;
+ while (currentNode) {
+ if ((currentNode->iParent == aParent) && (currentNode->iType == aType))
+ break;
+
+ currentNode = currentNode->next;
+ }
+ return currentNode;
+}
+
+//creates and adds a new CMonitorTriggerInfo object to the end of linked list
+bool CBackendMonitorInfo::addMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, TLbtTriggerId aTriggerID, enTriggerType aType)
+{
+ CMonitorTriggerInfo* currentNode = NULL;
+
+ CMonitorTriggerInfo* temp = new CMonitorTriggerInfo;
+
+ if (!temp) {
+ return FALSE;
+ }
+
+ temp->iTriggerID = aTriggerID;
+ temp->iParent = aParent;
+ temp->iType = aType;
+ temp->next = NULL;
+
+ currentNode = iMonitorInfo;
+
+ while (currentNode && (currentNode->next != NULL))
+ currentNode = currentNode->next;
+
+ if (!currentNode) {
+ iMonitorInfo = temp;
+ } else {
+ currentNode->next = temp;
+ }
+
+ return TRUE;
+}
+
+//deletes the node corresponding to aTrigID
+void CBackendMonitorInfo::removeMonitorTriggerInfo(TLbtTriggerId aTrigID)
+{
+ CMonitorTriggerInfo* currentNode = NULL;
+
+ CMonitorTriggerInfo* prevNode = NULL;
+
+ currentNode = prevNode = iMonitorInfo;
+
+ while (currentNode && (currentNode->iTriggerID != aTrigID)) {
+ prevNode = currentNode;
+ currentNode = currentNode->next;
+ }
+
+ if (currentNode == NULL)
+ return;
+
+ else if (currentNode == iMonitorInfo) {
+ iMonitorInfo = currentNode->next;
+ }
+
+ else {
+ prevNode->next = currentNode->next;
+ }
+
+ delete currentNode;
+}
+
+//deletes all the nodes in the linked list
+CBackendMonitorInfo::~CBackendMonitorInfo()
+{
+ CMonitorTriggerInfo* currentNode = NULL;
+ CMonitorTriggerInfo* prevNode = NULL;
+
+ prevNode = iMonitorInfo;
+
+ while (prevNode) {
+ currentNode = prevNode;
+ prevNode = prevNode->next;
+ delete currentNode;
+ }
+
+ iMonitorInfo = NULL;
+ iBackendMonitorInfo = NULL;
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qmlbackendmonitorinfo_s60_p.h b/src/location/qmlbackendmonitorinfo_s60_p.h
new file mode 100644
index 00000000..e137fa60
--- /dev/null
+++ b/src/location/qmlbackendmonitorinfo_s60_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBACKENDMONITORINFO_H_
+#define QMLBACKENDMONITORINFO_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmlbackendmonitorao_s60_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+//linked list information structure
+struct CMonitorTriggerInfo {
+ QGeoAreaMonitorS60* iParent;
+
+ TLbtTriggerId iTriggerID;
+
+ enum enTriggerType iType;
+
+ CMonitorTriggerInfo* next;
+};
+
+
+class CBackendMonitorInfo : public CBase
+{
+public :
+
+ static CBackendMonitorInfo *NewL();
+
+ //return CMonitorTriggerInfo from TriggerID
+ CMonitorTriggerInfo* getMonitorTriggerInfo(TLbtTriggerId aTrigID);
+
+ //return CMonitorTriggerInfo from the QGeoAreaMonitorS60
+ CMonitorTriggerInfo* getMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, enTriggerType aType);
+
+ //return the header of the linked list
+ inline CMonitorTriggerInfo* getMonitorTriggerInfo() {
+ return iMonitorInfo;
+ }
+
+ //add the entry and exit trigger info to the list
+ bool addMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, TLbtTriggerId aTriggerID, enTriggerType aType);
+
+ //remove the CMonitorTriggerInfo corresponding to the TriggerID
+ void removeMonitorTriggerInfo(TLbtTriggerId aTrigID);
+
+
+ ~CBackendMonitorInfo();
+private :
+
+ CBackendMonitorInfo() : iMonitorInfo(NULL) { }
+
+ CMonitorTriggerInfo* iMonitorInfo;
+
+ static CBackendMonitorInfo* iBackendMonitorInfo;
+};
+
+QTM_END_NAMESPACE
+
+#endif /* QMLBACKENDMONITORINFO_H_ */
diff --git a/src/location/qmlbackendtriggerchangeao_s60.cpp b/src/location/qmlbackendtriggerchangeao_s60.cpp
new file mode 100644
index 00000000..9b642bac
--- /dev/null
+++ b/src/location/qmlbackendtriggerchangeao_s60.cpp
@@ -0,0 +1,349 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlbackendmonitorao_s60_p.h"
+#include "qgeoareamonitor_s60_p.h"
+#include "qmlbackendmonitorinfo_s60_p.h"
+#include "qmlbackendtriggerchangeao_s60_p.h"
+
+#include <lbtsessiontrigger.h>
+#include <lbttriggerentry.h>
+
+QTM_BEGIN_NAMESPACE
+
+//Design chnages
+
+QMLBackendTriggerChangeAO* QMLBackendTriggerChangeAO::instance = NULL;
+TInt QMLBackendTriggerChangeAO::refCount = 0;
+
+
+//request for the notification of trigger change event with the
+//LBT server
+void QMLBackendTriggerChangeAO::NotifyChangeEvent()
+{
+ if (!IsActive()) {
+ iStatus = KRequestPending;
+ iLbt.NotifyTriggerChangeEvent(iTriggerChangeEvent, iStatus);
+ SetActive();
+ }
+}
+
+
+QMLBackendTriggerChangeAO::~QMLBackendTriggerChangeAO()
+{
+ Cancel();
+ iLbt.Close();
+}
+
+void QMLBackendTriggerChangeAO::DoCancel()
+{
+ if (IsActive()) { //if AO is active,cancel the trigger change event request
+ iLbt.CancelNotifyTriggerChangeEvent();
+ }
+}
+
+void QMLBackendTriggerChangeAO::RunL()
+{
+ switch (iStatus.Int()) {
+ case KErrNone :
+#if 0
+ //implementation takes the updation, deletion into consideration
+ //from the UI, which isn't possible with the current UI for LBT.
+ //The same should be considered once made availbale as part of the UI
+ //check for Multiple trigger change events
+ if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventMultiple) {
+ CMonitorTriggerInfo* triggerInfo1 = NULL;
+
+ CMonitorTriggerInfo* triggerInfo2 = NULL;
+
+ CMonitorTriggerInfo* triggerInfo3 = NULL;
+
+ TInt i = 0, count = 0;
+
+ RPointerArray < CLbtTriggerInfo > trigInfoList;
+
+ CLbtTriggerEntry* entry = NULL;
+
+ //retrieve the list of triggers created by the client
+ iLbt.GetTriggersL(trigInfoList);
+
+ CleanupClosePushL(trigInfoList);
+
+ count = trigInfoList.Count();
+
+ //get the header of the linked list holding the information
+ //of the trigger
+ triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo();
+
+ while (triggerInfo1) {
+ for (i = 0; i < count; i++) {
+ //get the trigger entryinfo
+ entry = trigInfoList[i]->TriggerEntry();
+
+ //if the triggerinfo retrieved matches the trigInfoList
+ //id break
+ if (triggerInfo1->iTriggerID == entry->Id())
+ break;
+ }
+
+ triggerInfo2 = triggerInfo1->next;
+
+ if (i == count) //if the triggerinfo1->triggerid not found
+ //in the trigger list of the LBT server,
+ //remove the triggerinfo from the linked list
+ {
+ iTriggerMonitorInfo->removeMonitorTriggerInfo(
+ triggerInfo1->iTriggerID);
+ } else {
+
+ //if triggerinfo1->triggerid is found in the trigger list,
+ //and if it is an entry trigger, search for the corresponding
+ //exit trigger in the linked list
+ if (triggerInfo1->iType == EntryTrigger)
+ triggerInfo3 = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ triggerInfo1->iParent , ExitTrigger);
+
+ //if triggerinfo1->triggerid is found in the trigger list,
+ //and if it is an entry trigger, search for the corresponding
+ //entry trigger in the linked list
+ else if (triggerInfo1->iType == ExitTrigger)
+ triggerInfo3 = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ triggerInfo1->iParent, EntryTrigger);
+
+ //callback called for the notification change event of the trigger
+ if (triggerInfo3) {
+
+ (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, trigInfoList[i],
+ triggerInfo3->iTriggerID);
+ } else {
+ (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, trigInfoList[i],
+ NULL);
+ }
+
+ }
+ triggerInfo3 = NULL;
+
+ triggerInfo1 = triggerInfo2;
+ }
+
+ CleanupStack::Pop(1);
+
+ //cloae the trigInfoList, holding the list of trigger
+ //info
+ trigInfoList.Close();
+
+ }
+ //check for trigger delete event
+ else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventDeleted) {
+ //delete the entry from the linked list,corresponding to the
+ //iTriggerChangeEvent.iTriggerId
+ iTriggerMonitorInfo->removeMonitorTriggerInfo(
+ iTriggerChangeEvent.iTriggerId);
+ }
+ //check for trigger updation event
+ else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventUpdated) {
+ CLbtTriggerInfo *info = NULL;
+
+ //get the triggerinfo from the linked list corresponding
+ //to the iTriggerChangeEvent.iTriggerId
+ CMonitorTriggerInfo* triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ iTriggerChangeEvent.iTriggerId);
+
+ if (!triggerInfo1)
+ break;
+
+ //get the triggerinfo of trigger with id - iTriggerChangeEvent.iTriggerId
+ //from the LBT server
+ info = iLbt.GetTriggerLC(iTriggerChangeEvent.iTriggerId);
+
+ if (info == NULL)
+ break;
+
+ //change in one-trigger,must update the corresponding entry/exit
+ //trigger
+ if (triggerInfo1) {
+ CMonitorTriggerInfo* triggerInfo2 = NULL;
+
+ //if the trigger updated is EntryTrigger, get the information
+ //of the corresponding ExitTrigger if any,from the
+ //linked list
+ if (triggerInfo1->iType == EntryTrigger)
+ triggerInfo2 = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ triggerInfo1->iParent, ExitTrigger);
+
+ //if the trigger updated is ExitTrigger, get the information
+ //of the corresponding EntryTrigger if any,fro mthe
+ //linked list
+ else if (triggerInfo1->iType == ExitTrigger)
+ triggerInfo2 = iTriggerMonitorInfo->getMonitorTriggerInfo(
+ triggerInfo1->iParent, EntryTrigger);
+
+ //callback called for the notification change event for the trigger
+ if (triggerInfo2) {
+ (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, info,
+ triggerInfo2->iTriggerID);
+ } else {
+ (triggerInfo1->iParent)->handleTriggerChangeEvent(iTriggerChangeEvent.iEventType, info,
+ NULL);
+ }
+ }
+
+ //pop and destroy the triggerinfo retrived from GetTriggerLC()
+ CleanupStack::PopAndDestroy(info);
+ }
+#endif
+ if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventMultiple) {
+
+ CMonitorTriggerInfo* triggerInfo1 = NULL;
+
+ CMonitorTriggerInfo* triggerInfo2 = NULL;
+
+ TInt i = 0, count = 0;
+
+ RArray < TLbtTriggerId > triggerIdList;
+
+
+ //retrieve the list of trigger IDs created by the client
+ TRAPD(ret, iLbt.ListTriggerIdsL(triggerIdList));
+
+ if (ret != KErrNone) {
+ break;
+ }
+
+ CleanupClosePushL(triggerIdList);
+
+ count = triggerIdList.Count();
+
+ //get the header of the linked list holding the information
+ //of the trigger
+ triggerInfo1 = iTriggerMonitorInfo->getMonitorTriggerInfo();
+
+ while (triggerInfo1) {
+ for (i = 0; i < count; i++) {
+ //if the triggerinfo retrieved matches the triggerIdList
+ //id break
+ if (triggerInfo1->iTriggerID == triggerIdList[i])
+ break;
+ }
+
+ triggerInfo2 = triggerInfo1->next;
+
+ if (i == count) //if the triggerinfo1->triggerid not found
+ //in the trigger list of the LBT server,
+ //remove the triggerinfo from the linked list
+ {
+ iTriggerMonitorInfo->removeMonitorTriggerInfo(
+ triggerInfo1->iTriggerID);
+ }
+
+ triggerInfo1 = triggerInfo2;
+ }
+
+ CleanupStack::Pop(1);
+
+ //close the trigInfoList, holding the list of trigger
+ //info
+ triggerIdList.Close();
+ }
+
+ //check for trigger delete event
+ else if (iTriggerChangeEvent.iEventType == ELbtTriggerChangeEventDeleted) {
+ //delete the entry from the linked list,corresponding to the
+ //iTriggerChangeEvent.iTriggerId
+ iTriggerMonitorInfo->removeMonitorTriggerInfo(
+ iTriggerChangeEvent.iTriggerId);
+ }
+ break;
+
+ default :
+ break;
+ }
+
+ //request for the notification of any notification change events
+ NotifyChangeEvent();
+}
+
+
+//static function called prior to the destruction of the
+//singleton QMLBackendTriggerChangeAO object
+void QMLBackendTriggerChangeAO::DeleteAO()
+{
+ //decrement the referent count
+ refCount--;
+
+ if (!refCount) { //if reference count becomes 0 delete the instance
+ delete instance;
+ instance = NULL;
+ }
+}
+
+QMLBackendTriggerChangeAO* QMLBackendTriggerChangeAO::NewL(RLbtServer& aLbtServ)
+{
+
+ if (!instance) {
+ instance = new QMLBackendTriggerChangeAO;
+ instance->ConstructL(aLbtServ);
+ if (!instance->isValid()) {
+ delete instance;
+ instance = NULL;
+ return NULL;
+ }
+ }
+ refCount++;
+ return instance;
+
+}
+
+QMLBackendTriggerChangeAO::QMLBackendTriggerChangeAO() : CActive(EPriorityNormal), iTriggerMonitorInfo(NULL)
+{
+ CActiveScheduler::Add(this); //add current AO, to the Schedular
+}
+
+void QMLBackendTriggerChangeAO::ConstructL(RLbtServer& aLbtServ)
+{
+ if (iLbt.Open(aLbtServ) == KErrNone) { //open the RLBT subsesion
+ subsessionCreated = TRUE;
+ //Get the pointer to the CBackendMonitorInfo singleton object
+ iTriggerMonitorInfo = CBackendMonitorInfo::NewL();
+ }
+}
+
+QTM_END_NAMESPACE
diff --git a/src/location/qmlbackendtriggerchangeao_s60_p.h b/src/location/qmlbackendtriggerchangeao_s60_p.h
new file mode 100644
index 00000000..32e18a45
--- /dev/null
+++ b/src/location/qmlbackendtriggerchangeao_s60_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBACKENDTRIGGERCHANGEAO_H_
+#define QMLBACKENDTRIGGERCHANGEAO_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <e32base.h> // For CActive, link against: euser.lib
+#include <lbs.h>
+#include <lbscommon.h>
+#include <lbtsessiontrigger.h>
+
+#include "qgeoareamonitor.h"
+
+#include <lbt.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QMLBackendTriggerChangeAO : public CActive
+{
+public :
+
+ static QMLBackendTriggerChangeAO* NewL(RLbtServer& aLbtServ);
+ static void DeleteAO();
+ void NotifyChangeEvent();
+ void DoCancel();
+ void RunL();
+
+private :
+ QMLBackendTriggerChangeAO();
+ ~QMLBackendTriggerChangeAO();
+ inline bool isValid() {
+ return subsessionCreated && (iTriggerMonitorInfo != NULL);
+ }
+ void ConstructL(RLbtServer& albtServ);
+
+ static QMLBackendTriggerChangeAO* instance;
+ CBackendMonitorInfo* iTriggerMonitorInfo; //single instance of the CBackendMonitorInfo object
+ TLbtTriggerChangeEvent iTriggerChangeEvent;
+ bool subsessionCreated;
+ static TInt refCount;
+ RLbt iLbt;
+
+};
+
+QTM_END_NAMESPACE
+
+#endif /* QMLBACKENDMONITORAO_H_ */
diff --git a/src/location/qnmeapositioninfosource.cpp b/src/location/qnmeapositioninfosource.cpp
new file mode 100644
index 00000000..19e86553
--- /dev/null
+++ b/src/location/qnmeapositioninfosource.cpp
@@ -0,0 +1,611 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qnmeapositioninfosource_p.h"
+#include "qlocationutils_p.h"
+
+#include <QIODevice>
+#include <QBasicTimer>
+#include <QTimerEvent>
+#include <QTimer>
+
+
+QTM_BEGIN_NAMESPACE
+
+QNmeaRealTimeReader::QNmeaRealTimeReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
+ : QNmeaReader(sourcePrivate)
+{
+}
+
+void QNmeaRealTimeReader::readAvailableData()
+{
+ QGeoPositionInfo update;
+ bool hasFix = false;
+
+ char buf[1024];
+ qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf));
+ while (size > 0) {
+ if (m_proxy->parsePosInfoFromNmeaData(buf, size, &update, &hasFix))
+ m_proxy->notifyNewUpdate(&update, hasFix);
+ memset(buf, 0, size);
+ size = m_proxy->m_device->readLine(buf, sizeof(buf));
+ }
+}
+
+
+//============================================================
+
+QNmeaSimulatedReader::QNmeaSimulatedReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
+ : QNmeaReader(sourcePrivate),
+ m_currTimerId(-1),
+ m_hasValidDateTime(false)
+{
+}
+
+QNmeaSimulatedReader::~QNmeaSimulatedReader()
+{
+ if (m_currTimerId > 0)
+ killTimer(m_currTimerId);
+}
+
+void QNmeaSimulatedReader::readAvailableData()
+{
+ if (m_currTimerId > 0) // we are already reading
+ return;
+
+ if (!m_hasValidDateTime) { // first update
+ Q_ASSERT(m_proxy->m_device && (m_proxy->m_device->openMode() & QIODevice::ReadOnly));
+
+ if (!setFirstDateTime()) {
+ //m_proxy->notifyReachedEndOfFile();
+ qWarning("QNmeaPositionInfoSource: cannot find NMEA sentence with valid date & time");
+ return;
+ }
+
+ m_hasValidDateTime = true;
+ simulatePendingUpdate();
+
+ } else {
+ // previously read to EOF, but now new data has arrived
+ processNextSentence();
+ }
+}
+
+bool QNmeaSimulatedReader::setFirstDateTime()
+{
+ // find the first update with valid date and time
+ QGeoPositionInfo update;
+ bool hasFix = false;
+ while (m_proxy->m_device->bytesAvailable() > 0) {
+ char buf[1024];
+ qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf));
+ if (size <= 0)
+ continue;
+ bool ok = m_proxy->parsePosInfoFromNmeaData(buf, size, &update, &hasFix);
+ if (ok && update.timestamp().isValid()) {
+ QPendingGeoPositionInfo pending;
+ pending.info = update;
+ pending.hasFix = hasFix;
+ m_pendingUpdates.enqueue(pending);
+ return true;
+ }
+ }
+ return false;
+}
+
+void QNmeaSimulatedReader::simulatePendingUpdate()
+{
+ if (m_pendingUpdates.size() > 0) {
+ // will be dequeued in processNextSentence()
+ QPendingGeoPositionInfo &pending = m_pendingUpdates.head();
+ if (pending.info.coordinate().type() != QGeoCoordinate::InvalidCoordinate)
+ m_proxy->notifyNewUpdate(&pending.info, pending.hasFix);
+ }
+
+ processNextSentence();
+}
+
+void QNmeaSimulatedReader::timerEvent(QTimerEvent *event)
+{
+ killTimer(event->timerId());
+ m_currTimerId = -1;
+ simulatePendingUpdate();
+}
+
+void QNmeaSimulatedReader::processNextSentence()
+{
+ QGeoPositionInfo info;
+ bool hasFix = false;
+ int timeToNextUpdate = -1;
+ QTime prevTime;
+ if (m_pendingUpdates.size() > 0)
+ prevTime = m_pendingUpdates.head().info.timestamp().time();
+
+ // find the next update with a valid time (as long as the time is valid,
+ // we can calculate when the update should be emitted)
+ while (m_proxy->m_device && m_proxy->m_device->bytesAvailable() > 0) {
+ char buf[1024];
+ qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf));
+ if (size <= 0)
+ continue;
+ if (m_proxy->parsePosInfoFromNmeaData(buf, size, &info, &hasFix)) {
+ QTime time = info.timestamp().time();
+ if (time.isValid()) {
+ if (!prevTime.isValid()) {
+ timeToNextUpdate = 0;
+ break;
+ }
+ timeToNextUpdate = prevTime.msecsTo(time);
+ if (timeToNextUpdate >= 0)
+ break;
+ }
+ }
+ }
+
+ if (timeToNextUpdate < 0)
+ return;
+
+ m_pendingUpdates.dequeue();
+
+ QPendingGeoPositionInfo pending;
+ pending.info = info;
+ pending.hasFix = hasFix;
+ m_pendingUpdates.enqueue(pending);
+ m_currTimerId = startTimer(timeToNextUpdate);
+}
+
+
+//============================================================
+
+
+QNmeaPositionInfoSourcePrivate::QNmeaPositionInfoSourcePrivate(QNmeaPositionInfoSource *parent)
+ : QObject(parent),
+ m_invokedStart(false),
+ m_source(parent),
+ m_nmeaReader(0),
+ m_updateTimer(0),
+ m_requestTimer(0),
+ m_noUpdateLastInterval(false),
+ m_updateTimeoutSent(false),
+ m_connectedReadyRead(false)
+{
+}
+
+QNmeaPositionInfoSourcePrivate::~QNmeaPositionInfoSourcePrivate()
+{
+ delete m_nmeaReader;
+ delete m_updateTimer;
+}
+
+bool QNmeaPositionInfoSourcePrivate::openSourceDevice()
+{
+ if (!m_device) {
+ qWarning("QNmeaPositionInfoSource: no QIODevice data source, call setDevice() first");
+ return false;
+ }
+
+ if (!m_device->isOpen() && !m_device->open(QIODevice::ReadOnly)) {
+ qWarning("QNmeaPositionInfoSource: cannot open QIODevice data source");
+ return false;
+ }
+
+ connect(m_device, SIGNAL(aboutToClose()), SLOT(sourceDataClosed()));
+ connect(m_device, SIGNAL(readChannelFinished()), SLOT(sourceDataClosed()));
+ connect(m_device, SIGNAL(destroyed()), SLOT(sourceDataClosed()));
+
+ return true;
+}
+
+void QNmeaPositionInfoSourcePrivate::sourceDataClosed()
+{
+ if (m_nmeaReader && m_device && m_device->bytesAvailable())
+ m_nmeaReader->readAvailableData();
+}
+
+void QNmeaPositionInfoSourcePrivate::readyRead()
+{
+ if (m_nmeaReader)
+ m_nmeaReader->readAvailableData();
+}
+
+bool QNmeaPositionInfoSourcePrivate::initialize()
+{
+ if (m_nmeaReader)
+ return true;
+
+ if (!openSourceDevice())
+ return false;
+
+ if (m_updateMode == QNmeaPositionInfoSource::RealTimeMode)
+ m_nmeaReader = new QNmeaRealTimeReader(this);
+ else
+ m_nmeaReader = new QNmeaSimulatedReader(this);
+
+ return true;
+}
+
+void QNmeaPositionInfoSourcePrivate::prepareSourceDevice()
+{
+ // some data may already be available
+ if (m_updateMode == QNmeaPositionInfoSource::SimulationMode) {
+ if (m_nmeaReader && m_device->bytesAvailable())
+ m_nmeaReader->readAvailableData();
+ }
+
+ if (!m_connectedReadyRead) {
+ connect(m_device, SIGNAL(readyRead()), SLOT(readyRead()));
+ m_connectedReadyRead = true;
+ }
+}
+
+bool QNmeaPositionInfoSourcePrivate::parsePosInfoFromNmeaData(const char *data, int size,
+ QGeoPositionInfo *posInfo, bool *hasFix)
+{
+ return m_source->parsePosInfoFromNmeaData(data, size, posInfo, hasFix);
+}
+
+void QNmeaPositionInfoSourcePrivate::startUpdates()
+{
+ if (m_invokedStart)
+ return;
+
+ m_invokedStart = true;
+ m_pendingUpdate = QGeoPositionInfo();
+ m_noUpdateLastInterval = false;
+
+ bool initialized = initialize();
+ if (!initialized)
+ return;
+
+ if (m_updateMode == QNmeaPositionInfoSource::RealTimeMode) {
+ // skip over any buffered data - we only want the newest data
+ if (m_device->bytesAvailable()) {
+ if (m_device->isSequential())
+ m_device->readAll();
+ else
+ m_device->seek(m_device->bytesAvailable());
+ }
+ }
+
+ if (m_updateTimer)
+ m_updateTimer->stop();
+
+ if (m_source->updateInterval() > 0) {
+ if (!m_updateTimer)
+ m_updateTimer = new QBasicTimer;
+ m_updateTimer->start(m_source->updateInterval(), this);
+ }
+
+ if (initialized)
+ prepareSourceDevice();
+}
+
+void QNmeaPositionInfoSourcePrivate::stopUpdates()
+{
+ m_invokedStart = false;
+ if (m_updateTimer)
+ m_updateTimer->stop();
+ m_pendingUpdate = QGeoPositionInfo();
+ m_noUpdateLastInterval = false;
+}
+
+void QNmeaPositionInfoSourcePrivate::requestUpdate(int msec)
+{
+ if (m_requestTimer && m_requestTimer->isActive())
+ return;
+
+ if (msec <= 0 || msec < m_source->minimumUpdateInterval()) {
+ emit m_source->updateTimeout();
+ return;
+ }
+
+ if (!m_requestTimer) {
+ m_requestTimer = new QTimer(this);
+ connect(m_requestTimer, SIGNAL(timeout()), SLOT(updateRequestTimeout()));
+ }
+
+ bool initialized = initialize();
+ if (!initialized) {
+ emit m_source->updateTimeout();
+ return;
+ }
+
+ m_requestTimer->start(msec);
+
+ if (initialized)
+ prepareSourceDevice();
+}
+
+void QNmeaPositionInfoSourcePrivate::updateRequestTimeout()
+{
+ m_requestTimer->stop();
+ emit m_source->updateTimeout();
+}
+
+void QNmeaPositionInfoSourcePrivate::notifyNewUpdate(QGeoPositionInfo *update, bool hasFix)
+{
+ // include <QDebug> before uncommenting
+ //qDebug() << "QNmeaPositionInfoSourcePrivate::notifyNewUpdate()" << update->timestamp() << hasFix << m_invokedStart << (m_requestTimer && m_requestTimer->isActive());
+
+ QDate date = update->timestamp().date();
+ if (date.isValid()) {
+ m_currentDate = date;
+ } else {
+ // some sentence have time but no date
+ QTime time = update->timestamp().time();
+ if (time.isValid() && m_currentDate.isValid())
+ update->setTimestamp(QDateTime(m_currentDate, time, Qt::UTC));
+ }
+
+ if (hasFix && update->isValid()) {
+ if (m_requestTimer && m_requestTimer->isActive()) {
+ m_requestTimer->stop();
+ emitUpdated(*update);
+ } else if (m_invokedStart) {
+ if (m_updateTimer && m_updateTimer->isActive()) {
+ // for periodic updates, only want the most recent update
+ m_pendingUpdate = *update;
+ if (m_noUpdateLastInterval) {
+ emitPendingUpdate();
+ m_noUpdateLastInterval = false;
+ }
+ } else {
+ emitUpdated(*update);
+ }
+ }
+ m_lastUpdate = *update;
+ }
+}
+
+void QNmeaPositionInfoSourcePrivate::timerEvent(QTimerEvent *)
+{
+ emitPendingUpdate();
+}
+
+void QNmeaPositionInfoSourcePrivate::emitPendingUpdate()
+{
+ if (m_pendingUpdate.isValid()) {
+ m_updateTimeoutSent = false;
+ m_noUpdateLastInterval = false;
+ emitUpdated(m_pendingUpdate);
+ m_pendingUpdate = QGeoPositionInfo();
+ } else {
+ if (m_noUpdateLastInterval && !m_updateTimeoutSent) {
+ m_updateTimeoutSent = true;
+ m_pendingUpdate = QGeoPositionInfo();
+ emit m_source->updateTimeout();
+ }
+ m_noUpdateLastInterval = true;
+ }
+}
+
+void QNmeaPositionInfoSourcePrivate::emitUpdated(const QGeoPositionInfo &update)
+{
+ m_lastUpdate = update;
+ emit m_source->positionUpdated(update);
+}
+
+//=========================================================
+
+/*!
+ \class QNmeaPositionInfoSource
+ \brief The QNmeaPositionInfoSource class provides positional information using a NMEA data source.
+
+ \inmodule QtLocation
+ \since 1.0
+
+ \ingroup location
+
+ NMEA is a commonly used protocol for the specification of one's global
+ position at a certain point in time. The QNmeaPositionInfoSource class reads NMEA
+ data and uses it to provide positional data in the form of
+ QGeoPositionInfo objects.
+
+ A QNmeaPositionInfoSource instance operates in either \l {RealTimeMode} or
+ \l {SimulationMode}. These modes allow NMEA data to be read from either a
+ live source of positional data, or replayed for simulation purposes from
+ previously recorded NMEA data.
+
+ The source of NMEA data is set with setDevice().
+
+ Use startUpdates() to start receiving regular position updates and stopUpdates() to stop these
+ updates. If you only require updates occasionally, you can call requestUpdate() to request a
+ single update.
+
+ In both cases the position information is received via the positionUpdated() signal and the
+ last known position can be accessed with lastKnownPosition().
+*/
+
+
+/*!
+ \enum QNmeaPositionInfoSource::UpdateMode
+ Defines the available update modes.
+
+ \value RealTimeMode Positional data is read and distributed from the data source as it becomes available. Use this mode if you are using a live source of positional data (for example, a GPS hardware device).
+ \value SimulationMode The data and time information in the NMEA source data is used to provide positional updates at the rate at which the data was originally recorded. Use this mode if the data source contains previously recorded NMEA data and you want to replay the data for simulation purposes.
+*/
+
+
+/*!
+ Constructs a QNmeaPositionInfoSource instance with the given \a parent
+ and \a updateMode.
+*/
+QNmeaPositionInfoSource::QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent)
+ : QGeoPositionInfoSource(parent),
+ d(new QNmeaPositionInfoSourcePrivate(this))
+{
+ d->m_updateMode = updateMode;
+ d->m_device = 0;
+}
+
+/*!
+ Destroys the position source.
+*/
+QNmeaPositionInfoSource::~QNmeaPositionInfoSource()
+{
+ delete d;
+}
+
+/*!
+ Parses an NMEA sentence string into a QGeoPositionInfo.
+
+ The default implementation will parse standard NMEA sentences.
+ This method should be reimplemented in a subclass whenever the need to deal with non-standard
+ NMEA sentences arises.
+
+ The parser reads \a size bytes from \a data and uses that information to setup \a posInfo and
+ \a hasFix. If \a hasFix is set to false then \a posInfo may contain only the time or the date
+ and the time.
+
+ Returns true if the sentence was succsesfully parsed, otherwise returns false and should not
+ modifiy \a posInfo or \a hasFix.
+*/
+bool QNmeaPositionInfoSource::parsePosInfoFromNmeaData(const char *data, int size,
+ QGeoPositionInfo *posInfo, bool *hasFix)
+{
+ return QLocationUtils::getPosInfoFromNmea(data, size, posInfo, hasFix);
+}
+
+/*!
+ Returns the update mode.
+*/
+QNmeaPositionInfoSource::UpdateMode QNmeaPositionInfoSource::updateMode() const
+{
+ return d->m_updateMode;
+}
+
+/*!
+ Sets the NMEA data source to \a device. If the device is not open, it
+ will be opened in QIODevice::ReadOnly mode.
+
+ The source device can only be set once and must be set before calling
+ startUpdates() or requestUpdate().
+
+ \bold {Note:} The \a device must emit QIODevice::readyRead() for the
+ source to be notified when data is available for reading.
+ QNmeaPositionInfoSource does not assume the ownership of the device,
+ and hence does not deallocate it upon destruction.
+*/
+void QNmeaPositionInfoSource::setDevice(QIODevice *device)
+{
+ if (device != d->m_device) {
+ if (!d->m_device)
+ d->m_device = device;
+ else
+ qWarning("QNmeaPositionInfoSource: source device has already been set");
+ }
+}
+
+/*!
+ Returns the NMEA data source.
+*/
+QIODevice *QNmeaPositionInfoSource::device() const
+{
+ return d->m_device;
+}
+
+/*!
+ \reimp
+*/
+void QNmeaPositionInfoSource::setUpdateInterval(int msec)
+{
+ int interval = msec;
+ if (interval != 0)
+ interval = qMax(msec, minimumUpdateInterval());
+ QGeoPositionInfoSource::setUpdateInterval(interval);
+ if (d->m_invokedStart) {
+ d->stopUpdates();
+ d->startUpdates();
+ }
+}
+
+/*!
+ \reimp
+*/
+void QNmeaPositionInfoSource::startUpdates()
+{
+ d->startUpdates();
+}
+
+/*!
+ \reimp
+*/
+void QNmeaPositionInfoSource::stopUpdates()
+{
+ d->stopUpdates();
+}
+
+/*!
+ \reimp
+*/
+void QNmeaPositionInfoSource::requestUpdate(int msec)
+{
+ d->requestUpdate(msec == 0 ? 60000 * 5 : msec);
+}
+
+/*!
+ \reimp
+*/
+QGeoPositionInfo QNmeaPositionInfoSource::lastKnownPosition(bool) const
+{
+ // the bool value does not matter since we only use satellite positioning
+ return d->m_lastUpdate;
+}
+
+/*!
+ \reimp
+*/
+QGeoPositionInfoSource::PositioningMethods QNmeaPositionInfoSource::supportedPositioningMethods() const
+{
+ return SatellitePositioningMethods;
+}
+
+/*!
+ \reimp
+*/
+int QNmeaPositionInfoSource::minimumUpdateInterval() const
+{
+ return 100;
+}
+
+#include "moc_qnmeapositioninfosource.cpp"
+#include "moc_qnmeapositioninfosource_p.cpp"
+
+QTM_END_NAMESPACE
diff --git a/src/location/qnmeapositioninfosource.h b/src/location/qnmeapositioninfosource.h
new file mode 100644
index 00000000..bad84719
--- /dev/null
+++ b/src/location/qnmeapositioninfosource.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QNMEAPOSITIONINFOSOURCE_H
+#define QNMEAPOSITIONINFOSOURCE_H
+
+#include "qmobilityglobal.h"
+#include "qgeopositioninfosource.h"
+
+QT_BEGIN_NAMESPACE
+class QIODevice;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QNmeaPositionInfoSourcePrivate;
+class Q_LOCATION_EXPORT QNmeaPositionInfoSource : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+public:
+ enum UpdateMode {
+ RealTimeMode = 1,
+ SimulationMode
+ };
+
+ explicit QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent = 0);
+ ~QNmeaPositionInfoSource();
+
+ UpdateMode updateMode() const;
+
+ void setDevice(QIODevice *source);
+ QIODevice *device() const;
+
+ void setUpdateInterval(int msec);
+
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
+ int minimumUpdateInterval() const;
+
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 0);
+
+protected:
+ virtual bool parsePosInfoFromNmeaData(const char *data,
+ int size,
+ QGeoPositionInfo *posInfo,
+ bool *hasFix);
+
+private:
+ Q_DISABLE_COPY(QNmeaPositionInfoSource)
+ friend class QNmeaPositionInfoSourcePrivate;
+ QNmeaPositionInfoSourcePrivate *d;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/qnmeapositioninfosource_p.h b/src/location/qnmeapositioninfosource_p.h
new file mode 100644
index 00000000..f69ff868
--- /dev/null
+++ b/src/location/qnmeapositioninfosource_p.h
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QNMEAPOSITIONINFOSOURCE_P_H
+#define QNMEAPOSITIONINFOSOURCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qnmeapositioninfosource.h"
+#include "qgeopositioninfo.h"
+
+#include <QObject>
+#include <QQueue>
+#include <QPointer>
+
+QT_BEGIN_NAMESPACE
+class QBasicTimer;
+class QTimerEvent;
+class QTimer;
+QT_END_NAMESPACE
+
+QT_BEGIN_HEADER
+
+QTM_BEGIN_NAMESPACE
+
+class QNmeaReader;
+struct QPendingGeoPositionInfo {
+ QGeoPositionInfo info;
+ bool hasFix;
+};
+
+
+class QNmeaPositionInfoSourcePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QNmeaPositionInfoSourcePrivate(QNmeaPositionInfoSource *parent);
+ ~QNmeaPositionInfoSourcePrivate();
+
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int msec);
+
+ bool parsePosInfoFromNmeaData(const char *data,
+ int size,
+ QGeoPositionInfo *posInfo,
+ bool *hasFix);
+
+ void notifyNewUpdate(QGeoPositionInfo *update, bool fixStatus);
+
+ QNmeaPositionInfoSource::UpdateMode m_updateMode;
+ QPointer<QIODevice> m_device;
+ QGeoPositionInfo m_lastUpdate;
+ bool m_invokedStart;
+
+public Q_SLOTS:
+ void readyRead();
+
+protected:
+ void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void emitPendingUpdate();
+ void sourceDataClosed();
+ void updateRequestTimeout();
+
+private:
+ bool openSourceDevice();
+ bool initialize();
+ void prepareSourceDevice();
+ void emitUpdated(const QGeoPositionInfo &update);
+
+ QNmeaPositionInfoSource *m_source;
+ QNmeaReader *m_nmeaReader;
+ QBasicTimer *m_updateTimer;
+ QGeoPositionInfo m_pendingUpdate;
+ QDate m_currentDate;
+ QTimer *m_requestTimer;
+ bool m_noUpdateLastInterval;
+ bool m_updateTimeoutSent;
+ bool m_connectedReadyRead;
+};
+
+
+class QNmeaReader
+{
+public:
+ explicit QNmeaReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
+ : m_proxy(sourcePrivate) {}
+ virtual ~QNmeaReader() {}
+
+ virtual void readAvailableData() = 0;
+
+protected:
+ QNmeaPositionInfoSourcePrivate *m_proxy;
+};
+
+
+class QNmeaRealTimeReader : public QNmeaReader
+{
+public:
+ explicit QNmeaRealTimeReader(QNmeaPositionInfoSourcePrivate *sourcePrivate);
+ virtual void readAvailableData();
+};
+
+
+class QNmeaSimulatedReader : public QObject, public QNmeaReader
+{
+ Q_OBJECT
+public:
+ explicit QNmeaSimulatedReader(QNmeaPositionInfoSourcePrivate *sourcePrivate);
+ ~QNmeaSimulatedReader();
+ virtual void readAvailableData();
+
+protected:
+ virtual void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void simulatePendingUpdate();
+
+private:
+ bool setFirstDateTime();
+ void processNextSentence();
+
+ QQueue<QPendingGeoPositionInfo> m_pendingUpdates;
+ int m_currTimerId;
+ bool m_hasValidDateTime;
+};
+
+QTM_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif