summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/location/common/imports/QtLocation/examples/components/Slider.qml1
-rw-r--r--examples/location/mapviewer/content/map/ImageItem.qml2
-rw-r--r--examples/location/mapviewer/content/map/MapComponent.qml14
-rw-r--r--examples/location/mapviewer/content/map/Marker.qml6
-rw-r--r--examples/location/mapviewer/content/map/MiniMap.qml3
-rw-r--r--examples/location/mapviewer/content/map/PolygonItem.qml2
-rw-r--r--examples/location/mapviewer/content/map/RectangleItem.qml2
-rw-r--r--examples/location/places/content/places/SearchResultView.qml2
-rw-r--r--examples/location/places/places.qml17
-rw-r--r--examples/positioning/positioning.pro2
-rw-r--r--examples/positioning/satelliteinfo/main.cpp66
-rw-r--r--examples/positioning/satelliteinfo/satelliteinfo.pro22
-rw-r--r--examples/positioning/satelliteinfo/satelliteinfo.qml304
-rw-r--r--examples/positioning/satelliteinfo/satelliteinfo.qrc5
-rw-r--r--examples/positioning/satelliteinfo/satellitemodel.cpp309
-rw-r--r--examples/positioning/satelliteinfo/satellitemodel.h124
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp49
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h1
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp69
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h19
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp62
-rw-r--r--src/imports/location/location.cpp5
-rw-r--r--src/imports/location/location.pro4
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp55
-rw-r--r--src/imports/location/qdeclarativecirclemapitem_p.h6
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp349
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h23
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp169
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea_p.h44
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp43
-rw-r--r--src/imports/location/qdeclarativegeomapitembase_p.h3
-rw-r--r--src/imports/location/qdeclarativegeomapitemview.cpp1
-rw-r--r--src/imports/location/qdeclarativegeomapmousearea.cpp492
-rw-r--r--src/imports/location/qdeclarativegeomapmouseevent.cpp250
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp69
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem_p.h6
-rw-r--r--src/imports/location/qdeclarativegeomaptype.cpp4
-rw-r--r--src/imports/location/qdeclarativegeomaptype_p.h2
-rw-r--r--src/imports/location/qdeclarativegeoroute.cpp4
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel.cpp75
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel_p.h6
-rw-r--r--src/imports/location/qdeclarativegeoserviceprovider.cpp4
-rw-r--r--src/imports/location/qdeclarativegeoserviceprovider_p.h2
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp87
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem_p.h6
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp137
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem_p.h7
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp37
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem_p.h6
-rw-r--r--src/imports/location/qdeclarativeroutemapitem.cpp6
-rw-r--r--src/imports/location/qdeclarativeroutemapitem_p.h1
-rw-r--r--src/imports/location/qgeomapitemgeometry.cpp7
-rw-r--r--src/imports/positioning/locationsingleton.cpp18
-rw-r--r--src/imports/positioning/locationsingleton.h2
-rw-r--r--src/imports/positioning/plugins.qmltypes15
-rw-r--r--src/imports/positioning/positioning.cpp10
-rw-r--r--src/imports/positioning/positioning.pro6
-rw-r--r--src/imports/positioning/qdeclarativegeocoordinateanimation.cpp120
-rw-r--r--src/imports/positioning/qdeclarativegeocoordinateanimation_p.h (renamed from src/imports/location/qdeclarativegeomapmousearea_p.h)57
-rw-r--r--src/imports/positioning/qdeclarativeposition.cpp315
-rw-r--r--src/imports/positioning/qdeclarativeposition_p.h55
-rw-r--r--src/imports/positioning/qdeclarativepositionsource.cpp15
-rw-r--r--src/location/doc/snippets/declarative/declarative.pro3
-rw-r--r--src/location/doc/snippets/places/requesthandler.h14
-rw-r--r--src/location/doc/src/maps.qdoc15
-rw-r--r--src/location/doc/src/places.qdoc2
-rw-r--r--src/location/doc/src/plugins/nokia.qdoc7
-rw-r--r--src/location/doc/src/plugins/osm.qdoc3
-rw-r--r--src/location/doc/src/qml-maps.qdoc4
-rw-r--r--src/location/location.pro4
-rw-r--r--src/location/maps/maps.pri8
-rw-r--r--src/location/maps/qgeocameradata.cpp47
-rw-r--r--src/location/maps/qgeocameradata_p.h8
-rw-r--r--src/location/maps/qgeocameratiles.cpp10
-rw-r--r--src/location/maps/qgeocodingmanagerengine.cpp2
-rw-r--r--src/location/maps/qgeocodingmanagerengine.h2
-rw-r--r--src/location/maps/qgeomap.cpp11
-rw-r--r--src/location/maps/qgeomap_p.h6
-rw-r--r--src/location/maps/qgeomapcontroller.cpp78
-rw-r--r--src/location/maps/qgeomapcontroller_p.h31
-rw-r--r--src/location/maps/qgeomapdata.cpp34
-rw-r--r--src/location/maps/qgeomapdata_p.h12
-rw-r--r--src/location/maps/qgeomapdata_p_p.h11
-rw-r--r--src/location/maps/qgeomappingmanagerengine_p.h2
-rw-r--r--src/location/maps/qgeomapscene.cpp42
-rw-r--r--src/location/maps/qgeomapscene_p.h5
-rw-r--r--src/location/maps/qgeomaptype_p.h2
-rw-r--r--src/location/maps/qgeoroutereply.cpp8
-rw-r--r--src/location/maps/qgeoroutereply.h1
-rw-r--r--src/location/maps/qgeorouterequest.cpp5
-rw-r--r--src/location/maps/qgeoroutingmanager.cpp27
-rw-r--r--src/location/maps/qgeoroutingmanager.h10
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.cpp32
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.h12
-rw-r--r--src/location/maps/qgeoroutingmanagerengine_p.h1
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp2
-rw-r--r--src/location/maps/qgeoserviceprovider_p.h4
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.cpp8
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.h8
-rw-r--r--src/location/maps/qgeotilecache.cpp12
-rw-r--r--src/location/maps/qgeotiledmapdata.cpp77
-rw-r--r--src/location/maps/qgeotiledmapdata_p.h6
-rw-r--r--src/location/maps/qgeotiledmapdata_p_p.h10
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp35
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine_p_p.h3
-rw-r--r--src/location/maps/qgeotilefetcher.cpp106
-rw-r--r--src/location/maps/qgeotilefetcher_p.h7
-rw-r--r--src/location/maps/qgeotilefetcher_p_p.h9
-rw-r--r--src/location/places/qplacecontentreply.cpp42
-rw-r--r--src/location/places/qplacecontentreply.h5
-rw-r--r--src/location/places/qplacecontentrequest.cpp74
-rw-r--r--src/location/places/qplacecontentrequest.h8
-rw-r--r--src/location/places/qplacecontentrequest_p.h6
-rw-r--r--src/location/places/qplacemanager.cpp7
-rw-r--r--src/location/places/qplacemanager.h2
-rw-r--r--src/location/places/qplacemanagerengine.cpp9
-rw-r--r--src/location/places/qplacemanagerengine.h5
-rw-r--r--src/location/places/qplacesearchreply.cpp62
-rw-r--r--src/location/places/qplacesearchreply.h9
-rw-r--r--src/location/places/qplacesearchrequest.cpp28
-rw-r--r--src/location/places/qplacesearchrequest.h2
-rw-r--r--src/plugins/geoservices/nokia/logo.pngbin884 -> 1217 bytes
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro2
-rw-r--r--src/plugins/geoservices/nokia/nokia_plugin.json2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp11
-rw-r--r--src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp35
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp6
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp18
-rw-r--r--src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.h2
-rw-r--r--src/plugins/geoservices/nokia/qgeoerror_messages.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.cpp4
-rw-r--r--src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.h4
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp77
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutereply_nokia.h4
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp157
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h9
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp35
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp121
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h12
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp146
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h14
-rw-r--r--src/plugins/geoservices/nokia/qgeouriprovider.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeouriprovider.h2
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp104
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h4
-rw-r--r--src/plugins/geoservices/nokia/uri_constants.cpp6
-rw-r--r--src/plugins/geoservices/nokia/uri_constants.h2
-rw-r--r--src/plugins/geoservices/osm/osm.pro2
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.cpp3
-rw-r--r--src/plugins/geoservices/osm/qgeoroutereplyosm.cpp145
-rw-r--r--src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp4
-rw-r--r--src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h2
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp1
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.cpp11
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.h2
-rw-r--r--src/plugins/position/android/android.pro2
-rw-r--r--src/plugins/position/android/jar/AndroidManifest.xml6
-rw-r--r--src/plugins/position/android/jar/bundledjar.pro3
-rw-r--r--src/plugins/position/android/jar/distributedjar.pro3
-rw-r--r--src/plugins/position/android/jar/jar.pri14
-rw-r--r--src/plugins/position/android/jar/jar.pro2
-rw-r--r--src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java543
-rw-r--r--src/plugins/position/android/src/jnipositioning.cpp568
-rw-r--r--src/plugins/position/android/src/jnipositioning.h65
-rw-r--r--src/plugins/position/android/src/plugin.json8
-rw-r--r--src/plugins/position/android/src/positionfactory_android.cpp62
-rw-r--r--src/plugins/position/android/src/positionfactory_android.h (renamed from src/location/maps/qgeocoordinateinterpolator_p.h)39
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android.cpp263
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android_p.h87
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp218
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h88
-rw-r--r--src/plugins/position/android/src/src.pro20
-rw-r--r--src/plugins/position/corelocation/corelocation.pro23
-rw-r--r--src/plugins/position/corelocation/plugin.json8
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl.mm241
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h (renamed from src/imports/location/qdeclarativegeomapmouseevent_p.h)82
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h60
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm60
-rw-r--r--src/plugins/position/geoclue/qgeocluemaster.cpp3
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp7
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h1
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp14
-rw-r--r--src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.cpp7
-rw-r--r--src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.h2
-rw-r--r--src/plugins/position/position.pro2
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.cpp6
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.h2
-rw-r--r--src/positioning/doc/images/example-satelliteinfo.pngbin0 -> 27371 bytes
-rw-r--r--src/positioning/doc/snippets/cpp/cppqml.cpp10
-rw-r--r--src/positioning/doc/snippets/snippets.pro2
-rw-r--r--src/positioning/doc/src/examples/satelliteinfo.qdoc73
-rw-r--r--src/positioning/doc/src/qtpositioning.qdoc1
-rw-r--r--src/positioning/positioning.pro22
-rw-r--r--src/positioning/qdoublevector2d.cpp (renamed from src/location/maps/qdoublevector2d.cpp)17
-rw-r--r--src/positioning/qdoublevector2d_p.h (renamed from src/location/maps/qdoublevector2d_p.h)110
-rw-r--r--src/positioning/qdoublevector3d.cpp (renamed from src/location/maps/qdoublevector3d.cpp)45
-rw-r--r--src/positioning/qdoublevector3d_p.h (renamed from src/location/maps/qdoublevector3d_p.h)137
-rw-r--r--src/positioning/qgeocircle.cpp13
-rw-r--r--src/positioning/qgeocircle_p.h2
-rw-r--r--src/positioning/qgeoprojection.cpp (renamed from src/location/maps/qgeoprojection.cpp)36
-rw-r--r--src/positioning/qgeoprojection_p.h (renamed from src/location/maps/qgeoprojection_p.h)5
-rw-r--r--src/positioning/qgeorectangle.cpp67
-rw-r--r--src/positioning/qgeorectangle.h1
-rw-r--r--src/positioning/qgeorectangle_p.h2
-rw-r--r--src/positioning/qgeoshape.cpp11
-rw-r--r--src/positioning/qgeoshape.h2
-rw-r--r--src/positioning/qgeoshape_p.h2
-rw-r--r--src/positioning/qlocationutils.cpp54
-rw-r--r--src/positioning/qlocationutils_p.h4
-rw-r--r--src/positioning/qnmeapositioninfosource.cpp65
-rw-r--r--src/positioning/qnmeapositioninfosource.h3
-rw-r--r--src/positioning/qnmeapositioninfosource_p.h3
-rw-r--r--src/positioning/qpositioningglobal.h8
-rw-r--r--src/src.pro27
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/declarative_core/tst_editorialmodel.qml13
-rw-r--r--tests/auto/declarative_core/tst_imagemodel.qml13
-rw-r--r--tests/auto/declarative_core/tst_placesearchmodel.qml1
-rw-r--r--tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml3
-rw-r--r--tests/auto/declarative_core/tst_position.qml10
-rw-r--r--tests/auto/declarative_core/tst_positionsource.qml20
-rw-r--r--tests/auto/declarative_core/tst_reviewmodel.qml13
-rw-r--r--tests/auto/declarative_core/tst_supplier.qml1
-rw-r--r--tests/auto/declarative_core/utils.js38
-rw-r--r--tests/auto/declarative_geoshape/declarative_geoshape.pro14
-rw-r--r--tests/auto/declarative_geoshape/main.cpp (renamed from src/location/maps/qgeocoordinateinterpolator.cpp)12
-rw-r--r--tests/auto/declarative_geoshape/tst_locationsingleton.qml (renamed from tests/auto/declarative_core/tst_geoshape.qml)26
-rw-r--r--tests/auto/declarative_ui/tst_map.qml49
-rw-r--r--tests/auto/declarative_ui/tst_map_coordinateanimation.qml147
-rw-r--r--tests/auto/declarative_ui/tst_map_geocoding.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml92
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml41
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml70
-rw-r--r--tests/auto/declarative_ui/tst_map_mouse.qml68
-rw-r--r--tests/auto/declarative_ui/tst_map_pinch_and_flick.qml2
-rw-r--r--tests/auto/doublevectors/doublevectors.pro7
-rw-r--r--tests/auto/doublevectors/tst_doublevectors.cpp4
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro2
-rw-r--r--tests/auto/geotestplugin/qgeocodingmanagerengine_test.h2
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h2
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp10
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h8
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h2
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h44
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h37
-rw-r--r--tests/auto/nokia_services/places_semiauto/tst_places.cpp64
-rw-r--r--tests/auto/nokia_services/routing/optim-economic.xml402
-rw-r--r--tests/auto/nokia_services/routing/optim-scenic.xml402
-rw-r--r--tests/auto/nokia_services/routing/tst_routing.cpp8
-rw-r--r--tests/auto/placemanager_utils/placemanager_utils.cpp3
-rw-r--r--tests/auto/placemanager_utils/placemanager_utils.h7
-rw-r--r--tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp2
-rw-r--r--tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h2
-rw-r--r--tests/auto/positionplugin/plugin.cpp14
-rw-r--r--tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro2
-rw-r--r--tests/auto/qgeocameradata/qgeocameradata.pro2
-rw-r--r--tests/auto/qgeocameradata/tst_qgeocameradata.cpp24
-rw-r--r--tests/auto/qgeocameratiles/qgeocameratiles.pro2
-rw-r--r--tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp4
-rw-r--r--tests/auto/qgeocircle/tst_qgeocircle.cpp52
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h2
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp2
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h2
-rw-r--r--tests/auto/qgeomapcontroller/qgeomapcontroller.pro2
-rw-r--r--tests/auto/qgeomapcontroller/tst_qgeomapcontroller.cpp72
-rw-r--r--tests/auto/qgeomapscene/qgeomapscene.pro2
-rw-r--r--tests/auto/qgeomapscene/tst_qgeomapscene.cpp9
-rw-r--r--tests/auto/qgeorectangle/tst_qgeorectangle.cpp110
-rw-r--r--tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp1
-rw-r--r--tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp2
-rw-r--r--tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp18
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h2
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp5
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h2
-rw-r--r--tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp61
-rw-r--r--tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h2
-rw-r--r--tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp7
-rw-r--r--tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp2
-rw-r--r--tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp2
-rw-r--r--tests/auto/qplacesearchreply/tst_qplacesearchreply.cpp5
-rw-r--r--tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp4
-rw-r--r--tests/auto/utils/qlocationtestutils.cpp5
-rw-r--r--tests/auto/utils/qlocationtestutils_p.h1
287 files changed, 6827 insertions, 4038 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 104f7dba..efd0e68f 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += qt_example_installs
-MODULE_VERSION = 5.2.2
+MODULE_VERSION = 5.3.0
diff --git a/examples/location/common/imports/QtLocation/examples/components/Slider.qml b/examples/location/common/imports/QtLocation/examples/components/Slider.qml
index 1a337425..93fc8989 100644
--- a/examples/location/common/imports/QtLocation/examples/components/Slider.qml
+++ b/examples/location/common/imports/QtLocation/examples/components/Slider.qml
@@ -117,6 +117,7 @@ Item {
hoverEnabled: false
anchors.fill: parent; drag.target: parent
drag.axis: Drag.XAxis; drag.minimumX: 0; drag.maximumX: slider.length
+ preventStealing: true
onPositionChanged: { slider.value = (slider.maximum - slider.minimum) * handle.x / slider.length + slider.minimum; }
}
}
diff --git a/examples/location/mapviewer/content/map/ImageItem.qml b/examples/location/mapviewer/content/map/ImageItem.qml
index a7146fbf..81e9f1c1 100644
--- a/examples/location/mapviewer/content/map/ImageItem.qml
+++ b/examples/location/mapviewer/content/map/ImageItem.qml
@@ -43,7 +43,7 @@ import QtLocation 5.0
MapQuickItem { //to be used inside MapComponent only
id: imageItem
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
diff --git a/examples/location/mapviewer/content/map/MapComponent.qml b/examples/location/mapviewer/content/map/MapComponent.qml
index e51373a7..505c795a 100644
--- a/examples/location/mapviewer/content/map/MapComponent.qml
+++ b/examples/location/mapviewer/content/map/MapComponent.qml
@@ -298,7 +298,7 @@ Map {
smooth: true
opacity: 0.8
//! [routedelegate0]
- MapMouseArea {
+ MouseArea {
id: routeMouseArea
anchors.fill: parent
hoverEnabled: false
@@ -346,7 +346,7 @@ Map {
opacity: 0.6
center: locationData.coordinate
//! [pointdel0]
- MapMouseArea {
+ MouseArea {
anchors.fill:parent
id: circleMouseArea
hoverEnabled: false
@@ -365,7 +365,8 @@ Map {
Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold ||
Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) {
map.state = ""
- if (pressed) parent.radius = parent.center.distanceTo(mouseToCoordinate(mouse))
+ if (pressed) parent.radius = parent.center.distanceTo(
+ map.toCoordinate(Qt.point(mouse.x, mouse.y)))
}
if ((mouse.button == Qt.LeftButton) & (map.state == "")) {
map.lastX = mouse.x + parent.x
@@ -844,7 +845,7 @@ Map {
}
}
- MapMouseArea {
+ MouseArea {
id: mouseArea
property variant lastCoordinate
anchors.fill: parent
@@ -856,7 +857,7 @@ Map {
map.lastY = mouse.y
map.pressX = mouse.x
map.pressY = mouse.y
- lastCoordinate = mouseArea.mouseToCoordinate(mouse)
+ lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y))
// if (mouse.button == Qt.MiddleButton)
// addMarker()
}
@@ -879,7 +880,7 @@ Map {
}
onDoubleClicked: {
- map.center = mouseArea.mouseToCoordinate(mouse)
+ map.center = map.toCoordinate(Qt.point(mouse.x, mouse.y))
if (mouse.button == Qt.LeftButton){
map.zoomLevel += 1
} else if (mouse.button == Qt.RightButton) map.zoomLevel -= 1
@@ -970,6 +971,7 @@ Map {
var marker = Qt.createQmlObject ('Marker {}', map)
map.addMapItem(marker)
marker.z = map.z+1
+ marker.coordinate = mouseArea.lastCoordinate
//update list of markers
var myArray = new Array()
diff --git a/examples/location/mapviewer/content/map/Marker.qml b/examples/location/mapviewer/content/map/Marker.qml
index d7a1e838..0e9f1537 100644
--- a/examples/location/mapviewer/content/map/Marker.qml
+++ b/examples/location/mapviewer/content/map/Marker.qml
@@ -57,7 +57,7 @@ MapQuickItem {
id: image
//! [mqi-anchor]
source: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "../../resources/marker_selected.png" :"../../resources/marker_hovered.png") : "../../resources/marker.png"
- MapMouseArea {
+ MouseArea {
id: markerMouseArea
property int pressX : -1
property int pressY : -1
@@ -67,6 +67,7 @@ MapQuickItem {
anchors.fill: parent
hoverEnabled : false
drag.target: marker
+ preventStealing: true
onPressed : {
map.pressX = mouse.x
@@ -108,7 +109,8 @@ MapQuickItem {
}
//! [mqi-closeimage]
- Component.onCompleted: coordinate = mouseArea.lastCoordinate
+ Component.onCompleted: coordinate = map.toCoordinate(Qt.point(markerMouseArea.mouseX,
+ markerMouseArea.mouseY));
//! [mqi-close]
}
//! [mqi-close]
diff --git a/examples/location/mapviewer/content/map/MiniMap.qml b/examples/location/mapviewer/content/map/MiniMap.qml
index e5d03e49..5bee404c 100644
--- a/examples/location/mapviewer/content/map/MiniMap.qml
+++ b/examples/location/mapviewer/content/map/MiniMap.qml
@@ -62,9 +62,6 @@ Rectangle{
center: map.center
plugin: map.plugin
gesture.enabled: false
- MapMouseArea{
- anchors.fill: parent
- }
MapRectangle {
color: "#44ff0000"
diff --git a/examples/location/mapviewer/content/map/PolygonItem.qml b/examples/location/mapviewer/content/map/PolygonItem.qml
index b6e41ea6..9b52bbca 100644
--- a/examples/location/mapviewer/content/map/PolygonItem.qml
+++ b/examples/location/mapviewer/content/map/PolygonItem.qml
@@ -55,7 +55,7 @@ MapPolygon {
addCoordinate(markers[i].coordinate)
}
}
- MapMouseArea {
+ MouseArea {
anchors.fill:parent
id: mousearea
drag.target: parent
diff --git a/examples/location/mapviewer/content/map/RectangleItem.qml b/examples/location/mapviewer/content/map/RectangleItem.qml
index 97896883..1b58f468 100644
--- a/examples/location/mapviewer/content/map/RectangleItem.qml
+++ b/examples/location/mapviewer/content/map/RectangleItem.qml
@@ -65,7 +65,7 @@ MapRectangle {
(bottomRight.longitude == 153.3021))
}
- MapMouseArea {
+ MouseArea {
anchors.fill:parent
id: mousearea
hoverEnabled: false
diff --git a/examples/location/places/content/places/SearchResultView.qml b/examples/location/places/content/places/SearchResultView.qml
index b9d48776..da62a5c5 100644
--- a/examples/location/places/content/places/SearchResultView.qml
+++ b/examples/location/places/content/places/SearchResultView.qml
@@ -97,6 +97,7 @@ Item {
Button {
text: qsTr("Previous")
+ enabled: placeSearchModel.previousPagesAvailable
onClicked: placeSearchModel.previousPage()
anchors.left: parent.left
@@ -111,6 +112,7 @@ Item {
Button {
text: qsTr("Next")
+ enabled: placeSearchModel.nextPagesAvailable
onClicked: placeSearchModel.nextPage()
anchors.right: parent.right
diff --git a/examples/location/places/places.qml b/examples/location/places/places.qml
index 6b4b32dd..4a144d55 100644
--- a/examples/location/places/places.qml
+++ b/examples/location/places/places.qml
@@ -366,7 +366,6 @@ Item {
recommendationId = "";
searchArea = searchRegion
limit = -1;
- offset = 0;
update();
}
@@ -376,7 +375,6 @@ Item {
recommendationId = "";
searchArea = searchRegion
limit = -1;
- offset = 0;
update();
}
@@ -386,21 +384,6 @@ Item {
recommendationId = placeId;
searchArea = null;
limit = -1;
- offset = 0;
- update();
- }
-
- function previousPage() {
- if (limit === -1)
- limit = count;
- offset = Math.max(0, offset - limit);
- update();
- }
-
- function nextPage() {
- if (limit === -1)
- limit = count;
- offset += limit;
update();
}
diff --git a/examples/positioning/positioning.pro b/examples/positioning/positioning.pro
index 468ff9eb..2f40d326 100644
--- a/examples/positioning/positioning.pro
+++ b/examples/positioning/positioning.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
qtHaveModule(widgets): SUBDIRS += logfilepositionsource
-qtHaveModule(quick): SUBDIRS += flickr weatherinfo
+qtHaveModule(quick): SUBDIRS += flickr weatherinfo satelliteinfo
diff --git a/examples/positioning/satelliteinfo/main.cpp b/examples/positioning/satelliteinfo/main.cpp
new file mode 100644
index 00000000..328b69d7
--- /dev/null
+++ b/examples/positioning/satelliteinfo/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/qqml.h>
+#include <QtQml/QQmlEngine>
+#include <QtQuick/QQuickView>
+#include "satellitemodel.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ qmlRegisterType<SatelliteModel>("Local", 1, 0, "SatelliteModel");
+
+ QQuickView view;
+ view.setSource(QStringLiteral("qrc:///satelliteinfo.qml"));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+
+ QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+#if defined(Q_OS_QNX)
+ view.showFullScreen();
+#else
+ view.show();
+#endif
+
+ return app.exec();
+}
+
+
diff --git a/examples/positioning/satelliteinfo/satelliteinfo.pro b/examples/positioning/satelliteinfo/satelliteinfo.pro
new file mode 100644
index 00000000..fe4f728e
--- /dev/null
+++ b/examples/positioning/satelliteinfo/satelliteinfo.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+TARGET = satelliteinfo
+
+QT += quick positioning
+
+SOURCES += main.cpp \
+ satellitemodel.cpp
+
+HEADERS += \
+ satellitemodel.h
+
+OTHER_FILES += \
+ satelliteinfo.qml
+
+RESOURCES += \
+ satelliteinfo.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtpositioning/satelliteinfo
+INSTALLS += target
+
+
+
diff --git a/examples/positioning/satelliteinfo/satelliteinfo.qml b/examples/positioning/satelliteinfo/satelliteinfo.qml
new file mode 100644
index 00000000..f3fc5a78
--- /dev/null
+++ b/examples/positioning/satelliteinfo/satelliteinfo.qml
@@ -0,0 +1,304 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Local 1.0
+
+Rectangle {
+ id: page
+ width: 360
+ height: 360
+
+ SatelliteModel {
+ id: satelliteModel
+ running: true
+ onErrorFound: errorLabel.text = qsTr("Last Error: %1", "%1=error number").arg(code)
+ }
+
+ Item {
+ id: header
+ height: column.height + 30
+ width: parent.width
+ state: "running"
+
+ anchors.top: parent.top
+
+ function toggle()
+ {
+ switch (header.state) {
+ case "single": header.state = "running"; break;
+ default:
+ case "running": header.state = "stopped"; break;
+ case "stopped": header.state = "single"; break;
+ }
+ }
+
+ function enterSingle()
+ {
+ satelliteModel.singleRequestMode = true;
+ satelliteModel.running = true;
+ }
+
+ function enterRunning()
+ {
+ satelliteModel.running = false;
+ satelliteModel.singleRequestMode = false;
+ satelliteModel.running = true;
+ }
+
+ states: [
+ State {
+ name: "stopped"
+ PropertyChanges { target: startStop; bText: qsTr("Single") }
+ PropertyChanges {
+ target: modeLabel; text: qsTr("Current Mode: stopped")
+ }
+ PropertyChanges { target: satelliteModel; running: false; }
+ },
+ State {
+ name: "single"
+ PropertyChanges { target: startStop; bText: qsTr("Start") }
+ PropertyChanges {
+ target: modeLabel; text: qsTr("Current Mode: single")
+ }
+ StateChangeScript { script: header.enterSingle(); }
+ },
+ State {
+ name: "running"
+ PropertyChanges { target: startStop; bText: qsTr("Stop") }
+ PropertyChanges {
+ target: modeLabel; text: qsTr("Current Mode: running")
+ }
+ StateChangeScript { script: header.enterRunning(); }
+ }
+ ]
+
+ Column {
+ id: column
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.margins: 7
+ Text {
+ id: overview
+ text: satelliteModel.satelliteInfoAvailable
+ ? qsTr("Known Satellites")
+ : qsTr("Known Satellites (Demo Mode)")
+ font.pointSize: 12
+ }
+
+ Text {
+ id: modeLabel
+ font.pointSize: 12
+ }
+
+ Text {
+ id: errorLabel
+ text: qsTr("Last Error: None")
+ font.pointSize: 12
+ }
+ }
+ Rectangle {
+ id: startStop
+ border.color: "black"
+ border.width: 3
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.margins: 7
+ radius: 10
+ height: maxField.height*1.4
+ width: maxField.width*1.4
+
+ property string bText: qsTr("Stop");
+
+ Text { //need this for sizing
+ id: maxField
+ text: qsTr("Single")
+ font.pointSize: 13
+ opacity: 0
+ }
+
+ Text {
+ id: buttonText
+ anchors.centerIn: parent
+ text: startStop.bText
+ font.pointSize: 13
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: { startStop.color = "lightGray" }
+ onClicked: { header.toggle() }
+ onReleased: { startStop.color = "white" }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.top: header.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: rect.myMargin
+ border.width: 3
+ radius: 10
+ border.color: "black"
+
+ Item {
+ id: rect
+ anchors.fill: parent
+ anchors.margins: myMargin
+ property int myMargin: 7
+
+ Row {
+ id: view
+ property int rows: repeater.model.entryCount
+ property int singleWidth: ((rect.width - scale.width)/rows )-rect.myMargin
+ spacing: rect.myMargin
+
+ Rectangle {
+ id: scale
+ width: strengthLabel.width+10
+ height: rect.height
+ color: "#32cd32"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: lawngreenRect.top
+ font.pointSize: 11
+ text: "50"
+ }
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: parent.top
+ font.pointSize: 11
+ text: "100"
+ }
+
+ Rectangle {
+ id: redRect
+ width: parent.width
+ color: "red"
+ height: parent.height*10/100
+ anchors.bottom: parent.bottom
+ Text {
+ id: strengthLabel
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ font.pointSize: 11
+ text: "00"
+ }
+ }
+ Rectangle {
+ id: orangeRect
+ height: parent.height*10/100
+ anchors.bottom: redRect.top
+ width: parent.width
+ color: "#ffa500"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ font.pointSize: 11
+ text: "10"
+ }
+ }
+ Rectangle {
+ id: goldRect
+ height: parent.height*10/100
+ anchors.bottom: orangeRect.top
+ width: parent.width
+ color: "#ffd700"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ font.pointSize: 11
+ text: "20"
+ }
+ }
+ Rectangle {
+ id: yellowRect
+ height: parent.height*10/100
+ anchors.bottom: goldRect.top
+ width: parent.width
+ color: "yellow"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ font.pointSize: 11
+ text: "30"
+ }
+ }
+ Rectangle {
+ id: lawngreenRect
+ height: parent.height*10/100
+ anchors.bottom: yellowRect.top
+ width: parent.width
+ color: "#7cFc00"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ font.pointSize: 11
+ text: "40"
+ }
+ }
+ }
+
+ Repeater {
+ id: repeater
+ model: satelliteModel
+ delegate: Rectangle {
+ height: rect.height
+ width: view.singleWidth
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: parent.height*signalStrength/100
+ color: isInUse ? "#7FFF0000" : "#7F0000FF"
+ }
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ text: satelliteIdentifier
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/positioning/satelliteinfo/satelliteinfo.qrc b/examples/positioning/satelliteinfo/satelliteinfo.qrc
new file mode 100644
index 00000000..8745f87e
--- /dev/null
+++ b/examples/positioning/satelliteinfo/satelliteinfo.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>satelliteinfo.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/positioning/satelliteinfo/satellitemodel.cpp b/examples/positioning/satelliteinfo/satellitemodel.cpp
new file mode 100644
index 00000000..d8c45ccb
--- /dev/null
+++ b/examples/positioning/satelliteinfo/satellitemodel.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "satellitemodel.h"
+#include <QTimer>
+#include <QDebug>
+
+SatelliteModel::SatelliteModel(QObject *parent) :
+ QAbstractListModel(parent), source(0), m_componentCompleted(false), m_running(false),
+ m_runningRequested(false), demo(false), isSingle(false), singleRequestServed(false)
+{
+ source = QGeoSatelliteInfoSource::createDefaultSource(this);
+ if (!demo && !source) {
+ qWarning() << "No satellite data source found. Changing to demo mode.";
+ demo = true;
+ }
+ if (!demo) {
+ source->setUpdateInterval(3000);
+ connect(source, SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)),
+ this, SLOT(satellitesInViewUpdated(QList<QGeoSatelliteInfo>)));
+ connect(source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>)),
+ this, SLOT(satellitesInUseUpdated(QList<QGeoSatelliteInfo>)));
+ connect(source, SIGNAL(error(QGeoSatelliteInfoSource::Error)),
+ this, SLOT(error(QGeoSatelliteInfoSource::Error)));
+ }
+
+ if (demo) {
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(updateDemoData()));
+ timer->start(3000);
+ }
+}
+
+int SatelliteModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ if (!source && !demo)
+ return 0;
+
+ return knownSatellites.count();
+}
+
+QVariant SatelliteModel::data(const QModelIndex &index, int role) const
+{
+ if (!demo && !source)
+ return QVariant();
+
+ if (!index.isValid() || index.row() < 0)
+ return QVariant();
+
+ if (index.row() >= knownSatellites.count()) {
+ qWarning() << "SatelliteModel: Index out of bound";
+ return QVariant();
+ }
+
+ const QGeoSatelliteInfo &info = knownSatellites.at(index.row());
+ switch (role) {
+ case IdentifierRole:
+ return info.satelliteIdentifier();
+ case InUseRole:
+ return satellitesInUse.contains(info.satelliteIdentifier());
+ case SignalStrengthRole:
+ return info.signalStrength();
+ case ElevationRole:
+ if (!info.hasAttribute(QGeoSatelliteInfo::Elevation))
+ return QVariant();
+ return info.attribute(QGeoSatelliteInfo::Elevation);
+ case AzimuthRole:
+ if (!info.hasAttribute(QGeoSatelliteInfo::Azimuth))
+ return QVariant();
+ return info.attribute(QGeoSatelliteInfo::Azimuth);
+ default:
+ break;
+
+ }
+
+ return QVariant();
+}
+
+QHash<int, QByteArray> SatelliteModel::roleNames() const
+{
+ QHash<int, QByteArray> roleNames;
+ roleNames.insert(IdentifierRole, "satelliteIdentifier");
+ roleNames.insert(InUseRole, "isInUse");
+ roleNames.insert(SignalStrengthRole, "signalStrength");
+ roleNames.insert(ElevationRole, "elevation");
+ roleNames.insert(AzimuthRole, "azimuth");
+ return roleNames;
+}
+
+void SatelliteModel::componentComplete()
+{
+ m_componentCompleted = true;
+ if (m_runningRequested)
+ setRunning(true);
+}
+
+bool SatelliteModel::running() const
+{
+ return m_running;
+}
+
+bool SatelliteModel::isSingleRequest() const
+{
+ return isSingle;
+}
+
+void SatelliteModel::setSingleRequest(bool single)
+{
+ if (running()) {
+ qWarning() << "Cannot change single request mode while running";
+ return;
+ }
+
+ if (single != isSingle) { //flag changed
+ isSingle = single;
+ emit singleRequestChanged();
+ }
+}
+
+void SatelliteModel::setRunning(bool isActive)
+{
+ if (!source && !demo)
+ return;
+
+ if (!m_componentCompleted) {
+ m_runningRequested = isActive;
+ return;
+ }
+
+ if (m_running == isActive)
+ return;
+
+ m_running = isActive;
+
+ if (m_running) {
+ clearModel();
+ if (demo)
+ timer->start(2000);
+ else if (isSingleRequest())
+ source->requestUpdate(10000);
+ else
+ source->startUpdates();
+
+ if (demo)
+ singleRequestServed = false;
+ } else {
+ if (demo)
+ timer->stop();
+ else if (!isSingleRequest())
+ source->stopUpdates();
+ }
+
+
+ Q_EMIT runningChanged();
+}
+
+int SatelliteModel::entryCount() const
+{
+ return knownSatellites.count();
+}
+
+bool SatelliteModel::canProvideSatelliteInfo() const
+{
+ return !demo;
+}
+
+void SatelliteModel::clearModel()
+{
+ beginResetModel();
+ knownSatelliteIds.clear();
+ knownSatellites.clear();
+ satellitesInUse.clear();
+ endResetModel();
+}
+
+void SatelliteModel::updateDemoData()
+{
+ static bool flag = true;
+ QList<QGeoSatelliteInfo> satellites;
+ if (flag) {
+ for (int i = 0; i<5; i++) {
+ QGeoSatelliteInfo info;
+ info.setSatelliteIdentifier(i);
+ info.setSignalStrength(20 + 20*i);
+ satellites.append(info);
+ }
+ } else {
+ for (int i = 0; i<9; i++) {
+ QGeoSatelliteInfo info;
+ info.setSatelliteIdentifier(i*2);
+ info.setSignalStrength(20 + 10*i);
+ satellites.append(info);
+ }
+ }
+
+
+ satellitesInViewUpdated(satellites);
+ flag ? satellitesInUseUpdated(QList<QGeoSatelliteInfo>() << satellites.at(2))
+ : satellitesInUseUpdated(QList<QGeoSatelliteInfo>() << satellites.at(3));
+ flag = !flag;
+
+ emit errorFound(flag);
+
+ if (isSingleRequest() && !singleRequestServed) {
+ singleRequestServed = true;
+ setRunning(false);
+ }
+}
+
+void SatelliteModel::error(QGeoSatelliteInfoSource::Error error)
+{
+ emit errorFound((int)error);
+}
+
+QT_BEGIN_NAMESPACE
+inline bool operator<(const QGeoSatelliteInfo& a, const QGeoSatelliteInfo& b)
+{
+ return a.satelliteIdentifier() < b.satelliteIdentifier();
+}
+QT_END_NAMESPACE
+
+void SatelliteModel::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &infos)
+{
+ if (!running())
+ return;
+
+ int oldEntryCount = knownSatellites.count();
+
+
+ QSet<int> satelliteIdsInUpdate;
+ foreach (const QGeoSatelliteInfo &info, infos)
+ satelliteIdsInUpdate.insert(info.satelliteIdentifier());
+
+ QSet<int> toBeRemoved = knownSatelliteIds - satelliteIdsInUpdate;
+
+ //We reset the model as in reality just about all entry values change
+ //and there are generally a lot of inserts and removals each time
+ //Hence we don't bother with complex model update logic beyond resetModel()
+ beginResetModel();
+
+ knownSatellites = infos;
+
+ //sort them for presentation purposes
+ std::sort(knownSatellites.begin(), knownSatellites.end());
+
+ //remove old "InUse" data
+ //new satellites are by default not in "InUse"
+ //existing satellites keep their "inUse" state
+ satellitesInUse -= toBeRemoved;
+
+ knownSatelliteIds = satelliteIdsInUpdate;
+ endResetModel();
+
+ if (oldEntryCount != knownSatellites.count())
+ emit entryCountChanged();
+}
+
+void SatelliteModel::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &infos)
+{
+ if (!running())
+ return;
+
+ beginResetModel();
+
+ satellitesInUse.clear();
+ foreach (const QGeoSatelliteInfo &info, infos)
+ satellitesInUse.insert(info.satelliteIdentifier());
+
+ endResetModel();
+}
+
diff --git a/examples/positioning/satelliteinfo/satellitemodel.h b/examples/positioning/satelliteinfo/satellitemodel.h
new file mode 100644
index 00000000..d7ce84e3
--- /dev/null
+++ b/examples/positioning/satelliteinfo/satellitemodel.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SATELLITEMODEL_H
+#define SATELLITEMODEL_H
+
+#include <QAbstractListModel>
+#include <QSet>
+#include <QtQml/qqml.h>
+#include <QtQml/QQmlParserStatus>
+#include <QtPositioning/QGeoSatelliteInfoSource>
+
+QT_FORWARD_DECLARE_CLASS(QTimer)
+QT_FORWARD_DECLARE_CLASS(QGeoSatelliteInfoSource)
+
+class SatelliteModel : public QAbstractListModel, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool satelliteInfoAvailable READ canProvideSatelliteInfo NOTIFY canProvideSatelliteInfoChanged)
+ Q_PROPERTY(int entryCount READ entryCount NOTIFY entryCountChanged)
+ Q_PROPERTY(bool singleRequestMode READ isSingleRequest WRITE setSingleRequest NOTIFY singleRequestChanged)
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ explicit SatelliteModel(QObject *parent = 0);
+
+ enum {
+ IdentifierRole = Qt::UserRole + 1,
+ InUseRole,
+ SignalStrengthRole,
+ ElevationRole,
+ AzimuthRole
+ };
+
+ //From QAbstractListModel
+ int rowCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QHash<int, QByteArray> roleNames() const;
+
+ //From QQmlParserStatus
+ void classBegin() {}
+ void componentComplete();
+
+ bool running() const;
+ void setRunning(bool isActive);
+
+ bool isSingleRequest() const;
+ void setSingleRequest(bool single);
+
+ int entryCount() const;
+
+ bool canProvideSatelliteInfo() const;
+
+signals:
+ void runningChanged();
+ void entryCountChanged();
+ void errorFound(int code);
+ void canProvideSatelliteInfoChanged();
+ void singleRequestChanged();
+
+public slots:
+ void clearModel();
+ void updateDemoData();
+
+private slots:
+ void error(QGeoSatelliteInfoSource::Error);
+ void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &infos);
+ void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &infos);
+
+private:
+ QGeoSatelliteInfoSource *source;
+ bool m_componentCompleted;
+ bool m_running;
+ bool m_runningRequested;
+ QList <QGeoSatelliteInfo> knownSatellites;
+ QSet<int> knownSatelliteIds;
+ QSet<int> satellitesInUse;
+ bool demo;
+ QTimer *timer;
+ bool isSingle;
+ bool singleRequestServed;
+
+};
+
+QML_DECLARE_TYPE(SatelliteModel)
+
+#endif // SATELLITEMODEL_H
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index 6f0ad05e..2308ba96 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -121,26 +121,6 @@ int QDeclarativePlaceContentModel::totalCount() const
/*!
\internal
-*/
-static QPair<int, int> findMissingKey(const QMap<int, QPlaceContent> &map)
-{
- int start = 0;
- while (map.contains(start))
- ++start;
-
- QMap<int, QPlaceContent>::const_iterator it = map.lowerBound(start);
- if (it == map.end())
- return qMakePair(start, -1);
-
- int end = start;
- while (!map.contains(end))
- ++end;
-
- return qMakePair(start, end - 1);
-}
-
-/*!
- \internal
Clears the model data but does not reset it.
*/
void QDeclarativePlaceContentModel::clearData()
@@ -160,6 +140,8 @@ void QDeclarativePlaceContentModel::clearData()
m_reply->deleteLater();
m_reply = 0;
}
+
+ m_nextRequest.clear();
}
/*!
@@ -288,22 +270,17 @@ void QDeclarativePlaceContentModel::fetchMore(const QModelIndex &parent)
if (!placeManager)
return;
- QPlaceContentRequest request;
- request.setContentType(m_type);
-
- if (m_contentCount == -1) {
- request.setOffset(0);
+ if (m_nextRequest == QPlaceContentRequest()) {
+ QPlaceContentRequest request;
+ request.setContentType(m_type);
+ request.setPlaceId(m_place->place().placeId());
request.setLimit(m_batchSize);
+
+ m_reply = placeManager->getPlaceContent(request);
} else {
- QPair<int, int> missing = findMissingKey(m_content);
- request.setOffset(missing.first);
- if (missing.second == -1)
- request.setLimit(m_batchSize);
- else
- request.setLimit(qMin(m_batchSize, missing.second - missing.first + 1));
+ m_reply = placeManager->getPlaceContent(m_nextRequest);
}
- m_reply = placeManager->getPlaceContent(m_place->place().placeId(), request);
connect(m_reply, SIGNAL(finished()), this, SLOT(fetchFinished()), Qt::QueuedConnection);
}
@@ -334,6 +311,8 @@ void QDeclarativePlaceContentModel::fetchFinished()
QPlaceContentReply *reply = m_reply;
m_reply = 0;
+ m_nextRequest = reply->nextPageRequest();
+
if (m_contentCount != reply->totalCount()) {
m_contentCount = reply->totalCount();
emit totalCountChanged();
@@ -409,6 +388,12 @@ void QDeclarativePlaceContentModel::fetchFinished()
startIndex = -1;
}
}
+
+ // The fetch didn't add any new content and we haven't fetched all content yet. This is
+ // likely due to the model being prepopulated by Place::getDetails(). Keep fetching more
+ // data until new content is available.
+ if (newIndexes.isEmpty() && m_content.count() != m_contentCount)
+ fetchMore(QModelIndex());
}
reply->deleteLater();
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
index 930726cb..b5a8a56d 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
@@ -120,6 +120,7 @@ private:
int m_contentCount;
QPlaceContentReply *m_reply;
+ QPlaceContentRequest m_nextRequest;
bool m_complete;
};
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
index b8275da5..d773c3b9 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
@@ -120,41 +120,37 @@ void QDeclarativeSearchModelBase::setSearchArea(const QVariant &searchArea)
/*!
\internal
*/
-int QDeclarativeSearchModelBase::offset() const
+int QDeclarativeSearchModelBase::limit() const
{
- return m_request.offset();
+ return m_request.limit();
}
/*!
\internal
*/
-void QDeclarativeSearchModelBase::setOffset(int offset)
+void QDeclarativeSearchModelBase::setLimit(int limit)
{
- if (m_request.offset() == offset)
+ if (m_request.limit() == limit)
return;
- m_request.setOffset(offset);
- emit offsetChanged();
+ m_request.setLimit(limit);
+ emit limitChanged();
}
/*!
\internal
*/
-int QDeclarativeSearchModelBase::limit() const
+bool QDeclarativeSearchModelBase::previousPagesAvailable() const
{
- return m_request.limit();
+ return m_previousPageRequest != QPlaceSearchRequest();
}
/*!
\internal
*/
-void QDeclarativeSearchModelBase::setLimit(int limit)
+bool QDeclarativeSearchModelBase::nextPagesAvailable() const
{
- if (m_request.limit() == limit)
- return;
-
- m_request.setLimit(limit);
- emit limitChanged();
+ return m_nextPageRequest != QPlaceSearchRequest();
}
/*!
@@ -263,6 +259,30 @@ QString QDeclarativeSearchModelBase::errorString() const
/*!
\internal
*/
+void QDeclarativeSearchModelBase::previousPage()
+{
+ if (m_previousPageRequest == QPlaceSearchRequest())
+ return;
+
+ m_request = m_previousPageRequest;
+ update();
+}
+
+/*!
+ \internal
+*/
+void QDeclarativeSearchModelBase::nextPage()
+{
+ if (m_nextPageRequest == QPlaceSearchRequest())
+ return;
+
+ m_request = m_nextPageRequest;
+ update();
+}
+
+/*!
+ \internal
+*/
void QDeclarativeSearchModelBase::clearData(bool suppressSignal)
{
Q_UNUSED(suppressSignal)
@@ -320,3 +340,24 @@ void QDeclarativeSearchModelBase::pluginNameChanged()
{
initializePlugin(m_plugin);
}
+
+/*!
+ \internal
+*/
+void QDeclarativeSearchModelBase::setPreviousPageRequest(const QPlaceSearchRequest &previous)
+{
+ if (m_previousPageRequest == previous)
+ return;
+
+ m_previousPageRequest = previous;
+ emit previousPagesAvailableChanged();
+}
+
+void QDeclarativeSearchModelBase::setNextPageRequest(const QPlaceSearchRequest &next)
+{
+ if (m_nextPageRequest == next)
+ return;
+
+ m_nextPageRequest = next;
+ emit nextPagesAvailableChanged();
+}
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h
index 5b3b831c..a9516407 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h
@@ -63,8 +63,9 @@ class QDeclarativeSearchModelBase : public QAbstractListModel, public QQmlParser
Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
Q_PROPERTY(QVariant searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged)
- Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
+ Q_PROPERTY(bool previousPagesAvailable READ previousPagesAvailable NOTIFY previousPagesAvailableChanged)
+ Q_PROPERTY(bool nextPagesAvailable READ nextPagesAvailable NOTIFY nextPagesAvailableChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_ENUMS(Status)
@@ -88,12 +89,12 @@ public:
QVariant searchArea() const;
void setSearchArea(const QVariant &searchArea);
- int offset() const;
- void setOffset(int offset);
-
int limit() const;
void setLimit(int limit);
+ bool previousPagesAvailable() const;
+ bool nextPagesAvailable() const;
+
Status status() const;
void setStatus(Status status, const QString &errorString = QString());
@@ -104,6 +105,9 @@ public:
Q_INVOKABLE QString errorString() const;
+ Q_INVOKABLE void previousPage();
+ Q_INVOKABLE void nextPage();
+
virtual void clearData(bool suppressSignal = false);
// From QQmlParserStatus
@@ -113,8 +117,9 @@ public:
Q_SIGNALS:
void pluginChanged();
void searchAreaChanged();
- void offsetChanged();
void limitChanged();
+ void previousPagesAvailableChanged();
+ void nextPagesAvailableChanged();
void statusChanged();
protected:
@@ -128,6 +133,8 @@ private Q_SLOTS:
protected:
virtual QPlaceReply *sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) = 0;
+ void setPreviousPageRequest(const QPlaceSearchRequest &previous);
+ void setNextPageRequest(const QPlaceSearchRequest &next);
QPlaceSearchRequest m_request;
QDeclarativeGeoServiceProvider *m_plugin;
@@ -137,6 +144,8 @@ private:
bool m_complete;
Status m_status;
QString m_errorString;
+ QPlaceSearchRequest m_previousPageRequest;
+ QPlaceSearchRequest m_nextPageRequest;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index d9492ca2..ed97e93e 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -157,18 +157,17 @@ QT_USE_NAMESPACE
\section1 Paging
The PlaceSearchModel API has some limited support
- for paging. The \l offset and \l limit properties can be used to access
- paged search results. When the \l offset and \l limit properties are set
- the search results between \l offset and (\l offset + \l limit - 1) will be
- returned. For example, if the backend has 5 search results in total
- [a,b,c,d,e], an offset of 0 specifies that the first item returned in the
- model will be 'a'. An offset of 1 secifies that the first item in the model
- will be 'b' and so on. The limit specifies the maximum number of items to
- be returned. For example, assuming an offset of 0 and limit of 3 then a,b,c is
- returned. If the offset exceeds (or equals) the total number of items, then
- 0 results are returned in the model. Note that the API currently does not
- support a means to retrieve the total number of items available from the
- backed. Also note that support for \l offset and \l limit can vary
+ for paging. The \l nextPage() and \l previousPage() functions as well as
+ the \l limit property can be used to access
+ paged search results. When the \l limit property is set
+ the search result page contains at most \l limit entries (of type place result).
+ For example, if the backend has 5 search results in total
+ [a,b,c,d,e], and assuming the first page is shown and limit of 3 has been set
+ then a,b,c is returned. The \l nextPage() would return d,e. The
+ \l nextPagesAvailable and \l previousPagesAvailable properties
+ can be used to check for further pages. At the moment the API does not
+ support the means to retrieve the total number of items available from the
+ backed. Note that support for \l nextPage(), previousPage() and \l limit can vary
according to the \l plugin.
*/
@@ -223,19 +222,25 @@ QT_USE_NAMESPACE
*/
/*!
- \qmlproperty int PlaceSearchModel::offset
+ \qmlproperty int PlaceSearchModel::limit
- This property holds the index of the first search result in the model.
+ This property holds the limit of the number of items that will be returned.
+*/
+
+/*!
+ \qmlproperty bool PlaceSearchModel::previousPagesAvailable
- \sa limit
+ This property holds whether there is one or more previous pages of search results available.
+
+ \sa previousPage()
*/
/*!
- \qmlproperty int PlaceSearchModel::limit
+ \qmlproperty bool PlaceSearchModel::nextPagesAvailable
- This property holds the limit of the number of items that will be returned.
+ This property holds whether there is one or more additional pages of search results available.
- \sa offset
+ \sa nextPage()
*/
/*!
@@ -264,8 +269,8 @@ QT_USE_NAMESPACE
Updates the model based on the provided query parameters. The model will be populated with a
list of places matching the search parameters specified by the type's properties. Search
- criteria is specified by setting properties such as the \l searchTerm, \l categories, \l limit
- and \l offset. Support for these properties may vary according to \l plugin. \c update() then
+ criteria is specified by setting properties such as the \l searchTerm, \l categories, \l searchArea and \l limit.
+ Support for these properties may vary according to \l plugin. \c update() then
submits the set of criteria to the \l plugin to process.
While the model is updating the \l status of the model is set to
@@ -325,6 +330,20 @@ QT_USE_NAMESPACE
textual representation.
*/
+/*!
+ \qmlmethod PlaceSearchModel::previousPage()
+
+ Updates the model to display the previous page of search results. If there is no previous page
+ then this method does nothing.
+*/
+
+/*!
+ \qmlmethod PlaceSearchModel::nextPage()
+
+ Updates the model to display the next page of search results. If there is no next page then
+ this method does nothing.
+*/
+
QDeclarativeSearchResultModel::QDeclarativeSearchResultModel(QObject *parent)
: QDeclarativeSearchModelBase(parent), m_favoritesPlugin(0)
{
@@ -730,6 +749,9 @@ void QDeclarativeSearchResultModel::queryFinished()
Q_ASSERT(searchReply);
m_resultsBuffer = searchReply->results();
+ setPreviousPageRequest(searchReply->previousPageRequest());
+ setNextPageRequest(searchReply->nextPageRequest());
+
reply->deleteLater();
if (!m_favoritesPlugin) {
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 894d555e..9f68178e 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -42,9 +42,6 @@
#include "qdeclarativegeoserviceprovider_p.h"
#include "qdeclarativegeomap_p.h"
-#include "qdeclarativegeomapmousearea_p.h"
-#include "qdeclarativegeomapmouseevent_p.h"
-
#include "qdeclarativegeoroute_p.h"
#include "qdeclarativegeoroutemodel_p.h"
#include "qdeclarativegeocodemodel_p.h"
@@ -110,8 +107,6 @@ public:
qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase>(uri, 5, 0, "GeoMapItemBase", QCoreApplication::translate(CONTEXT_NAME, NOT_INSTANTIABLE_BY_DEVELOPER).arg("GeoMapItemBase"));
qmlRegisterType<QDeclarativeGeoMapQuickItem>(uri, 5, 0, "MapQuickItem");
qmlRegisterType<QDeclarativeGeoMapItemView>(uri, 5, 0, "MapItemView");
- qmlRegisterType<QDeclarativeGeoMapMouseArea>(uri, 5, 0, "MapMouseArea");
- qmlRegisterType<QDeclarativeGeoMapMouseEvent>(uri, 5, 0, "MapMouseEvent");
qmlRegisterType<QDeclarativeGeocodeModel>(uri, 5, 0, "GeocodeModel"); // geocoding and reverse geocoding
qmlRegisterType<QDeclarativeGeoRouteModel>(uri, 5, 0, "RouteModel");
diff --git a/src/imports/location/location.pro b/src/imports/location/location.pro
index 8dccfa2d..1538fe55 100644
--- a/src/imports/location/location.pro
+++ b/src/imports/location/location.pro
@@ -17,8 +17,6 @@ win32 {
HEADERS += \
qdeclarativegeomapitemview_p.h \
- qdeclarativegeomapmouseevent_p.h \
- qdeclarativegeomapmousearea_p.h \
qdeclarativegeoserviceprovider_p.h \
qdeclarativegeocodemodel_p.h \
qdeclarativegeoroutemodel_p.h \
@@ -44,8 +42,6 @@ HEADERS += \
SOURCES += \
location.cpp \
qdeclarativegeomapitemview.cpp \
- qdeclarativegeomapmouseevent.cpp \
- qdeclarativegeomapmousearea.cpp \
qdeclarativegeoserviceprovider.cpp \
qdeclarativegeocodemodel.cpp \
qdeclarativegeoroutemodel.cpp \
diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 2029a023..f26995b3 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -44,10 +44,15 @@
#include "qdeclarativepolygonmapitem_p.h"
#include "qgeocameracapabilities_p.h"
#include "qgeoprojection_p.h"
+
#include <cmath>
+
+#include <QtCore/QScopedValueRollback>
#include <QPen>
#include <QPainter>
+#include "qdoublevector2d_p.h"
+
/* poly2tri triangulator includes */
#include "../../3rdparty/poly2tri/common/shapes.h"
#include "../../3rdparty/poly2tri/sweep/cdt.h"
@@ -82,7 +87,7 @@ QT_BEGIN_NAMESPACE
accuracy of the circle's shape, depending on position and map
projection.
- \note Dragging a MapCircle (through the use of \l MapMouseArea)
+ \note Dragging a MapCircle (through the use of \l MouseArea)
causes new points to be generated at the same distance (in meters)
from the center. This is in contrast to other map items which store
their dimensions in terms of latitude and longitude differences between
@@ -149,7 +154,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
return;
}
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false);
+ QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
QPainterPath ppi = srcPath_;
@@ -168,10 +173,10 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
// calculate actual width of map on screen in pixels
QGeoCoordinate mapCenter(0, map.cameraData().center().longitude());
- QPointF midPoint = map.coordinateToScreenPosition(mapCenter, false);
- QPointF midPointPlusOne = QPoint(midPoint.x() + 1.0, midPoint.y());
+ QDoubleVector2D midPoint = map.coordinateToScreenPosition(mapCenter, false);
+ QDoubleVector2D midPointPlusOne = QDoubleVector2D(midPoint.x() + 1.0, midPoint.y());
QGeoCoordinate coord1 = map.screenPositionToCoordinate(midPointPlusOne, false);
- qreal geoDistance = coord1.longitude() - map.cameraData().center().longitude();
+ double geoDistance = coord1.longitude() - map.cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360.0;
double mapWidth = 360.0 / geoDistance;
@@ -298,7 +303,8 @@ static void calculatePeripheralPoints(QList<QGeoCoordinate> &path, const QGeoCoo
}
QDeclarativeCircleMapItem::QDeclarativeCircleMapItem(QQuickItem *parent)
-: QDeclarativeGeoMapItemBase(parent), color_(Qt::transparent), radius_(0), dirtyMaterial_(true)
+: QDeclarativeGeoMapItemBase(parent), color_(Qt::transparent), radius_(0), dirtyMaterial_(true),
+ updatingGeometry_(false)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
@@ -464,6 +470,9 @@ void QDeclarativeCircleMapItem::updateMapItem()
if (!map() || !center().isValid())
return;
+ QScopedValueRollback<bool> rollback(updatingGeometry_);
+ updatingGeometry_ = true;
+
if (geometry_.isSourceDirty()) {
circlePath_.clear();
calculatePeripheralPoints(circlePath_, center_, radius_, 125);
@@ -541,37 +550,33 @@ void QDeclarativeCircleMapItem::afterViewportChanged(const QGeoMapViewportChange
updateMapItem();
}
-
/*!
\internal
*/
-void QDeclarativeCircleMapItem::dragStarted()
+bool QDeclarativeCircleMapItem::contains(const QPointF &point) const
{
- geometry_.markFullScreenDirty();
- borderGeometry_.markFullScreenDirty();
- updateMapItem();
+ return (geometry_.contains(point) || borderGeometry_.contains(point));
}
/*!
\internal
*/
-void QDeclarativeCircleMapItem::dragEnded()
+void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- QPointF newPoint = QPointF(x(),y()) + QPointF(width(), height()) / 2;
+ if (updatingGeometry_ || newGeometry == oldGeometry) {
+ QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
+ return;
+ }
+
+ QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(width(), height()) / 2;
QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid())
setCenter(newCoordinate);
-}
-/*!
- \internal
-*/
-bool QDeclarativeCircleMapItem::contains(const QPointF &point) const
-{
- return (geometry_.contains(point) || borderGeometry_.contains(point));
+ // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
+ // call to this function.
}
-
bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QGeoCoordinate> &path,
const QGeoCoordinate &center, qreal distance,
QGeoCoordinate &leftBoundCoord)
@@ -609,19 +614,19 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
return;
QList<int> wrapPathIndex;
// calculate actual width of map on screen in pixels
- QPointF midPoint = map()->coordinateToScreenPosition(map()->cameraData().center(), false);
- QPointF midPointPlusOne(midPoint.x() + 1.0, midPoint.y());
+ QDoubleVector2D midPoint = map()->coordinateToScreenPosition(map()->cameraData().center(), false);
+ QDoubleVector2D midPointPlusOne(midPoint.x() + 1.0, midPoint.y());
QGeoCoordinate coord1 = map()->screenPositionToCoordinate(midPointPlusOne, false);
qreal geoDistance = coord1.longitude() - map()->cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360;
qreal mapWidth = 360.0 / geoDistance;
mapWidth = qMin(static_cast<int>(mapWidth), map()->width());
- QPointF prev = map()->coordinateToScreenPosition(path.at(0), false);
+ QDoubleVector2D prev = map()->coordinateToScreenPosition(path.at(0), false);
// find the points in path where wrapping occurs
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QPointF point = map()->coordinateToScreenPosition(path.at(index), false);
+ QDoubleVector2D point = map()->coordinateToScreenPosition(path.at(index), false);
if ( (qAbs(point.x() - prev.x())) >= mapWidth/2.0 ) {
wrapPathIndex << index;
if (wrapPathIndex.size() == 2 || !(crossNorthPole && crossSouthPole))
diff --git a/src/imports/location/qdeclarativecirclemapitem_p.h b/src/imports/location/qdeclarativecirclemapitem_p.h
index 7c899546..e09e0ea4 100644
--- a/src/imports/location/qdeclarativecirclemapitem_p.h
+++ b/src/imports/location/qdeclarativecirclemapitem_p.h
@@ -90,8 +90,6 @@ public:
QDeclarativeMapLineProperties *border();
- void dragStarted();
- void dragEnded();
bool contains(const QPointF &point) const;
Q_SIGNALS:
@@ -99,6 +97,9 @@ Q_SIGNALS:
void radiusChanged(qreal radius);
void colorChanged(const QColor &color);
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
protected Q_SLOTS:
virtual void updateMapItem();
void updateMapItemAssumeDirty();
@@ -119,6 +120,7 @@ private:
bool dirtyMaterial_;
QGeoMapCircleGeometry geometry_;
QGeoMapPolylineGeometry borderGeometry_;
+ bool updatingGeometry_;
};
//////////////////////////////////////////////////////////////////////
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index e203a778..8310fd48 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qdeclarativegeomap_p.h"
-#include "qdeclarativegeomapmousearea_p.h"
#include "error_messages.h"
#include "qdeclarativecirclemapitem_p.h"
@@ -57,9 +56,14 @@
#include "mapnode_p.h"
#include <cmath>
+#include <QtPositioning/QGeoCoordinate>
+#include <QtPositioning/QGeoCircle>
+#include <QtPositioning/QGeoRectangle>
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/private/qgeomappingmanager_p.h>
+#include "qdoublevector2d_p.h"
+#include <QPointF>
#include <QtQml/QQmlContext>
#include <QtQml/qqmlinfo.h>
#include <QModelIndex>
@@ -129,13 +133,6 @@ QT_BEGIN_NAMESPACE
specially at startup and cannot be replaced or destroyed. Its properties
can be altered, however, to control its behavior.
- Mouse and touch interaction with Maps and map objects is slightly different
- to ordinary QML types. In a Map or Map object, you will need to make use
- of the \l MapMouseArea type instead of the normal Qt Quick MouseArea.
- MapMouseArea is, in almost all respects, a drop-in replacement for
- MouseArea, but the documentation for that type should be referred to for
- further details.
-
\section2 Performance
Maps are rendered using OpenGL (ES) and the Qt Scene Graph stack, and as
@@ -190,8 +187,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
serviceProvider_(0),
mappingManager_(0),
zoomLevel_(8.0),
- bearing_(0.0),
- tilt_(0.0),
+ center_(0,0),
activeMapType_(0),
componentCompleted_(false),
mappingManagerInitialized_(false),
@@ -473,8 +469,15 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
map_ = mappingManager_->createMap(this);
gestureArea_->setMap(map_);
- gestureArea_->zoomLevelLimits(mappingManager_->cameraCapabilities().minimumZoomLevel(),
- mappingManager_->cameraCapabilities().maximumZoomLevel());
+
+ //The zoom level limits are only restricted by the plugins values, if the user has set a more
+ //strict zoom level limit before initialization nothing is done here.
+ if (mappingManager_->cameraCapabilities().minimumZoomLevel() > gestureArea_->minimumZoomLevel())
+ setMinimumZoomLevel(mappingManager_->cameraCapabilities().minimumZoomLevel());
+
+ if (gestureArea_->maximumZoomLevel() < 0
+ || mappingManager_->cameraCapabilities().maximumZoomLevel() < gestureArea_->maximumZoomLevel())
+ setMaximumZoomLevel(mappingManager_->cameraCapabilities().maximumZoomLevel());
map_->setActiveMapType(QGeoMapType());
@@ -484,38 +487,21 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
copyrightsWPtr_.data(),
SLOT(copyrightsChanged(const QImage &, const QPoint &)));
- QGeoCameraCapabilities capabilities = mappingManager_->cameraCapabilities();
- if (zoomLevel_ < capabilities.minimumZoomLevel())
- setZoomLevel(capabilities.minimumZoomLevel());
- else if (zoomLevel_ > capabilities.maximumZoomLevel())
- setZoomLevel(capabilities.maximumZoomLevel());
connect(map_,
SIGNAL(updateRequired()),
this,
SLOT(update()));
connect(map_->mapController(),
- SIGNAL(centerChanged(AnimatableCoordinate)),
- this,
- SLOT(mapCenterChanged(AnimatableCoordinate)));
- connect(map_->mapController(),
- SIGNAL(bearingChanged(qreal)),
- this,
- SLOT(mapBearingChanged(qreal)));
- connect(map_->mapController(),
- SIGNAL(tiltChanged(qreal)),
+ SIGNAL(centerChanged(QGeoCoordinate)),
this,
- SLOT(mapTiltChanged(qreal)));
+ SIGNAL(centerChanged(QGeoCoordinate)));
connect(map_->mapController(),
SIGNAL(zoomChanged(qreal)),
this,
SLOT(mapZoomLevelChanged(qreal)));
- AnimatableCoordinate acenter = map_->mapController()->center();
- acenter.setCoordinate(center_);
- map_->mapController()->setCenter(acenter);
+ map_->mapController()->setCenter(center_);
map_->mapController()->setZoom(zoomLevel_);
- map_->mapController()->setBearing(bearing_);
- map_->mapController()->setTilt(tilt_);
QList<QGeoMapType> types = mappingManager_->supportedMapTypes();
for (int i = 0; i < types.size(); ++i) {
@@ -567,112 +553,75 @@ QDeclarativeGeoServiceProvider *QDeclarativeGeoMap::plugin() const
}
/*!
- \qmlproperty real QtLocation::Map::minimumZoomLevel
-
- This property holds the minimum valid zoom level for the map.
-
- The minimum zoom level is defined by the \l plugin used.
- If a plugin supporting mapping is not set, -1.0 is returned.
+ \internal
+ Sets the gesture areas minimum zoom level. If the camera capabilities
+ has been set this method honors the boundaries set by it.
*/
-
-qreal QDeclarativeGeoMap::minimumZoomLevel() const
+void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel)
{
- if (mappingManager_ && mappingManagerInitialized_)
- return mappingManager_->cameraCapabilities().minimumZoomLevel();
- else
- return -1.0;
+ if (gestureArea_ && minimumZoomLevel >= 0) {
+ if (mappingManagerInitialized_
+ && minimumZoomLevel < mappingManager_->cameraCapabilities().minimumZoomLevel()) {
+ minimumZoomLevel = mappingManager_->cameraCapabilities().minimumZoomLevel();
+ }
+ gestureArea_->setMinimumZoomLevel(minimumZoomLevel);
+ setZoomLevel(qBound<qreal>(minimumZoomLevel, zoomLevel(), maximumZoomLevel()));
+ }
}
/*!
-\qmlproperty real QtLocation::Map::maximumZoomLevel
+ \qmlproperty real QtLocation::Map::minimumZoomLevel
- This property holds the maximum valid zoom level for the map.
+ This property holds the minimum valid zoom level for the map.
- The maximum zoom level is defined by the \l plugin used.
+ The minimum zoom level is defined by the \l plugin used.
If a plugin supporting mapping is not set, -1.0 is returned.
*/
-qreal QDeclarativeGeoMap::maximumZoomLevel() const
+qreal QDeclarativeGeoMap::minimumZoomLevel() const
{
- if (mappingManager_ && mappingManagerInitialized_)
- return mappingManager_->cameraCapabilities().maximumZoomLevel();
+ if (gestureArea_->minimumZoomLevel() != -1)
+ return gestureArea_->minimumZoomLevel();
+ else if (mappingManager_ && mappingManagerInitialized_)
+ return mappingManager_->cameraCapabilities().minimumZoomLevel();
else
return -1.0;
}
/*!
\internal
+ Sets the gesture areas maximum zoom level. If the camera capabilities
+ has been set this method honors the boundaries set by it.
*/
-void QDeclarativeGeoMap::setBearing(qreal bearing)
+void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel)
{
- if (bearing_ == bearing)
- return;
- bool clockwise = (bearing >= 0);
- qreal fractions = bearing - int(bearing);
- bearing = (int(qAbs(bearing))) % 359;
- if (!clockwise)
- bearing = (-1.0 * bearing) + 360;
- bearing_ = bearing + fractions;
- if (mappingManagerInitialized_)
- map_->mapController()->setBearing(bearing_);
- emit bearingChanged(bearing_);
-}
-
-/*!
- \qmlproperty real Map::bearing
-
- This property holds the current bearing (starting from 0 and increasing
- clockwise to 359,9 degrees) pointing up.
-
- For example setting bearing to 10 will set bearing 10 to point up, which
- visually looks like rotating the map counter-clockwise.
-
- You can also assign negative values, which will internally get
- translated into positive bearing (for example -10 equals 350). This is primarily for
- convenience (for example you can decrement bearing without worrying about it).
- Assigning values greater than abs(360) will be mod'd (for example 365 will result
- in 5).
-
- The default value is 0 corresponding North pointing up.
-*/
-
-qreal QDeclarativeGeoMap::bearing() const
-{
- if (mappingManagerInitialized_) {
- if (map_->mapController()->bearing() >= 0)
- return map_->mapController()->bearing();
- else
- return map_->mapController()->bearing() + 360;
- } else {
- return bearing_;
+ if (gestureArea_ && maximumZoomLevel >= 0) {
+ if (mappingManagerInitialized_
+ && maximumZoomLevel > mappingManager_->cameraCapabilities().maximumZoomLevel()) {
+ maximumZoomLevel = mappingManager_->cameraCapabilities().maximumZoomLevel();
+ }
+ gestureArea_->setMaximumZoomLevel(maximumZoomLevel);
+ setZoomLevel(qBound<qreal>(minimumZoomLevel(), zoomLevel(), maximumZoomLevel));
}
}
/*!
- \qmlproperty real Map::tilt
-
- This property holds the current tilt (starting from 0 and increasing to 85 degrees).
+ \qmlproperty real QtLocation::Map::maximumZoomLevel
- The tilt gives the map a 2.5D feel. Certain map objects may be rendered
- in 3D if the tilt is different from 0.
+ This property holds the maximum valid zoom level for the map.
- The default value is 0 corresponding to no tilt.
+ The maximum zoom level is defined by the \l plugin used.
+ If a plugin supporting mapping is not set, -1.0 is returned.
*/
-qreal QDeclarativeGeoMap::tilt() const
-{
- if (!mappingManagerInitialized_)
- return tilt_;
- return map_->mapController()->tilt();
-}
-void QDeclarativeGeoMap::setTilt(qreal tilt)
+qreal QDeclarativeGeoMap::maximumZoomLevel() const
{
- if (tilt_ == tilt || tilt > 85.0 || tilt < 0)
- return;
- tilt_ = tilt;
- if (mappingManagerInitialized_)
- map_->mapController()->setTilt(tilt);
- emit tiltChanged(tilt);
+ if (gestureArea_->maximumZoomLevel() != -1)
+ return gestureArea_->maximumZoomLevel();
+ else if (mappingManager_ && mappingManagerInitialized_)
+ return mappingManager_->cameraCapabilities().maximumZoomLevel();
+ else
+ return -1.0;
}
/*!
@@ -688,13 +637,9 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel)
if (zoomLevel_ == zoomLevel || zoomLevel < 0)
return;
- if (mappingManagerInitialized_) {
- QGeoCameraCapabilities capabilities = mappingManager_->cameraCapabilities();
- if ((zoomLevel < capabilities.minimumZoomLevel() ||
- zoomLevel > capabilities.maximumZoomLevel())) {
- return;
- }
- }
+ if ((zoomLevel < minimumZoomLevel()
+ || (maximumZoomLevel() >= 0 && zoomLevel > maximumZoomLevel())))
+ return;
zoomLevel_ = zoomLevel;
if (mappingManagerInitialized_)
@@ -720,15 +665,13 @@ qreal QDeclarativeGeoMap::zoomLevel() const
*/
void QDeclarativeGeoMap::setCenter(const QGeoCoordinate &center)
{
- if (center == center_)
+ if (!mappingManagerInitialized_ && center == center_)
return;
center_ = center;
if (center_.isValid() && mappingManagerInitialized_) {
- AnimatableCoordinate acoord = map_->mapController()->center();
- acoord.setCoordinate(center_);
- map_->mapController()->setCenter(acoord);
+ map_->mapController()->setCenter(center_);
update();
} else {
emit centerChanged(center_);
@@ -738,7 +681,7 @@ void QDeclarativeGeoMap::setCenter(const QGeoCoordinate &center)
QGeoCoordinate QDeclarativeGeoMap::center() const
{
if (mappingManagerInitialized_)
- return map_->mapController()->center().coordinate();
+ return map_->mapController()->center();
else
return center_;
}
@@ -755,36 +698,6 @@ void QDeclarativeGeoMap::mapZoomLevelChanged(qreal zoom)
}
/*!
- \internal
-*/
-void QDeclarativeGeoMap::mapTiltChanged(qreal tilt)
-{
- if (tilt == zoomLevel_)
- return;
- tilt_ = tilt;
- emit tiltChanged(tilt_);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMap::mapBearingChanged(qreal bearing)
-{
- if (bearing == bearing_)
- return;
- bearing_ = bearing;
- emit bearingChanged(bearing_);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMap::mapCenterChanged(AnimatableCoordinate center)
-{
- emit centerChanged(center.coordinate());
-}
-
-/*!
\qmlproperty list<MapType> QtLocation::Map::supportedMapTypes
This read-only property holds the set of \l{MapType}{map types} supported by this map.
@@ -809,7 +722,7 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes()
QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &screenPosition) const
{
if (map_)
- return map_->screenPositionToCoordinate(screenPosition);
+ return map_->screenPositionToCoordinate(QDoubleVector2D(screenPosition));
else
return QGeoCoordinate();
}
@@ -827,7 +740,7 @@ QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &screenPosition) c
QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
{
if (map_)
- return map_->coordinateToScreenPosition(coordinate);
+ return map_->coordinateToScreenPosition(coordinate).toPointF();
else
return QPointF(qQNaN(), qQNaN());
}
@@ -841,7 +754,7 @@ QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) c
Positive values for \a dx move the map right, negative values left.
Positive values for \a dy move the map down, negative values up.
- During panning the \l center, \l tilt, \l bearing, and \l zoomLevel may change.
+ During panning the \l center, and \l zoomLevel may change.
*/
void QDeclarativeGeoMap::pan(int dx, int dy)
{
@@ -884,6 +797,7 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
{
QLOC_TRACE0;
event->accept();
+ gestureArea_->wheelEvent(event);
emit wheelAngleChanged(event->angleDelta());
}
@@ -898,11 +812,21 @@ bool QDeclarativeGeoMap::childMouseEventFilter(QQuickItem *item, QEvent *event)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
+ if (!item->keepMouseGrab())
+ return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event));
+ else
+ return false;
+ case QEvent::UngrabMouse:
return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event));
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
- return gestureArea_->filterMapChildTouchEvent(static_cast<QTouchEvent *>(event));
+ if (!item->keepMouseGrab())
+ return gestureArea_->filterMapChildTouchEvent(static_cast<QTouchEvent *>(event));
+ else
+ return false;
+ case QEvent::Wheel:
+ return gestureArea_->wheelEvent(static_cast<QWheelEvent *>(event));
default:
return false;
}
@@ -1046,6 +970,85 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
}
/*!
+ \qmlmethod QtLocation::Map::fitViewportToGeoShape(QGeoShape shape)
+
+ Fits the current viewport to the boundary of the shape. The camera is positioned
+ in the center of the shape, and at the largest integral zoom level possible which
+ allows the whole shape to be visible on screen
+
+*/
+void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
+{
+ if (!map_ || !mappingManagerInitialized_)
+ return;
+
+ QGeoShape shape;
+
+ if (variantShape.userType() == qMetaTypeId<QGeoRectangle>())
+ shape = variantShape.value<QGeoRectangle>();
+ else if (variantShape.userType() == qMetaTypeId<QGeoCircle>())
+ shape = variantShape.value<QGeoCircle>();
+ else if (variantShape.userType() == qMetaTypeId<QGeoShape>())
+ shape = variantShape.value<QGeoShape>();
+
+ if (!shape.isValid())
+ return;
+
+ double bboxWidth;
+ double bboxHeight;
+ QGeoCoordinate centerCoordinate;
+
+ switch (shape.type()) {
+ case QGeoShape::RectangleType:
+ {
+ QGeoRectangle rect = shape;
+ QDoubleVector2D topLeftPoint = map_->coordinateToScreenPosition(rect.topLeft(), false);
+ QDoubleVector2D botRightPoint = map_->coordinateToScreenPosition(rect.bottomRight(), false);
+ bboxWidth = qAbs(topLeftPoint.x() - botRightPoint.x());
+ bboxHeight = qAbs(topLeftPoint.y() - botRightPoint.y());
+ centerCoordinate = rect.center();
+ break;
+ }
+ case QGeoShape::CircleType:
+ {
+ QGeoCircle circle = shape;
+ centerCoordinate = circle.center();
+ QGeoCoordinate edge = centerCoordinate.atDistanceAndAzimuth(circle.radius(), 90);
+ QDoubleVector2D centerPoint = map_->coordinateToScreenPosition(centerCoordinate, false);
+ QDoubleVector2D edgePoint = map_->coordinateToScreenPosition(edge, false);
+ bboxWidth = qAbs(centerPoint.x() - edgePoint.x()) * 2;
+ bboxHeight = bboxWidth;
+ break;
+ }
+ case QGeoShape::UnknownType:
+ //Fallthrough to default
+ default:
+ return;
+ }
+
+ // position camera to the center of bounding box
+ setProperty("center", QVariant::fromValue(centerCoordinate));
+
+ //If the shape is empty we just change centerposition, not zoom
+ if (bboxHeight == 0 && bboxWidth == 0)
+ return;
+
+ // adjust zoom
+ double bboxWidthRatio = bboxWidth / (bboxWidth + bboxHeight);
+ double mapWidthRatio = width() / (width() + height());
+ double zoomRatio;
+
+ if (bboxWidthRatio > mapWidthRatio)
+ zoomRatio = bboxWidth / width();
+ else
+ zoomRatio = bboxHeight / height();
+
+ qreal newZoom = log10(zoomRatio) / log10(0.5);
+ newZoom = floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
+ setProperty("zoomLevel", QVariant::fromValue(newZoom));
+}
+
+/*!
\qmlmethod QtLocation::Map::fitViewportToMapItems()
Fits the current viewport to the boundary of all map items. The camera is positioned
@@ -1068,18 +1071,18 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
if (mapItems_.size() == 0)
return;
- qreal minX = 0;
- qreal maxX = 0;
- qreal minY = 0;
- qreal maxY = 0;
- qreal topLeftX = 0;
- qreal topLeftY = 0;
- qreal bottomRightX = 0;
- qreal bottomRightY = 0;
+ double minX = 0;
+ double maxX = 0;
+ double minY = 0;
+ double maxY = 0;
+ double topLeftX = 0;
+ double topLeftY = 0;
+ double bottomRightX = 0;
+ double bottomRightY = 0;
// find bounds of all map items
QGeoCoordinate geoCenter;
- QPointF centerPt;
+ QDoubleVector2D centerPt;
int itemCount = 0;
for (int i = 0; i < mapItems_.count(); ++i) {
if (!mapItems_.at(i))
@@ -1131,17 +1134,15 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
if (itemCount == 0)
return;
- qreal bboxWidth = maxX - minX;
- qreal bboxHeight = maxY - minY;
- qreal bboxCenterX = minX + (bboxWidth / 2.0);
- qreal bboxCenterY = minY + (bboxHeight / 2.0);
+ double bboxWidth = maxX - minX;
+ double bboxHeight = maxY - minY;
+ double bboxCenterX = minX + (bboxWidth / 2.0);
+ double bboxCenterY = minY + (bboxHeight / 2.0);
// position camera to the center of bounding box
QGeoCoordinate coordinate;
- coordinate = map_->screenPositionToCoordinate(QPointF(bboxCenterX, bboxCenterY), false);
- AnimatableCoordinate acenter = map_->mapController()->center();
- acenter.setCoordinate(coordinate);
- setCenter(coordinate);
+ coordinate = map_->screenPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
+ setProperty("center", QVariant::fromValue(coordinate));
// adjust zoom
double bboxWidthRatio = bboxWidth / (bboxWidth + bboxHeight);
@@ -1155,7 +1156,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
qreal newZoom = log10(zoomRatio) / log10(0.5);
newZoom = floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
- setZoomLevel(newZoom);
+ setProperty("zoomLevel", QVariant::fromValue(newZoom));
// as map quick items retain the same screen size after the camera zooms in/out
// we refine the viewport again to achieve better results
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index c69541a7..fb00e1b7 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -72,7 +72,6 @@
#include "qgeocameradata_p.h"
#include "qgeomap_p.h"
#include "qdeclarativegeomaptype_p.h"
-#include <QWeakPointer>
QT_BEGIN_NAMESPACE
@@ -100,16 +99,13 @@ class QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QDeclarativeGeoMapGestureArea *gesture READ gesture CONSTANT)
Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
- Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel NOTIFY minimumZoomLevelChanged)
- Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel NOTIFY maximumZoomLevelChanged)
+ Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel WRITE setMinimumZoomLevel NOTIFY minimumZoomLevelChanged)
+ Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel WRITE setMaximumZoomLevel NOTIFY maximumZoomLevelChanged)
Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
Q_PROPERTY(QDeclarativeGeoMapType *activeMapType READ activeMapType WRITE setActiveMapType NOTIFY activeMapTypeChanged)
Q_PROPERTY(QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes READ supportedMapTypes NOTIFY supportedMapTypesChanged)
Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
Q_PROPERTY(QList<QObject *> mapItems READ mapItems NOTIFY mapItemsChanged)
- // Tilt and bearing are not part of supported API
- Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
- Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -132,18 +128,15 @@ public:
void setActiveMapType(QDeclarativeGeoMapType *mapType);
QDeclarativeGeoMapType *activeMapType() const;
+ void setMinimumZoomLevel(qreal minimumZoomLevel);
qreal minimumZoomLevel() const;
+
+ void setMaximumZoomLevel(qreal maximumZoomLevel);
qreal maximumZoomLevel() const;
void setZoomLevel(qreal zoomLevel);
qreal zoomLevel() const;
- void setBearing(qreal bearing);
- qreal bearing() const;
-
- void setTilt(qreal tilt);
- qreal tilt() const;
-
void setCenter(const QGeoCoordinate &center);
QGeoCoordinate center() const;
@@ -162,6 +155,7 @@ public:
QDeclarativeGeoMapGestureArea *gesture();
+ Q_INVOKABLE void fitViewportToGeoShape(const QVariant &shape);
Q_INVOKABLE void fitViewportToMapItems();
Q_INVOKABLE void pan(int dx, int dy);
Q_INVOKABLE void cameraStopped(); // optional hint for prefetch
@@ -180,8 +174,6 @@ Q_SIGNALS:
void wheelAngleChanged(QPoint angleDelta);
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
void zoomLevelChanged(qreal zoomLevel);
- void bearingChanged(qreal bearing);
- void tiltChanged(qreal tilt);
void centerChanged(const QGeoCoordinate &coordinate);
void activeMapTypeChanged();
void supportedMapTypesChanged();
@@ -193,9 +185,6 @@ private Q_SLOTS:
void updateMapDisplay(const QRectF &target);
void mappingManagerInitialized();
void mapZoomLevelChanged(qreal zoom);
- void mapTiltChanged(qreal tilt);
- void mapBearingChanged(qreal bearing);
- void mapCenterChanged(AnimatableCoordinate center);
void pluginReady();
void onMapChildrenChanged();
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index bb13ce21..9adc422d 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -45,12 +45,14 @@
#include <QtGui/QGuiApplication>
#include <QtGui/qevent.h>
+#include <QtGui/QWheelEvent>
#include <QtGui/QStyleHints>
#include <QtQml/qqmlinfo.h>
#include <QPropertyAnimation>
#include <QDebug>
#include "math.h"
#include "qgeomap_p.h"
+#include "qdoublevector2d_p.h"
#define QML_MAP_FLICK_DEFAULTMAXVELOCITY 2500
#define QML_MAP_FLICK_MINIMUMDECELERATION 500
@@ -232,16 +234,10 @@ QT_BEGIN_NAMESPACE
\list
\li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).
\li MapGestureArea.ZoomGesture - Support the map zoom gesture (value: 0x0001).
- \li MapGestureArea.RotationGesture - Support the map rotation gesture (value: 0x0002).
- \li MapGestureArea.TiltGesture - Support the map tilt gesture (value: 0x0004).
- \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0008).
- \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0010).
+ \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002).
+ \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004).
\endlist
- For the extremist, one may OR flag the RotationGesture or TiltGesture
- but these come with absolutely no warranty or guarantees at the moment
- (may be removed, changed, moved around)
-
\note For the time being, only MapGestureArea.ZoomGesture is supported.
*/
@@ -257,16 +253,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty real MapGestureArea::rotationFactor
-
- This property holds the rotation factor for zoom, essentially meant to be used for setting
- the rotation sensitivity.
-
- It is an indicative measure; the default value 1.0 means the map roughly follows the fingers,
- whereas 2.0 means rotating twice as fast. Maximum value is 5.0.
-*/
-
-/*!
\qmlproperty real MapGestureArea::flickDeceleration
This property holds the rate at which a flick will decelerate.
@@ -384,10 +370,6 @@ void QDeclarativeGeoMapGestureArea::setActiveGestures(ActiveGestures activeGestu
if (activeGestures == activeGestures_)
return;
activeGestures_ = activeGestures;
- if (activeGestures_ & RotationGesture)
- qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, PINCH_ROTATE_GESTURE_ACTIVATED);
- if (activeGestures_ & TiltGesture)
- qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, PINCH_TILT_GESTURE_ACTIVATED);
emit activeGesturesChanged();
}
@@ -471,54 +453,61 @@ void QDeclarativeGeoMapGestureArea::setPanEnabled(bool enabled)
/*!
\internal
- called internally when plugin's limits change. somewhat dodgy but
- initialization order complicates the zoom limit settings a bit (for example when is
- it possible to check against mapping plugins' limits)
-*/
-void QDeclarativeGeoMapGestureArea::zoomLevelLimits(qreal min, qreal max)
+ Used internally to set the minimum zoom level of the gesture area.
+ The caller is responsible to only send values that are valid
+ for the map plugin. Negative values are ignored.
+ */
+void QDeclarativeGeoMapGestureArea::setMinimumZoomLevel(qreal min)
{
- if (pinch_.zoom.minimum == -1.0 || min > pinch_.zoom.minimum)
+ if (min >= 0)
pinch_.zoom.minimum = min;
- if (pinch_.zoom.maximum == -1.0 || max < pinch_.zoom.maximum)
- pinch_.zoom.maximum = max;
}
/*!
- \internal
-*/
-qreal QDeclarativeGeoMapGestureArea::maximumZoomLevelChange() const
+ \internal
+ */
+qreal QDeclarativeGeoMapGestureArea::minimumZoomLevel() const
{
- return pinch_.zoom.maximumChange;
+ return pinch_.zoom.minimum;
}
/*!
\internal
-*/
-void QDeclarativeGeoMapGestureArea::setMaximumZoomLevelChange(qreal maxChange)
+ Used internally to set the maximum zoom level of the gesture area.
+ The caller is responsible to only send values that are valid
+ for the map plugin. Negative values are ignored.
+ */
+void QDeclarativeGeoMapGestureArea::setMaximumZoomLevel(qreal max)
{
- if (maxChange == pinch_.zoom.maximumChange || maxChange < 0.1 || maxChange > 10.0)
- return;
- pinch_.zoom.maximumChange = maxChange;
- emit maximumZoomLevelChangeChanged();
+ if (max >= 0)
+ pinch_.zoom.maximum = max;
+}
+
+/*!
+ \internal
+ */
+qreal QDeclarativeGeoMapGestureArea::maximumZoomLevel() const
+{
+ return pinch_.zoom.maximum;
}
/*!
\internal
*/
-qreal QDeclarativeGeoMapGestureArea::rotationFactor() const
+qreal QDeclarativeGeoMapGestureArea::maximumZoomLevelChange() const
{
- return pinch_.rotation.factor;
+ return pinch_.zoom.maximumChange;
}
/*!
\internal
*/
-void QDeclarativeGeoMapGestureArea::setRotationFactor(qreal factor)
+void QDeclarativeGeoMapGestureArea::setMaximumZoomLevelChange(qreal maxChange)
{
- if (pinch_.rotation.factor == factor || factor < 0 || factor > 5)
+ if (maxChange == pinch_.zoom.maximumChange || maxChange < 0.1 || maxChange > 10.0)
return;
- pinch_.rotation.factor = factor;
- emit rotationFactorChanged();
+ pinch_.zoom.maximumChange = maxChange;
+ emit maximumZoomLevelChangeChanged();
}
/*!
@@ -629,6 +618,12 @@ void QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
}
}
+bool QDeclarativeGeoMapGestureArea::wheelEvent(QWheelEvent *event)
+{
+ declarativeMap_->setZoomLevel(qBound(minimumZoomLevel(), declarativeMap_->zoomLevel() + event->angleDelta().y() * qreal(0.001), maximumZoomLevel()));
+ return true;
+}
+
/*!
\internal
*/
@@ -645,6 +640,10 @@ bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event)
case QEvent::MouseMove:
used = mouseMoveEvent(event);
break;
+ case QEvent::UngrabMouse:
+ touchPoints_.clear();
+ update();
+ break;
default:
used = false;
break;
@@ -668,7 +667,6 @@ void QDeclarativeGeoMapGestureArea::clearTouchData()
{
velocityX_ = 0;
velocityY_ = 0;
- pressTime_.start();
sceneCenter_.setX(0);
sceneCenter_.setY(0);
touchCenterCoord_.setLongitude(0);
@@ -710,7 +708,7 @@ void QDeclarativeGeoMapGestureArea::update()
touchPointStateMachine();
// Parallel state machine for pinch
- if (isPinchActive() || (enabled_ && pinch_.enabled && (activeGestures_ & (ZoomGesture | TiltGesture | RotationGesture))))
+ if (isPinchActive() || (enabled_ && pinch_.enabled && (activeGestures_ & (ZoomGesture))))
pinchStateMachine();
// Parallel state machine for pan (since you can pan at the same time as pinching)
@@ -743,7 +741,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 2) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false);
+ touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startTwoTouchPoints();
touchPointState_ = touchPoints2;
}
@@ -752,7 +750,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 1) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false);
+ touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startOneTouchPoint();
touchPointState_ = touchPoints1;
}
@@ -780,7 +778,7 @@ void QDeclarativeGeoMapGestureArea::startOneTouchPoint()
sceneStartPoint1_ = touchPoints_.at(0).scenePos();
lastPos_ = sceneStartPoint1_;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(sceneStartPoint1_, false);
+ QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(sceneStartPoint1_), false);
// ensures a smooth transition for panning
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
@@ -808,7 +806,7 @@ void QDeclarativeGeoMapGestureArea::startTwoTouchPoints()
QPointF startPos = (sceneStartPoint1_ + sceneStartPoint2_) * 0.5;
lastPos_ = startPos;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(startPos, false);
+ QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(startPos), false);
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
startCoord_.setLatitude(startCoord_.latitude() + startCoord.latitude() -
@@ -915,16 +913,12 @@ void QDeclarativeGeoMapGestureArea::startPinch()
{
pinch_.startDist = distanceBetweenTouchPoints_;
pinch_.zoom.previous = 1.0;
- pinch_.tilt.previous = 0.0;
pinch_.lastAngle = twoTouchAngle_;
- pinch_.rotation.angle = 0.0;
pinch_.lastPoint1 = touchPoints_.at(0).scenePos();
pinch_.lastPoint2 = touchPoints_.at(1).scenePos();
pinch_.zoom.start = declarativeMap_->zoomLevel();
- pinch_.rotation.start = declarativeMap_->bearing();
- pinch_.tilt.start = declarativeMap_->tilt();
}
/*!
@@ -948,7 +942,6 @@ void QDeclarativeGeoMapGestureArea::updatePinch()
da -= 360;
else if (da < -180)
da += 360;
- pinch_.rotation.angle -= da;
pinch_.event.setCenter(declarativeMap_->mapFromScene(sceneCenter_));
pinch_.event.setAngle(twoTouchAngle_);
@@ -969,37 +962,6 @@ void QDeclarativeGeoMapGestureArea::updatePinch()
newZoomLevel = qMin(qMax(perPinchMinimumZoomLevel, newZoomLevel), perPinchMaximumZoomLevel);
declarativeMap_->setZoomLevel(newZoomLevel);
}
- if (activeGestures_ & TiltGesture && pinch_.zoom.minimum >= 0 && pinch_.zoom.maximum >= 0) {
- // Note: tilt is not yet supported.
- qreal newTilt = pinch_.tilt.previous;
- if (distanceBetweenTouchPoints_) {
- newTilt =
- // How much further/closer the current touchpoints are (in pixels) compared to pinch start
- ((distanceBetweenTouchPoints_ - pinch_.startDist) *
- // How much one pixel corresponds in units of tilt degrees (and multiply by above delta)
- (pinch_.tilt.maximumChange / ((declarativeMap_->width() + declarativeMap_->height()) / 2))) +
- // Add to starting tilt.
- pinch_.tilt.start;
- }
- qreal perPinchMinimumTilt = qMax(pinch_.tilt.start - pinch_.tilt.maximumChange, pinch_.tilt.minimum);
- qreal perPinchMaximumTilt = qMin(pinch_.tilt.start + pinch_.tilt.maximumChange, pinch_.tilt.maximum);
- newTilt = qMin(qMax(perPinchMinimumTilt, newTilt), perPinchMaximumTilt);
- pinch_.tilt.previous = newTilt;
- declarativeMap_->setTilt(newTilt);
- }
- if (activeGestures_ & RotationGesture) {
- bool unlimitedRotation = (pinch_.rotation.minimum == 0.0 && pinch_.rotation.maximum == 0.0);
- if ((pinch_.rotation.start >= pinch_.rotation.minimum && pinch_.rotation.start <= pinch_.rotation.maximum) || unlimitedRotation) {
- qreal r = pinch_.rotation.angle * pinch_.rotation.factor + pinch_.rotation.start;
- if (!unlimitedRotation)
- r = qMin(qMax(pinch_.rotation.minimum,r), pinch_.rotation.maximum);
- if (r > 360.0)
- r -= 360;
- if (r < -360.0)
- r += 360.0;
- declarativeMap_->setBearing(r);
- }
- }
}
/*!
@@ -1028,8 +990,13 @@ void QDeclarativeGeoMapGestureArea::panStateMachine()
// Transitions
switch (panState_) {
case panInactive:
- if (canStartPan())
+ if (canStartPan()) {
+ // Update startCoord_ to ensure smooth start for panning when going over startDragDistance
+ QGeoCoordinate newStartCoord = map_->screenPositionToCoordinate(QDoubleVector2D(lastPos_), false);
+ startCoord_.setLongitude(newStartCoord.longitude());
+ startCoord_.setLatitude(newStartCoord.latitude());
panState_ = panActive;
+ }
break;
case panActive:
if (touchPoints_.count() == 0) {
@@ -1038,8 +1005,10 @@ void QDeclarativeGeoMapGestureArea::panStateMachine()
{
panState_ = panInactive;
// mark as inactive for use by camera
- if (pinchState_ == pinchInactive)
+ if (pinchState_ == pinchInactive) {
+ emit panFinished();
emit movementStopped();
+ }
}
}
break;
@@ -1078,8 +1047,7 @@ bool QDeclarativeGeoMapGestureArea::canStartPan()
QPointF p1 = touchPoints_.at(0).scenePos();
int dyFromPress = int(p1.y() - sceneStartPoint1_.y());
int dxFromPress = int(p1.x() - sceneStartPoint1_.x());
- if ((qAbs(dyFromPress) > startDragDistance || qAbs(dxFromPress) > startDragDistance
- || pressTime_.elapsed() > 200))
+ if ((qAbs(dyFromPress) > startDragDistance || qAbs(dxFromPress) > startDragDistance))
return true;
return false;
}
@@ -1089,16 +1057,14 @@ bool QDeclarativeGeoMapGestureArea::canStartPan()
*/
void QDeclarativeGeoMapGestureArea::updatePan()
{
- QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false);
+ QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false).toPointF();
int dx = static_cast<int>(sceneCenter_.x() - startPoint.x());
int dy = static_cast<int>(sceneCenter_.y() - startPoint.y());
QPointF mapCenterPoint;
mapCenterPoint.setY(map_->height() / 2.0 - dy);
mapCenterPoint.setX(map_->width() / 2.0 - dx);
- AnimatableCoordinate animationStartCoordinate;
- animationStartCoordinate.setCoordinate(map_->screenPositionToCoordinate(mapCenterPoint, false));
+ QGeoCoordinate animationStartCoordinate = map_->screenPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
map_->mapController()->setCenter(animationStartCoordinate);
-
}
/*!
@@ -1152,16 +1118,15 @@ void QDeclarativeGeoMapGestureArea::startFlick(int dx, int dy, int timeMs)
{
if (timeMs < 0)
return;
- AnimatableCoordinate animationStartCoordinate = map_->mapController()->center();
- QGeoCoordinate coordinate = animationStartCoordinate.coordinate();
+
+ QGeoCoordinate animationStartCoordinate = map_->mapController()->center();
if (pan_.animation_->state() == QPropertyAnimation::Running)
pan_.animation_->stop();
- AnimatableCoordinate animationEndCoordinate = map_->mapController()->center();
+ QGeoCoordinate animationEndCoordinate = map_->mapController()->center();
pan_.animation_->setDuration(timeMs);
- coordinate.setLongitude(coordinate.longitude() - (dx / pow(2.0, map_->mapController()->zoom())));
- coordinate.setLatitude(coordinate.latitude() + (dy / pow(2.0, map_->mapController()->zoom())));
- animationEndCoordinate.setCoordinate(coordinate);
+ animationEndCoordinate.setLongitude(animationStartCoordinate.longitude() - (dx / pow(2.0, map_->mapController()->zoom())));
+ animationEndCoordinate.setLatitude(animationStartCoordinate.latitude() + (dy / pow(2.0, map_->mapController()->zoom())));
pan_.animation_->setStartValue(QVariant::fromValue(animationStartCoordinate));
pan_.animation_->setEndValue(QVariant::fromValue(animationEndCoordinate));
pan_.animation_->start();
diff --git a/src/imports/location/qdeclarativegeomapgesturearea_p.h b/src/imports/location/qdeclarativegeomapgesturearea_p.h
index 0f0dc194..3b87bbe0 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea_p.h
+++ b/src/imports/location/qdeclarativegeomapgesturearea_p.h
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
class QDeclarativeGeoMap;
class QTouchEvent;
+class QWheelEvent;
class QGeoMap;
class QPropertyAnimation;
@@ -105,7 +106,7 @@ private:
// tbd: should we have a 'active' / 'moving' boolean attribute when pinch is active?
-// class QDeclarativeGeoMapGestureArea: public QObject // supporting pinching, panning, flicking, tilting
+// class QDeclarativeGeoMapGestureArea: public QObject // supporting pinching, panning, flicking
class QDeclarativeGeoMapGestureArea: public QObject
{
Q_OBJECT
@@ -119,7 +120,6 @@ class QDeclarativeGeoMapGestureArea: public QObject
Q_PROPERTY(bool isPanActive READ isPanActive)
Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
- Q_PROPERTY(qreal rotationFactor READ rotationFactor WRITE setRotationFactor NOTIFY rotationFactorChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
public:
QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap *map, QObject *parent = 0);
@@ -128,10 +128,8 @@ public:
enum ActiveGesture {
NoGesture = 0x0000,
ZoomGesture = 0x0001,
- RotationGesture = 0x0002,
- TiltGesture = 0x0004,
- PanGesture = 0x0008,
- FlickGesture = 0x0010
+ PanGesture = 0x0002,
+ FlickGesture = 0x004
};
Q_DECLARE_FLAGS(ActiveGestures, ActiveGesture)
@@ -154,14 +152,13 @@ public:
qreal maximumZoomLevelChange() const;
void setMaximumZoomLevelChange(qreal maxChange);
- qreal rotationFactor() const;
- void setRotationFactor(qreal factor);
-
qreal flickDeceleration() const;
void setFlickDeceleration(qreal deceleration);
void touchEvent(QTouchEvent *event);
+ bool wheelEvent(QWheelEvent *event);
+
bool mousePressEvent(QMouseEvent *event);
bool mouseMoveEvent(QMouseEvent *event);
bool mouseReleaseEvent(QMouseEvent *event);
@@ -169,14 +166,18 @@ public:
bool filterMapChildMouseEvent(QMouseEvent *event);
bool filterMapChildTouchEvent(QTouchEvent *event);
- void zoomLevelLimits(qreal min, qreal max);
+ void setMinimumZoomLevel(qreal min);
+ qreal minimumZoomLevel() const;
+
+ void setMaximumZoomLevel(qreal max);
+ qreal maximumZoomLevel() const;
+
void setMap(QGeoMap *map);
Q_SIGNALS:
void pinchActiveChanged();
void enabledChanged();
void maximumZoomLevelChangeChanged();
- void rotationFactorChanged();
void activeGesturesChanged();
void flickDecelerationChanged();
@@ -203,7 +204,7 @@ private:
void startTwoTouchPoints();
void updateTwoTouchPoints();
- // All pinch related code, which encompasses zoom, rotation and tilt
+ // All pinch related code, which encompasses zoom
void pinchStateMachine();
bool canStartPinch();
void startPinch();
@@ -246,24 +247,6 @@ private:
qreal previous;
qreal maximumChange;
} zoom;
- struct Rotation
- {
- Rotation() : minimum(0.0), maximum(0.0), start(0.0), angle(0.0), factor(1.0) {}
- qreal minimum;
- qreal maximum;
- qreal start;
- qreal angle;
- qreal factor;
- } rotation;
- struct Tilt
- {
- Tilt() : minimum(0.0), maximum(90.0), maximumChange(20.0), previous(0.0), start(0.0) {}
- qreal minimum;
- qreal maximum;
- qreal maximumChange;
- qreal previous;
- qreal start;
- } tilt;
QPointF lastPoint1;
QPointF lastPoint2;
@@ -286,7 +269,6 @@ private:
qreal velocityY_;
QElapsedTimer lastPosTime_;
QPointF lastPos_;
- QElapsedTimer pressTime_;
QList<QTouchEvent::TouchPoint> touchPoints_;
QPointF sceneStartPoint1_;
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index 8f90e299..d53da881 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -40,10 +40,10 @@
****************************************************************************/
#include "qdeclarativegeomapitembase_p.h"
-#include "qdeclarativegeomapmousearea_p.h"
#include "qgeocameradata_p.h"
#include <QtQml/QQmlInfo>
#include <QtQuick/QSGOpacityNode>
+#include <QtQuick/private/qquickmousearea_p.h>
QT_BEGIN_NAMESPACE
@@ -80,10 +80,9 @@ QGeoMapViewportChangeEvent &QGeoMapViewportChangeEvent::operator=(const QGeoMapV
}
QDeclarativeGeoMapItemBase::QDeclarativeGeoMapItemBase(QQuickItem *parent)
- : QQuickItem(parent),
- map_(0),
- quickMap_(0)
+: QQuickItem(parent), map_(0), quickMap_(0)
{
+ setFiltersChildMouseEvents(true);
connect(this, SIGNAL(childrenChanged()),
this, SLOT(afterChildrenChanged()));
}
@@ -105,7 +104,7 @@ void QDeclarativeGeoMapItemBase::afterChildrenChanged()
bool printedWarning = false;
foreach (QQuickItem *i, kids) {
if (i->flags() & QQuickItem::ItemHasContents
- && !qobject_cast<QDeclarativeGeoMapMouseArea *>(i)) {
+ && !qobject_cast<QQuickMouseArea *>(i)) {
if (!printedWarning) {
qmlInfo(this) << "Geographic map items do not support child items";
printedWarning = true;
@@ -121,20 +120,6 @@ void QDeclarativeGeoMapItemBase::afterChildrenChanged()
/*!
\internal
*/
-void QDeclarativeGeoMapItemBase::dragStarted()
-{
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapItemBase::dragEnded()
-{
-}
-
-/*!
- \internal
-*/
void QDeclarativeGeoMapItemBase::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
if (quickMap == quickMap_)
@@ -194,7 +179,7 @@ void QDeclarativeGeoMapItemBase::setPositionOnMap(const QGeoCoordinate &coordina
if (!map_ || !quickMap_)
return;
- QPointF topLeft = map_->coordinateToScreenPosition(coordinate, false) - offset;
+ QPointF topLeft = map_->coordinateToScreenPosition(coordinate, false).toPointF() - offset;
setPosition(topLeft);
}
@@ -212,6 +197,24 @@ float QDeclarativeGeoMapItemBase::zoomLevelOpacity() const
return 0.0;
}
+bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent *event)
+{
+ Q_UNUSED(item)
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ if (contains(static_cast<QMouseEvent*>(event)->pos())) {
+ return false;
+ } else {
+ event->setAccepted(false);
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
/*!
\internal
*/
diff --git a/src/imports/location/qdeclarativegeomapitembase_p.h b/src/imports/location/qdeclarativegeomapitembase_p.h
index 78424124..82a8033e 100644
--- a/src/imports/location/qdeclarativegeomapitembase_p.h
+++ b/src/imports/location/qdeclarativegeomapitembase_p.h
@@ -75,8 +75,6 @@ public:
virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map);
virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset);
- virtual void dragStarted();
- virtual void dragEnded();
QDeclarativeGeoMap *quickMap() { return quickMap_; }
QGeoMap *map() { return map_; }
@@ -91,6 +89,7 @@ protected Q_SLOTS:
protected:
float zoomLevelOpacity() const;
+ bool childMouseEventFilter(QQuickItem *item, QEvent *event);
private Q_SLOTS:
void baseCameraDataChanged(const QGeoCameraData &camera);
diff --git a/src/imports/location/qdeclarativegeomapitemview.cpp b/src/imports/location/qdeclarativegeomapitemview.cpp
index 553cb5fd..ccfc4537 100644
--- a/src/imports/location/qdeclarativegeomapitemview.cpp
+++ b/src/imports/location/qdeclarativegeomapitemview.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qdeclarativegeomapitemview_p.h"
-#include "qdeclarativegeomapmousearea_p.h"
#include "qdeclarativegeomap_p.h"
#include "qdeclarativegeomapitembase_p.h"
diff --git a/src/imports/location/qdeclarativegeomapmousearea.cpp b/src/imports/location/qdeclarativegeomapmousearea.cpp
deleted file mode 100644
index 8146ecc3..00000000
--- a/src/imports/location/qdeclarativegeomapmousearea.cpp
+++ /dev/null
@@ -1,492 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegeomapmousearea_p.h"
-#include "qdeclarativegeomapitembase_p.h"
-#include <QtQml/qqmlinfo.h>
-#include <QtQuick/QQuickWindow>
-
-#include <QtQuick/private/qquickevents_p_p.h>
-#include <QtQuick/private/qquickdrag_p.h>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype MapMouseArea
- \instantiates QDeclarativeGeoMapMouseArea
-
- \brief The MapMouseArea item enables simple mouse handling.
-
- \inqmlmodule QtLocation
- \ingroup qml-QtLocation5-maps
-
- Like a standard Qt Quick \l{MouseArea}, the MapMouseArea provides mouse
- handling for an item. Creating a normal Qt Quick MouseArea inside a
- map object type (for example MapPolygon) will result in undefined behavior
- due to the way in which Map objects are rendered, so MapMouseArea exists to
- provide this functionality instead.
-
- The only exception to this is the MapQuickItem, which can have normal
- MouseArea objects defined within the sourceItem. See the documentation
- for \l{MapQuickItem} for more details.
-
- MapMouseArea objects should only ever be used within a map object, such as
- a MapPolygon or MapQuickItem, and never within another Qt Quick component.
-
- The \l enabled property of the MapMouseArea is used to enable and disable
- mouse handling for the proxied item. When disabled, the mouse area becomes
- transparent to mouse events.
-
- The \l pressed read-only property indicates whether or not the user is
- holding down a mouse button over the mouse area. This property is often
- used in bindings between properties in a user interface.
-
- Information about the mouse position and button clicks are provided via
- signals for which event handler properties are defined. The most commonly
- used handlers involve handling mouse presses and clicks: onClicked,
- onDoubleClicked, onPressed and onReleased.
-
- \section2 Example Usage
-
- The following example shows a map containing a MapCircle object. When
- the user clicks the MapCircle, a message is printed to the console.
-
- \code
- Map {
- MapCircle {
- center {
- latitude: -27.5
- longitude: 153
- }
- radius: 100
-
- MapMouseArea {
- anchors.fill: parent
-
- onClicked: {
- console.log("You clicked the circle!");
- }
- }
- }
- }
- \endcode
-
- \section2 Limitations
-
- Some important limitations apply to the use of a MapMouseArea:
- \list
- \li The mouse event is guaranteed only to be valid for the
- duration of the signal handler (for example onPositionChanged, onClicked). Consequently
- the mouse event itself should not be stored. The main reason for this is to
- optimize memory usage; we do not want to allocate heap memory every time the mouse
- moves.
- \li Nested mouse areas are not supported (MapMouseArea { MapMouseArea {} }.
- \li If two or more MapMouseAreas overlap, the declaration order is significant (not for example 'z' value).
- \li Only one MapMouseArea per MapItem is supported, and it always fills the whole MapItem.
- \endlist
-
- \sa MapMouseEvent
-*/
-
-QDeclarativeGeoMapMouseArea::QDeclarativeGeoMapMouseArea(QQuickItem *parent)
- : QQuickMouseArea(parent),
- componentCompleted_(false),
- dragActive_(false)
-{
-}
-
-QDeclarativeGeoMapMouseArea::~QDeclarativeGeoMapMouseArea()
-{
-}
-
-/*!
- \qmlmethod coordinate QtLocation::MapMouseArea::mouseToCoordinate(MouseEvent event)
-
- Converts the \a event's coordinates to geo coordinates.
- */
-QGeoCoordinate QDeclarativeGeoMapMouseArea::mouseToCoordinate(QQuickMouseEvent *event)
-{
- // figure out the map association for this mouse area and use it to resolve geocoordinate
- QDeclarativeGeoMap *quickmap = map();
- if (quickmap)
- return quickmap->toCoordinate(quickmap->mapFromItem(this, QPointF(event->x(), event->y())));
- return QGeoCoordinate(); // return invalid coordinate
-}
-
-/*!
- \internal
-*/
-// TODO: cache the map association and hook up to parent change -signals
-QDeclarativeGeoMap *QDeclarativeGeoMapMouseArea::map()
-{
- QQuickItem *pmi = parentMapItem();
- QDeclarativeGeoMap *map = 0;
- if (pmi) {
- map = qobject_cast<QDeclarativeGeoMap *>(pmi);
- if (!map) {
- QDeclarativeGeoMapItemBase *item = qobject_cast<QDeclarativeGeoMapItemBase *>(pmi);
- if (item)
- map = item->quickMap();
- }
- }
- return map;
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::dragActiveChanged()
-{
- if (drag() && drag()->property("active").toBool()) {
- dragActive_ = true;
- QQuickItem *pmi = parentMapItem();
- if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi))
- qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)->dragStarted();
- }
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::componentComplete()
-{
- componentCompleted_ = true;
- connect(drag(), SIGNAL(activeChanged()), this, SLOT(dragActiveChanged()));
- QQuickMouseArea::componentComplete();
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::mousePressEvent(QMouseEvent *event)
-{
- // ignore event if it misses non-rectangular geometry (e.g. circle, route)
- QQuickItem *pmi = parentMapItem();
- bool contains = true;
- if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi))
- contains = pmi->contains(event->pos());
-
- if (contains)
- QQuickMouseArea::mousePressEvent(event);
- else
- event->ignore();
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::mouseReleaseEvent(QMouseEvent *event)
-{
- QQuickItem *pmi = parentMapItem();
-
- if (dragActive_ && pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)) {
- // position of the item may have changed by the time the activeChanged
- // is received, hence update already on mouse release
- qobject_cast<QDeclarativeGeoMapItemBase *>(pmi)->dragEnded();
- dragActive_ = false;
- }
-
- QQuickMouseArea::mouseReleaseEvent(event);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::mouseDoubleClickEvent(QMouseEvent *event)
-{
- QQuickMouseArea::mouseDoubleClickEvent(event);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::mouseMoveEvent(QMouseEvent *event)
-{
- QQuickMouseArea::mouseMoveEvent(event);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::hoverEnterEvent(QHoverEvent *event)
-{
- QQuickItem *pmi = parentMapItem();
- bool contains = true;
- if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi))
- contains = pmi->contains(event->pos());
-
- /* for many objects it's doubtful this will ever be true */
- if (!hovered() && contains)
- QQuickMouseArea::hoverEnterEvent(event);
- else
- event->ignore();
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::hoverMoveEvent(QHoverEvent *event)
-{
- QQuickItem *pmi = parentMapItem();
- bool contains = true;
- if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi))
- contains = pmi->contains(event->pos());
-
- /* we may have already entered the object from scenegraph's perspective
- * (ie, the hoverEnterEvent fired and we ignored it), so make sure our
- * state is set correctly here */
- if (hovered() && !contains)
- QQuickMouseArea::hoverLeaveEvent(event);
- else if (!hovered() && contains)
- QQuickMouseArea::hoverEnterEvent(event);
- else if (hovered() && contains)
- QQuickMouseArea::hoverMoveEvent(event);
- else
- event->ignore();
-}
-
-/*!
- \internal
-*/
-void QDeclarativeGeoMapMouseArea::hoverLeaveEvent(QHoverEvent *event)
-{
- QQuickItem *pmi = parentMapItem();
- bool contains = true;
- if (pmi && qobject_cast<QDeclarativeGeoMapItemBase *>(pmi))
- contains = pmi->contains(event->pos());
-
- if (!hovered() && contains)
- QQuickMouseArea::hoverEnterEvent(event);
-
- if (hovered())
- QQuickMouseArea::hoverLeaveEvent(event);
- else
- event->ignore();
-}
-
-/*!
- \internal
-*/
-QQuickItem *QDeclarativeGeoMapMouseArea::parentMapItem()
-{
- QQuickItem *item = this;
- while (item->parentItem()) {
- item = item->parentItem();
- if (qobject_cast<QDeclarativeGeoMap *>(item) ||
- qobject_cast<QDeclarativeGeoMapItemBase *>(item))
- return item;
- }
- return 0;
-}
-
-/*!
- \qmlproperty real QtLocation::MapMouseArea::mouseX
- \qmlproperty real QtLocation::MapMouseArea::mouseY
-
- These properties hold the screen coordinates of the mouse cursor.
-
- These properties will only be valid while a button is pressed, and will remain
- valid as long as the button is held down even if the mouse is moved outside the area.
-
- The screen coordinates are relative to the MapMouseArea.
-*/
-
-/*!
- \qmlproperty bool QtLocation::MapMouseArea::containsMouse
- This property holds whether the mouse is currently inside the mouse area.
-
- \warning This property is not updated if the area moves under the mouse: \e containsMouse will not change.
- In addition, containsMouse will only be valid when the mouse is pressed.
-*/
-
-/*!
- \qmlproperty bool QtLocation::MapMouseArea::pressed
- This property holds whether the mouse area is currently pressed.
-*/
-
-/*!
- \qmlproperty bool QtLocation::MapMouseArea::enabled
- This property holds whether the item accepts mouse events.
-
- By default, this property is true.
-*/
-
-/*!
- \qmlproperty MouseButton QtLocation::MapMouseArea::pressedButtons
- This property holds the mouse buttons currently pressed.
-
- It contains a bitwise combination of:
- \list
- \li Qt.LeftButton
- \li Qt.RightButton
- \li Qt.MiddleButton
- \endlist
-
- \sa acceptedButtons
-*/
-
-/*!
- \qmlproperty Qt::MouseButtons QtLocation::MapMouseArea::acceptedButtons
- This property holds the mouse buttons that the mouse area reacts to.
-
- The available buttons are:
- \list
- \li Qt.LeftButton
- \li Qt.RightButton
- \li Qt.MiddleButton
- \endlist
-
- To accept more than one button the flags can be combined with the
- "|" (or) operator:
-
- \code
- MapMouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }
- \endcode
-
- The default value is \c Qt.LeftButton.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onPressed(MapMouseEvent mouse)
-
- This handler is called when there is a press.
-
- The \l {MapMouseEvent}{mouse} parameter provides information about the
- press, including the x and y position and which button was pressed.
-
- The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter determines whether
- this MapMouseArea will handle the press and all future mouse events until
- release. The default is to accept the event and not allow other
- MapMouseArea beneath this one to handle the event. If \l {MapMouseEvent}{accepted}
- is set to false, no further events will be sent to this MapMouseArea until
- the button is next pressed.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onReleased(MapMouseEvent mouse)
-
- This handler is called when there is a release.
- The \l {MapMouseEvent}{mouse} parameter provides information about the
- click, including the x and y position of the release of the click.
-
- The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter is ignored
- in this handler.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onClicked(MapMouseEvent mouse)
-
- This handler is called when there is a click. A click is defined as a
- press followed by a release, both inside the MapMouseArea (pressing,
- moving outside the MapMouseArea, and then moving back inside and
- releasing is also considered a click).
-
- The \l {MapMouseEvent}{mouse} parameter provides information about the
- click, including the x and y position of the release of the click.
-
- The \l {MapMouseEvent}{accepted} property of the MapMouseEvent parameter is ignored in
- this handler.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onDoubleClicked(MapMouseEvent mouse)
-
- This handler is called when there is a double-click (a press followed
- by a release followed by a press).
-
- The \l {MapMouseEvent}{mouse} parameter provides information about the
- click, including the x and y position of the release of the click.
-
- If the \l {MapMouseEvent}{accepted} property of the \l {MapMouseEvent}{mouse} parameter is
- set to false in the handler, the onPressed/onReleased/onClicked handlers
- will be called for the second click; otherwise they are suppressed.
- The accepted property defaults to true.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onEntered()
-
- This handler is called when the mouse enters the mouse area.
-
- The onEntered handler is only called while a button is
- pressed.
-
- \sa onExited
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onPositionChanged(MapMouseEvent mouse)
-
- This handler is called when the mouse position changes.
-
- The \l {MapMouseEvent}{mouse} parameter provides information about the mouse, including the x and y
- position, and any buttons currently pressed.
-
- The \e accepted property of the MapMouseEvent parameter is ignored in this handler.
-
- The onPositionChanged handler is only called while a button is pressed.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onPressAndHold(MapMouseEvent mouse)
-
- This handler is called when there is a long press (currently 800ms).
- The \l {MapMouseEvent}{mouse} parameter provides information about the press, including the x and y
- position of the press, and which button is pressed.
-
- The \e accepted property of the MapMouseEvent parameter is ignored in this handler.
-*/
-
-/*!
- \qmlsignal QtLocation::MapMouseArea::onExited()
-
- This handler is called when the mouse exits the mouse area.
-
- The onExited handler is only called while a button is pressed.
-
- \sa onEntered
-*/
-
-#include "moc_qdeclarativegeomapmousearea_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapmouseevent.cpp b/src/imports/location/qdeclarativegeomapmouseevent.cpp
deleted file mode 100644
index 23e245b9..00000000
--- a/src/imports/location/qdeclarativegeomapmouseevent.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegeomapmouseevent_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype MapMouseEvent
- \instantiates QDeclarativeGeoMapMouseEvent
- \inqmlmodule QtLocation
- \ingroup qml-QtLocation5-maps
- \since Qt Location 5.0
-
- \brief The MapMouseEvent object provides information about a mouse event.
-
- The position of the mouse can be found via the \l x and \l y properties
- or the \l coordinate property. Both \a x and \a y are relative to the
- \l MapMouseArea that generated the event.
- The button that caused the event is available via the \l button property.
-
- \sa MapMouseArea
-*/
-
-QDeclarativeGeoMapMouseEvent::QDeclarativeGeoMapMouseEvent(QObject *parent)
- : QObject(parent),
- accepted_(false),
- button_(Qt::NoButton),
- modifiers_(Qt::NoModifier),
- wasHeld_(false),
- x_(0),
- y_(0),
- buttons_(Qt::NoButton)
-{
-}
-
-QDeclarativeGeoMapMouseEvent::~QDeclarativeGeoMapMouseEvent()
-{
-}
-
-/*!
- \qmlproperty bool QtLocation::MapMouseEvent::accepted
-
- Setting \a accepted to true prevents the mouse event from being
- propagated to items below the item currently handling the event.
-
- Generally, if the item acts on the mouse event then it should be accepted
- so that items lower in the stacking order do not also respond to the same event.
-*/
-
-void QDeclarativeGeoMapMouseEvent::setAccepted(bool accepted)
-{
- accepted_ = accepted;
-}
-
-bool QDeclarativeGeoMapMouseEvent::accepted() const
-{
- return accepted_;
-}
-
-/*!
- \qmlproperty enumeration QtLocation::MapMouseEvent::button
-
- This property holds the button that caused the event. It can be one of:
-
- \list
- \li Qt.LeftButton
- \li Qt.RightButton
- \li Qt.MiddleButton
- \endlist
-
- \sa buttons
-*/
-
-void QDeclarativeGeoMapMouseEvent::setButton(int button)
-{
- button_ = button;
-}
-
-int QDeclarativeGeoMapMouseEvent::button() const
-{
- return button_;
-}
-
-/*!
- \qmlproperty enumeration QtLocation::MapMouseEvent::buttons
-
- This property holds the mouse buttons pressed when the event was
- generated. For mouse move events, this is all buttons that are pressed
- down. For mouse press and double click events this includes the button
- that caused the event. For mouse release events this excludes the button
- that caused the event.
-
- It contains a bitwise combination of:
-
- \list
- \li Qt.LeftButton
- \li Qt.RightButton
- \li Qt.MiddleButton
- \endlist
-
- \sa button
-*/
-
-void QDeclarativeGeoMapMouseEvent::setButtons(int buttons)
-{
- buttons_ = buttons;
-}
-
-int QDeclarativeGeoMapMouseEvent::buttons() const
-{
- return buttons_;
-}
-
-/*!
- \qmlproperty int QtLocation::MapMouseEvent::modifiers
-
- This property holds the keyboard modifier flags that existed immediately
- before the event occurred.
-
- It contains a bitwise combination of:
- \list
- \li Qt.NoModifier - No modifier key is pressed.
- \li Qt.ShiftModifier - A Shift key on the keyboard is pressed.
- \li Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
- \li Qt.AltModifier - An Alt key on the keyboard is pressed.
- \li Qt.MetaModifier - A Meta key on the keyboard is pressed.
- \li Qt.KeypadModifier - A keypad button is pressed.
- \endlist
-*/
-
-void QDeclarativeGeoMapMouseEvent::setModifiers(int modifiers)
-{
- modifiers_ = modifiers;
-}
-
-int QDeclarativeGeoMapMouseEvent::modifiers() const
-{
- return modifiers_;
-}
-
-/*!
- \qmlproperty bool QtLocation::MapMouseEvent::wasHeld
-
- This property is true if the mouse button has been held pressed longer the threshold (800ms).
-*/
-
-void QDeclarativeGeoMapMouseEvent::setWasHeld(bool wasHeld)
-{
- wasHeld_ = wasHeld;
-}
-
-bool QDeclarativeGeoMapMouseEvent::wasHeld() const
-{
- return wasHeld_;
-}
-
-/*!
- \qmlproperty int QtLocation::MapMouseEvent::x
-
- This property holds the x-screen coordinate of the position supplied
- by the mouse event.
-*/
-
-void QDeclarativeGeoMapMouseEvent::setX(int x)
-{
- x_ = x;
-}
-
-int QDeclarativeGeoMapMouseEvent::x() const
-{
- return x_;
-}
-
-/*!
- \qmlproperty int QtLocation::MapMouseEvent::y
-
- This property holds the y-screen coordinate of the position supplied
- by the mouse event.
-*/
-
-void QDeclarativeGeoMapMouseEvent::setY(int y)
-{
- y_ = y;
-}
-
-int QDeclarativeGeoMapMouseEvent::y() const
-{
- return y_;
-}
-
-/*!
- \qmlproperty coordinate QtLocation::MapMouseEvent::coordinate
-
- This property holds the coordinate corresponding to the latitude
- and longitude of the position on the map at which the mouse event
- occurred.
-*/
-
-void QDeclarativeGeoMapMouseEvent::setCoordinate(const QGeoCoordinate &coordinate)
-{
- coordinate_ = coordinate;
-}
-
-QGeoCoordinate QDeclarativeGeoMapMouseEvent::coordinate()
-{
- return coordinate_;
-}
-
-#include "moc_qdeclarativegeomapmouseevent_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 8bb78e14..50f23f54 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -40,9 +40,12 @@
****************************************************************************/
#include "qdeclarativegeomapquickitem_p.h"
-#include "qdeclarativegeomapmousearea_p.h"
+
+#include <QtCore/QScopedValueRollback>
#include <QtQml/qqmlinfo.h>
#include <QtQuick/QSGOpacityNode>
+#include "qdoublevector2d_p.h"
+#include <QtQuick/private/qquickmousearea_p.h>
#include <QDebug>
#include <cmath>
@@ -88,50 +91,6 @@ QT_BEGIN_NAMESPACE
"on the screen" rather than "on the map", so that its size remains the same
regardless of the zoom level of the Map.
- \section2 Interaction
-
- MapQuickItem is different to the other map objects in that it can
- accept "normal" QtQuick mouse and touch interaction types as well as
- the MapMouseArea and friends. For example, for a MapQuickItem, the following
- two situations are equivalent:
-
- \code
- MapQuickItem {
- sourceItem: Rectangle {
- width: 20; height: 20
- }
-
- MapMouseArea {
- onClicked: {
- console.log("clicked!");
- }
- }
- }
- \endcode
-
- \code
- MapQuickItem {
- sourceItem: Rectangle {
- width: 20; height: 20
-
- MouseArea {
- onClicked: {
- console.log("clicked!");
- }
- }
- }
- }
- \endcode
-
- Note, however, that using a MapMouseArea inside the sourceItem (in this
- case, inside the Rectangle object), is unsupported, and may not work as
- desired.
-
- MouseAreas used inside a complex \l{sourceItem} can be used to create, for
- example, a "close" button within a speech bubble that can be clicked
- separately to the rest of the bubble, which would be impossible using
- MapMouseArea alone.
-
\section2 Performance
Performance of a MapQuickItem is normally in the same ballpark as the
@@ -162,7 +121,7 @@ QT_BEGIN_NAMESPACE
QDeclarativeGeoMapQuickItem::QDeclarativeGeoMapQuickItem(QQuickItem *parent)
: QDeclarativeGeoMapItemBase(parent), zoomLevel_(0.0), inUpdate_(false),
- mapAndSourceItemSet_(false)
+ mapAndSourceItemSet_(false), updatingGeometry_(false)
{
setFlag(ItemHasContents, true);
opacityContainer_ = new QQuickItem(this);
@@ -214,13 +173,20 @@ void QDeclarativeGeoMapQuickItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
/*!
\internal
*/
-void QDeclarativeGeoMapQuickItem::dragEnded()
+void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (!mapAndSourceItemSet_)
+ if (!mapAndSourceItemSet_ || updatingGeometry_ ||
+ newGeometry.topLeft() == oldGeometry.topLeft()) {
+ QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(QPointF(x(), y()) + (scaleFactor() * anchorPoint_), false);
+ }
+
+ QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
if (newCoordinate.isValid())
setCoordinate(newCoordinate);
+
+ // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
+ // call to this function.
}
/*!
@@ -262,7 +228,7 @@ void QDeclarativeGeoMapQuickItem::afterChildrenChanged()
bool printedWarning = false;
foreach (QQuickItem *i, kids) {
if (i->flags() & QQuickItem::ItemHasContents
- && !qobject_cast<QDeclarativeGeoMapMouseArea *>(i)
+ && !qobject_cast<QQuickMouseArea *>(i)
&& sourceItem_.data() != i
&& opacityContainer_ != i) {
if (!printedWarning) {
@@ -359,6 +325,9 @@ void QDeclarativeGeoMapQuickItem::updateMapItem()
this, SLOT(updateMapItem()));
}
+ QScopedValueRollback<bool> rollback(updatingGeometry_);
+ updatingGeometry_ = true;
+
opacityContainer_->setOpacity(zoomLevelOpacity());
sourceItem_.data()->setScale(scaleFactor());
diff --git a/src/imports/location/qdeclarativegeomapquickitem_p.h b/src/imports/location/qdeclarativegeomapquickitem_p.h
index 1ed658d9..b9510b37 100644
--- a/src/imports/location/qdeclarativegeomapquickitem_p.h
+++ b/src/imports/location/qdeclarativegeomapquickitem_p.h
@@ -76,14 +76,15 @@ public:
void setZoomLevel(qreal zoomLevel);
qreal zoomLevel() const;
- void dragEnded();
-
Q_SIGNALS:
void coordinateChanged();
void sourceItemChanged();
void anchorPointChanged();
void zoomLevelChanged();
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
protected Q_SLOTS:
virtual void updateMapItem();
virtual void afterChildrenChanged();
@@ -98,6 +99,7 @@ private:
qreal zoomLevel_;
bool inUpdate_;
bool mapAndSourceItemSet_;
+ bool updatingGeometry_;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomaptype.cpp b/src/imports/location/qdeclarativegeomaptype.cpp
index b85bb66d..046c16d1 100644
--- a/src/imports/location/qdeclarativegeomaptype.cpp
+++ b/src/imports/location/qdeclarativegeomaptype.cpp
@@ -77,8 +77,10 @@ QDeclarativeGeoMapType::~QDeclarativeGeoMapType() {}
\li MapType.SatelliteMapDay - A map with day-time satellite imagery.
\li MapType.SatelliteMapNight - A map with night-time satellite imagery.
\li MapType.TerrainMap - A terrain map.
- \li MapType.HybridMap - A map with satellite imagery and streen information.
+ \li MapType.HybridMap - A map with satellite imagery and street information.
\li MapType.GrayStreetMap - A gray-shaded street map.
+ \li MapType::PedestrianMap - A street map suitable for pedestriants.
+ \li MapType::CarNavigationMap - A street map suitable for car navigation.
\li MapType.CustomMap - A custom map type.
\endlist
*/
diff --git a/src/imports/location/qdeclarativegeomaptype_p.h b/src/imports/location/qdeclarativegeomaptype_p.h
index da5e29cb..974e00a0 100644
--- a/src/imports/location/qdeclarativegeomaptype_p.h
+++ b/src/imports/location/qdeclarativegeomaptype_p.h
@@ -68,6 +68,8 @@ public:
HybridMap = QGeoMapType::HybridMap,
TransitMap = QGeoMapType::TransitMap,
GrayStreetMap = QGeoMapType::GrayStreetMap,
+ PedestrianMap = QGeoMapType::PedestrianMap,
+ CarNavigationMap = QGeoMapType::CarNavigationMap,
CustomMap = 100
};
diff --git a/src/imports/location/qdeclarativegeoroute.cpp b/src/imports/location/qdeclarativegeoroute.cpp
index 4a4fe9f8..f7db10ea 100644
--- a/src/imports/location/qdeclarativegeoroute.cpp
+++ b/src/imports/location/qdeclarativegeoroute.cpp
@@ -100,7 +100,9 @@ void QDeclarativeGeoRoute::init()
{
QGeoRouteSegment segment = route_.firstRouteSegment();
while (segment.isValid()) {
- segments_.append(new QDeclarativeGeoRouteSegment(segment, this));
+ QDeclarativeGeoRouteSegment *routeSegment = new QDeclarativeGeoRouteSegment(segment, this);
+ QQmlEngine::setContextForObject(routeSegment, QQmlEngine::contextForObject(this));
+ segments_.append(routeSegment);
segment = segment.nextRouteSegment();
}
}
diff --git a/src/imports/location/qdeclarativegeoroutemodel.cpp b/src/imports/location/qdeclarativegeoroutemodel.cpp
index 48375c56..829398cf 100644
--- a/src/imports/location/qdeclarativegeoroutemodel.cpp
+++ b/src/imports/location/qdeclarativegeoroutemodel.cpp
@@ -286,7 +286,14 @@ void QDeclarativeGeoRouteModel::setPlugin(QDeclarativeGeoServiceProvider *plugin
return;
reset(); // reset the model
+
+ if (plugin_)
+ disconnect(plugin_, SIGNAL(localesChanged()), this, SIGNAL(measurementSystemChanged()));
+ if (plugin)
+ connect(plugin, SIGNAL(localesChanged()), this, SIGNAL(measurementSystemChanged()));
+
plugin_ = plugin;
+
if (complete_)
emit pluginChanged();
@@ -408,6 +415,65 @@ bool QDeclarativeGeoRouteModel::autoUpdate() const
}
/*!
+ \qmlproperty Locale::MeasurementSystem QtLocation::RouteModel::measurementSystem
+
+ This property holds the measurement system which will be used when calculating the route. This
+ property is changed when the \l {QtLocation::Plugin::locales}{Plugin::locales} property of
+ \l {QtLocation::RouteModel::plugin}{plugin} changes.
+
+ If setting this property it must be set after the \l {QtLocation::RouteModel::plugin}{plugin}
+ property is set.
+*/
+void QDeclarativeGeoRouteModel::setMeasurementSystem(QLocale::MeasurementSystem ms)
+{
+ if (!plugin_) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_PLUGIN_NOT_SET);
+ return;
+ }
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return;
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ return;
+ }
+
+ if (routingManager->measurementSystem() == ms)
+ return;
+
+ routingManager->setMeasurementSystem(ms);
+ emit measurementSystemChanged();
+}
+
+QLocale::MeasurementSystem QDeclarativeGeoRouteModel::measurementSystem() const
+{
+ if (!plugin_)
+ return QLocale().measurementSystem();
+
+ QGeoServiceProvider *serviceProvider = plugin_->sharedGeoServiceProvider();
+ if (!serviceProvider) {
+ if (plugin_->locales().isEmpty())
+ return QLocale().measurementSystem();
+
+ return QLocale(plugin_->locales().first()).measurementSystem();
+ }
+
+ QGeoRoutingManager *routingManager = serviceProvider->routingManager();
+ if (!routingManager) {
+ qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, ROUTE_MGR_NOT_SET);
+ if (plugin_->locales().isEmpty())
+ return QLocale().measurementSystem();
+
+ return QLocale(plugin_->locales().first()).measurementSystem();
+ }
+
+ return routingManager->measurementSystem();
+}
+
+/*!
\internal
*/
void QDeclarativeGeoRouteModel::setStatus(QDeclarativeGeoRouteModel::Status status)
@@ -560,8 +626,11 @@ void QDeclarativeGeoRouteModel::routingFinished(QGeoRouteReply *reply)
qDeleteAll(routes_);
// Convert routes to declarative
routes_.clear();
- for (int i = 0; i < reply->routes().size(); ++i)
- routes_.append(new QDeclarativeGeoRoute(reply->routes().at(i), this));
+ for (int i = 0; i < reply->routes().size(); ++i) {
+ QDeclarativeGeoRoute *route = new QDeclarativeGeoRoute(reply->routes().at(i), this);
+ QQmlEngine::setContextForObject(route, QQmlEngine::contextForObject(this));
+ routes_.append(route);
+ }
endResetModel();
setErrorString("");
@@ -820,7 +889,7 @@ void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value)
QGeoRectangle r = parseRectangle(value.property(i), &ok);
if (!ok || !r.isValid()) {
- qmlInfo(this) << "Unsupported waypoint type";
+ qmlInfo(this) << "Unsupported area type";
return;
}
diff --git a/src/imports/location/qdeclarativegeoroutemodel_p.h b/src/imports/location/qdeclarativegeoroutemodel_p.h
index 0d663eed..bd9b9718 100644
--- a/src/imports/location/qdeclarativegeoroutemodel_p.h
+++ b/src/imports/location/qdeclarativegeoroutemodel_p.h
@@ -77,6 +77,8 @@ class QDeclarativeGeoRouteModel : public QAbstractListModel, public QQmlParserSt
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
Q_PROPERTY(RouteError error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QLocale::MeasurementSystem measurementSystem READ measurementSystem WRITE setMeasurementSystem NOTIFY measurementSystemChanged)
+
Q_INTERFACES(QQmlParserStatus)
public:
@@ -121,6 +123,9 @@ public:
void setAutoUpdate(bool autoUpdate);
bool autoUpdate() const;
+ void setMeasurementSystem(QLocale::MeasurementSystem ms);
+ QLocale::MeasurementSystem measurementSystem() const;
+
Status status() const;
QString errorString() const;
RouteError error() const;
@@ -139,6 +144,7 @@ Q_SIGNALS:
void errorStringChanged();
void errorChanged();
void routesChanged();
+ void measurementSystemChanged();
public Q_SLOTS:
void update();
diff --git a/src/imports/location/qdeclarativegeoserviceprovider.cpp b/src/imports/location/qdeclarativegeoserviceprovider.cpp
index f91b9ed1..da92644c 100644
--- a/src/imports/location/qdeclarativegeoserviceprovider.cpp
+++ b/src/imports/location/qdeclarativegeoserviceprovider.cpp
@@ -571,9 +571,9 @@ void QDeclarativeGeoServiceProvider::parameter_clear(QQmlListProperty<QDeclarati
/*!
\internal
*/
-QMap<QString, QVariant> QDeclarativeGeoServiceProvider::parameterMap() const
+QVariantMap QDeclarativeGeoServiceProvider::parameterMap() const
{
- QMap<QString, QVariant> map;
+ QVariantMap map;
for (int i = 0; i < parameters_.size(); ++i) {
QDeclarativeGeoServiceProviderParameter *parameter = parameters_.at(i);
diff --git a/src/imports/location/qdeclarativegeoserviceprovider_p.h b/src/imports/location/qdeclarativegeoserviceprovider_p.h
index 75743f83..b859f803 100644
--- a/src/imports/location/qdeclarativegeoserviceprovider_p.h
+++ b/src/imports/location/qdeclarativegeoserviceprovider_p.h
@@ -169,7 +169,7 @@ public:
QString name() const;
QQmlListProperty<QDeclarativeGeoServiceProviderParameter> parameters();
- QMap<QString, QVariant> parameterMap() const;
+ QVariantMap parameterMap() const;
QStringList availableServiceProviders();
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index efd8be2c..55261ed1 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -45,6 +45,7 @@
#include "error_messages.h"
#include "locationvaluetypehelper_p.h"
+#include <QtCore/QScopedValueRollback>
#include <QtGui/private/qtriangulator_p.h>
#include <QtQml/QQmlInfo>
#include <QtQml/QQmlContext>
@@ -55,6 +56,8 @@
#include <QPainterPath>
#include <qnumeric.h>
+#include "qdoublevector2d_p.h"
+
/* poly2tri triangulator includes */
#include "../../3rdparty/poly2tri/common/shapes.h"
#include "../../3rdparty/poly2tri/sweep/cdt.h"
@@ -96,7 +99,7 @@ QT_BEGIN_NAMESPACE
\l border.width properties.
\note Since MapPolygons are geographic items, dragging a MapPolygon
- (through the use of \l MapMouseArea) causes its vertices to be
+ (through the use of \l MouseArea) causes its vertices to be
recalculated in the geographic coordinate space. The edges retain the
same geographic lengths (latitude and longitude differences between the
vertices), but they remain straight. Apparent stretching of the item occurs
@@ -112,7 +115,7 @@ QT_BEGIN_NAMESPACE
or removing points.
Like the other map objects, MapPolygon is normally drawn without a smooth
- appearance. Setting the \l {QtQuick2::Item::opacity}{opacity} property will force the object to
+ appearance. Setting the \l {QtQuick::Item::opacity}{opacity} property will force the object to
be blended, which decreases performance considerably depending on the hardware in use.
\section2 Example Usage
@@ -156,14 +159,14 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
if (!sourceDirty_)
return;
- qreal minX = -1.0;
+ double minX = -1.0;
// build the actual path
- QPointF origin;
- QPointF lastPoint;
+ QDoubleVector2D origin;
+ QDoubleVector2D lastPoint;
srcPath_ = QPainterPath();
- qreal unwrapBelowX = 0;
+ double unwrapBelowX = 0;
if (preserveGeometry_ )
unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
@@ -173,7 +176,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QPointF point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -188,14 +191,14 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
origin = point;
minX = point.x();
srcOrigin_ = coord;
- srcPath_.moveTo(point - origin);
+ srcPath_.moveTo(point.toPointF() - origin.toPointF());
lastPoint = point;
} else {
if (point.x() <= minX)
minX = point.x();
- const QPointF diff = (point - lastPoint);
+ const QDoubleVector2D diff = (point - lastPoint);
if (diff.x() * diff.x() + diff.y() * diff.y() >= 3.0) {
- srcPath_.lineTo(point - origin);
+ srcPath_.lineTo(point.toPointF() - origin.toPointF());
lastPoint = point;
}
}
@@ -207,7 +210,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
srcPath_ = srcPath_.simplified();
sourceBounds_ = srcPath_.boundingRect();
- geoLeftBound_ = map.screenPositionToCoordinate(QPointF(minX, 0), false);
+ geoLeftBound_ = map.screenPositionToCoordinate(QDoubleVector2D(minX, 0), false);
}
/*!
@@ -223,12 +226,12 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
return;
}
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false);
+ QDoubleVector2D origin = map.coordinateToScreenPosition(srcOrigin_, false);
// Create the viewport rect in the same coordinate system
// as the actual points
QRectF viewport(0, 0, map.width(), map.height());
- viewport.translate(-1 * origin);
+ viewport.translate(-1 * origin.toPointF());
QPainterPath vpPath;
vpPath.addRect(viewport);
@@ -318,10 +321,9 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
}
-QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent) :
- QDeclarativeGeoMapItemBase(parent),
- color_(Qt::transparent),
- dirtyMaterial_(true)
+QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
+: QDeclarativeGeoMapItemBase(parent), color_(Qt::transparent), dirtyMaterial_(true),
+ updatingGeometry_(false)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
@@ -349,7 +351,7 @@ QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem()
\qmlproperty color MapPolygon::border.color
This property is part of the border property group. The border property
- group holds the width and color used to draw the border of the circle.
+ group holds the width and color used to draw the border of the polygon.
The width is in pixels and is independent of the zoom level of the map.
@@ -538,26 +540,27 @@ void QDeclarativePolygonMapItem::updateMapItem()
if (!map() || path_.count() == 0)
return;
+ QScopedValueRollback<bool> rollback(updatingGeometry_);
+ updatingGeometry_ = true;
+
geometry_.updateSourcePoints(*map(), path_);
geometry_.updateScreenPoints(*map());
- if (border_.color() != Qt::transparent && border_.width() > 0) {
- QList<QGeoCoordinate> closedPath = path_;
- closedPath << closedPath.first();
- borderGeometry_.updateSourcePoints(*map(), closedPath);
+ QList<QGeoCoordinate> closedPath = path_;
+ closedPath << closedPath.first();
+ borderGeometry_.clear();
+ borderGeometry_.updateSourcePoints(*map(), closedPath);
+
+ if (border_.color() != Qt::transparent && border_.width() > 0)
borderGeometry_.updateScreenPoints(*map(), border_.width());
- QList<QGeoMapItemGeometry *> geoms;
- geoms << &geometry_ << &borderGeometry_;
- QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms);
+ QList<QGeoMapItemGeometry *> geoms;
+ geoms << &geometry_ << &borderGeometry_;
+ QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms);
+
+ setWidth(combined.width());
+ setHeight(combined.height());
- setWidth(combined.width());
- setHeight(combined.height());
- } else {
- borderGeometry_.clear();
- setWidth(geometry_.sourceBoundingBox().width());
- setHeight(geometry_.sourceBoundingBox().height());
- }
setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft());
update();
}
@@ -609,19 +612,14 @@ bool QDeclarativePolygonMapItem::contains(const QPointF &point) const
/*!
\internal
*/
-void QDeclarativePolygonMapItem::dragStarted()
+void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- geometry_.markFullScreenDirty();
- borderGeometry_.markFullScreenDirty();
- updateMapItem();
-}
+ if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
+ return;
+ }
-/*!
- \internal
-*/
-void QDeclarativePolygonMapItem::dragEnded()
-{
- QPointF newPoint = QPointF(x(),y()) + geometry_.firstPointOffset();
+ QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
@@ -660,6 +658,9 @@ void QDeclarativePolygonMapItem::dragEnded()
updateMapItem();
emit pathChanged();
}
+
+ // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
+ // call to this function.
}
//////////////////////////////////////////////////////////////////////
diff --git a/src/imports/location/qdeclarativepolygonmapitem_p.h b/src/imports/location/qdeclarativepolygonmapitem_p.h
index d95e1de3..e96dd2cf 100644
--- a/src/imports/location/qdeclarativepolygonmapitem_p.h
+++ b/src/imports/location/qdeclarativepolygonmapitem_p.h
@@ -101,13 +101,14 @@ public:
QDeclarativeMapLineProperties *border();
bool contains(const QPointF &point) const;
- void dragStarted();
- void dragEnded();
Q_SIGNALS:
void pathChanged();
void colorChanged(const QColor &color);
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
protected Q_SLOTS:
virtual void updateMapItem();
void handleBorderUpdated();
@@ -122,6 +123,7 @@ private:
bool dirtyMaterial_;
QGeoMapPolygonGeometry geometry_;
QGeoMapPolylineGeometry borderGeometry_;
+ bool updatingGeometry_;
};
//////////////////////////////////////////////////////////////////////
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index 5ffe9e8a..65b61da1 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -44,7 +44,9 @@
#include "qlocationutils_p.h"
#include "error_messages.h"
#include "locationvaluetypehelper_p.h"
+#include "qdoublevector2d_p.h"
+#include <QtCore/QScopedValueRollback>
#include <QtQml/QQmlInfo>
#include <QtQml/QQmlContext>
#include <QtQml/private/qqmlengine_p.h>
@@ -94,7 +96,7 @@ QT_BEGIN_NAMESPACE
the Map grows in direct proportion to the number of points in the polyline.
Like the other map objects, MapPolyline is normally drawn without a smooth
- appearance. Setting the \l {QtQuick2::Item::opacity}{opacity} property will force the object to
+ appearance. Setting the \l {QtQuick::Item::opacity}{opacity} property will force the object to
be blended, which decreases performance considerably depending on the hardware in use.
\note MapPolylines are implemented using the OpenGL GL_LINES
@@ -190,10 +192,10 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
const QList<QGeoCoordinate> &path)
{
bool foundValid = false;
- qreal minX = -1.0;
- qreal minY = -1.0;
- qreal maxX = -1.0;
- qreal maxY = -1.0;
+ double minX = -1.0;
+ double minY = -1.0;
+ double maxX = -1.0;
+ double maxY = -1.0;
if (!sourceDirty_)
return;
@@ -204,9 +206,9 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
srcPointTypes_.clear();
srcPointTypes_.reserve(path.size());
- QPointF origin, lastPoint, lastAddedPoint;
+ QDoubleVector2D origin, lastPoint, lastAddedPoint;
- qreal unwrapBelowX = 0;
+ double unwrapBelowX = 0;
if (preserveGeometry_)
unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
@@ -216,7 +218,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QPointF point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -231,7 +233,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
foundValid = true;
srcOrigin_ = coord;
origin = point;
- point = QPointF(0,0);
+ point = QDoubleVector2D(0,0);
minX = point.x();
maxX = minX;
@@ -241,8 +243,6 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
srcPoints_ << point.x() << point.y();
srcPointTypes_ << QPainterPath::MoveToElement;
lastAddedPoint = point;
-
-
} else {
point -= origin;
@@ -264,7 +264,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
sourceBounds_ = QRectF(QPointF(minX, minY), QPointF(maxX, maxY));
geoLeftBound_ = map.screenPositionToCoordinate(
- QPointF(minX + origin.x(), minY + origin.y()), false);
+ QDoubleVector2D(minX + origin.x(), minY + origin.y()), false);
}
////////////////////////////////////////////////////////////////////////////
@@ -390,7 +390,7 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
if (!screenDirty_)
return;
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false);
+ QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
if (!qIsFinite(origin.x()) || !qIsFinite(origin.y())) {
clear();
@@ -450,9 +450,8 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
this->translate( -1 * sourceBounds_.topLeft());
}
-QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent) :
- QDeclarativeGeoMapItemBase(parent),
- dirtyMaterial_(true)
+QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent)
+: QDeclarativeGeoMapItemBase(parent), dirtyMaterial_(true), updatingGeometry_(false)
{
setFlag(ItemHasContents, true);
QObject::connect(&line_, SIGNAL(colorChanged(QColor)),
@@ -612,6 +611,57 @@ QDeclarativeMapLineProperties *QDeclarativePolylineMapItem::line()
/*!
\internal
*/
+void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
+ return;
+ }
+
+ QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
+ QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ if (newCoordinate.isValid()) {
+ double firstLongitude = path_.at(0).longitude();
+ double firstLatitude = path_.at(0).latitude();
+ double minMaxLatitude = firstLatitude;
+ // prevent dragging over valid min and max latitudes
+ for (int i = 0; i < path_.count(); ++i) {
+ double newLatitude = path_.at(i).latitude()
+ + newCoordinate.latitude() - firstLatitude;
+ if (!QLocationUtils::isValidLat(newLatitude)) {
+ if (qAbs(newLatitude) > qAbs(minMaxLatitude)) {
+ minMaxLatitude = newLatitude;
+ }
+ }
+ }
+ // calculate offset needed to re-position the item within map border
+ double offsetLatitude = minMaxLatitude - QLocationUtils::clipLat(minMaxLatitude);
+ for (int i = 0; i < path_.count(); ++i) {
+ QGeoCoordinate coord = path_.at(i);
+ // handle dateline crossing
+ coord.setLongitude(QLocationUtils::wrapLong(coord.longitude()
+ + newCoordinate.longitude() - firstLongitude));
+ coord.setLatitude(coord.latitude()
+ + newCoordinate.latitude() - firstLatitude - offsetLatitude);
+ path_.replace(i, coord);
+ }
+
+ QGeoCoordinate leftBoundCoord = geometry_.geoLeftBound();
+ leftBoundCoord.setLongitude(QLocationUtils::wrapLong(leftBoundCoord.longitude()
+ + newCoordinate.longitude() - firstLongitude));
+ geometry_.setPreserveGeometry(true, leftBoundCoord);
+ geometry_.markSourceDirty();
+ updateMapItem();
+ emit pathChanged();
+ }
+
+ // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
+ // call to this function.
+}
+
+/*!
+ \internal
+*/
void QDeclarativePolylineMapItem::afterViewportChanged(const QGeoMapViewportChangeEvent &event)
{
if (event.mapSize.width() <= 0 || event.mapSize.height() <= 0)
@@ -648,6 +698,9 @@ void QDeclarativePolylineMapItem::updateMapItem()
if (!map() || path_.count() == 0)
return;
+ QScopedValueRollback<bool> rollback(updatingGeometry_);
+ updatingGeometry_ = true;
+
geometry_.updateSourcePoints(*map(), path_);
geometry_.updateScreenPoints(*map(), line_.width());
@@ -685,58 +738,6 @@ bool QDeclarativePolylineMapItem::contains(const QPointF &point) const
return geometry_.contains(point);
}
-/*!
- \internal
-*/
-void QDeclarativePolylineMapItem::dragStarted()
-{
- geometry_.markFullScreenDirty();
- updateMapItem();
-}
-
-/*!
- \internal
-*/
-void QDeclarativePolylineMapItem::dragEnded()
-{
- QPointF newPoint = QPointF(x(),y()) + geometry_.firstPointOffset();
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
- if (newCoordinate.isValid()) {
- double firstLongitude = path_.at(0).longitude();
- double firstLatitude = path_.at(0).latitude();
- double minMaxLatitude = firstLatitude;
- // prevent dragging over valid min and max latitudes
- for (int i = 0; i < path_.count(); ++i) {
- double newLatitude = path_.at(i).latitude()
- + newCoordinate.latitude() - firstLatitude;
- if (!QLocationUtils::isValidLat(newLatitude)) {
- if (qAbs(newLatitude) > qAbs(minMaxLatitude)) {
- minMaxLatitude = newLatitude;
- }
- }
- }
- // calculate offset needed to re-position the item within map border
- double offsetLatitude = minMaxLatitude - QLocationUtils::clipLat(minMaxLatitude);
- for (int i = 0; i < path_.count(); ++i) {
- QGeoCoordinate coord = path_.at(i);
- // handle dateline crossing
- coord.setLongitude(QLocationUtils::wrapLong(coord.longitude()
- + newCoordinate.longitude() - firstLongitude));
- coord.setLatitude(coord.latitude()
- + newCoordinate.latitude() - firstLatitude - offsetLatitude);
- path_.replace(i, coord);
- }
-
- QGeoCoordinate leftBoundCoord = geometry_.geoLeftBound();
- leftBoundCoord.setLongitude(QLocationUtils::wrapLong(leftBoundCoord.longitude()
- + newCoordinate.longitude() - firstLongitude));
- geometry_.setPreserveGeometry(true, leftBoundCoord);
- geometry_.markSourceDirty();
- updateMapItem();
- emit pathChanged();
- }
-}
-
//////////////////////////////////////////////////////////////////////
/*!
diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h
index c6e5740d..18f85b09 100644
--- a/src/imports/location/qdeclarativepolylinemapitem_p.h
+++ b/src/imports/location/qdeclarativepolylinemapitem_p.h
@@ -124,12 +124,12 @@ public:
QDeclarativeMapLineProperties *line();
- void dragStarted();
- void dragEnded();
-
Q_SIGNALS:
void pathChanged();
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
protected Q_SLOTS:
virtual void updateMapItem();
void updateAfterLinePropertiesChanged();
@@ -143,6 +143,7 @@ private:
QColor color_;
bool dirtyMaterial_;
QGeoMapPolylineGeometry geometry_;
+ bool updatingGeometry_;
};
//////////////////////////////////////////////////////////////////////
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 797ba26d..54514ea5 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -47,6 +47,7 @@
#include <qnumeric.h>
#include <QRectF>
#include <QPointF>
+#include <QtCore/QScopedValueRollback>
QT_BEGIN_NAMESPACE
@@ -136,8 +137,8 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
if (!screenDirty_ && !sourceDirty_)
return;
- QPointF tl = map.coordinateToScreenPosition(topLeft, false);
- QPointF br = map.coordinateToScreenPosition(bottomRight, false);
+ QDoubleVector2D tl = map.coordinateToScreenPosition(topLeft, false);
+ QDoubleVector2D br = map.coordinateToScreenPosition(bottomRight, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -147,14 +148,13 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
return;
if ( preserveGeometry_ ) {
- qreal unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ double unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
if (br.x() < unwrapBelowX)
br.setX(tl.x() + screenBounds_.width());
}
-
- QRectF re(tl, br);
- re.translate(-1 * tl);
+ QRectF re(tl.toPointF(), br.toPointF());
+ re.translate(-1 * tl.toPointF());
clear();
screenVertices_.reserve(6);
@@ -178,7 +178,8 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
}
QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent)
-: QDeclarativeGeoMapItemBase(parent), color_(Qt::transparent), dirtyMaterial_(true)
+: QDeclarativeGeoMapItemBase(parent), color_(Qt::transparent), dirtyMaterial_(true),
+ updatingGeometry_(false)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
@@ -343,6 +344,9 @@ void QDeclarativeRectangleMapItem::updateMapItem()
if (!map() || !topLeft().isValid() || !bottomRight().isValid())
return;
+ QScopedValueRollback<bool> rollback(updatingGeometry_);
+ updatingGeometry_ = true;
+
geometry_.updatePoints(*map(), topLeft_, bottomRight_);
QList<QGeoCoordinate> pathClosed;
@@ -420,18 +424,14 @@ bool QDeclarativeRectangleMapItem::contains(const QPointF &point) const
/*!
\internal
*/
-void QDeclarativeRectangleMapItem::dragStarted()
+void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- borderGeometry_.markFullScreenDirty();
- updateMapItem();
-}
+ if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
+ return;
+ }
-/*!
- \internal
-*/
-void QDeclarativeRectangleMapItem::dragEnded()
-{
- QPointF newTopLeftPoint = QPointF(x(),y());
+ QDoubleVector2D newTopLeftPoint = QDoubleVector2D(x(),y());
QGeoCoordinate newTopLeft = map()->screenPositionToCoordinate(newTopLeftPoint, false);
if (newTopLeft.isValid()) {
// calculate new geo width while checking for dateline crossing
@@ -460,6 +460,9 @@ void QDeclarativeRectangleMapItem::dragEnded()
emit topLeftChanged(topLeft_);
emit bottomRightChanged(bottomRight_);
}
+
+ // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
+ // call to this function.
}
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativerectanglemapitem_p.h b/src/imports/location/qdeclarativerectanglemapitem_p.h
index 71915d5b..ead79f59 100644
--- a/src/imports/location/qdeclarativerectanglemapitem_p.h
+++ b/src/imports/location/qdeclarativerectanglemapitem_p.h
@@ -92,8 +92,6 @@ public:
QDeclarativeMapLineProperties *border();
- void dragStarted();
- void dragEnded();
bool contains(const QPointF &point) const;
Q_SIGNALS:
@@ -101,6 +99,9 @@ Q_SIGNALS:
void bottomRightChanged(const QGeoCoordinate &bottomRight);
void colorChanged(const QColor &color);
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
protected Q_SLOTS:
virtual void updateMapItem();
void updateMapItemAssumeDirty();
@@ -114,6 +115,7 @@ private:
bool dirtyMaterial_;
QGeoMapRectangleGeometry geometry_;
QGeoMapPolylineGeometry borderGeometry_;
+ bool updatingGeometry_;
};
//////////////////////////////////////////////////////////////////////
diff --git a/src/imports/location/qdeclarativeroutemapitem.cpp b/src/imports/location/qdeclarativeroutemapitem.cpp
index f084dbb8..4f2ee546 100644
--- a/src/imports/location/qdeclarativeroutemapitem.cpp
+++ b/src/imports/location/qdeclarativeroutemapitem.cpp
@@ -44,6 +44,7 @@
#include "qdeclarativepolylinemapitem_p.h"
#include "qgeocameracapabilities_p.h"
#include "qdeclarativegeoroute_p.h"
+
#include <QtQml/QQmlInfo>
#include <QtGui/QPainter>
@@ -81,9 +82,8 @@
*/
-QDeclarativeRouteMapItem::QDeclarativeRouteMapItem(QQuickItem *parent):
- QDeclarativeGeoMapItemBase(parent),
- route_(0)
+QDeclarativeRouteMapItem::QDeclarativeRouteMapItem(QQuickItem *parent)
+: QDeclarativeGeoMapItemBase(parent), route_(0)
{
setFlag(ItemHasContents, true);
line_.setWidth(3.0);
diff --git a/src/imports/location/qdeclarativeroutemapitem_p.h b/src/imports/location/qdeclarativeroutemapitem_p.h
index 479a621d..f80e896d 100644
--- a/src/imports/location/qdeclarativeroutemapitem_p.h
+++ b/src/imports/location/qdeclarativeroutemapitem_p.h
@@ -87,7 +87,6 @@ private:
QDeclarativeGeoRoute *route_;
QList<QGeoCoordinate> path_;
bool dirtyMaterial_;
- bool dragActive_;
QGeoMapPolylineGeometry geometry_;
};
diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp
index 0f750cab..528b084c 100644
--- a/src/imports/location/qgeomapitemgeometry.cpp
+++ b/src/imports/location/qgeomapitemgeometry.cpp
@@ -43,6 +43,7 @@
#include "qdeclarativegeomap_p.h"
#include "qlocationutils_p.h"
#include <QtQuick/QSGGeometry>
+#include "qdoublevector2d_p.h"
QT_BEGIN_NAMESPACE
@@ -131,15 +132,15 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map,
const QGeoCoordinate &fromCoord,
const QGeoCoordinate &toCoord)
{
- QGeoCoordinate mapMid = map.screenPositionToCoordinate(QPointF(map.width()/2.0, 0));
+ QGeoCoordinate mapMid = map.screenPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0));
double halfGeoDist = toCoord.longitude() - fromCoord.longitude();
if (toCoord.longitude() < fromCoord.longitude())
halfGeoDist += 360;
halfGeoDist /= 2.0;
QGeoCoordinate geoDelta = QGeoCoordinate(0,
QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist));
- QPointF halfScreenDist = map.coordinateToScreenPosition(geoDelta, false)
- - QPointF(map.width()/2.0, 0);
+ QDoubleVector2D halfScreenDist = map.coordinateToScreenPosition(geoDelta, false)
+ - QDoubleVector2D(map.width()/2.0, 0);
return halfScreenDist.x() * 2.0;
}
diff --git a/src/imports/positioning/locationsingleton.cpp b/src/imports/positioning/locationsingleton.cpp
index 5fb96f49..4f675d26 100644
--- a/src/imports/positioning/locationsingleton.cpp
+++ b/src/imports/positioning/locationsingleton.cpp
@@ -141,6 +141,24 @@ QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate &topLeft,
}
/*!
+ \qmlmethod georectangle QtLocation5::QtLocation::rectangle(list<coordinate> coordinates) const
+
+ Constructs a georectangle from the list of coordinates, the returned list is the smallest possible
+ containing all the coordinates.
+
+ \sa {georectangle}
+*/
+QGeoRectangle LocationSingleton::rectangle(const QVariantList &coordinates) const
+{
+ QList<QGeoCoordinate> internalCoordinates;
+ for (int i = 0; i < coordinates.size(); i++) {
+ if (coordinates.at(i).canConvert<QGeoCoordinate>())
+ internalCoordinates << coordinates.at(i).value<QGeoCoordinate>();
+ }
+ return QGeoRectangle(internalCoordinates);
+}
+
+/*!
\qmlmethod geocircle QtPositioning::circle() const
Constructs an invalid geocircle.
diff --git a/src/imports/positioning/locationsingleton.h b/src/imports/positioning/locationsingleton.h
index b5e6476e..6c8d4496 100644
--- a/src/imports/positioning/locationsingleton.h
+++ b/src/imports/positioning/locationsingleton.h
@@ -48,6 +48,7 @@
#include <QtPositioning/QGeoShape>
#include <QtPositioning/QGeoRectangle>
#include <QtPositioning/QGeoCircle>
+#include <QVariant>
class LocationSingleton : public QObject
{
@@ -67,6 +68,7 @@ public:
double width, double height) const;
Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate &topLeft,
const QGeoCoordinate &bottomRight) const;
+ Q_INVOKABLE QGeoRectangle rectangle(const QVariantList &coordinates) const;
Q_INVOKABLE QGeoCircle circle() const;
Q_INVOKABLE QGeoCircle circle(const QGeoCoordinate &center, qreal radius = -1.0) const;
diff --git a/src/imports/positioning/plugins.qmltypes b/src/imports/positioning/plugins.qmltypes
index 55cfac45..32a3c67d 100644
--- a/src/imports/positioning/plugins.qmltypes
+++ b/src/imports/positioning/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.1
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -notrelocatable QtPositioning 5.2'
+// 'qmlplugindump -notrelocatable QtPositioning 5.3'
Module {
Component {
@@ -66,6 +66,11 @@ Module {
Parameter { name: "topLeft"; type: "QGeoCoordinate" }
Parameter { name: "bottomRight"; type: "QGeoCoordinate" }
}
+ Method {
+ name: "rectangle"
+ type: "QGeoRectangle"
+ Parameter { name: "coordinates"; type: "QVariantList" }
+ }
Method { name: "circle"; type: "QGeoCircle" }
Method {
name: "circle"
@@ -97,6 +102,14 @@ Module {
Property { name: "isTextGenerated"; type: "bool"; isReadonly: true }
}
Component {
+ name: "QDeclarativeGeoCoordinateAnimation"
+ prototype: "QQuickPropertyAnimation"
+ exports: ["QtPositioning/CoordinateAnimation 5.3"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "from"; type: "QGeoCoordinate" }
+ Property { name: "to"; type: "QGeoCoordinate" }
+ }
+ Component {
name: "QDeclarativeGeoLocation"
prototype: "QObject"
exports: ["QtPositioning/Location 5.0", "QtPositioning/Location 5.2"]
diff --git a/src/imports/positioning/positioning.cpp b/src/imports/positioning/positioning.cpp
index 0804a8ce..4314582d 100644
--- a/src/imports/positioning/positioning.cpp
+++ b/src/imports/positioning/positioning.cpp
@@ -51,9 +51,12 @@
#include "qdeclarativegeorectangle.h"
#include "qdeclarativegeocircle.h"
#include "qdeclarativecoordinate_p.h"
+#include "qdeclarativegeocoordinateanimation_p.h"
#include "locationsingleton.h"
+#include <QtCore/QVariantAnimation>
+
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
#include <QtQml/private/qqmlvaluetype_p.h>
@@ -105,6 +108,7 @@ public:
qRegisterMetaType<QGeoCircle>("QGeoCircle");
qRegisterMetaType<QGeoLocation>("QGeoLocation");
+ qRegisterAnimationInterpolator<QGeoCoordinate>(geoCoordinateInterpolator);
QQml_addValueTypeProvider(getValueTypeProvider());
// Register the 5.0 types
@@ -124,6 +128,12 @@ public:
qmlRegisterType<QDeclarativePositionSource >(uri, major, minor, "PositionSource");
qmlRegisterType<QDeclarativeGeoAddress >(uri, major, minor, "Address");
qmlRegisterType<QDeclarativeGeoLocation >(uri, major, minor, "Location");
+
+ // Register the 5.3 types
+ // Introduction of 5.3 version; existing 5.2 exports automatically become availabe under 5.3 as well
+ minor = 3;
+ qmlRegisterType<QDeclarativeGeoCoordinateAnimation >(uri, major, minor, "CoordinateAnimation");
+ qmlRegisterType<QDeclarativePosition, 1 >(uri, major, minor, "Position");
} else {
qDebug() << "Unsupported URI given to load positioning QML plugin: " << QLatin1String(uri);
}
diff --git a/src/imports/positioning/positioning.pro b/src/imports/positioning/positioning.pro
index 1f71f03c..6af459d8 100644
--- a/src/imports/positioning/positioning.pro
+++ b/src/imports/positioning/positioning.pro
@@ -11,7 +11,8 @@ HEADERS += qdeclarativeposition_p.h \
qdeclarativegeocircle.h \
locationvaluetypeprovider.h \
locationsingleton.h \
- error_messages.h
+ error_messages.h \
+ qdeclarativegeocoordinateanimation_p.h
SOURCES += qdeclarativeposition.cpp \
positioning.cpp \
@@ -22,7 +23,8 @@ SOURCES += qdeclarativeposition.cpp \
qdeclarativegeocircle.cpp \
locationvaluetypeprovider.cpp \
locationsingleton.cpp \
- error_messages.cpp
+ error_messages.cpp \
+ qdeclarativegeocoordinateanimation.cpp
load(qml_plugin)
diff --git a/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp b/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp
new file mode 100644
index 00000000..894ba33e
--- /dev/null
+++ b/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegeocoordinateanimation_p.h"
+#include <QtQuick/private/qquickanimation_p_p.h>
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype CoordinateAnimation
+ \instantiates QDeclarativeGeoCoordinateAnimation
+ \inherits PropertyAnimation
+ \inqmlmodule QtPositioning
+ \since 5.3
+
+ \brief A PropertyAnimation for geo coordinate properties.
+
+ A specialized \l{PropertyAnimation} that defines an animation
+ between two geo coordinates.
+*/
+
+QDeclarativeGeoCoordinateAnimation::QDeclarativeGeoCoordinateAnimation(QObject *parent)
+ : QQuickPropertyAnimation(parent)
+{
+ Q_D(QQuickPropertyAnimation);
+ d->interpolatorType = qMetaTypeId<QGeoCoordinate>();
+ d->defaultToInterpolatorType = true;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+}
+
+QDeclarativeGeoCoordinateAnimation::~QDeclarativeGeoCoordinateAnimation()
+{
+}
+
+/*!
+ \qmlproperty coordinate CoordinateAnimation::from
+ This property holds the coordinate where the animation should begin.
+*/
+QGeoCoordinate QDeclarativeGeoCoordinateAnimation::from() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->from.value<QGeoCoordinate>();
+}
+
+void QDeclarativeGeoCoordinateAnimation::setFrom(const QGeoCoordinate &f)
+{
+ QQuickPropertyAnimation::setFrom(QVariant::fromValue(f));
+}
+
+/*!
+ \qmlproperty coordinate CoordinateAnimation::to
+ This property holds the coordinate where the animation should end.
+*/
+QGeoCoordinate QDeclarativeGeoCoordinateAnimation::to() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->to.value<QGeoCoordinate>();
+}
+
+void QDeclarativeGeoCoordinateAnimation::setTo(const QGeoCoordinate &t)
+{
+ QQuickPropertyAnimation::setTo(QVariant::fromValue(t));
+}
+
+QVariant geoCoordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
+{
+ if (from == to) {
+ if (progress < 0.5) {
+ return QVariant::fromValue(from);
+ } else {
+ return QVariant::fromValue(to);
+ }
+ }
+
+ QGeoCoordinate result = QGeoProjection::coordinateInterpolation(from, to, progress);
+
+ return QVariant::fromValue(result);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapmousearea_p.h b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
index 3c89ef0b..86a0459a 100644
--- a/src/imports/location/qdeclarativegeomapmousearea_p.h
+++ b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtLocation module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -39,54 +39,37 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEGEOMAPMOUSEAREA_H
-#define QDECLARATIVEGEOMAPMOUSEAREA_H
+#ifndef QDECLARATIVEGEOCOORDINATEANIMATION_P_H
+#define QDECLARATIVEGEOCOORDINATEANIMATION_P_H
-#include "qdeclarativegeomap_p.h"
-#include "qdeclarativegeomapmouseevent_p.h"
-
-#include <QtQuick/QQuickItem>
-#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
+#include "qdeclarativecoordinate_p.h"
QT_BEGIN_NAMESPACE
-class QDeclarativeGeoMapMouseArea : public QQuickMouseArea
+
+QVariant geoCoordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
+
+class QDeclarativeGeoCoordinateAnimation : public QQuickPropertyAnimation
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
+ Q_PROPERTY(QGeoCoordinate from READ from WRITE setFrom)
+ Q_PROPERTY(QGeoCoordinate to READ to WRITE setTo)
public:
- explicit QDeclarativeGeoMapMouseArea(QQuickItem *parent = 0);
- ~QDeclarativeGeoMapMouseArea();
-
- Q_INVOKABLE QGeoCoordinate mouseToCoordinate(QQuickMouseEvent *event);
-
- // From QQmlParserStatus
- virtual void componentComplete();
-
-protected:
- // from QQuickItem
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void hoverEnterEvent(QHoverEvent *event);
- void hoverMoveEvent(QHoverEvent *event);
- void hoverLeaveEvent(QHoverEvent *event);
-
-private Q_SLOTS:
- void dragActiveChanged();
+ QDeclarativeGeoCoordinateAnimation(QObject *parent=0);
+ ~QDeclarativeGeoCoordinateAnimation();
-private:
- QQuickItem *parentMapItem();
- QDeclarativeGeoMap *map();
+ QGeoCoordinate from() const;
+ void setFrom(const QGeoCoordinate &);
-private:
- bool componentCompleted_;
- bool dragActive_;
+ QGeoCoordinate to() const;
+ void setTo(const QGeoCoordinate &);
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QDeclarativeGeoMapMouseArea)
+QML_DECLARE_TYPE(QDeclarativeGeoCoordinateAnimation)
-#endif
+#endif // QDECLARATIVEGEOCOORDINATEANIMATION_P_H
diff --git a/src/imports/positioning/qdeclarativeposition.cpp b/src/imports/positioning/qdeclarativeposition.cpp
index fa2bd943..b667cbe6 100644
--- a/src/imports/positioning/qdeclarativeposition.cpp
+++ b/src/imports/positioning/qdeclarativeposition.cpp
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2014 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -39,6 +41,7 @@
**
****************************************************************************/
+#include <QtCore/QtNumeric>
#include "qdeclarativeposition_p.h"
#include <QtQml/qqml.h>
#include <qnmeapositioninfosource.h>
@@ -79,13 +82,35 @@ QT_BEGIN_NAMESPACE
\l{flickr}{Flickr} example application.
\sa PositionSource, coordinate
-
*/
+namespace
+{
+
+bool equalOrNaN(double a, double b)
+{
+ return a == b || (qIsNaN(a) && qIsNaN(b));
+}
+
+bool equalOrNaN(float a, float b)
+{
+ return a == b || (qIsNaN(a) && qIsNaN(b));
+}
+
+bool exclusiveNaN(double a, double b)
+{
+ return qIsNaN(a) != qIsNaN(b);
+}
+
+bool exclusiveNaN(float a, float b)
+{
+ return qIsNaN(a) != qIsNaN(b);
+}
+
+}
+
QDeclarativePosition::QDeclarativePosition(QObject *parent)
- : QObject(parent), m_latitudeValid(false), m_longitudeValid(false),
- m_altitudeValid(false), m_speed(-1), m_speedValid(false), m_horizontalAccuracyValid(false),
- m_verticalAccuracyValid(false), m_horizontalAccuracy(-1), m_verticalAccuracy(-1)
+: QObject(parent)
{
}
@@ -93,6 +118,88 @@ QDeclarativePosition::~QDeclarativePosition()
{
}
+void QDeclarativePosition::setPosition(const QGeoPositionInfo &info)
+{
+ // timestamp
+ const QDateTime pTimestamp = m_info.timestamp();
+ const QDateTime timestamp = info.timestamp();
+ bool emitTimestampChanged = pTimestamp != timestamp;
+
+ // coordinate
+ const QGeoCoordinate pCoordinate = m_info.coordinate();
+ const QGeoCoordinate coordinate = info.coordinate();
+ bool emitCoordinateChanged = pCoordinate != coordinate;
+ bool emitLatitudeValidChanged = exclusiveNaN(pCoordinate.latitude(), coordinate.latitude());
+ bool emitLongitudeValidChanged = exclusiveNaN(pCoordinate.longitude(), coordinate.longitude());
+ bool emitAltitudeValidChanged = exclusiveNaN(pCoordinate.altitude(), coordinate.altitude());
+
+ // direction
+ const qreal pDirection = m_info.attribute(QGeoPositionInfo::Direction);
+ const qreal direction = info.attribute(QGeoPositionInfo::Direction);
+ bool emitDirectionChanged = !equalOrNaN(pDirection, direction);
+ bool emitDirectionValidChanged = exclusiveNaN(pDirection, direction);
+
+ // ground speed
+ const qreal pSpeed = m_info.attribute(QGeoPositionInfo::GroundSpeed);
+ const qreal speed = info.attribute(QGeoPositionInfo::GroundSpeed);
+ bool emitSpeedChanged = !equalOrNaN(pSpeed, speed);
+ bool emitSpeedValidChanged = exclusiveNaN(pSpeed, speed);
+
+ // vertical speed
+ const qreal pVerticalSpeed = m_info.attribute(QGeoPositionInfo::VerticalSpeed);
+ const qreal verticalSpeed = info.attribute(QGeoPositionInfo::VerticalSpeed);
+ bool emitVerticalSpeedChanged = !equalOrNaN(pVerticalSpeed, verticalSpeed);
+ bool emitVerticalSpeedValidChanged = exclusiveNaN(pVerticalSpeed, verticalSpeed);
+
+ // magnetic variation
+ // not in QML API
+
+ // horizontal accuracy
+ const qreal pHorizontalAccuracy = m_info.attribute(QGeoPositionInfo::HorizontalAccuracy);
+ const qreal horizontalAccuracy = info.attribute(QGeoPositionInfo::HorizontalAccuracy);
+ bool emitHorizontalAccuracyChanged = !equalOrNaN(pHorizontalAccuracy, horizontalAccuracy);
+ bool emitHorizontalAccuracyValidChanged = exclusiveNaN(pHorizontalAccuracy, horizontalAccuracy);
+
+ // vertical accuracy
+ const qreal pVerticalAccuracy = m_info.attribute(QGeoPositionInfo::VerticalAccuracy);
+ const qreal verticalAccuracy = info.attribute(QGeoPositionInfo::VerticalAccuracy);
+ bool emitVerticalAccuracyChanged = !equalOrNaN(pVerticalAccuracy, verticalAccuracy);
+ bool emitVerticalAccuracyValidChanged = exclusiveNaN(pVerticalAccuracy, verticalAccuracy);
+
+ m_info = info;
+
+ if (emitTimestampChanged)
+ emit timestampChanged();
+ if (emitCoordinateChanged)
+ emit coordinateChanged();
+ if (emitLatitudeValidChanged)
+ emit latitudeValidChanged();
+ if (emitLongitudeValidChanged)
+ emit longitudeValidChanged();
+ if (emitAltitudeValidChanged)
+ emit altitudeValidChanged();
+ if (emitDirectionChanged)
+ emit directionChanged();
+ if (emitDirectionValidChanged)
+ emit directionValidChanged();
+ if (emitSpeedChanged)
+ emit speedChanged();
+ if (emitSpeedValidChanged)
+ emit speedValidChanged();
+ if (emitVerticalSpeedChanged)
+ emit verticalSpeedChanged();
+ if (emitVerticalSpeedValidChanged)
+ emit verticalSpeedValidChanged();
+ if (emitHorizontalAccuracyChanged)
+ emit horizontalAccuracyChanged();
+ if (emitHorizontalAccuracyValidChanged)
+ emit horizontalAccuracyValidChanged();
+ if (emitVerticalAccuracyChanged)
+ emit verticalAccuracyChanged();
+ if (emitVerticalAccuracyValidChanged)
+ emit verticalAccuracyValidChanged();
+}
+
/*!
\qmlproperty coordinate Position::coordinate
@@ -102,46 +209,9 @@ QDeclarativePosition::~QDeclarativePosition()
\sa longitudeValid, latitudeValid, altitudeValid
*/
-
-void QDeclarativePosition::setCoordinate(const QGeoCoordinate &coordinate)
-{
- if (m_coordinate == coordinate)
- return;
-
- m_coordinate = coordinate;
-
- if (coordinate.type() == QGeoCoordinate::Coordinate3D && !m_altitudeValid) {
- m_altitudeValid = true;
- emit altitudeValidChanged();
- } else if (m_altitudeValid) {
- m_altitudeValid = false;
- emit altitudeValidChanged();
- }
- if (coordinate.isValid()) {
- if (!m_longitudeValid) {
- m_longitudeValid = true;
- emit longitudeValidChanged();
- }
- if (!m_latitudeValid) {
- m_latitudeValid = true;
- emit latitudeValidChanged();
- }
- } else {
- if (m_longitudeValid) {
- m_longitudeValid = false;
- emit longitudeValidChanged();
- }
- if (m_latitudeValid) {
- m_latitudeValid = false;
- emit latitudeValidChanged();
- }
- }
- emit coordinateChanged();
-}
-
QGeoCoordinate QDeclarativePosition::coordinate()
{
- return m_coordinate;
+ return m_info.coordinate();
}
/*!
@@ -152,12 +222,10 @@ QGeoCoordinate QDeclarativePosition::coordinate()
does not necessarily contain all data).
\sa coordinate
-
*/
-
bool QDeclarativePosition::isLatitudeValid() const
{
- return m_latitudeValid;
+ return !qIsNaN(m_info.coordinate().latitude());
}
@@ -169,12 +237,10 @@ bool QDeclarativePosition::isLatitudeValid() const
does not necessarily contain all data).
\sa coordinate
-
*/
-
bool QDeclarativePosition::isLongitudeValid() const
{
- return m_longitudeValid;
+ return !qIsNaN(m_info.coordinate().longitude());
}
@@ -186,12 +252,10 @@ bool QDeclarativePosition::isLongitudeValid() const
does not necessarily contain all data).
\sa speed
-
*/
-
bool QDeclarativePosition::isSpeedValid() const
{
- return m_speedValid;
+ return !qIsNaN(m_info.attribute(QGeoPositionInfo::GroundSpeed));
}
/*!
@@ -202,12 +266,10 @@ bool QDeclarativePosition::isSpeedValid() const
does not necessarily contain all data).
\sa coordinate
-
*/
-
bool QDeclarativePosition::isAltitudeValid() const
{
- return m_altitudeValid;
+ return !qIsNaN(m_info.coordinate().altitude());
}
/*!
@@ -219,22 +281,9 @@ bool QDeclarativePosition::isAltitudeValid() const
\sa speedValid, coordinate
*/
-
-void QDeclarativePosition::setSpeed(double speed)
-{
- if (speed == m_speed)
- return;
- m_speed = speed;
- if (!m_speedValid) {
- m_speedValid = true;
- emit speedValidChanged();
- }
- emit speedChanged();
-}
-
double QDeclarativePosition::speed() const
{
- return m_speed;
+ return m_info.attribute(QGeoPositionInfo::GroundSpeed);
}
/*!
@@ -244,22 +293,24 @@ double QDeclarativePosition::speed() const
\sa horizontalAccuracyValid, coordinate
*/
-
void QDeclarativePosition::setHorizontalAccuracy(qreal horizontalAccuracy)
{
- if (horizontalAccuracy == m_horizontalAccuracy)
+ const qreal pHorizontalAccuracy = m_info.attribute(QGeoPositionInfo::HorizontalAccuracy);
+
+ if (equalOrNaN(pHorizontalAccuracy, horizontalAccuracy))
return;
- m_horizontalAccuracy = horizontalAccuracy;
- if (!m_horizontalAccuracyValid) {
- m_horizontalAccuracyValid = true;
- emit horizontalAccuracyValidChanged();
- }
+
+ bool validChanged = exclusiveNaN(pHorizontalAccuracy, horizontalAccuracy);
+
+ m_info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, horizontalAccuracy);
emit horizontalAccuracyChanged();
+ if (validChanged)
+ emit horizontalAccuracyValidChanged();
}
qreal QDeclarativePosition::horizontalAccuracy() const
{
- return m_horizontalAccuracy;
+ return m_info.attribute(QGeoPositionInfo::HorizontalAccuracy);
}
/*!
@@ -270,12 +321,10 @@ qreal QDeclarativePosition::horizontalAccuracy() const
does not necessarily contain all data).
\sa horizontalAccuracy
-
*/
-
bool QDeclarativePosition::isHorizontalAccuracyValid() const
{
- return m_horizontalAccuracyValid;
+ return !qIsNaN(m_info.attribute(QGeoPositionInfo::HorizontalAccuracy));
}
/*!
@@ -285,22 +334,24 @@ bool QDeclarativePosition::isHorizontalAccuracyValid() const
\sa verticalAccuracyValid, coordinate
*/
-
void QDeclarativePosition::setVerticalAccuracy(qreal verticalAccuracy)
{
- if (verticalAccuracy == m_verticalAccuracy)
+ const qreal pVerticalAccuracy = m_info.attribute(QGeoPositionInfo::VerticalAccuracy);
+
+ if (equalOrNaN(pVerticalAccuracy, verticalAccuracy))
return;
- m_verticalAccuracy = verticalAccuracy;
- if (!m_verticalAccuracyValid) {
- m_verticalAccuracyValid = true;
- emit verticalAccuracyValidChanged();
- }
+
+ bool validChanged = exclusiveNaN(pVerticalAccuracy, verticalAccuracy);
+
+ m_info.setAttribute(QGeoPositionInfo::VerticalAccuracy, verticalAccuracy);
emit verticalAccuracyChanged();
+ if (validChanged)
+ emit verticalAccuracyValidChanged();
}
qreal QDeclarativePosition::verticalAccuracy() const
{
- return m_verticalAccuracy;
+ return m_info.attribute(QGeoPositionInfo::VerticalAccuracy);
}
/*!
@@ -311,12 +362,10 @@ qreal QDeclarativePosition::verticalAccuracy() const
does not necessarily contain all data).
\sa verticalAccuracy
-
*/
-
bool QDeclarativePosition::isVerticalAccuracyValid() const
{
- return m_verticalAccuracyValid;
+ return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalAccuracy));
}
/*!
@@ -327,47 +376,67 @@ bool QDeclarativePosition::isVerticalAccuracyValid() const
It is a read-only property.
*/
+QDateTime QDeclarativePosition::timestamp() const
+{
+ return m_info.timestamp();
+}
+
+/*!
+ \qmlproperty bool Position::directionValid
+ \since Qt Positioning 5.3
+
+ This property is true if \l direction has been set (to indicate whether that data has been
+ received or not, as every update does not necessarily contain all data).
+
+ \sa direction
+*/
+bool QDeclarativePosition::isDirectionValid() const
+{
+ return !qIsNaN(m_info.attribute(QGeoPositionInfo::Direction));
+}
+
+/*!
+ \qmlproperty double Position::direction
+ \since Qt Positioning 5.3
+
+ This property holds the value of the direction of travel in degrees from true north.
-void QDeclarativePosition::setTimestamp(const QDateTime &timestamp)
+ It is a read-only property.
+
+ \sa directionValid
+*/
+double QDeclarativePosition::direction() const
{
- if (timestamp == m_timestamp)
- return;
- m_timestamp = timestamp;
- emit timestampChanged();
+ return m_info.attribute(QGeoPositionInfo::Direction);
}
-QDateTime QDeclarativePosition::timestamp() const
+/*!
+ \qmlproperty bool Position::verticalSpeedValid
+ \since Qt Positioning 5.3
+
+ This property is true if \l verticalSpeed has been set (to indicate whether that data has been
+ received or not, as every update does not necessarily contain all data).
+
+ \sa verticalSpeed
+*/
+bool QDeclarativePosition::isVerticalSpeedValid() const
{
- return m_timestamp;
+ return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalSpeed));
}
-void QDeclarativePosition::invalidate()
+/*!
+ \qmlproperty double Position::verticalSpeed
+ \since Qt Positioning 5.3
+
+ This property holds the value of the vertical speed in meters per second.
+
+ It is a read-only property.
+
+ \sa verticalSpeedValid
+*/
+double QDeclarativePosition::verticalSpeed() const
{
- // Invalidate all data
- if (m_latitudeValid) {
- m_latitudeValid = false;
- emit latitudeValidChanged();
- }
- if (m_longitudeValid) {
- m_longitudeValid = false;
- emit longitudeValidChanged();
- }
- if (m_altitudeValid) {
- m_altitudeValid = false;
- emit altitudeValidChanged();
- }
- if (m_speedValid) {
- m_speedValid = false;
- emit speedValidChanged();
- }
- if (m_horizontalAccuracyValid) {
- m_horizontalAccuracyValid = false;
- emit horizontalAccuracyValidChanged();
- }
- if (m_verticalAccuracyValid) {
- m_verticalAccuracyValid = false;
- emit verticalAccuracyValidChanged();
- }
+ return m_info.attribute(QGeoPositionInfo::VerticalSpeed);
}
#include "moc_qdeclarativeposition_p.cpp"
diff --git a/src/imports/positioning/qdeclarativeposition_p.h b/src/imports/positioning/qdeclarativeposition_p.h
index 99c2d8fc..d9235368 100644
--- a/src/imports/positioning/qdeclarativeposition_p.h
+++ b/src/imports/positioning/qdeclarativeposition_p.h
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2014 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -42,25 +44,17 @@
#ifndef QDECLARATIVEPOSITION_H
#define QDECLARATIVEPOSITION_H
-#include <QtCore>
-#include <QDateTime>
-#include <qgeopositioninfosource.h>
-#include <qgeopositioninfo.h>
-#include "qdeclarativecoordinate_p.h"
+#include <QtCore/QObject>
+#include <QtCore/QDateTime>
#include <QtQml/qqml.h>
-
-// Define this to get qDebug messages
-// #define QDECLARATIVE_POSITION_DEBUG
-
-#ifdef QDECLARATIVE_POSITION_DEBUG
-#include <QDebug>
-#endif
+#include <QtPositioning/QGeoPositionInfo>
QT_BEGIN_NAMESPACE
class QDeclarativePosition : public QObject
{
Q_OBJECT
+
Q_PROPERTY(bool latitudeValid READ isLatitudeValid NOTIFY latitudeValidChanged)
Q_PROPERTY(bool longitudeValid READ isLongitudeValid NOTIFY longitudeValidChanged)
Q_PROPERTY(bool altitudeValid READ isAltitudeValid NOTIFY altitudeValidChanged)
@@ -73,8 +67,12 @@ class QDeclarativePosition : public QObject
Q_PROPERTY(bool horizontalAccuracyValid READ isHorizontalAccuracyValid NOTIFY horizontalAccuracyValidChanged)
Q_PROPERTY(bool verticalAccuracyValid READ isVerticalAccuracyValid NOTIFY verticalAccuracyValidChanged)
-public:
+ Q_PROPERTY(bool directionValid READ isDirectionValid NOTIFY directionValidChanged REVISION 1)
+ Q_PROPERTY(double direction READ direction NOTIFY directionChanged REVISION 1)
+ Q_PROPERTY(bool verticalSpeedValid READ isVerticalSpeedValid NOTIFY verticalSpeedValidChanged REVISION 1)
+ Q_PROPERTY(double verticalSpeed READ verticalSpeed NOTIFY verticalSpeedChanged REVISION 1)
+public:
explicit QDeclarativePosition(QObject *parent = 0);
~QDeclarativePosition();
@@ -82,9 +80,7 @@ public:
bool isLongitudeValid() const;
bool isAltitudeValid() const;
QDateTime timestamp() const;
- void setTimestamp(const QDateTime &timestamp);
double speed() const;
- void setSpeed(double speed);
bool isSpeedValid() const;
QGeoCoordinate coordinate();
bool isHorizontalAccuracyValid() const;
@@ -94,9 +90,15 @@ public:
qreal verticalAccuracy() const;
void setVerticalAccuracy(qreal verticalAccuracy);
- // C++
- void setCoordinate(const QGeoCoordinate &coordinate);
- void invalidate();
+ bool isDirectionValid() const;
+ double direction() const;
+ void setDirection(double direction);
+
+ bool isVerticalSpeedValid() const;
+ double verticalSpeed() const;
+ void setVerticalSpeed(double speed);
+
+ void setPosition(const QGeoPositionInfo &info);
Q_SIGNALS:
void latitudeValidChanged();
@@ -111,18 +113,13 @@ Q_SIGNALS:
void verticalAccuracyChanged();
void verticalAccuracyValidChanged();
+ Q_REVISION(1) void directionValidChanged();
+ Q_REVISION(1) void directionChanged();
+ Q_REVISION(1) void verticalSpeedValidChanged();
+ Q_REVISION(1) void verticalSpeedChanged();
+
private:
- bool m_latitudeValid;
- bool m_longitudeValid;
- bool m_altitudeValid;
- QDateTime m_timestamp;
- double m_speed;
- bool m_speedValid;
- bool m_horizontalAccuracyValid;
- bool m_verticalAccuracyValid;
- qreal m_horizontalAccuracy;
- qreal m_verticalAccuracy;
- QGeoCoordinate m_coordinate;
+ QGeoPositionInfo m_info;
};
QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativepositionsource.cpp b/src/imports/positioning/qdeclarativepositionsource.cpp
index a13092fc..fe2a3e56 100644
--- a/src/imports/positioning/qdeclarativepositionsource.cpp
+++ b/src/imports/positioning/qdeclarativepositionsource.cpp
@@ -43,6 +43,7 @@
#include "qdeclarativeposition_p.h"
#include "error_messages.h"
+#include <QtCore/QCoreApplication>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqml.h>
#include <qnmeapositioninfosource.h>
@@ -370,19 +371,7 @@ void QDeclarativePositionSource::socketError(QAbstractSocket::SocketError error)
void QDeclarativePositionSource::setPosition(const QGeoPositionInfo &pi)
{
- if (pi.isValid()) {
- m_position.setTimestamp(pi.timestamp());
- m_position.setCoordinate(pi.coordinate());
- if (pi.hasAttribute(QGeoPositionInfo::GroundSpeed))
- m_position.setSpeed(pi.attribute(QGeoPositionInfo::GroundSpeed));
- if (pi.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- m_position.setHorizontalAccuracy(pi.attribute(QGeoPositionInfo::HorizontalAccuracy));
- if (pi.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
- m_position.setVerticalAccuracy(pi.attribute(QGeoPositionInfo::VerticalAccuracy));
- } else {
- m_position.invalidate();
- }
-
+ m_position.setPosition(pi);
emit positionChanged();
}
diff --git a/src/location/doc/snippets/declarative/declarative.pro b/src/location/doc/snippets/declarative/declarative.pro
index 40fb082f..e6ff7ce6 100644
--- a/src/location/doc/snippets/declarative/declarative.pro
+++ b/src/location/doc/snippets/declarative/declarative.pro
@@ -7,6 +7,9 @@ content.files = \
routing.qml \
places_loader.qml
+OTHER_FILES = \
+ $${content.files}
+
# Put content in INSTALLS so that content.files become part of the project tree in Qt Creator,
# but scoped with false as we don't actually want to install them. They are documentation
# snippets.
diff --git a/src/location/doc/snippets/places/requesthandler.h b/src/location/doc/snippets/places/requesthandler.h
index 92e1a935..e18b6276 100644
--- a/src/location/doc/snippets/places/requesthandler.h
+++ b/src/location/doc/snippets/places/requesthandler.h
@@ -100,7 +100,6 @@ public:
{
//! [Search paging]
QPlaceSearchRequest searchRequest;
- searchRequest.setOffset(10); //specify the index of the first result
searchRequest.setLimit(15); //specify how many results are to be retrieved.
//! [Search paging]
}
@@ -123,9 +122,9 @@ public:
//! [Image request]
QPlaceContentRequest request;
request.setContentType(QPlaceContent::ImageType);
- request.setOffset(0);
+ request.setPlaceId(place.placeId());
request.setLimit(5);
- /*QPlaceContentReply * */ contentReply = manager->getPlaceContent(place.placeId(), request);
+ /*QPlaceContentReply * */ contentReply = manager->getPlaceContent(request);
connect(contentReply, SIGNAL(finished()), this, SLOT(handleImagesReply()));
//! [Image request]
}
@@ -220,9 +219,8 @@ public:
//closer places have greater weighting in the ranking of results.
searchRequest.setRelevanceHint(QPlaceSearchRequest::DistanceHint);
- //use offset and limit to provide pagination.
- //this retrieves the next 5 items from the 10th index
- searchRequest.setOffset(9);
+ //use limit to adjust pagination.
+ //this limits the number of place results to 5 per page.
searchRequest.setLimit(5);
//provide some categories to narrow down search
@@ -237,10 +235,10 @@ public:
//! [Content request]
QPlaceContentRequest request;
request.setContentType(QPlaceContent::ImageType);
- request.setOffset(9);
+ request.setPlaceId(place.placeId());
request.setLimit(5);
- QPlaceContentReply *contentReply = manager->getPlaceContent(place.placeId(), request);
+ QPlaceContentReply *contentReply = manager->getPlaceContent(request);
//..connect signals..//
//! [Content request]
diff --git a/src/location/doc/src/maps.qdoc b/src/location/doc/src/maps.qdoc
index a9816f52..180eb04c 100644
--- a/src/location/doc/src/maps.qdoc
+++ b/src/location/doc/src/maps.qdoc
@@ -113,26 +113,11 @@ only be created within a \l{QtLocation::Map}{Map}.
\section2 Interaction with Map Overlay Objects
-Interaction with the pre-defined map overlay object types is done using the
-\l{QtLocation::MapMouseArea}{MapMouseArea} type, which behaves much like a
-normal QtQuick MouseArea. MapQuickItems can also contain MapMouseArea objects,
-but can additionally use normal QtQuick MouseAreas to provide interaction.
-
Properties of map overlay objects that influence their appearance on the display can
be changed at any time, and many can also be used in animations. Animating
coordinate-based map overlay objects, such as MapPolygon and MapPolyline, is not yet
available.
-\b{Key Types}
-\table
- \row
- \li \l{QtLocation::MapMouseArea}{MapMouseArea}
- \li Accepts mouse events for a pre-defined map overlay object (for example MapCircle).
- \row
- \li \l{QtLocation::MapMouseEvent}{MapMouseEvent}
- \li Provides additional information unique to mouse events on a Map.
-\endtable
-
\section1 Geocoding -- Address to Coordinate and Vice Versa
Geocoding is the translation of geographic coordinates into addresses, or vice
diff --git a/src/location/doc/src/places.qdoc b/src/location/doc/src/places.qdoc
index 62a6d0d5..74a25b79 100644
--- a/src/location/doc/src/places.qdoc
+++ b/src/location/doc/src/places.qdoc
@@ -248,7 +248,7 @@
Any places similar to the given place are retrieved.
\section3 Paging
- If the plugin supports paging, limit and offset parameters may be provided to the search request.
+ If the plugin supports paging, the limit parameter may be provided to the search request.
\snippet places/requesthandler.h Search paging
\section2 Fetching Place Details
diff --git a/src/location/doc/src/plugins/nokia.qdoc b/src/location/doc/src/plugins/nokia.qdoc
index 181acbb8..203602ce 100644
--- a/src/location/doc/src/plugins/nokia.qdoc
+++ b/src/location/doc/src/plugins/nokia.qdoc
@@ -80,12 +80,15 @@ The following table lists optional parameters that can be passed to the Nokia pl
\note See the notes in \l{QNetworkProxyFactory::systemProxyForQuery()} for further information.
\row
\li mapping.host
- \li Map tile service URL used by mapping manager.
+ \li Base map tile service URL used by mapping manager.
+\row
+ \li mapping.host.aerial
+ \li Aerial map tile service URL used by mapping manager. For all satellite, hybrid and terrain schemes.
\row
\li mapping.cache.directory
\li Map tile cache directory used as network disk cache.
- Default place for the cache is "QtLocation" directory in \l {QStandardPaths::writableLocation(QStandardPaths::CacheLocation)}.
+ Default place for the cache is "QtLocation" directory in \l {QStandardPaths::writableLocation()} {QStandardPaths::writableLocation}(\l{QStandardPaths::GenericCacheLocation}).
\row
\li mapping.cache.disk.size
\li Map tile disk cache size in bytes. Default size of the cache is 20MB.
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index 752454d4..ee9b2a48 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -37,6 +37,9 @@
This geo services plugin allows applications to access
\l {http://openstreetmap.org}{Open Street Map} location based services using the Qt Location API.
+Data, imagery and map information provided by \l {http://www.mapquest.com}{MapQuest}, OpenStreetMap and
+contributors. The data is available under the \l {http://www.opendatacommons.org/licenses/odbl}{Open Database License}.
+
The Open Street Map geo services plugin can be loaded by using the plugin key "osm".
\section1 Parameters
diff --git a/src/location/doc/src/qml-maps.qdoc b/src/location/doc/src/qml-maps.qdoc
index 84ccfbf4..460ec170 100644
--- a/src/location/doc/src/qml-maps.qdoc
+++ b/src/location/doc/src/qml-maps.qdoc
@@ -48,9 +48,7 @@ Map item you can center the map, zoom, pinch and make the item flickable.
The places to be added to the map are
\l {Maps and Navigation (QML)#Putting Objects on a Map (Map Overlay Objects)}{MapItems}. The item's
position is defined by a \l {coordinate}{coordinate} which includes latitude,
-longitude and altitude. The item is then displayed automatically after it is added to the Map.
-Interaction with the added items, and the \l Map itself, is handled by \l MapMouseArea when items
-are added as children of the
+longitude and altitude. The item is then displayed automatically after it is added to the Map.
\l {Maps and Navigation (QML)#Putting Objects on a Map (Map Overlay Objects)}{MapItems} or \l Map.
\section2 Position on map
diff --git a/src/location/location.pro b/src/location/location.pro
index c09ea06f..052a1970 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -1,6 +1,8 @@
TARGET = QtLocation
-QT = core-private positioning
+QT = core-private positioning-private
+MODULE_PLUGIN_TYPES = \
+ geoservices
QMAKE_DOCS = $$PWD/doc/qtlocation.qdocconf
OTHER_FILES += doc/src/*.qdoc # show .qdoc files in Qt Creator
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri
index dda60622..3a43c5ea 100644
--- a/src/location/maps/maps.pri
+++ b/src/location/maps/maps.pri
@@ -18,15 +18,12 @@ PUBLIC_HEADERS += \
maps/qgeoserviceprovider.h
PRIVATE_HEADERS += \
- maps/qdoublevector2d_p.h \
- maps/qdoublevector3d_p.h \
maps/qgeocameracapabilities_p.h \
maps/qgeocameradata_p.h \
maps/qgeocameratiles_p.h \
maps/qgeocodereply_p.h \
maps/qgeocodingmanagerengine_p.h \
maps/qgeocodingmanager_p.h \
- maps/qgeocoordinateinterpolator_p.h \
maps/qgeomaneuver_p.h \
maps/qgeomapcontroller_p.h \
maps/qgeomapscene_p.h \
@@ -46,7 +43,6 @@ PRIVATE_HEADERS += \
maps/qgeotiledmappingmanagerengine_p_p.h \
maps/qgeomaptype_p.h \
maps/qgeomaptype_p_p.h \
- maps/qgeoprojection_p.h \
maps/qgeoroute_p.h \
maps/qgeoroutereply_p.h \
maps/qgeorouterequest_p.h \
@@ -62,15 +58,12 @@ PRIVATE_HEADERS += \
maps/qcache3q_p.h
SOURCES += \
- maps/qdoublevector2d.cpp \
- maps/qdoublevector3d.cpp \
maps/qgeocameracapabilities.cpp \
maps/qgeocameradata.cpp \
maps/qgeocameratiles.cpp \
maps/qgeocodereply.cpp \
maps/qgeocodingmanager.cpp \
maps/qgeocodingmanagerengine.cpp \
- maps/qgeocoordinateinterpolator.cpp \
maps/qgeomaneuver.cpp \
maps/qgeomapcontroller.cpp \
maps/qgeomapscene.cpp \
@@ -83,7 +76,6 @@ SOURCES += \
maps/qgeotiledmappingmanagerengine.cpp \
maps/qgeotilefetcher.cpp \
maps/qgeomaptype.cpp \
- maps/qgeoprojection.cpp \
maps/qgeoroute.cpp \
maps/qgeoroutereply.cpp \
maps/qgeorouterequest.cpp \
diff --git a/src/location/maps/qgeocameradata.cpp b/src/location/maps/qgeocameradata.cpp
index e1d7e114..085a3134 100644
--- a/src/location/maps/qgeocameradata.cpp
+++ b/src/location/maps/qgeocameradata.cpp
@@ -39,14 +39,13 @@
**
****************************************************************************/
#include "qgeocameradata_p.h"
+#include <QtPositioning/private/qgeocoordinate_p.h>
#include <QVariant>
#include <QVariantAnimation>
#include <QMetaType>
-#include <QWeakPointer>
-
#include <cmath>
QT_BEGIN_NAMESPACE
@@ -66,8 +65,6 @@ public:
double tilt_;
double roll_;
double zoomLevel_;
-
- QWeakPointer<QGeoCoordinateInterpolator> interpolator_;
};
QGeoCameraDataPrivate::QGeoCameraDataPrivate()
@@ -84,8 +81,7 @@ QGeoCameraDataPrivate::QGeoCameraDataPrivate(const QGeoCameraDataPrivate &rhs)
bearing_(rhs.bearing_),
tilt_(rhs.tilt_),
roll_(rhs.roll_),
- zoomLevel_(rhs.zoomLevel_),
- interpolator_(rhs.interpolator_) {}
+ zoomLevel_(rhs.zoomLevel_) {}
QGeoCameraDataPrivate &QGeoCameraDataPrivate::operator = (const QGeoCameraDataPrivate &rhs)
{
@@ -97,11 +93,6 @@ QGeoCameraDataPrivate &QGeoCameraDataPrivate::operator = (const QGeoCameraDataPr
tilt_ = rhs.tilt_;
roll_ = rhs.roll_;
zoomLevel_ = rhs.zoomLevel_;
- QSharedPointer<QGeoCoordinateInterpolator> i = rhs.interpolator_.toStrongRef();
- if (i)
- interpolator_ = i.toWeakRef();
- else
- interpolator_.clear();
return *this;
}
@@ -120,16 +111,20 @@ QVariant cameraInterpolator(const QGeoCameraData &start,
qreal progress)
{
QGeoCameraData result = start;
-
-
- QSharedPointer<QGeoCoordinateInterpolator> i = start.coordinateInterpolator();
- if (!i)
- i = end.coordinateInterpolator();
-
- if (!i)
- result.setCenter(start.center());
- else
- result.setCenter(i->interpolate(start.center(), end.center(), progress));
+ QGeoCoordinate from = start.center();
+ QGeoCoordinate to = end.center();
+
+ if (from == to) {
+ if (progress < 0.5) {
+ result.setCenter(from);
+ } else {
+ result.setCenter(to);
+ }
+ }
+ else {
+ QGeoCoordinate coordinateResult = QGeoProjection::coordinateInterpolation(from, to, progress);
+ result.setCenter(coordinateResult);
+ }
double sf = 1.0 - progress;
double ef = progress;
@@ -225,14 +220,4 @@ double QGeoCameraData::zoomLevel() const
return d->zoomLevel_;
}
-void QGeoCameraData::setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator)
-{
- d->interpolator_ = interpolator.toWeakRef();
-}
-
-QSharedPointer<QGeoCoordinateInterpolator> QGeoCameraData::coordinateInterpolator() const
-{
- return d->interpolator_.toStrongRef();
-}
-
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeocameradata_p.h b/src/location/maps/qgeocameradata_p.h
index ca2bf4a9..fd24c065 100644
--- a/src/location/maps/qgeocameradata_p.h
+++ b/src/location/maps/qgeocameradata_p.h
@@ -52,14 +52,13 @@
// We mean it.
//
+#include "qlocationglobal.h"
#include "qgeocoordinate.h"
-#include "qgeoprojection_p.h"
-#include "qgeocoordinateinterpolator_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
#include <QMetaType>
-#include <QSharedPointer>
#include <QSharedDataPointer>
QT_BEGIN_NAMESPACE
@@ -93,9 +92,6 @@ public:
void setZoomLevel(double zoomLevel);
double zoomLevel() const;
- void setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator() const;
-
private:
QSharedDataPointer<QGeoCameraDataPrivate> d;
};
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp
index 1e799874..32bbae36 100644
--- a/src/location/maps/qgeocameratiles.cpp
+++ b/src/location/maps/qgeocameratiles.cpp
@@ -39,16 +39,14 @@
**
****************************************************************************/
#include "qgeocameratiles_p.h"
-
#include "qgeocameradata_p.h"
-#include "qgeoprojection_p.h"
#include "qgeotilespec_p.h"
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-
#include "qgeomaptype_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qdoublevector3d_p.h>
+
#include <QVector>
#include <QMap>
#include <QPair>
diff --git a/src/location/maps/qgeocodingmanagerengine.cpp b/src/location/maps/qgeocodingmanagerengine.cpp
index f3aa2870..965f09a5 100644
--- a/src/location/maps/qgeocodingmanagerengine.cpp
+++ b/src/location/maps/qgeocodingmanagerengine.cpp
@@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE
Constructs a new engine with the specified \a parent, using \a parameters
to pass any implementation specific data to the engine.
*/
-QGeoCodingManagerEngine::QGeoCodingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
+QGeoCodingManagerEngine::QGeoCodingManagerEngine(const QVariantMap &parameters, QObject *parent)
: QObject(parent),
d_ptr(new QGeoCodingManagerEnginePrivate())
{
diff --git a/src/location/maps/qgeocodingmanagerengine.h b/src/location/maps/qgeocodingmanagerengine.h
index aa2839a0..11862db3 100644
--- a/src/location/maps/qgeocodingmanagerengine.h
+++ b/src/location/maps/qgeocodingmanagerengine.h
@@ -56,7 +56,7 @@ class Q_LOCATION_EXPORT QGeoCodingManagerEngine : public QObject
{
Q_OBJECT
public:
- QGeoCodingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ QGeoCodingManagerEngine(const QVariantMap &parameters, QObject *parent = 0);
virtual ~QGeoCodingManagerEngine();
QString managerName() const;
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 98718bbb..1f2b6e9b 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -44,11 +44,12 @@
#include "qgeotilecache_p.h"
#include "qgeotilespec_p.h"
-#include "qgeoprojection_p.h"
+
#include "qgeocameracapabilities_p.h"
#include "qgeomapcontroller_p.h"
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
+
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector3d_p.h>
#include "qgeocameratiles_p.h"
#include "qgeotilerequestmanager_p.h"
@@ -139,12 +140,12 @@ QGeoCameraData QGeoMap::cameraData() const
return mapData_->cameraData();
}
-QGeoCoordinate QGeoMap::screenPositionToCoordinate(const QPointF &pos, bool clipToViewport) const
+QGeoCoordinate QGeoMap::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
return mapData_->screenPositionToCoordinate(pos, clipToViewport);
}
-QPointF QGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
return mapData_->coordinateToScreenPosition(coordinate, clipToViewport);
}
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index e001a99d..e956d886 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -56,7 +56,7 @@
#include "qgeocameradata_p.h"
#include "qgeomaptype_p.h"
-#include "qgeocoordinateinterpolator_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
QT_BEGIN_NAMESPACE
@@ -98,8 +98,8 @@ public:
QGeoCameraData cameraData() const;
QGeoCameraCapabilities cameraCapabilities() const;
- QGeoCoordinate screenPositionToCoordinate(const QPointF &pos, bool clipToViewport = true) const;
- QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
diff --git a/src/location/maps/qgeomapcontroller.cpp b/src/location/maps/qgeomapcontroller.cpp
index 0d5965df..2fecc3ea 100644
--- a/src/location/maps/qgeomapcontroller.cpp
+++ b/src/location/maps/qgeomapcontroller.cpp
@@ -42,74 +42,16 @@
#include "qgeomapcontroller_p.h"
#include "qgeomapdata_p.h"
-#include "qgeoprojection_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
#include <QPointF>
-#include <QVariant>
-#include <QVariantAnimation>
-
QT_BEGIN_NAMESPACE
-QVariant coordinateInterpolator(const AnimatableCoordinate &start,
- const AnimatableCoordinate &end,
- qreal progress)
-{
- AnimatableCoordinate result = start;
-
- QSharedPointer<QGeoCoordinateInterpolator> i = start.interpolator();
- if (!i)
- i = end.interpolator();
-
- if (!i)
- result.setCoordinate(start.coordinate());
- else
- result.setCoordinate(i->interpolate(start.coordinate(),
- end.coordinate(),
- progress));
-
- result.setInterpolator(i);
-
- return QVariant::fromValue(result);
-}
-
-AnimatableCoordinate::AnimatableCoordinate() {}
-
-AnimatableCoordinate::AnimatableCoordinate(const QGeoCoordinate &coordinate,
- QSharedPointer<QGeoCoordinateInterpolator> interpolator)
- : coordinate_(coordinate),
- interpolator_(interpolator)
-{
-}
-
-QGeoCoordinate AnimatableCoordinate::coordinate() const
-{
- return coordinate_;
-}
-
-void AnimatableCoordinate::setCoordinate(const QGeoCoordinate &coordinate)
-{
- coordinate_ = coordinate;
-}
-
-QSharedPointer<QGeoCoordinateInterpolator> AnimatableCoordinate::interpolator() const
-{
- return interpolator_;
-}
-
-void AnimatableCoordinate::setInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator)
-{
- interpolator_ = interpolator;
-}
-
-QGeoMapController::QGeoMapController(QGeoMapData *map, QSharedPointer<QGeoCoordinateInterpolator> interpolator)
+QGeoMapController::QGeoMapController(QGeoMapData *map)
: QObject(map),
- map_(map),
- interpolator_(interpolator)
+ map_(map)
{
- qRegisterMetaType<AnimatableCoordinate>();
- qRegisterAnimationInterpolator<AnimatableCoordinate>(coordinateInterpolator);
-
oldCameraData_ = map_->cameraData();
connect(map_,
@@ -123,7 +65,7 @@ QGeoMapController::~QGeoMapController() {}
void QGeoMapController::cameraDataChanged(const QGeoCameraData &cameraData)
{
if (oldCameraData_.center() != cameraData.center())
- emit centerChanged(AnimatableCoordinate(cameraData.center(), interpolator_));
+ emit centerChanged(cameraData.center());
if (oldCameraData_.bearing() != cameraData.bearing())
emit bearingChanged(cameraData.bearing());
@@ -140,19 +82,19 @@ void QGeoMapController::cameraDataChanged(const QGeoCameraData &cameraData)
oldCameraData_ = cameraData;
}
-AnimatableCoordinate QGeoMapController::center() const
+QGeoCoordinate QGeoMapController::center() const
{
- return AnimatableCoordinate(map_->cameraData().center(), interpolator_);
+ return map_->cameraData().center();
}
-void QGeoMapController::setCenter(const AnimatableCoordinate &center)
+void QGeoMapController::setCenter(const QGeoCoordinate &center)
{
QGeoCameraData cd = map_->cameraData();
- if (center.coordinate() == cd.center())
+ if (center == cd.center())
return;
- cd.setCenter(center.coordinate());
+ cd.setCenter(center);
map_->setCameraData(cd);
}
@@ -263,7 +205,7 @@ void QGeoMapController::pan(qreal dx, qreal dy)
return;
QGeoCameraData cd = map_->cameraData();
QGeoCoordinate coord = map_->screenPositionToCoordinate(
- QPointF(map_->width() / 2 + dx,
+ QDoubleVector2D(map_->width() / 2 + dx,
map_->height() / 2 + dy));
diff --git a/src/location/maps/qgeomapcontroller_p.h b/src/location/maps/qgeomapcontroller_p.h
index 7af95a3d..247adcc3 100644
--- a/src/location/maps/qgeomapcontroller_p.h
+++ b/src/location/maps/qgeomapcontroller_p.h
@@ -56,46 +56,28 @@
#include "qgeocoordinate.h"
#include "qgeocameradata_p.h"
-#include "qgeocoordinateinterpolator_p.h"
QT_BEGIN_NAMESPACE
class QGeoMapData;
-class Q_LOCATION_EXPORT AnimatableCoordinate
-{
-public:
- AnimatableCoordinate();
- AnimatableCoordinate(const QGeoCoordinate &coordinate,
- QSharedPointer<QGeoCoordinateInterpolator> interpolator);
-
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate &coordinate);
-
- QSharedPointer<QGeoCoordinateInterpolator> interpolator() const;
- void setInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator);
-
-private:
- QGeoCoordinate coordinate_;
- QSharedPointer<QGeoCoordinateInterpolator> interpolator_;
-};
class Q_LOCATION_EXPORT QGeoMapController : public QObject
{
Q_OBJECT
- Q_PROPERTY(AnimatableCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
Q_PROPERTY(qreal roll READ roll WRITE setRoll NOTIFY rollChanged)
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
public:
- QGeoMapController(QGeoMapData *map, QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator);
+ QGeoMapController(QGeoMapData *map);
~QGeoMapController();
- AnimatableCoordinate center() const;
- void setCenter(const AnimatableCoordinate &center);
+ QGeoCoordinate center() const;
+ void setCenter(const QGeoCoordinate &center);
void setLatitude(qreal latitude);
void setLongitude(qreal longitude);
@@ -119,7 +101,7 @@ private Q_SLOTS:
void cameraDataChanged(const QGeoCameraData &cameraData);
Q_SIGNALS:
- void centerChanged(const AnimatableCoordinate &center);
+ void centerChanged(const QGeoCoordinate &center);
void bearingChanged(qreal bearing);
void tiltChanged(qreal tilt);
void rollChanged(qreal roll);
@@ -127,12 +109,9 @@ Q_SIGNALS:
private:
QGeoMapData *map_;
- QSharedPointer<QGeoCoordinateInterpolator> interpolator_;
QGeoCameraData oldCameraData_;
};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(AnimatableCoordinate)
-
#endif // QGEOMAPCONTROLLER_P_H
diff --git a/src/location/maps/qgeomapdata.cpp b/src/location/maps/qgeomapdata.cpp
index c26d9adb..69e11530 100644
--- a/src/location/maps/qgeomapdata.cpp
+++ b/src/location/maps/qgeomapdata.cpp
@@ -44,11 +44,8 @@
#include "qgeotilecache_p.h"
#include "qgeotilespec_p.h"
-#include "qgeoprojection_p.h"
#include "qgeocameracapabilities_p.h"
#include "qgeomapcontroller_p.h"
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
#include "qgeocameratiles_p.h"
#include "qgeotilerequestmanager_p.h"
@@ -56,6 +53,11 @@
#include "qgeomappingmanager_p.h"
+
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qdoublevector3d_p.h>
+
#include <QMutex>
#include <QMap>
@@ -157,18 +159,6 @@ QString QGeoMapData::pluginString()
return d->pluginString();
}
-QSharedPointer<QGeoCoordinateInterpolator> QGeoMapData::coordinateInterpolator()
-{
- Q_D(QGeoMapData);
- return d->coordinateInterpolator();
-}
-
-void QGeoMapData::setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator)
-{
- Q_D(QGeoMapData);
- return d->setCoordinateInterpolator(interpolator);
-}
-
QGeoCameraCapabilities QGeoMapData::cameraCapabilities()
{
Q_D(QGeoMapData);
@@ -216,20 +206,10 @@ QString QGeoMapDataPrivate::pluginString()
return pluginString_;
}
-QSharedPointer<QGeoCoordinateInterpolator> QGeoMapDataPrivate::coordinateInterpolator() const
-{
- return coordinateInterpolator_;
-}
-
-void QGeoMapDataPrivate::setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator)
-{
- coordinateInterpolator_ = interpolator;
-}
-
QGeoMapController *QGeoMapDataPrivate::mapController()
{
if (!controller_)
- controller_ = new QGeoMapController(map_, coordinateInterpolator_);
+ controller_ = new QGeoMapController(map_);
return controller_;
}
@@ -268,8 +248,6 @@ void QGeoMapDataPrivate::setCameraData(const QGeoCameraData &cameraData)
cameraData_.setRoll(0.0);
}
- cameraData_.setCoordinateInterpolator(coordinateInterpolator_.toWeakRef());
-
// Do not call this expensive function if the width is 0, since it will get called
// anyway when it is resized to a width > 0.
// this is mainly an optimisation to the initalization of the geomap, which would otherwise
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/maps/qgeomapdata_p.h
index be8649f3..35ed32c2 100644
--- a/src/location/maps/qgeomapdata_p.h
+++ b/src/location/maps/qgeomapdata_p.h
@@ -53,11 +53,9 @@
//
#include <QObject>
-
+#include <QtPositioning/private/qdoublevector2d_p.h>
#include "qgeocameradata_p.h"
#include "qgeomaptype_p.h"
-#include "qgeocoordinateinterpolator_p.h"
-#include "qgeocoordinateinterpolator_p.h"
QT_BEGIN_NAMESPACE
@@ -98,10 +96,8 @@ public:
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator();
-
- virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos, bool clipToViewport = true) const = 0;
- virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
+ virtual QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
+ virtual QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
QString pluginString();
QGeoCameraCapabilities cameraCapabilities();
@@ -109,8 +105,6 @@ public:
virtual void prefetchData() {}
protected:
- void setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator);
-
virtual void mapResized(int width, int height) = 0;
virtual void changeCameraData(const QGeoCameraData &oldCameraData) = 0;
virtual void changeActiveMapType(const QGeoMapType mapType) = 0;
diff --git a/src/location/maps/qgeomapdata_p_p.h b/src/location/maps/qgeomapdata_p_p.h
index 6df9f86e..5e81d457 100644
--- a/src/location/maps/qgeomapdata_p_p.h
+++ b/src/location/maps/qgeomapdata_p_p.h
@@ -60,13 +60,13 @@
#include <QSizeF>
#include <QMatrix4x4>
#include <QString>
-#include <QSharedPointer>
+
+#include <QtPositioning/private/qdoublevector3d_p.h>
+
#include "qgeocameradata_p.h"
#include "qgeomaptype_p.h"
-#include "qdoublevector3d_p.h"
-
QT_BEGIN_NAMESPACE
class QGeoMappingManagerEngine;
@@ -101,9 +101,6 @@ public:
void setActiveMapType(const QGeoMapType &mapType);
QString pluginString();
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator() const;
- void setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator);
-
private:
int width_;
int height_;
@@ -117,8 +114,6 @@ private:
QGeoCameraData cameraData_;
QGeoMapType activeMapType_;
-
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator_;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h
index 903ac14b..a26a4cbd 100644
--- a/src/location/maps/qgeomappingmanagerengine_p.h
+++ b/src/location/maps/qgeomappingmanagerengine_p.h
@@ -87,7 +87,7 @@ public:
virtual QGeoMapData *createMapData() = 0;
- QMap<QString, QVariant> parameters() const;
+ QVariantMap parameters() const;
QString managerName() const;
int managerVersion() const;
diff --git a/src/location/maps/qgeomapscene.cpp b/src/location/maps/qgeomapscene.cpp
index 0247c6fc..cb24861f 100644
--- a/src/location/maps/qgeomapscene.cpp
+++ b/src/location/maps/qgeomapscene.cpp
@@ -41,12 +41,13 @@
#include "qgeomapscene_p.h"
#include "qgeocameradata_p.h"
-#include "qgeoprojection_p.h"
+
#include "qgeotilecache_p.h"
#include "qgeotilespec_p.h"
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qdoublevector3d_p.h>
#include <Qt3D/qglscenenode.h>
#include <Qt3D/qglbuilder.h>
@@ -124,8 +125,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QPointF &pos) const;
- QPointF mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
void setVisibleTiles(const QSet<QGeoTileSpec> &tiles);
void removeTiles(const QSet<QGeoTileSpec> &oldTiles);
@@ -198,13 +199,13 @@ void QGeoMapScene::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileText
d->addTile(spec, texture);
}
-QDoubleVector2D QGeoMapScene::screenPositionToMercator(const QPointF &pos) const
+QDoubleVector2D QGeoMapScene::screenPositionToMercator(const QDoubleVector2D &pos) const
{
Q_D(const QGeoMapScene);
return d->screenPositionToMercator(pos);
}
-QPointF QGeoMapScene::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScene::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
{
Q_D(const QGeoMapScene);
return d->mercatorToScreenPosition(mercator);
@@ -278,7 +279,7 @@ QGeoMapScenePrivate::~QGeoMapScenePrivate()
delete light_;
}
-QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QPointF &pos) const
+QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QDoubleVector2D &pos) const
{
double x = mercatorWidth_ * (((pos.x() - screenOffsetX_) / screenWidth_) - 0.5);
x += mercatorCenterX_;
@@ -297,7 +298,7 @@ QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QPointF &pos
return QDoubleVector2D(x, y);
}
-QPointF QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
{
double mx = sideLength_ * mercator.x();
@@ -336,7 +337,7 @@ QPointF QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mer
double x = screenWidth_ * (0.5 + m);
double y = screenHeight_ * (0.5 + (sideLength_ * mercator.y() - mercatorCenterY_) / mercatorHeight_);
- return QPointF(x + screenOffsetX_, y + screenOffsetY_);
+ return QDoubleVector2D(x + screenOffsetX_, y + screenOffsetY_);
}
QGeometryData QGeoMapScenePrivate::buildGeometry(const QGeoTileSpec &spec)
@@ -371,21 +372,22 @@ QGeometryData QGeoMapScenePrivate::buildGeometry(const QGeoTileSpec &spec)
QDoubleVector3D n = QDoubleVector3D(0, 0, 1);
+ //Texture coordinate order for veritcal flip of texture
g.appendVertex(QVector3D(x1, y1, 0.0));
g.appendNormal(n);
- g.appendTexCoord(QVector2D(0.0, 1.0));
+ g.appendTexCoord(QVector2D(0.0, 0.0));
g.appendVertex(QVector3D(x1, y2, 0.0));
g.appendNormal(n);
- g.appendTexCoord(QVector2D(0.0, 0.0));
+ g.appendTexCoord(QVector2D(0.0, 1.0));
g.appendVertex(QVector3D(x2, y2, 0.0));
g.appendNormal(n);
- g.appendTexCoord(QVector2D(1.0, 0.0));
+ g.appendTexCoord(QVector2D(1.0, 1.0));
g.appendVertex(QVector3D(x2, y1, 0.0));
g.appendNormal(n);
- g.appendTexCoord(QVector2D(1.0, 1.0));
+ g.appendTexCoord(QVector2D(1.0, 0.0));
return g;
}
@@ -425,6 +427,18 @@ void QGeoMapScenePrivate::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoT
(~QGLTexture2D::LinearFilteringBindOption));
}
+ //Avoid expensive conversion of ARGB32_Premultiplied to ARGB32
+ if (texture->texture->image().format() == QImage::Format_ARGB32_Premultiplied) {
+ texture->texture->setBindOptions(texture->texture->bindOptions() |
+ (QGLTexture2D::PremultipliedAlphaBindOption));
+ }
+
+ //There are tiles for different zoom levels, no need for mipmaps
+ texture->texture->setBindOptions(texture->texture->bindOptions() & (~QGLTexture2D::MipmapBindOption));
+
+ //We flip the texture coordinates instead of the texture
+ texture->texture->setBindOptions(texture->texture->bindOptions() & (~QGLTexture2D::InvertedYBindOption));
+
QGLSceneNode *node = nodes_.value(spec, 0);
if (!node) {
QGeometryData geom = buildGeometry(spec);
diff --git a/src/location/maps/qgeomapscene_p.h b/src/location/maps/qgeomapscene_p.h
index 2bb4626b..203eeb8a 100644
--- a/src/location/maps/qgeomapscene_p.h
+++ b/src/location/maps/qgeomapscene_p.h
@@ -57,6 +57,7 @@
#include <QSharedPointer>
#include <QSize>
#include <QtLocation/qlocationglobal.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
QT_BEGIN_NAMESPACE
@@ -93,8 +94,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QPointF &pos) const;
- QPointF mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
QGLCamera *camera() const;
QGLSceneNode *sceneNode() const;
diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h
index 99e5baf0..7b1cc2c9 100644
--- a/src/location/maps/qgeomaptype_p.h
+++ b/src/location/maps/qgeomaptype_p.h
@@ -74,6 +74,8 @@ public:
HybridMap,
TransitMap,
GrayStreetMap,
+ PedestrianMap,
+ CarNavigationMap,
CustomMap = 100
};
diff --git a/src/location/maps/qgeoroutereply.cpp b/src/location/maps/qgeoroutereply.cpp
index 0074ee4c..2bdaef50 100644
--- a/src/location/maps/qgeoroutereply.cpp
+++ b/src/location/maps/qgeoroutereply.cpp
@@ -209,6 +209,14 @@ void QGeoRouteReply::setRoutes(const QList<QGeoRoute> &routes)
}
/*!
+ Appends the list of \a routes to the existing list.
+*/
+void QGeoRouteReply::addRoutes(const QList<QGeoRoute> &routes)
+{
+ d_ptr->routes.append(routes);
+}
+
+/*!
Cancels the operation immediately.
This will do nothing if the reply is finished.
diff --git a/src/location/maps/qgeoroutereply.h b/src/location/maps/qgeoroutereply.h
index dc22b0a2..96a052fb 100644
--- a/src/location/maps/qgeoroutereply.h
+++ b/src/location/maps/qgeoroutereply.h
@@ -88,6 +88,7 @@ protected:
void setFinished(bool finished);
void setRoutes(const QList<QGeoRoute> &routes);
+ void addRoutes(const QList<QGeoRoute> &routes);
private:
QGeoRouteReplyPrivate *d_ptr;
diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp
index c279b375..89d32f77 100644
--- a/src/location/maps/qgeorouterequest.cpp
+++ b/src/location/maps/qgeorouterequest.cpp
@@ -318,13 +318,14 @@ QList<QGeoRectangle> QGeoRouteRequest::excludeAreas() const
}
/*!
- Sets the number of alternative routes to request to \a alternatives.
+ Sets the number of alternative routes to request to \a alternatives. If \a alternatives is
+ negative the number of alternative routes is set to 0.
The default value is 0.
*/
void QGeoRouteRequest::setNumberAlternativeRoutes(int alternatives)
{
- d_ptr->numberAlternativeRoutes = alternatives;
+ d_ptr->numberAlternativeRoutes = qMax(0, alternatives);
}
/*!
diff --git a/src/location/maps/qgeoroutingmanager.cpp b/src/location/maps/qgeoroutingmanager.cpp
index 5637a269..07af687b 100644
--- a/src/location/maps/qgeoroutingmanager.cpp
+++ b/src/location/maps/qgeoroutingmanager.cpp
@@ -347,6 +347,33 @@ QLocale QGeoRoutingManager::locale() const
}
/*!
+ Sets the measurement system used by this manager to \a system.
+
+ The measurement system can be set independently of the locale. Both setLocale() and this
+ function set the measurement system. The value set by the last function called will be used.
+
+ \sa measurementSystem(), locale(), setLocale()
+*/
+void QGeoRoutingManager::setMeasurementSystem(QLocale::MeasurementSystem system)
+{
+ d_ptr->engine->setMeasurementSystem(system);
+}
+
+/*!
+ Returns the measurement system used by this manager.
+
+ If setMeasurementSystem() has been called then the value returned by this function may be
+ different to that returned by locale().\l {QLocale::measurementSystem()}{measurementSystem()}.
+ In which case the value returned by this function is what will be used by the manager.
+
+ \sa setMeasurementSystem(), setLocale()
+*/
+QLocale::MeasurementSystem QGeoRoutingManager::measurementSystem() const
+{
+ return d_ptr->engine->measurementSystem();
+}
+
+/*!
\fn void QGeoRoutingManager::finished(QGeoRouteReply *reply)
This signal is emitted when \a reply has finished processing.
diff --git a/src/location/maps/qgeoroutingmanager.h b/src/location/maps/qgeoroutingmanager.h
index d9ff6816..72dfc370 100644
--- a/src/location/maps/qgeoroutingmanager.h
+++ b/src/location/maps/qgeoroutingmanager.h
@@ -42,22 +42,20 @@
#ifndef QGEOROUTINGMANAGER_H
#define QGEOROUTINGMANAGER_H
+#include <QtCore/QObject>
+#include <QtCore/QLocale>
#include <QtLocation/QGeoRouteRequest>
#include <QtLocation/QGeoRouteReply>
-#include <QObject>
-#include <QMap>
-
QT_BEGIN_NAMESPACE
-class QLocale;
-
class QGeoRoutingManagerEngine;
class QGeoRoutingManagerPrivate;
class Q_LOCATION_EXPORT QGeoRoutingManager : public QObject
{
Q_OBJECT
+
public:
~QGeoRoutingManager();
@@ -76,6 +74,8 @@ public:
void setLocale(const QLocale &locale);
QLocale locale() const;
+ void setMeasurementSystem(QLocale::MeasurementSystem system);
+ QLocale::MeasurementSystem measurementSystem() const;
Q_SIGNALS:
void finished(QGeoRouteReply *reply);
diff --git a/src/location/maps/qgeoroutingmanagerengine.cpp b/src/location/maps/qgeoroutingmanagerengine.cpp
index 8629bcb5..7b81d7a6 100644
--- a/src/location/maps/qgeoroutingmanagerengine.cpp
+++ b/src/location/maps/qgeoroutingmanagerengine.cpp
@@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE
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)
+QGeoRoutingManagerEngine::QGeoRoutingManagerEngine(const QVariantMap &parameters, QObject *parent)
: QObject(parent),
d_ptr(new QGeoRoutingManagerEnginePrivate())
{
@@ -347,6 +347,7 @@ QGeoRouteRequest::ManeuverDetails QGeoRoutingManagerEngine::supportedManeuverDet
void QGeoRoutingManagerEngine::setLocale(const QLocale &locale)
{
d_ptr->locale = locale;
+ d_ptr->measurementSystem = locale.measurementSystem();
}
/*!
@@ -359,6 +360,33 @@ QLocale QGeoRoutingManagerEngine::locale() const
}
/*!
+ Sets the measurement system used by this manager to \a system.
+
+ The measurement system can be set independently of the locale. Both setLocale() and this
+ function set the measurement system. The value set by the last function called will be used.
+
+ \sa measurementSystem(), locale(), setLocale()
+*/
+void QGeoRoutingManagerEngine::setMeasurementSystem(QLocale::MeasurementSystem system)
+{
+ d_ptr->measurementSystem = system;
+}
+
+/*!
+ Returns the measurement system used by this manager.
+
+ If setMeasurementSystem() has been called then the value returned by this function may be
+ different to that returned by locale().\l {QLocale::measurementSystem()}{measurementSystem()}.
+ In which case the value returned by this function is what will be used by the manager.
+
+ \sa setMeasurementSystem(), setLocale()
+*/
+QLocale::MeasurementSystem QGeoRoutingManagerEngine::measurementSystem() const
+{
+ return d_ptr->measurementSystem;
+}
+
+/*!
\fn void QGeoRoutingManagerEngine::finished(QGeoRouteReply *reply)
This signal is emitted when \a reply has finished processing.
@@ -391,7 +419,7 @@ Use deleteLater() instead.
*******************************************************************************/
QGeoRoutingManagerEnginePrivate::QGeoRoutingManagerEnginePrivate()
- : managerVersion(-1)
+: managerVersion(-1), measurementSystem(locale.measurementSystem())
{
}
diff --git a/src/location/maps/qgeoroutingmanagerengine.h b/src/location/maps/qgeoroutingmanagerengine.h
index fa05b984..1e05b890 100644
--- a/src/location/maps/qgeoroutingmanagerengine.h
+++ b/src/location/maps/qgeoroutingmanagerengine.h
@@ -42,23 +42,21 @@
#ifndef QGEOROUTINGMANAGERENGINE_H
#define QGEOROUTINGMANAGERENGINE_H
+#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtCore/QLocale>
#include <QtLocation/QGeoRouteRequest>
#include <QtLocation/QGeoRouteReply>
-#include <QObject>
-#include <QMap>
-
QT_BEGIN_NAMESPACE
-class QLocale;
-
class QGeoRoutingManagerEnginePrivate;
class Q_LOCATION_EXPORT QGeoRoutingManagerEngine : public QObject
{
Q_OBJECT
public:
- QGeoRoutingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ QGeoRoutingManagerEngine(const QVariantMap &parameters, QObject *parent = 0);
virtual ~QGeoRoutingManagerEngine();
QString managerName() const;
@@ -76,6 +74,8 @@ public:
void setLocale(const QLocale &locale);
QLocale locale() const;
+ void setMeasurementSystem(QLocale::MeasurementSystem system);
+ QLocale::MeasurementSystem measurementSystem() const;
Q_SIGNALS:
void finished(QGeoRouteReply *reply);
diff --git a/src/location/maps/qgeoroutingmanagerengine_p.h b/src/location/maps/qgeoroutingmanagerengine_p.h
index e868fad8..ad6f8660 100644
--- a/src/location/maps/qgeoroutingmanagerengine_p.h
+++ b/src/location/maps/qgeoroutingmanagerengine_p.h
@@ -77,6 +77,7 @@ public:
QGeoRouteRequest::ManeuverDetails supportedManeuverDetails;
QLocale locale;
+ QLocale::MeasurementSystem measurementSystem;
private:
Q_DISABLE_COPY(QGeoRoutingManagerEnginePrivate)
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
index c91ef8a5..2babbba6 100644
--- a/src/location/maps/qgeoserviceprovider.cpp
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -641,7 +641,7 @@ void QGeoServiceProviderPrivate::loadMeta()
}
}
-void QGeoServiceProviderPrivate::loadPlugin(const QMap<QString, QVariant> &parameters)
+void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap &parameters)
{
Q_UNUSED(parameters)
diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h
index 1ec19c89..1d92149e 100644
--- a/src/location/maps/qgeoserviceprovider_p.h
+++ b/src/location/maps/qgeoserviceprovider_p.h
@@ -75,7 +75,7 @@ public:
~QGeoServiceProviderPrivate();
void loadMeta();
- void loadPlugin(const QMap<QString, QVariant> &parameters);
+ void loadPlugin(const QVariantMap &parameters);
void unload();
/* helper templates for generating the feature and manager accessors */
@@ -88,7 +88,7 @@ public:
QGeoServiceProviderFactory *factory;
QJsonObject metaData;
- QMap<QString, QVariant> parameterMap;
+ QVariantMap parameterMap;
bool experimental;
diff --git a/src/location/maps/qgeoserviceproviderfactory.cpp b/src/location/maps/qgeoserviceproviderfactory.cpp
index 8fbfb3d7..b1c7759c 100644
--- a/src/location/maps/qgeoserviceproviderfactory.cpp
+++ b/src/location/maps/qgeoserviceproviderfactory.cpp
@@ -78,7 +78,7 @@ Destroys this QGeoServiceProviderFactory instance.
The default implementation returns 0, which causes a
QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
*/
-QGeoCodingManagerEngine *QGeoServiceProviderFactory::createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
+QGeoCodingManagerEngine *QGeoServiceProviderFactory::createGeocodingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
{
@@ -104,7 +104,7 @@ QGeoCodingManagerEngine *QGeoServiceProviderFactory::createGeocodingManagerEngin
\internal
*/
-QGeoMappingManagerEngine *QGeoServiceProviderFactory::createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+QGeoMappingManagerEngine *QGeoServiceProviderFactory::createMappingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
{
@@ -128,7 +128,7 @@ QGeoMappingManagerEngine *QGeoServiceProviderFactory::createMappingManagerEngine
The default implementation returns 0, which causes a
QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
*/
-QGeoRoutingManagerEngine *QGeoServiceProviderFactory::createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+QGeoRoutingManagerEngine *QGeoServiceProviderFactory::createRoutingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
@@ -153,7 +153,7 @@ QGeoRoutingManagerEngine *QGeoServiceProviderFactory::createRoutingManagerEngine
The default implementation returns 0, which causes a
QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
*/
-QPlaceManagerEngine *QGeoServiceProviderFactory::createPlaceManagerEngine(const QMap<QString, QVariant> &parameters,
+QPlaceManagerEngine *QGeoServiceProviderFactory::createPlaceManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
diff --git a/src/location/maps/qgeoserviceproviderfactory.h b/src/location/maps/qgeoserviceproviderfactory.h
index 28c27ef0..b2843301 100644
--- a/src/location/maps/qgeoserviceproviderfactory.h
+++ b/src/location/maps/qgeoserviceproviderfactory.h
@@ -55,16 +55,16 @@ class Q_LOCATION_EXPORT QGeoServiceProviderFactory
public:
virtual ~QGeoServiceProviderFactory() {}
- virtual QGeoCodingManagerEngine *createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
+ virtual QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
- virtual QGeoMappingManagerEngine *createMappingManagerEngine(const QMap<QString, QVariant> &parameters,
+ virtual QGeoMappingManagerEngine *createMappingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
- virtual QGeoRoutingManagerEngine *createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ virtual QGeoRoutingManagerEngine *createRoutingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
- virtual QPlaceManagerEngine *createPlaceManagerEngine(const QMap<QString, QVariant> &parameters,
+ virtual QPlaceManagerEngine *createPlaceManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
};
diff --git a/src/location/maps/qgeotilecache.cpp b/src/location/maps/qgeotilecache.cpp
index 9bd9c977..54a850cd 100644
--- a/src/location/maps/qgeotilecache.cpp
+++ b/src/location/maps/qgeotilecache.cpp
@@ -116,7 +116,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent)
// of course override them)
if (directory_.isEmpty()) {
- directory_ = QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
+ directory_ = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)
+ QLatin1String("/QtLocation");
QDir::root().mkpath(directory_);
}
@@ -196,11 +196,13 @@ QGeoTileCache::~QGeoTileCache()
}
QList<QSharedPointer<QGeoCachedTileDisk> > queue;
diskCache_.serializeQueue(i, queue);
- int queueLength = queue.size();
- for (int j = 0; j<queueLength; j++) {
+ foreach (const QSharedPointer<QGeoCachedTileDisk> &tile, queue) {
+ if (tile.isNull())
+ continue;
+
// we just want the filename here, not the full path
- int index = queue[j]->filename.lastIndexOf(QLatin1Char('/'));
- QByteArray filename = queue[j]->filename.mid(index + 1).toLatin1() + '\n';
+ int index = tile->filename.lastIndexOf(QLatin1Char('/'));
+ QByteArray filename = tile->filename.mid(index + 1).toLatin1() + '\n';
file.write(filename);
}
file.close();
diff --git a/src/location/maps/qgeotiledmapdata.cpp b/src/location/maps/qgeotiledmapdata.cpp
index 2c322749..1655327b 100644
--- a/src/location/maps/qgeotiledmapdata.cpp
+++ b/src/location/maps/qgeotiledmapdata.cpp
@@ -44,14 +44,10 @@
#include "qgeotiledmappingmanagerengine_p.h"
#include "qgeotilecache_p.h"
#include "qgeotilespec_p.h"
-#include "qgeoprojection_p.h"
#include "qgeocameratiles_p.h"
#include "qgeotilerequestmanager_p.h"
#include "qgeomapscene_p.h"
-#include "qgeocoordinateinterpolator_p.h"
-#include "qgeoprojection_p.h"
-#include "qdoublevector2d_p.h"
#include "qgeocameracapabilities_p.h"
#include <QMutex>
@@ -68,74 +64,19 @@
#include <Qt3D/qglcamera.h>
#include <Qt3D/qglsubsurface.h>
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+
#include <cmath>
QT_BEGIN_NAMESPACE
-class QGeoCoordinateInterpolator2D : public QGeoCoordinateInterpolator
-{
-public:
- QGeoCoordinateInterpolator2D();
- virtual ~QGeoCoordinateInterpolator2D();
-
- virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress);
-};
-
-QGeoCoordinateInterpolator2D::QGeoCoordinateInterpolator2D() {}
-
-QGeoCoordinateInterpolator2D::~QGeoCoordinateInterpolator2D() {}
-
-QGeoCoordinate QGeoCoordinateInterpolator2D::interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress)
-{
- if (start == end) {
- if (progress < 0.5) {
- return start;
- } else {
- return end;
- }
- }
-
- QGeoCoordinate s2 = start;
- QGeoCoordinate e2 = end;
- QDoubleVector2D s = QGeoProjection::coordToMercator(s2);
- QDoubleVector2D e = QGeoProjection::coordToMercator(e2);
-
- double x = s.x();
-
- if (0.5 < qAbs(e.x() - s.x())) {
- // handle dateline crossing
- double ex = e.x();
- double sx = s.x();
- if (ex < sx)
- sx -= 1.0;
- else if (sx < ex)
- ex -= 1.0;
-
- x = (1.0 - progress) * sx + progress * ex;
-
- if (!qFuzzyIsNull(x) && (x < 0.0))
- x += 1.0;
-
- } else {
- x = (1.0 - progress) * s.x() + progress * e.x();
- }
-
- double y = (1.0 - progress) * s.y() + progress * e.y();
-
- QGeoCoordinate result = QGeoProjection::mercatorToCoord(QDoubleVector2D(x, y));
- result.setAltitude((1.0 - progress) * start.altitude() + progress * end.altitude());
- return result;
-}
-
-//------------------------
-//------------------------
QGeoTiledMapData::QGeoTiledMapData(QGeoTiledMappingManagerEngine *engine, QObject *parent)
: QGeoMapData(engine, parent)
{
d_ptr = new QGeoTiledMapDataPrivate(this, engine);
engine->registerMap(this);
- setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator>(new QGeoCoordinateInterpolator2D()));
}
QGeoTiledMapData::~QGeoTiledMapData()
@@ -198,7 +139,7 @@ void QGeoTiledMapData::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles
Q_UNUSED(visibleTiles);
}
-QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QPointF &pos, bool clipToViewport) const
+QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
if (clipToViewport) {
@@ -212,17 +153,17 @@ QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QPointF &pos,
return d->screenPositionToCoordinate(pos);
}
-QPointF QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
- QPointF pos = d->coordinateToScreenPosition(coordinate);
+ QDoubleVector2D pos = d->coordinateToScreenPosition(coordinate);
if (clipToViewport) {
int w = width();
int h = height();
if ((pos.x() < 0) || (w < pos.x()) || (pos.y() < 0) || (h < pos.y()))
- return QPointF(qQNaN(), qQNaN());
+ return QDoubleVector2D(qQNaN(), qQNaN());
}
return pos;
@@ -373,12 +314,12 @@ void QGeoTiledMapDataPrivate::paintGL(QGLPainter *painter)
cache_->GLContextAvailable();
}
-QGeoCoordinate QGeoTiledMapDataPrivate::screenPositionToCoordinate(const QPointF &pos) const
+QGeoCoordinate QGeoTiledMapDataPrivate::screenPositionToCoordinate(const QDoubleVector2D &pos) const
{
return QGeoProjection::mercatorToCoord(mapScene_->screenPositionToMercator(pos));
}
-QPointF QGeoTiledMapDataPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+QDoubleVector2D QGeoTiledMapDataPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
{
return mapScene_->mercatorToScreenPosition(QGeoProjection::coordToMercator(coordinate));
}
diff --git a/src/location/maps/qgeotiledmapdata_p.h b/src/location/maps/qgeotiledmapdata_p.h
index c709bb14..126454e4 100644
--- a/src/location/maps/qgeotiledmapdata_p.h
+++ b/src/location/maps/qgeotiledmapdata_p.h
@@ -59,6 +59,8 @@
#include "qgeocameradata_p.h"
#include "qgeomaptype_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
+
QT_BEGIN_NAMESPACE
class QGeoTileSpec;
@@ -84,8 +86,8 @@ public:
void newTileFetched(const QGeoTileSpec &spec);
- QGeoCoordinate screenPositionToCoordinate(const QPointF &pos, bool clipToViewport = true) const;
- QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void prefetchTiles();
// Alternative to exposing this is to make tileFetched a slot, but then requestManager would
diff --git a/src/location/maps/qgeotiledmapdata_p_p.h b/src/location/maps/qgeotiledmapdata_p_p.h
index 16e6be0c..67ad5cc1 100644
--- a/src/location/maps/qgeotiledmapdata_p_p.h
+++ b/src/location/maps/qgeotiledmapdata_p_p.h
@@ -60,14 +60,14 @@
#include <QSizeF>
#include <QMatrix4x4>
#include <QString>
-#include <QSharedPointer>
#include <QPointer>
+#include <QtPositioning/private/qdoublevector3d_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+
#include "qgeocameradata_p.h"
#include "qgeomaptype_p.h"
-#include "qdoublevector3d_p.h"
-
QT_BEGIN_NAMESPACE
class QGeoTile;
@@ -99,8 +99,8 @@ public:
void changeActiveMapType(const QGeoMapType mapType);
void resized(int width, int height);
- QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
- QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos) const;
+ QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
void newTileFetched(const QGeoTileSpec &spec);
QSet<QGeoTileSpec> visibleTiles();
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 6b60a1ce..69532f44 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -74,9 +74,6 @@ void QGeoTiledMappingManagerEngine::setTileFetcher(QGeoTileFetcher *fetcher)
Q_D(QGeoTiledMappingManagerEngine);
d->fetcher_ = fetcher;
- d->fetcher_->init();
-
- d->thread_ = new QThread;
qRegisterMetaType<QGeoTileSpec>();
@@ -91,26 +88,7 @@ void QGeoTiledMappingManagerEngine::setTileFetcher(QGeoTileFetcher *fetcher)
SLOT(engineTileError(QGeoTileSpec,QString)),
Qt::QueuedConnection);
- d->fetcher_->moveToThread(d_ptr->thread_);
-
- connect(d->thread_,
- SIGNAL(started()),
- d->fetcher_,
- SLOT(threadStarted()));
-
- connect(d->thread_,
- SIGNAL(finished()),
- d->fetcher_,
- SLOT(threadFinished()));
-
- connect(d->fetcher_,
- SIGNAL(destroyed()),
- d->thread_,
- SLOT(deleteLater()));
-
engineInitialized();
-
- QTimer::singleShot(0, d->thread_, SLOT(start()));
}
QGeoTileFetcher *QGeoTiledMappingManagerEngine::tileFetcher()
@@ -318,20 +296,13 @@ QSharedPointer<QGeoTileTexture> QGeoTiledMappingManagerEngine::getTileTexture(co
*******************************************************************************/
QGeoTiledMappingManagerEnginePrivate::QGeoTiledMappingManagerEnginePrivate()
- : thread_(0),
- cacheHint_(QGeoTiledMappingManagerEngine::AllCaches),
- tileCache_(0),
- fetcher_(0) {}
+: cacheHint_(QGeoTiledMappingManagerEngine::AllCaches), tileCache_(0), fetcher_(0)
+{
+}
QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate()
{
delete tileCache_;
-
- // but we still want to stop the fetcher's timer immediately
- fetcher_->stopTimer();
-
- // will delete fetcher and thread later
- thread_->exit();
}
#include "moc_qgeotiledmappingmanagerengine_p.cpp"
diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
index ae26ab46..dfdab6de 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h
@@ -55,10 +55,8 @@
//
#include <QSize>
-#include <QList>
#include <QHash>
#include <QSet>
-#include <QThread>
#include "qgeotiledmappingmanagerengine_p.h"
QT_BEGIN_NAMESPACE
@@ -74,7 +72,6 @@ public:
QGeoTiledMappingManagerEnginePrivate();
~QGeoTiledMappingManagerEnginePrivate();
- QThread *thread_;
QSize tileSize_;
QSet<QGeoTiledMapData *> tileMaps_;
QHash<QGeoTiledMapData *, QSet<QGeoTileSpec> > mapHash_;
diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp
index 450bf322..e0d6b6ea 100644
--- a/src/location/maps/qgeotilefetcher.cpp
+++ b/src/location/maps/qgeotilefetcher.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include <QtCore/QTimerEvent>
+
#include "qgeomappingmanagerengine_p.h"
#include "qgeotilefetcher_p.h"
#include "qgeotilefetcher_p_p.h"
@@ -48,60 +50,21 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcher::QGeoTileFetcher(QGeoTiledMappingManagerEngine *engine, QObject *parent)
- : QObject(parent),
- d_ptr(new QGeoTileFetcherPrivate(engine))
+QGeoTileFetcher::QGeoTileFetcher(QObject *parent)
+: QObject(parent), d_ptr(new QGeoTileFetcherPrivate)
{
Q_D(QGeoTileFetcher);
- d->engine_ = engine;
-}
-
-QGeoTileFetcher::~QGeoTileFetcher()
-{
- Q_D(QGeoTileFetcher);
- delete d;
-}
-
-void QGeoTileFetcher::threadStarted()
-{
- Q_D(QGeoTileFetcher);
-
- if (d->stopped_)
- return;
-
- d->timer_ = new QTimer(this);
- d->timer_->setInterval(0);
+ d->enabled_ = true;
- connect(d->timer_,
- SIGNAL(timeout()),
- this,
- SLOT(requestNextTile()));
-
- d->started_ = true;
if (!d->queue_.isEmpty())
- d->timer_->start();
-}
-
-bool QGeoTileFetcher::init()
-{
- return false;
+ d->timer_.start(0, this);
}
-void QGeoTileFetcher::stopTimer()
+QGeoTileFetcher::~QGeoTileFetcher()
{
- Q_D(QGeoTileFetcher);
- d->stopped_ = true;
- if (d->timer_) {
- disconnect(d->timer_);
- d->timer_->stop();
- }
-}
-void QGeoTileFetcher::threadFinished()
-{
- stopTimer();
- this->deleteLater();
+ delete d_ptr;
}
void QGeoTileFetcher::updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded,
@@ -111,15 +74,12 @@ void QGeoTileFetcher::updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded,
QMutexLocker ml(&d->queueMutex_);
- if (d->stopped_)
- return;
-
cancelTileRequests(tilesRemoved);
d->queue_ += tilesAdded.toList();
- if (!d->queue_.empty())
- d->timer_->start();
+ if (d->enabled_ && !d->queue_.isEmpty() && !d->timer_.isActive())
+ d->timer_.start(0, this);
}
void QGeoTileFetcher::cancelTileRequests(const QSet<QGeoTileSpec> &tiles)
@@ -139,9 +99,6 @@ void QGeoTileFetcher::cancelTileRequests(const QSet<QGeoTileSpec> &tiles)
}
d->queue_.removeAll(*tile);
}
-
- if (d->queue_.isEmpty())
- d->timer_->stop();
}
void QGeoTileFetcher::requestNextTile()
@@ -150,13 +107,11 @@ void QGeoTileFetcher::requestNextTile()
QMutexLocker ml(&d->queueMutex_);
- if (d->stopped_)
+ if (!d->enabled_)
return;
- if (d->queue_.isEmpty()) {
- d->timer_->stop();
+ if (d->queue_.isEmpty())
return;
- }
QGeoTileSpec ts = d->queue_.takeFirst();
@@ -175,7 +130,7 @@ void QGeoTileFetcher::requestNextTile()
}
if (d->queue_.isEmpty())
- d->timer_->stop();
+ d->timer_.stop();
}
void QGeoTileFetcher::finished()
@@ -200,11 +155,27 @@ void QGeoTileFetcher::finished()
handleReply(reply, spec);
}
+void QGeoTileFetcher::timerEvent(QTimerEvent *event)
+{
+ Q_D(QGeoTileFetcher);
+ if (event->timerId() != d->timer_.timerId()) {
+ QObject::timerEvent(event);
+ return;
+ }
+
+ if (d->queue_.isEmpty()) {
+ d->timer_.stop();
+ return;
+ }
+
+ requestNextTile();
+}
+
void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &spec)
{
Q_D(QGeoTileFetcher);
- if (d->stopped_) {
+ if (!d->enabled_) {
reply->deleteLater();
return;
}
@@ -221,22 +192,13 @@ void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &
/*******************************************************************************
*******************************************************************************/
-QGeoTileFetcherPrivate::QGeoTileFetcherPrivate(QGeoTiledMappingManagerEngine *engine)
- : engine_(engine),
- started_(false),
- stopped_(false),
- timer_(0) {}
+QGeoTileFetcherPrivate::QGeoTileFetcherPrivate()
+: enabled_(false)
+{
+}
QGeoTileFetcherPrivate::~QGeoTileFetcherPrivate()
{
}
QT_END_NAMESPACE
-
-
-
-
-
-
-
-
diff --git a/src/location/maps/qgeotilefetcher_p.h b/src/location/maps/qgeotilefetcher_p.h
index 45e38e05..36b6e0dc 100644
--- a/src/location/maps/qgeotilefetcher_p.h
+++ b/src/location/maps/qgeotilefetcher_p.h
@@ -72,13 +72,10 @@ class Q_LOCATION_EXPORT QGeoTileFetcher : public QObject
Q_OBJECT
public:
- QGeoTileFetcher(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0);
+ QGeoTileFetcher(QObject *parent = 0);
virtual ~QGeoTileFetcher();
- void stopTimer();
public Q_SLOTS:
- void threadStarted();
- void threadFinished();
void updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded, const QSet<QGeoTileSpec> &tilesRemoved);
private Q_SLOTS:
@@ -91,7 +88,7 @@ Q_SIGNALS:
void tileError(const QGeoTileSpec &spec, const QString &errorString);
protected:
- virtual bool init();
+ void timerEvent(QTimerEvent *event);
QGeoTiledMappingManagerEngine::CacheAreas cacheHint() const;
private:
diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h
index ba71a750..aa452413 100644
--- a/src/location/maps/qgeotilefetcher_p_p.h
+++ b/src/location/maps/qgeotilefetcher_p_p.h
@@ -73,14 +73,11 @@ class QGeoTiledMappingManagerEngine;
class QGeoTileFetcherPrivate
{
public:
- explicit QGeoTileFetcherPrivate(QGeoTiledMappingManagerEngine *engine);
+ QGeoTileFetcherPrivate();
virtual ~QGeoTileFetcherPrivate();
- QGeoTiledMappingManagerEngine *engine_;
-
- bool started_;
- bool stopped_;
- QTimer *timer_;
+ bool enabled_;
+ QBasicTimer timer_;
QMutex queueMutex_;
QList<QGeoTileSpec> queue_;
QHash<QGeoTileSpec, QGeoTiledMapReply *> invmap_;
diff --git a/src/location/places/qplacecontentreply.cpp b/src/location/places/qplacecontentreply.cpp
index 23252ea0..3b7d40f2 100644
--- a/src/location/places/qplacecontentreply.cpp
+++ b/src/location/places/qplacecontentreply.cpp
@@ -53,6 +53,8 @@ public:
QPlaceContent::Collection contentCollection;
int totalCount;
QPlaceContentRequest contentRequest;
+ QPlaceContentRequest previousPageRequest;
+ QPlaceContentRequest nextPageRequest;
};
QT_END_NAMESPACE
@@ -145,6 +147,26 @@ QPlaceContentRequest QPlaceContentReply::request() const
}
/*!
+ Returns a place content request that can be used to request the previous batch of place content
+ results.
+*/
+QPlaceContentRequest QPlaceContentReply::previousPageRequest() const
+{
+ Q_D(const QPlaceContentReply);
+ return d->previousPageRequest;
+}
+
+/*!
+ Returns a place content request that can be used to request the next batch of place content
+ results.
+*/
+QPlaceContentRequest QPlaceContentReply::nextPageRequest() const
+{
+ Q_D(const QPlaceContentReply);
+ return d->nextPageRequest;
+}
+
+/*!
Sets the content \a request used to generate this this reply.
*/
void QPlaceContentReply::setRequest(const QPlaceContentRequest &request)
@@ -152,3 +174,23 @@ void QPlaceContentReply::setRequest(const QPlaceContentRequest &request)
Q_D(QPlaceContentReply);
d->contentRequest = request;
}
+
+/*!
+ Sets the place content request that can be used to request the previous batch of place content
+ results to \a previous.
+*/
+void QPlaceContentReply::setPreviousPageRequest(const QPlaceContentRequest &previous)
+{
+ Q_D(QPlaceContentReply);
+ d->previousPageRequest = previous;
+}
+
+/*!
+ Sets the place content request that can be used to request the next batch of place content
+ results to \a next.
+*/
+void QPlaceContentReply::setNextPageRequest(const QPlaceContentRequest &next)
+{
+ Q_D(QPlaceContentReply);
+ d->nextPageRequest = next;
+}
diff --git a/src/location/places/qplacecontentreply.h b/src/location/places/qplacecontentreply.h
index 8d781a46..dcdcddc4 100644
--- a/src/location/places/qplacecontentreply.h
+++ b/src/location/places/qplacecontentreply.h
@@ -65,10 +65,15 @@ public:
QPlaceContentRequest request() const;
+ QPlaceContentRequest previousPageRequest() const;
+ QPlaceContentRequest nextPageRequest() const;
+
protected:
void setContent(const QPlaceContent::Collection &content);
void setTotalCount(int total);
void setRequest(const QPlaceContentRequest &request);
+ void setPreviousPageRequest(const QPlaceContentRequest &previous);
+ void setNextPageRequest(const QPlaceContentRequest &next);
private:
Q_DISABLE_COPY(QPlaceContentReply)
diff --git a/src/location/places/qplacecontentrequest.cpp b/src/location/places/qplacecontentrequest.cpp
index 1353ada4..9ad82149 100644
--- a/src/location/places/qplacecontentrequest.cpp
+++ b/src/location/places/qplacecontentrequest.cpp
@@ -46,14 +46,13 @@
QT_BEGIN_NAMESPACE
QPlaceContentRequestPrivate::QPlaceContentRequestPrivate()
- : QSharedData(), contentType(QPlaceContent::NoType),
- limit(-1), offset(0)
+: QSharedData(), contentType(QPlaceContent::NoType), limit(-1)
{
}
QPlaceContentRequestPrivate::QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other)
- : QSharedData(other), contentType(other.contentType),
- limit(other.limit), offset(other.offset)
+: QSharedData(other), contentType(other.contentType), placeId(other.placeId),
+ contentContext(other.contentContext), limit(other.limit)
{
}
@@ -64,15 +63,13 @@ QPlaceContentRequestPrivate::~QPlaceContentRequestPrivate()
bool QPlaceContentRequestPrivate::operator==(const QPlaceContentRequestPrivate &other) const
{
return contentType == other.contentType
- && limit == other.limit
- && offset == other.offset;
+ && limit == other.limit;
}
void QPlaceContentRequestPrivate::clear()
{
contentType = QPlaceContent::NoType;
limit = -1;
- offset = 0;
}
/*!
@@ -171,48 +168,75 @@ void QPlaceContentRequest::setContentType(QPlaceContent::Type type)
}
/*!
- Returns the maximum number of content items to retrieve.
+ Returns the identifier of the place content is to be fetched for.
+*/
+QString QPlaceContentRequest::placeId() const
+{
+ Q_D(const QPlaceContentRequest);
+ return d->placeId;
+}
- A negative value for limit means that it is undefined. It is left up to the backend
- provider to choose an appropriate number of items to return.
+/*!
+ Sets the identifier of the place to fetch content for to \a identifier.
+*/
+void QPlaceContentRequest::setPlaceId(const QString &identifier)
+{
+ Q_D(QPlaceContentRequest);
+ d->placeId = identifier;
+}
- The default limit is -1.
+/*!
+ Returns backend specific additional content context associated with this place content request.
*/
-int QPlaceContentRequest::limit() const
+QVariant QPlaceContentRequest::contentContext() const
{
Q_D(const QPlaceContentRequest);
- return d->limit;
+ return d->contentContext;
}
/*!
- Set the maximum number of content items to retrieve to
- \a limit.
+ Sets the content context to \a context.
+
+ \note This method is intended to be used by geo service plugins when returning place content
+ results.
+
+ The content context is used by backends to store additional content context related to the
+ content request. Other relevant fields should also be filled in. For example, if the content
+ request is for image content the content type should also be set with \l setContentType(). The
+ content context allows additional context to be kept which is not directly accessible via the
+ Qt Location API.
+
+ The content context can be of any type storable in a QVariant. The value of the content context
+ is not intended to be used directly by applications.
*/
-void QPlaceContentRequest::setLimit(int limit)
+void QPlaceContentRequest::setContentContext(const QVariant &context)
{
Q_D(QPlaceContentRequest);
- d->limit = limit;
+ d->contentContext = context;
}
/*!
- Returns the offset index of the first item that is to be retrieved.
+ Returns the maximum number of content items to retrieve.
- The default offset is 0.
+ A negative value for limit means that it is undefined. It is left up to the backend
+ provider to choose an appropriate number of items to return.
+
+ The default limit is -1.
*/
-int QPlaceContentRequest::offset() const
+int QPlaceContentRequest::limit() const
{
Q_D(const QPlaceContentRequest);
- return d->offset;
+ return d->limit;
}
/*!
- Sets the starting index of the first item to be retrieved
- to \a offset.
+ Set the maximum number of content items to retrieve to
+ \a limit.
*/
-void QPlaceContentRequest::setOffset(int offset)
+void QPlaceContentRequest::setLimit(int limit)
{
Q_D(QPlaceContentRequest);
- d->offset = offset;
+ d->limit = limit;
}
/*!
diff --git a/src/location/places/qplacecontentrequest.h b/src/location/places/qplacecontentrequest.h
index b535a133..164c4df9 100644
--- a/src/location/places/qplacecontentrequest.h
+++ b/src/location/places/qplacecontentrequest.h
@@ -65,8 +65,12 @@ public:
QPlaceContent::Type contentType() const;
void setContentType(QPlaceContent::Type type);
- int offset() const;
- void setOffset(int offset);
+ QString placeId() const;
+ void setPlaceId(const QString &identifier);
+
+ QVariant contentContext() const;
+ void setContentContext(const QVariant &context);
+
int limit() const;
void setLimit(int limit);
diff --git a/src/location/places/qplacecontentrequest_p.h b/src/location/places/qplacecontentrequest_p.h
index 05fb580b..213bdb58 100644
--- a/src/location/places/qplacecontentrequest_p.h
+++ b/src/location/places/qplacecontentrequest_p.h
@@ -43,7 +43,8 @@
#define QPLACECONTENTREQUEST_P_H
#include <QtCore/QSharedData>
-#include "qplacecontent.h"
+#include <QtCore/QVariant>
+#include <QtLocation/QPlaceContent>
QT_BEGIN_NAMESPACE
@@ -60,8 +61,9 @@ public:
void clear();
QPlaceContent::Type contentType;
+ QString placeId;
+ QVariant contentContext;
int limit;
- int offset;
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index d0e91312..863e8adc 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -208,14 +208,13 @@ QPlaceDetailsReply *QPlaceManager::getPlaceDetails(const QString &placeId) const
}
/*!
- Retrieves content for the place corresponding to \a placeId, according to the parameters specified in
- \a request.
+ Retrieves content for a place according to the parameters specified in \a request.
See \l {Fetching Rich Content} for an example of usage.
*/
-QPlaceContentReply *QPlaceManager::getPlaceContent(const QString &placeId, const QPlaceContentRequest &request) const
+QPlaceContentReply *QPlaceManager::getPlaceContent(const QPlaceContentRequest &request) const
{
- return d->getPlaceContent(placeId, request);
+ return d->getPlaceContent(request);
}
/*!
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 786fdc1d..a29e5ea6 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -76,7 +76,7 @@ public:
QPlaceDetailsReply *getPlaceDetails(const QString &placeId) const;
- QPlaceContentReply *getPlaceContent(const QString &placeId, const QPlaceContentRequest &request) const;
+ QPlaceContentReply *getPlaceContent(const QPlaceContentRequest &request) const;
QPlaceSearchReply *search(const QPlaceSearchRequest &query) const;
diff --git a/src/location/places/qplacemanagerengine.cpp b/src/location/places/qplacemanagerengine.cpp
index 67dbf9c6..74d96f0f 100644
--- a/src/location/places/qplacemanagerengine.cpp
+++ b/src/location/places/qplacemanagerengine.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
Constructs a new engine with the specified \a parent, using \a parameters to pass any
implementation specific data to the engine.
*/
-QPlaceManagerEngine::QPlaceManagerEngine(const QMap<QString, QVariant> &parameters,
+QPlaceManagerEngine::QPlaceManagerEngine(const QVariantMap &parameters,
QObject *parent)
: QObject(parent), d_ptr(new QPlaceManagerEnginePrivate)
{
@@ -151,13 +151,10 @@ QPlaceDetailsReply *QPlaceManagerEngine::getPlaceDetails(const QString &placeId)
}
/*!
- Retrieves content for the place corresponding to \a placeId, according to the parameters
- specified in \a request.
+ Retrieves content for a place according to the parameters specified in \a request.
*/
-QPlaceContentReply *QPlaceManagerEngine::getPlaceContent(const QString &placeId,
- const QPlaceContentRequest &request)
+QPlaceContentReply *QPlaceManagerEngine::getPlaceContent(const QPlaceContentRequest &request)
{
- Q_UNUSED(placeId)
Q_UNUSED(request)
return new QPlaceContentReplyUnsupported(this);
diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h
index ee019637..0eefa7ca 100644
--- a/src/location/places/qplacemanagerengine.h
+++ b/src/location/places/qplacemanagerengine.h
@@ -58,7 +58,7 @@ class Q_LOCATION_EXPORT QPlaceManagerEngine : public QObject
Q_OBJECT
public:
- QPlaceManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
+ QPlaceManagerEngine(const QVariantMap &parameters, QObject *parent = 0);
virtual ~QPlaceManagerEngine();
QString managerName() const;
@@ -66,8 +66,7 @@ public:
virtual QPlaceDetailsReply *getPlaceDetails(const QString &placeId);
- virtual QPlaceContentReply *getPlaceContent(const QString &placeId,
- const QPlaceContentRequest &request);
+ virtual QPlaceContentReply *getPlaceContent(const QPlaceContentRequest &request);
virtual QPlaceSearchReply *search(const QPlaceSearchRequest &request);
diff --git a/src/location/places/qplacesearchreply.cpp b/src/location/places/qplacesearchreply.cpp
index 26829607..9d89748a 100644
--- a/src/location/places/qplacesearchreply.cpp
+++ b/src/location/places/qplacesearchreply.cpp
@@ -39,23 +39,23 @@
**
****************************************************************************/
-#include "qplacesearchreply.h"
-#include "qplacereply_p.h"
-
+#include <QtLocation/QPlaceSearchRequest>
+#include <QtLocation/QPlaceSearchReply>
+#include <QtLocation/QPlaceProposedSearchResult>
+#include <QtLocation/private/qplacereply_p.h>
QT_BEGIN_NAMESPACE
+
class QPlaceSearchReplyPrivate : public QPlaceReplyPrivate
{
public:
QPlaceSearchReplyPrivate(){}
QList<QPlaceSearchResult> results;
QPlaceSearchRequest searchRequest;
+ QPlaceSearchRequest previousPageRequest;
+ QPlaceSearchRequest nextPageRequest;
};
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
-
/*!
\class QPlaceSearchReply
\inmodule QtLocation
@@ -121,6 +121,30 @@ QPlaceSearchRequest QPlaceSearchReply::request() const
}
/*!
+ Returns a place search request which can be used to request the previous page of search
+ results. An empty place search request is returned if there is no previous page of results.
+
+ \sa nextPageRequest(), setPreviousPageRequest()
+*/
+QPlaceSearchRequest QPlaceSearchReply::previousPageRequest() const
+{
+ Q_D(const QPlaceSearchReply);
+ return d->previousPageRequest;
+}
+
+/*!
+ Returns a place search request which can be used to request the next page of search results. An
+ empty place search request is returned if there is no next page of results.
+
+ \sa previousPageRequest(), setNextPageRequest()
+*/
+QPlaceSearchRequest QPlaceSearchReply::nextPageRequest() const
+{
+ Q_D(const QPlaceSearchReply);
+ return d->nextPageRequest;
+}
+
+/*!
Sets the search \a request used to generate this reply.
*/
void QPlaceSearchReply::setRequest(const QPlaceSearchRequest &request)
@@ -128,3 +152,27 @@ void QPlaceSearchReply::setRequest(const QPlaceSearchRequest &request)
Q_D(QPlaceSearchReply);
d->searchRequest = request;
}
+
+/*!
+ Sets the previous page of search results request to \a previous.
+
+ \sa previousPageRequest()
+*/
+void QPlaceSearchReply::setPreviousPageRequest(const QPlaceSearchRequest &previous)
+{
+ Q_D(QPlaceSearchReply);
+ d->previousPageRequest = previous;
+}
+
+/*!
+ Sets the next page of search results request to \a next.
+
+ \sa nextPageRequest()
+*/
+void QPlaceSearchReply::setNextPageRequest(const QPlaceSearchRequest &next)
+{
+ Q_D(QPlaceSearchReply);
+ d->nextPageRequest = next;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/places/qplacesearchreply.h b/src/location/places/qplacesearchreply.h
index 4266b988..51cb315f 100644
--- a/src/location/places/qplacesearchreply.h
+++ b/src/location/places/qplacesearchreply.h
@@ -44,11 +44,12 @@
#include <QtLocation/QPlaceReply>
#include <QtLocation/QPlaceSearchResult>
-#include <QtLocation/QPlaceSearchRequest>
QT_BEGIN_NAMESPACE
+class QPlaceSearchResult;
class QPlaceSearchReplyPrivate;
+
class Q_LOCATION_EXPORT QPlaceSearchReply : public QPlaceReply
{
Q_OBJECT
@@ -61,9 +62,15 @@ public:
QList<QPlaceSearchResult> results() const;
QPlaceSearchRequest request() const;
+ QPlaceSearchRequest previousPageRequest() const;
+ QPlaceSearchRequest nextPageRequest() const;
+
protected:
void setResults(const QList<QPlaceSearchResult> &results);
void setRequest(const QPlaceSearchRequest &request);
+ void setPreviousPageRequest(const QPlaceSearchRequest &previous);
+ void setNextPageRequest(const QPlaceSearchRequest &next);
+
private:
Q_DISABLE_COPY(QPlaceSearchReply)
Q_DECLARE_PRIVATE(QPlaceSearchReply)
diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp
index c5878b22..81cfeba4 100644
--- a/src/location/places/qplacesearchrequest.cpp
+++ b/src/location/places/qplacesearchrequest.cpp
@@ -68,7 +68,6 @@ public:
QLocation::VisibilityScope visibilityScope;
QPlaceSearchRequest::RelevanceHint relevanceHint;
int limit;
- int offset;
QVariant searchContext;
};
@@ -76,7 +75,7 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate()
: QSharedData(),
visibilityScope(QLocation::UnspecifiedVisibility),
relevanceHint(QPlaceSearchRequest::UnspecifiedHint),
- limit(-1), offset(0)
+ limit(-1)
{
}
@@ -89,7 +88,6 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequest
visibilityScope(other.visibilityScope),
relevanceHint(other.relevanceHint),
limit(other.limit),
- offset(other.offset),
searchContext(other.searchContext)
{
}
@@ -108,7 +106,6 @@ QPlaceSearchRequestPrivate &QPlaceSearchRequestPrivate::operator=(const QPlaceSe
visibilityScope = other.visibilityScope;
relevanceHint = other.relevanceHint;
limit = other.limit;
- offset = other.offset;
searchContext = other.searchContext;
}
@@ -124,14 +121,12 @@ bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &ot
visibilityScope == other.visibilityScope &&
relevanceHint == other.relevanceHint &&
limit == other.limit &&
- offset == other.offset &&
searchContext == other.searchContext;
}
void QPlaceSearchRequestPrivate::clear()
{
limit = -1;
- offset = 0;
searchTerm.clear();
categories.clear();
searchArea = QGeoShape();
@@ -429,27 +424,6 @@ void QPlaceSearchRequest::setLimit(int limit)
}
/*!
- Returns the offset index of the first item that is to be retrieved.
-
- The default offset is 0.
-*/
-int QPlaceSearchRequest::offset() const
-{
- Q_D(const QPlaceSearchRequest);
- return d->offset;
-}
-
-/*!
- Sets the starting index of the first item to be retrieved
- to \a offset.
-*/
-void QPlaceSearchRequest::setOffset(int offset)
-{
- Q_D(QPlaceSearchRequest);
- d->offset = offset;
-}
-
-/*!
Clears the search request.
*/
void QPlaceSearchRequest::clear()
diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h
index 65ca3fe0..34a6a1dd 100644
--- a/src/location/places/qplacesearchrequest.h
+++ b/src/location/places/qplacesearchrequest.h
@@ -94,8 +94,6 @@ public:
RelevanceHint relevanceHint() const;
void setRelevanceHint(RelevanceHint hint);
- int offset() const;
- void setOffset(int offset);
int limit() const;
void setLimit(int limit);
diff --git a/src/plugins/geoservices/nokia/logo.png b/src/plugins/geoservices/nokia/logo.png
index ed8f3321..ba421917 100644
--- a/src/plugins/geoservices/nokia/logo.png
+++ b/src/plugins/geoservices/nokia/logo.png
Binary files differ
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
index 9ce2a179..597f8bae 100644
--- a/src/plugins/geoservices/nokia/nokia.pro
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -1,5 +1,5 @@
TARGET = qtgeoservices_nokia
-QT += location-private network
+QT += location-private positioning-private network
contains(QT_CONFIG, location-china-support) {
# China support
diff --git a/src/plugins/geoservices/nokia/nokia_plugin.json b/src/plugins/geoservices/nokia/nokia_plugin.json
index 4f6d6316..eb6fa68d 100644
--- a/src/plugins/geoservices/nokia/nokia_plugin.json
+++ b/src/plugins/geoservices/nokia/nokia_plugin.json
@@ -1,7 +1,7 @@
{
"Keys": ["nokia"],
"Provider": "nokia",
- "Version": 100,
+ "Version": 101,
"Experimental": false,
"Features": [
"OnlineRoutingFeature",
diff --git a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp
index 1a18d15d..ac294d6e 100644
--- a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp
@@ -200,6 +200,7 @@ QPlaceEditorial parseEditorial(const QJsonObject &editorialObject,
void parseCollection(QPlaceContent::Type type, const QJsonObject &object,
QPlaceContent::Collection *collection, int *totalCount,
+ QPlaceContentRequest *previous, QPlaceContentRequest *next,
const QPlaceManagerEngineNokiaV2 *engine)
{
Q_ASSERT(engine);
@@ -211,6 +212,16 @@ void parseCollection(QPlaceContent::Type type, const QJsonObject &object,
if (object.contains(QLatin1String("offset")))
offset = object.value(QLatin1String("offset")).toDouble();
+ if (previous && object.contains(QStringLiteral("previous"))) {
+ previous->setContentType(type);
+ previous->setContentContext(QUrl(object.value(QStringLiteral("previous")).toString()));
+ }
+
+ if (next && object.contains(QStringLiteral("next"))) {
+ next->setContentType(type);
+ next->setContentContext(QUrl(object.value(QStringLiteral("next")).toString()));
+ }
+
if (collection) {
QJsonArray items = object.value(QLatin1String("items")).toArray();
for (int i = 0; i < items.count(); ++i) {
diff --git a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h
index 092addb9..ef01de19 100644
--- a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h
+++ b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h
@@ -54,6 +54,7 @@ class QPlaceImage;
class QPlaceReview;
class QPlaceEditorial;
class QPlaceCategory;
+class QPlaceContentRequest;
class QPlaceManagerEngineNokiaV2;
QGeoCoordinate parseCoordinate(const QJsonArray &coordinateArray);
@@ -74,6 +75,7 @@ QPlaceEditorial parseEditorial(const QJsonObject &editorialObject,
void parseCollection(QPlaceContent::Type type, const QJsonObject &object,
QPlaceContent::Collection *collection, int *totalCount,
+ QPlaceContentRequest *previous, QPlaceContentRequest *next,
const QPlaceManagerEngineNokiaV2 *engine);
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
index e47bd4d5..1b5a1776 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
@@ -94,22 +94,29 @@ void QPlaceContentReplyImpl::setError(QPlaceReply::Error error_, const QString &
void QPlaceContentReplyImpl::replyFinished()
{
- QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
- if (!document.isObject()) {
- setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR));
- return;
+ if (m_reply->isOpen()) {
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR));
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ QPlaceContent::Collection collection;
+ int totalCount;
+ QPlaceContentRequest previous;
+ QPlaceContentRequest next;
+
+ parseCollection(request().contentType(), object, &collection, &totalCount,
+ &previous, &next, m_engine);
+
+ setTotalCount(totalCount);
+ setContent(collection);
+ setPreviousPageRequest(previous);
+ setNextPageRequest(next);
}
- QJsonObject object = document.object();
-
- QPlaceContent::Collection collection;
- int totalCount;
-
- parseCollection(request().contentType(), object, &collection, &totalCount, m_engine);
-
- setTotalCount(totalCount);
- setContent(collection);
-
m_reply->deleteLater();
m_reply = 0;
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
index fda0c776..a5386341 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
@@ -307,7 +307,7 @@ void QPlaceDetailsReplyImpl::replyFinished()
parseCollection(QPlaceContent::ImageType,
mediaObject.value(QLatin1String("images")).toObject(),
- &collection, &totalCount, m_engine);
+ &collection, &totalCount, 0, 0, m_engine);
place.setTotalContentCount(QPlaceContent::ImageType, totalCount);
place.setContent(QPlaceContent::ImageType, collection);
@@ -318,7 +318,7 @@ void QPlaceDetailsReplyImpl::replyFinished()
parseCollection(QPlaceContent::EditorialType,
mediaObject.value(QLatin1String("editorials")).toObject(),
- &collection, &totalCount, m_engine);
+ &collection, &totalCount, 0, 0, m_engine);
place.setTotalContentCount(QPlaceContent::EditorialType, totalCount);
place.setContent(QPlaceContent::EditorialType, collection);
@@ -329,7 +329,7 @@ void QPlaceDetailsReplyImpl::replyFinished()
parseCollection(QPlaceContent::ReviewType,
mediaObject.value(QLatin1String("reviews")).toObject(),
- &collection, &totalCount, m_engine);
+ &collection, &totalCount, 0, 0, m_engine);
place.setTotalContentCount(QPlaceContent::ReviewType, totalCount);
place.setContent(QPlaceContent::ReviewType, collection);
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp
index 7bd20599..3b43c357 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp
@@ -121,11 +121,11 @@ void QPlaceSearchReplyImpl::replyFinished()
return;
}
- QJsonObject object = document.object();
+ QJsonObject resultsObject = document.object();
- //QJsonObject searchObject = object.value(QLatin1String("search")).toObject();
+ if (resultsObject.contains(QStringLiteral("results")))
+ resultsObject = resultsObject.value(QStringLiteral("results")).toObject();
- QJsonObject resultsObject = object.value(QLatin1String("results")).toObject();
QJsonArray items = resultsObject.value(QLatin1String("items")).toArray();
QList<QPlaceSearchResult> results;
@@ -139,6 +139,18 @@ void QPlaceSearchReplyImpl::replyFinished()
results.append(parseSearchResult(item));
}
+ if (resultsObject.contains(QStringLiteral("next"))) {
+ QPlaceSearchRequest request;
+ request.setSearchContext(QUrl(resultsObject.value(QStringLiteral("next")).toString()));
+ setNextPageRequest(request);
+ }
+
+ if (resultsObject.contains(QStringLiteral("previous"))) {
+ QPlaceSearchRequest request;
+ request.setSearchContext(QUrl(resultsObject.value(QStringLiteral("previous")).toString()));
+ setPreviousPageRequest(request);
+ }
+
setResults(results);
m_reply->deleteLater();
diff --git a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
index d00f4fb9..cbdf98f2 100644
--- a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
QGeoCodingManagerEngineNokia::QGeoCodingManagerEngineNokia(
QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QGeoCodingManagerEngine(parameters)
diff --git a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.h
index 6b9bf1e2..b4e5c75d 100644
--- a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.h
@@ -66,7 +66,7 @@ class QGeoCodingManagerEngineNokia : public QGeoCodingManagerEngine
Q_OBJECT
public:
QGeoCodingManagerEngineNokia(QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
~QGeoCodingManagerEngineNokia();
diff --git a/src/plugins/geoservices/nokia/qgeoerror_messages.cpp b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp
index a8f55217..05cb93fa 100644
--- a/src/plugins/geoservices/nokia/qgeoerror_messages.cpp
+++ b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
const char NOKIA_PLUGIN_CONTEXT_NAME[] = "QtLocationQML";
-const char MISSED_CREDENTIALS[] = QT_TRANSLATE_NOOP("QtLocationQML", "Qt Location requires app_id and token parameters.\nPlease register at https://api.developer.nokia.com/ to get your personal application credentials.");
+const char MISSED_CREDENTIALS[] = QT_TRANSLATE_NOOP("QtLocationQML", "Qt Location requires app_id and token parameters.\nPlease register at https://developer.here.com/ to get your personal application credentials.");
const char SAVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving places is not supported.");
const char REMOVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Removing places is not supported.");
const char SAVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving categories is not supported.");
diff --git a/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.cpp b/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.cpp
index 42da0070..69f3c9c9 100644
--- a/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.cpp
+++ b/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.cpp
@@ -54,7 +54,7 @@ QGeoIntrinsicNetworkAccessManager::QGeoIntrinsicNetworkAccessManager(QObject *pa
{
}
-QGeoIntrinsicNetworkAccessManager::QGeoIntrinsicNetworkAccessManager(const QMap<QString, QVariant> &parameters, const QString &token, QObject *parent)
+QGeoIntrinsicNetworkAccessManager::QGeoIntrinsicNetworkAccessManager(const QVariantMap &parameters, const QString &token, QObject *parent)
: QGeoNetworkAccessManager(parent)
, m_customProxyToken(token)
, m_networkManager(new QNetworkAccessManager(this))
@@ -62,7 +62,7 @@ QGeoIntrinsicNetworkAccessManager::QGeoIntrinsicNetworkAccessManager(const QMap<
configure(parameters);
}
-void QGeoIntrinsicNetworkAccessManager::configure(const QMap<QString, QVariant> &parameters)
+void QGeoIntrinsicNetworkAccessManager::configure(const QVariantMap &parameters)
{
QString proxy = parameters.value(QStringLiteral("proxy")).toString();
if (proxy.isEmpty() && !m_customProxyToken.isEmpty())
diff --git a/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.h b/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.h
index 18f655f6..72ae2990 100644
--- a/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.h
+++ b/src/plugins/geoservices/nokia/qgeointrinsicnetworkaccessmanager.h
@@ -54,13 +54,13 @@ class QGeoIntrinsicNetworkAccessManager : public QGeoNetworkAccessManager
{
public:
explicit QGeoIntrinsicNetworkAccessManager(QObject *parent = 0);
- QGeoIntrinsicNetworkAccessManager(const QMap<QString, QVariant> &parameters, const QString &token = QString(), QObject *parent = 0);
+ QGeoIntrinsicNetworkAccessManager(const QVariantMap &parameters, const QString &token = QString(), QObject *parent = 0);
virtual QNetworkReply *get(const QNetworkRequest &request);
virtual QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data);
private:
- void configure(const QMap<QString, QVariant> &parameters);
+ void configure(const QVariantMap &parameters);
const QString m_customProxyToken;
QNetworkAccessManager *m_networkManager;
diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
index 663410ad..2245b208 100644
--- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
@@ -53,42 +53,47 @@
QT_BEGIN_NAMESPACE
-QGeoRouteReplyNokia::QGeoRouteReplyNokia(const QGeoRouteRequest &request, QNetworkReply *reply, QObject *parent)
+QGeoRouteReplyNokia::QGeoRouteReplyNokia(const QGeoRouteRequest &request, const QList<QNetworkReply*> &replies, QObject *parent)
: QGeoRouteReply(request, parent),
- m_reply(reply)
+ m_replies(replies)
{
- connect(m_reply,
- SIGNAL(finished()),
- this,
- SLOT(networkFinished()));
-
- connect(m_reply,
- SIGNAL(error(QNetworkReply::NetworkError)),
- this,
- SLOT(networkError(QNetworkReply::NetworkError)));
+ foreach (QNetworkReply *reply, m_replies) {
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(networkFinished()));
+
+ connect(reply,
+ SIGNAL(error(QNetworkReply::NetworkError)),
+ this,
+ SLOT(networkError(QNetworkReply::NetworkError)));
+ }
}
QGeoRouteReplyNokia::~QGeoRouteReplyNokia()
{
+ abort();
}
void QGeoRouteReplyNokia::abort()
{
- if (!m_reply)
+ if (m_replies.isEmpty())
return;
- m_reply->abort();
-
- m_reply->deleteLater();
- m_reply = 0;
+ foreach (QNetworkReply *reply, m_replies) {
+ reply->abort();
+ reply->deleteLater();
+ }
+ m_replies.clear();
}
void QGeoRouteReplyNokia::networkFinished()
{
- if (!m_reply)
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ if (!reply)
return;
- if (m_reply->error() != QNetworkReply::NoError) {
+ if (reply->error() != QNetworkReply::NoError) {
// Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error.
//setError(QGeoRouteReply::CommunicationError, m_reply->errorString());
//m_reply->deleteLater();
@@ -97,42 +102,44 @@ void QGeoRouteReplyNokia::networkFinished()
}
QGeoRouteXmlParser parser(request());
-
- if (parser.parse(m_reply)) {
- setRoutes(parser.results());
- setFinished(true);
+ if (parser.parse(reply)) {
+ addRoutes(parser.results());
+ reply->deleteLater();
+ m_replies.removeOne(reply);
+ if (m_replies.isEmpty())
+ setFinished(true);
} else {
// add a qWarning with the actual parser.errorString()
setError(QGeoRouteReply::ParseError, "The response from the service was not in a recognisable format.");
+ abort();
}
-
- m_reply->deleteLater();
- m_reply = 0;
}
void QGeoRouteReplyNokia::networkError(QNetworkReply::NetworkError error)
{
Q_UNUSED(error)
- if (!m_reply)
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ if (!reply)
return;
bool resolvedError = false;
-
if (QNetworkReply::UnknownContentError == error) {
QGeoRouteXmlParser parser(request());
- if (parser.parse(m_reply)) {
- setRoutes(parser.results());
- setFinished(true);
+ if (parser.parse(reply)) {
+ addRoutes(parser.results());
+ reply->deleteLater();
+ m_replies.removeOne(reply);
resolvedError = true;
+ if (m_replies.isEmpty())
+ setFinished(true);
}
}
- if (!resolvedError)
- setError(QGeoRouteReply::CommunicationError, m_reply->errorString());
-
- m_reply->deleteLater();
- m_reply = 0;
+ if (!resolvedError) {
+ setError(QGeoRouteReply::CommunicationError, reply->errorString());
+ abort();
+ }
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h
index b8cb2db3..911e1920 100644
--- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.h
@@ -58,7 +58,7 @@ class QGeoRouteReplyNokia : public QGeoRouteReply
{
Q_OBJECT
public:
- QGeoRouteReplyNokia(const QGeoRouteRequest &request, QNetworkReply *reply, QObject *parent = 0);
+ QGeoRouteReplyNokia(const QGeoRouteRequest &request, const QList<QNetworkReply*> &replies, QObject *parent = 0);
~QGeoRouteReplyNokia();
void abort();
@@ -68,7 +68,7 @@ private Q_SLOTS:
void networkError(QNetworkReply::NetworkError error);
private:
- QNetworkReply *m_reply;
+ QList<QNetworkReply*> m_replies;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
index cd8a4bad..60840ec6 100644
--- a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp
@@ -435,7 +435,7 @@ bool QGeoRouteXmlParser::parseManeuver()
} else if (m_reader->name() == "ToLink") {
maneuverContainter.toId = m_reader->readElementText();
} else if (m_reader->name() == "TravelTime") {
- maneuverContainter.maneuver.setTimeToNextInstruction(m_reader->readElementText().toInt());
+ maneuverContainter.maneuver.setTimeToNextInstruction(qRound(m_reader->readElementText().toDouble()));
} else if (m_reader->name() == "Length") {
maneuverContainter.maneuver.setDistanceToNextInstruction(m_reader->readElementText().toDouble());
} else if (m_reader->name() == "Direction") {
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index 5ea99027..4380494a 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(
QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QGeoRoutingManagerEngine(parameters)
@@ -81,6 +81,7 @@ QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(
featureTypes |= QGeoRouteRequest::FerryFeature;
featureTypes |= QGeoRouteRequest::TunnelFeature;
featureTypes |= QGeoRouteRequest::DirtRoadFeature;
+ featureTypes |= QGeoRouteRequest::ParksFeature;
setSupportedFeatureTypes(featureTypes);
QGeoRouteRequest::FeatureWeights featureWeights;
@@ -96,14 +97,13 @@ QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(
QGeoRouteRequest::RouteOptimizations optimizations;
optimizations |= QGeoRouteRequest::ShortestRoute;
optimizations |= QGeoRouteRequest::FastestRoute;
- optimizations |= QGeoRouteRequest::MostEconomicRoute;
- optimizations |= QGeoRouteRequest::MostScenicRoute;
setSupportedRouteOptimizations(optimizations);
QGeoRouteRequest::TravelModes travelModes;
travelModes |= QGeoRouteRequest::CarTravel;
travelModes |= QGeoRouteRequest::PedestrianTravel;
travelModes |= QGeoRouteRequest::PublicTransitTravel;
+ travelModes |= QGeoRouteRequest::BicycleTravel;
setSupportedTravelModes(travelModes);
QGeoRouteRequest::SegmentDetails segmentDetails;
@@ -121,16 +121,19 @@ QGeoRoutingManagerEngineNokia::~QGeoRoutingManagerEngineNokia() {}
QGeoRouteReply *QGeoRoutingManagerEngineNokia::calculateRoute(const QGeoRouteRequest &request)
{
- QString reqString = calculateRouteRequestString(request);
+ const QStringList reqStrings = calculateRouteRequestString(request);
- if (reqString.isEmpty()) {
+ if (reqStrings.isEmpty()) {
QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this);
emit error(reply, reply->error(), reply->errorString());
return reply;
}
- QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString)));
- QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(request, networkReply, this);
+ QList<QNetworkReply*> replies;
+ foreach (const QString &reqString, reqStrings)
+ replies.append(m_networkManager->get(QNetworkRequest(QUrl(reqString))));
+
+ QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(request, replies, this);
connect(reply,
SIGNAL(finished()),
@@ -147,18 +150,21 @@ QGeoRouteReply *QGeoRoutingManagerEngineNokia::calculateRoute(const QGeoRouteReq
QGeoRouteReply *QGeoRoutingManagerEngineNokia::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position)
{
- QString reqString = updateRouteRequestString(route, position);
+ const QStringList reqStrings = updateRouteRequestString(route, position);
- if (reqString.isEmpty()) {
+ if (reqStrings.isEmpty()) {
QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this);
emit error(reply, reply->error(), reply->errorString());
return reply;
}
- QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString)));
+ QList<QNetworkReply*> replies;
+ foreach (const QString &reqString, reqStrings)
+ replies.append(m_networkManager->get(QNetworkRequest(QUrl(reqString))));
+
QGeoRouteRequest updateRequest(route.request());
updateRequest.setTravelModes(route.travelMode());
- QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(updateRequest, networkReply, this);
+ QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(updateRequest, replies, this);
connect(reply,
SIGNAL(finished()),
@@ -217,87 +223,100 @@ bool QGeoRoutingManagerEngineNokia::checkEngineSupport(const QGeoRouteRequest &r
return true;
}
-QString QGeoRoutingManagerEngineNokia::calculateRouteRequestString(const QGeoRouteRequest &request)
+QStringList QGeoRoutingManagerEngineNokia::calculateRouteRequestString(const QGeoRouteRequest &request)
{
bool supported = checkEngineSupport(request, request.travelModes());
if (!supported)
- return QString();
+ return QStringList();
+ QStringList requests;
- QString requestString = QStringLiteral("http://");
- requestString += m_uriProvider->getCurrentHost();
- requestString += QStringLiteral("/routing/6.2/calculateroute.xml");
+ QString baseRequest = QStringLiteral("http://");
+ baseRequest += m_uriProvider->getCurrentHost();
+ baseRequest += QStringLiteral("/routing/7.2/calculateroute.xml");
- requestString += QStringLiteral("?alternatives=");
- requestString += QString::number(request.numberAlternativeRoutes());
+ baseRequest += QStringLiteral("?alternatives=");
+ baseRequest += QString::number(request.numberAlternativeRoutes());
if (!m_appId.isEmpty() && !m_token.isEmpty()) {
- requestString += QStringLiteral("&app_id=");
- requestString += m_appId;
- requestString += QStringLiteral("&token=");
- requestString += m_token;
+ baseRequest += QStringLiteral("&app_id=");
+ baseRequest += m_appId;
+ baseRequest += QStringLiteral("&token=");
+ baseRequest += m_token;
}
int numWaypoints = request.waypoints().size();
if (numWaypoints < 2)
- return QString();
+ return QStringList();
for (int i = 0;i < numWaypoints;++i) {
- requestString += QStringLiteral("&waypoint");
- requestString += QString::number(i);
- requestString += QStringLiteral("=geo!");
- requestString += trimDouble(request.waypoints().at(i).latitude());
- requestString += ",";
- requestString += trimDouble(request.waypoints().at(i).longitude());
+ baseRequest += QStringLiteral("&waypoint");
+ baseRequest += QString::number(i);
+ baseRequest += QStringLiteral("=geo!");
+ baseRequest += trimDouble(request.waypoints().at(i).latitude());
+ baseRequest += ",";
+ baseRequest += trimDouble(request.waypoints().at(i).longitude());
}
- requestString += modesRequestString(request, request.travelModes());
- requestString += routeRequestString(request);
+ QGeoRouteRequest::RouteOptimizations optimization = request.routeOptimization();
- return requestString;
+ QStringList types;
+ if (optimization.testFlag(QGeoRouteRequest::ShortestRoute))
+ types.append("shortest");
+ if (optimization.testFlag(QGeoRouteRequest::FastestRoute))
+ types.append("fastest");
+
+ foreach (const QString &optimization, types) {
+ QString requestString = baseRequest;
+ requestString += modesRequestString(request, request.travelModes(), optimization);
+ requestString += routeRequestString(request);
+ requests << requestString;
+ }
+
+ return requests;
}
-QString QGeoRoutingManagerEngineNokia::updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position)
+QStringList QGeoRoutingManagerEngineNokia::updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position)
{
if (!checkEngineSupport(route.request(), route.travelMode()))
- return "";
+ return QStringList();
+ QStringList requests;
+
+ QString baseRequest = "http://";
+ baseRequest += m_uriProvider->getCurrentHost();
+ baseRequest += "/routing/7.2/getroute.xml";
- QString requestString = "http://";
- requestString += m_uriProvider->getCurrentHost();
- requestString += "/routing/6.2/getroute.xml";
+ baseRequest += "?routeid=";
+ baseRequest += route.routeId();
- requestString += "?routeid=";
- requestString += route.routeId();
+ baseRequest += "&pos=";
+ baseRequest += QString::number(position.latitude());
+ baseRequest += ",";
+ baseRequest += QString::number(position.longitude());
- requestString += "&pos=";
- requestString += QString::number(position.latitude());
- requestString += ",";
- requestString += QString::number(position.longitude());
+ QGeoRouteRequest::RouteOptimizations optimization = route.request().routeOptimization();
- requestString += modesRequestString(route.request(), route.travelMode());
+ QStringList types;
+ if (optimization.testFlag(QGeoRouteRequest::ShortestRoute))
+ types.append("shortest");
+ if (optimization.testFlag(QGeoRouteRequest::FastestRoute))
+ types.append("fastest");
- requestString += routeRequestString(route.request());
+ foreach (const QString &optimization, types) {
+ QString requestString = baseRequest;
+ requestString += modesRequestString(route.request(), route.travelMode(), optimization);
+ requestString += routeRequestString(route.request());
+ requests << requestString;
+ }
- return requestString;
+ return requests;
}
QString QGeoRoutingManagerEngineNokia::modesRequestString(const QGeoRouteRequest &request,
- QGeoRouteRequest::TravelModes travelModes) const
+ QGeoRouteRequest::TravelModes travelModes, const QString &optimization) const
{
QString requestString;
- QGeoRouteRequest::RouteOptimizations optimization = request.routeOptimization();
-
- QStringList types;
- if (optimization.testFlag(QGeoRouteRequest::ShortestRoute))
- types.append("shortest");
- if (optimization.testFlag(QGeoRouteRequest::FastestRoute))
- types.append("fastestNow");
- if (optimization.testFlag(QGeoRouteRequest::MostEconomicRoute))
- types.append("economic");
- if (optimization.testFlag(QGeoRouteRequest::MostScenicRoute))
- types.append("scenic");
-
QStringList modes;
if (travelModes.testFlag(QGeoRouteRequest::CarTravel))
modes.append("car");
@@ -358,12 +377,10 @@ QString QGeoRoutingManagerEngineNokia::modesRequestString(const QGeoRouteRequest
}
}
- for (int i = 0;i < types.count();++i) {
- requestString += "&mode" + QString::number(i) + "=";
- requestString += types[i] + ";" + modes.join(",");
- if (featureStrings.count())
- requestString += ";" + featureStrings.join(",");
- }
+ requestString += "&mode=";
+ requestString += optimization + ";" + modes.join(",");
+ if (featureStrings.count())
+ requestString += ";" + featureStrings.join(",");
return requestString;
}
@@ -425,10 +442,20 @@ QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest
requestString += "&instructionformat=text";
+ requestString += "&metricSystem=";
+ if (QLocale::MetricSystem == measurementSystem())
+ requestString += "metric";
+ else
+ requestString += "imperial";
+
const QLocale loc(locale());
+
if (QLocale::C != loc.language() && QLocale::AnyLanguage != loc.language()) {
requestString += "&language=";
requestString += loc.name();
+ //If the first language isn't supported, english will be selected automatically
+ if (QLocale::English != loc.language())
+ requestString += ",en_US";
}
return requestString;
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h
index 34da6200..cf9caab0 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.h
@@ -64,7 +64,7 @@ class QGeoRoutingManagerEngineNokia : public QGeoRoutingManagerEngine
Q_OBJECT
public:
QGeoRoutingManagerEngineNokia(QGeoNetworkAccessManager *networkInterface,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
~QGeoRoutingManagerEngineNokia();
@@ -77,13 +77,14 @@ private Q_SLOTS:
void routeError(QGeoRouteReply::Error error, const QString &errorString);
private:
- QString calculateRouteRequestString(const QGeoRouteRequest &request);
- QString updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position);
+ QStringList calculateRouteRequestString(const QGeoRouteRequest &request);
+ QStringList updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position);
QString routeRequestString(const QGeoRouteRequest &request) const;
bool checkEngineSupport(const QGeoRouteRequest &request,
QGeoRouteRequest::TravelModes travelModes) const;
QString modesRequestString(const QGeoRouteRequest &request,
- QGeoRouteRequest::TravelModes travelModes) const;
+ QGeoRouteRequest::TravelModes travelModes,
+ const QString &optimization) const;
static QString trimDouble(double degree, int decimalDigits = 10);
QGeoNetworkAccessManager *m_networkManager;
diff --git a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
index 010da22f..506b3f70 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
*/
QGeoTiledMapDataNokia::QGeoTiledMapDataNokia(QGeoTiledMappingManagerEngineNokia *engine, QObject *parent /*= 0*/) :
QGeoTiledMapData(engine, parent),
- logo(":/images/logo.png"), // Nokia logo image
+ logo(":/images/logo.png"), // HERE logo image
copyrightsSlab(1, 1, QImage::Format_ARGB32) {}
QGeoTiledMapDataNokia::~QGeoTiledMapDataNokia() {}
@@ -77,11 +77,11 @@ QGeoTiledMapDataNokia::~QGeoTiledMapDataNokia() {}
void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
{
const int copyrightsMargin = 10;
- const int shadowWidth = 2;
+ const int shadowWidth = 3;
const int fontSize = 10;
QGeoTiledMappingManagerEngineNokia *engineNokia = static_cast<QGeoTiledMappingManagerEngineNokia *>(engine());
- QString copyrightsString = engineNokia->evaluateCopyrightsText(activeMapType().style(), mapController()->zoom(), visibleTiles);
+ const QString copyrightsString = engineNokia->evaluateCopyrightsText(activeMapType(), mapController()->zoom(), visibleTiles);
if (width() > 0 && height() > 0 && (lastCopyrightsString.isNull() || copyrightsString != lastCopyrightsString)) {
copyrightsSlab = copyrightsSlab.copy(0, 0, width(), height());
@@ -90,9 +90,10 @@ void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visible
copyrightsSlab.fill(Qt::transparent);
QPainter painter(&copyrightsSlab);
- painter.drawImage(QPoint(1, 1), logo);
+ painter.drawImage(QPoint(0, copyrightsSlab.height() - logo.height()), logo);
QColor fontColor(Qt::black);
+ fontColor.setAlpha(64);
QFont font("Sans Serif");
font.setPixelSize(fontSize);
font.setStyleHint(QFont::SansSerif);
@@ -100,21 +101,21 @@ void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visible
painter.setFont(font);
painter.setPen(fontColor);
- QRect textLimitsRect(0,
- logo.height(),
- copyrightsSlab.width() - (copyrightsMargin * 2),
- copyrightsSlab.height() - logo.height());
+ QRect textLimitsRect(logo.width(),
+ 0,
+ copyrightsSlab.width() - (logo.width() + copyrightsMargin * 2),
+ copyrightsSlab.height());
// Drawing the copyrights base shadow (watermark)
QRect textBoundingRect;
QRect wmRect(textLimitsRect);
int x, y;
for (x = 0; x < shadowWidth; x++) {
- wmRect.setLeft(textLimitsRect.left() + x*shadowWidth);
+ wmRect.setLeft(textLimitsRect.left() + x);
for (y = 0; y < shadowWidth; y++) {
- wmRect.setTop(textLimitsRect.top() + y*shadowWidth);
+ wmRect.setBottom(textLimitsRect.bottom() - y);
painter.drawText(wmRect,
- Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
+ Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
copyrightsString,
&textBoundingRect);
}
@@ -126,17 +127,19 @@ void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visible
painter.setFont(font);
painter.setPen(fontColor);
wmRect.setLeft(textLimitsRect.left() + 1);
- wmRect.setTop(textLimitsRect.top() + 1);
+ wmRect.setBottom(textLimitsRect.bottom() - 1);
painter.drawText(wmRect,
- Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
+ Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
copyrightsString,
&textBoundingRect);
painter.end();
- copyrightsSlab = copyrightsSlab.copy(0, 0,
- qMax(logo.width(), textBoundingRect.width()) + shadowWidth,
- logo.height() + textBoundingRect.height());
+ int newHeight = qMax(logo.height(), textBoundingRect.height());
+
+ copyrightsSlab = copyrightsSlab.copy(0, copyrightsSlab.height() - newHeight,
+ logo.width() + textBoundingRect.width() + shadowWidth + copyrightsMargin * 2,
+ newHeight);
QPoint copyrightsPos(copyrightsMargin, height() - (copyrightsSlab.height() + copyrightsMargin));
lastCopyrightsPos = copyrightsPos;
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index 1df1934b..e7f1fec7 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -51,8 +51,6 @@
#include "qgeotiledmapdata_nokia.h"
#include "qgeotilefetcher_nokia.h"
#include "qgeotilespec_p.h"
-#include "qgeoprojection_p.h"
-#include "qdoublevector2d_p.h"
#include "qgeotilecache_p.h"
#include <QDebug>
@@ -67,7 +65,7 @@ QT_BEGIN_NAMESPACE
QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QGeoTiledMappingManagerEngine()
@@ -85,17 +83,25 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
setTileSize(QSize(256, 256));
QList<QGeoMapType> types;
- types << QGeoMapType(QGeoMapType::StreetMap,tr("Street Map"),tr("Nokia Street Map"), false, 1);
- types << QGeoMapType(QGeoMapType::SatelliteMapDay,tr("Satellite Map(day)"),tr("Nokia Satellite Map (day)"), false, 2);
- types << QGeoMapType(QGeoMapType::TerrainMap,tr("Terrain Map"),tr("Nokia Terrain Map"), false, 3);
- types << QGeoMapType(QGeoMapType::HybridMap,tr("Hybrid Map"),tr("Nokia Hybrid Map"), false, 4);
- types << QGeoMapType(QGeoMapType::TransitMap,tr("Transit Map"),tr("Nokia Transit Map"), false, 5);
- types << QGeoMapType(QGeoMapType::GrayStreetMap,tr("Gray Street Map"),tr("Nokia Gray Street Map"), false, 6);
- types << QGeoMapType(QGeoMapType::StreetMap,tr("Mobile Street Map"),tr("Nokia Mobile Street Map"), true, 7);
- types << QGeoMapType(QGeoMapType::TerrainMap,tr("Mobile Terrain Map"),tr("Nokia Mobile Terrain Map"), true, 8);
- types << QGeoMapType(QGeoMapType::HybridMap,tr("Mobile Hybrid Map"),tr("Nokia Mobile Hybrid Map"), true, 9);
- types << QGeoMapType(QGeoMapType::TransitMap,tr("Mobile Transit Map"),tr("Nokia Mobile Transit Map"), true, 10);
- types << QGeoMapType(QGeoMapType::GrayStreetMap,tr("Mobile Gray Street Map"),tr("Nokia Mobile Gray Street Map"), true, 11);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, 1);
+ types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, 2);
+ types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, 3);
+ types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, 4);
+ types << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Color-reduced map view with public transport scheme in daylight mode"), false, 5);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Street Map"), tr("Color-reduced map view in daylight mode (especially used for background maps)"), false, 6);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Street Map"), tr("Mobile normal map view in daylight mode"), true, 7);
+ types << QGeoMapType(QGeoMapType::TerrainMap, tr("Mobile Terrain Map"), tr("Mobile terrain map view in daylight mode"), true, 8);
+ types << QGeoMapType(QGeoMapType::HybridMap, tr("Mobile Hybrid Map"), tr("Mobile satellite map view with streets in daylight mode"), true, 9);
+ types << QGeoMapType(QGeoMapType::TransitMap, tr("Mobile Transit Map"), tr("Mobile color-reduced map view with public transport scheme in daylight mode"), true, 10);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Street Map"), tr("Mobile color-reduced map view in daylight mode (especially used for background maps)"), true, 11);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Custom Street Map"), tr("Normal map view in daylight mode"), false, 12);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Night Street Map"), tr("Normal map view in night mode"), false, 13);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Night Street Map"), tr("Mobile normal map view in night mode"), true, 14);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Night Street Map"), tr("Color-reduced map view in night mode (especially used for background maps)"), false, 15);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Night Street Map"), tr("Mobile color-reduced map view in night mode (especially used for background maps)"), true, 16);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Street Map"), tr("Pedestrian map view in daylight mode for mobile usage"), true, 17);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Night Street Map"), tr("Pedestrian map view in night mode for mobile usage"), true, 18);
+ types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, 19);
setSupportedMapTypes(types);
QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize());
@@ -131,29 +137,55 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
tileCache->setExtraTextureUsage(cacheSize);
}
- populateMapTypesDb();
+ populateMapSchemes();
QMetaObject::invokeMethod(fetcher, "fetchCopyrightsData", Qt::QueuedConnection);
}
-QGeoTiledMappingManagerEngineNokia::~QGeoTiledMappingManagerEngineNokia() {}
+QGeoTiledMappingManagerEngineNokia::~QGeoTiledMappingManagerEngineNokia()
+{
+}
-void QGeoTiledMappingManagerEngineNokia::populateMapTypesDb()
+void QGeoTiledMappingManagerEngineNokia::populateMapSchemes()
{
- m_mapTypeStrings[QGeoMapType::NoMap] = QLatin1String("normal");
- m_mapTypeStrings[QGeoMapType::TerrainMap] = QLatin1String("terrain");
- m_mapTypeStrings[QGeoMapType::StreetMap] = QLatin1String("normal");
- m_mapTypeStrings[QGeoMapType::SatelliteMapDay] = QLatin1String("satellite");
- m_mapTypeStrings[QGeoMapType::SatelliteMapNight] = QLatin1String("satellite");
- m_mapTypeStrings[QGeoMapType::HybridMap] = QLatin1String("hybrid");
- m_mapTypeStrings[QGeoMapType::TransitMap] = QLatin1String("normal");
- m_mapTypeStrings[QGeoMapType::GrayStreetMap] = QLatin1String("normal");
+ m_mapSchemes[0] = QLatin1String("normal.day");
+ m_mapSchemes[1] = QLatin1String("normal.day");
+ m_mapSchemes[2] = QLatin1String("satellite.day");
+ m_mapSchemes[3] = QLatin1String("terrain.day");
+ m_mapSchemes[4] = QLatin1String("hybrid.day");
+ m_mapSchemes[5] = QLatin1String("normal.day.transit");
+ m_mapSchemes[6] = QLatin1String("normal.day.grey");
+ m_mapSchemes[7] = QLatin1String("normal.day.mobile");
+ m_mapSchemes[8] = QLatin1String("terrain.day.mobile");
+ m_mapSchemes[9] = QLatin1String("hybrid.day.mobile");
+ m_mapSchemes[10] = QLatin1String("normal.day.transit.mobile");
+ m_mapSchemes[11] = QLatin1String("normal.day.grey.mobile");
+ m_mapSchemes[12] = QLatin1String("normal.day.custom");
+ m_mapSchemes[13] = QLatin1String("normal.night");
+ m_mapSchemes[14] = QLatin1String("normal.night.mobile");
+ m_mapSchemes[15] = QLatin1String("normal.night.grey");
+ m_mapSchemes[16] = QLatin1String("normal.night.grey.mobile");
+ m_mapSchemes[17] = QLatin1String("pedestrian.day");
+ m_mapSchemes[18] = QLatin1String("pedestrian.night");
+ m_mapSchemes[19] = QLatin1String("carnav.day.grey");
+}
+
+QString QGeoTiledMappingManagerEngineNokia::getScheme(int mapId)
+{
+ return m_mapSchemes[mapId];
+}
+
+QString QGeoTiledMappingManagerEngineNokia::getBaseScheme(int mapId)
+{
+ QString fullScheme(m_mapSchemes[mapId]);
+
+ return fullScheme.section(QLatin1Char('.'), 0, 0);
}
void QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(const QByteArray &jsonData)
{
QJsonDocument doc = QJsonDocument::fromJson(QByteArray(jsonData));
if (doc.isNull()) {
- qDebug() << "QGeoCopyrightsCacheNokia::copyrightsFetche() Invalid JSon document";
+ qDebug() << "QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson() Invalid JSon document";
return;
}
@@ -193,10 +225,11 @@ void QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(const
}
}
-QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMapType::MapStyle mapStyle,
- const int zoomLevel,
+QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMapType mapType,
+ const qreal zoomLevel,
const QSet<QGeoTileSpec> &tiles)
{
+ static const QChar copyrightSymbol(0x00a9);
typedef QSet<QGeoTileSpec>::const_iterator tile_iter;
QGeoRectangle viewport;
double viewX0, viewY0, viewX1, viewY1;
@@ -205,6 +238,7 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap
tile_iter lastTile = tiles.constEnd();
if (tiles.count()) {
+ double divFactor = qPow(2.0, tile->zoom());
viewX0 = viewX1 = tile->x();
viewY0 = viewY1 = tile->y();
@@ -227,7 +261,6 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap
viewY1++;
QDoubleVector2D pt;
- double divFactor = qPow(2.0, zoomLevel);
pt.setX(viewX0 / divFactor);
pt.setY(viewY0 / divFactor);
@@ -238,35 +271,37 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap
}
// TODO: the following invalidation detection algorithm may be improved later.
- QList<CopyrightDesc> descriptorList = m_copyrights[ m_mapTypeStrings[mapStyle] ];
+ QList<CopyrightDesc> descriptorList = m_copyrights[ getBaseScheme(mapType.mapId()) ];
CopyrightDesc *descriptor;
int descIndex, boxIndex;
- QString copyrightsString("");
+ QString copyrightsText;
+ QSet<QString> copyrightStrings;
for (descIndex = 0; descIndex < descriptorList.count(); descIndex++) {
if (descriptorList[descIndex].minLevel <= zoomLevel && zoomLevel <= descriptorList[descIndex].maxLevel) {
descriptor = &descriptorList[descIndex];
+
for (boxIndex = 0; boxIndex < descriptor->boxes.count(); boxIndex++) {
QGeoRectangle box = descriptor->boxes[boxIndex];
- QGeoCoordinate topRight = box.topRight();
- QGeoCoordinate bottomLeft = box.bottomLeft();
- if (descriptor->boxes[boxIndex].intersects(viewport)) {
- if (copyrightsString.length())
- copyrightsString += "\n";
- copyrightsString += descriptor->label;
+ if (box.intersects(viewport)) {
+ copyrightStrings.insert(descriptor->label);
break;
}
}
- if (!descriptor->boxes.count()) {
- if (copyrightsString.length())
- copyrightsString += "\n";
- copyrightsString += descriptor->label;
- }
+ if (!descriptor->boxes.count())
+ copyrightStrings.insert(descriptor->label);
}
}
- return copyrightsString;
+ foreach (const QString &copyrightString, copyrightStrings) {
+ if (copyrightsText.length())
+ copyrightsText += QLatin1Char('\n');
+ copyrightsText += copyrightSymbol;
+ copyrightsText += copyrightString;
+ }
+
+ return copyrightsText;
}
QGeoMapData *QGeoTiledMappingManagerEngineNokia::createMapData()
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
index 3ba30d90..a30dcf69 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.h
@@ -71,15 +71,17 @@ class QGeoTiledMappingManagerEngineNokia : public QGeoTiledMappingManagerEngine
public:
QGeoTiledMappingManagerEngineNokia(QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
~QGeoTiledMappingManagerEngineNokia();
virtual QGeoMapData *createMapData();
- QString evaluateCopyrightsText(const QGeoMapType::MapStyle mapStyle,
- const int zoomLevel,
+ QString evaluateCopyrightsText(const QGeoMapType mapType,
+ const qreal zoomLevel,
const QSet<QGeoTileSpec> &tiles);
+ QString getScheme(int mapId);
+ QString getBaseScheme(int mapId);
public Q_SLOTS:
void loadCopyrightsDescriptorsFromJson(const QByteArray &jsonData);
@@ -100,10 +102,10 @@ private:
};
void initialize();
- void populateMapTypesDb();
+ void populateMapSchemes();
QHash<QString, QList<CopyrightDesc> > m_copyrights;
- QHash<QGeoMapType::MapStyle, QString> m_mapTypeStrings;
+ QHash<int, QString> m_mapSchemes;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index 31fa12e0..ddd55ec4 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -81,71 +81,39 @@ namespace
return s128;
}
- QString mapIdToStr(int mapId)
+ bool isAerialType(const QString mapScheme)
{
- typedef std::map<int, QString> MapTypeRegistry;
- static MapTypeRegistry registeredTypes;
- if (registeredTypes.empty()) {
- registeredTypes[0] = "normal.day";
- registeredTypes[1] = "normal.day";
- registeredTypes[2] = "satellite.day";
- registeredTypes[3] = "terrain.day";
- registeredTypes[4] = "hybrid.day";
- registeredTypes[5] = "normal.day.transit";
- registeredTypes[6] = "normal.day.grey";
- registeredTypes[7] = "normal.day.mobile";
- registeredTypes[8] = "terrain.day.mobile";
- registeredTypes[9] = "hybrid.day.mobile";
- registeredTypes[10] = "normal.day.transit.mobile";
- registeredTypes[11] = "normal.day.grey.mobile";
- }
-
- MapTypeRegistry::const_iterator it = registeredTypes.find(mapId);
- if (it != registeredTypes.end()) {
- return it->second;
- }
-
- qWarning() << "Unknown mapId: " << mapId;
- return "normal.day";
+ return mapScheme.startsWith("satellite") || mapScheme.startsWith("hybrid") || mapScheme.startsWith("terrain");
}
}
-QGeoTileFetcherNokia::QGeoTileFetcherNokia(
- const QMap<QString, QVariant> &parameters,
- QGeoNetworkAccessManager *networkManager,
- QGeoTiledMappingManagerEngine *engine,
- const QSize &tileSize)
- : QGeoTileFetcher(engine),
- m_engineNokia(static_cast<QGeoTiledMappingManagerEngineNokia *>(engine)),
- m_networkManager(networkManager),
- m_parameters(parameters),
- m_tileSize(tileSize),
- m_copyrightsReply(0),
- m_uriProvider(new QGeoUriProvider(this, parameters, "mapping.host", MAP_TILES_HOST, MAP_TILES_HOST_CN))
+QGeoTileFetcherNokia::QGeoTileFetcherNokia(const QVariantMap &parameters,
+ QGeoNetworkAccessManager *networkManager,
+ QGeoTiledMappingManagerEngineNokia *engine,
+ const QSize &tileSize)
+: QGeoTileFetcher(engine), m_engineNokia(engine), m_networkManager(networkManager),
+ m_tileSize(tileSize), m_copyrightsReply(0),
+ m_baseUriProvider(new QGeoUriProvider(this, parameters, "mapping.host", MAP_TILES_HOST)),
+ m_aerialUriProvider(new QGeoUriProvider(this, parameters, "mapping.host.aerial", MAP_TILES_HOST_AERIAL))
{
Q_ASSERT(networkManager);
m_networkManager->setParent(this);
-}
-QGeoTileFetcherNokia::~QGeoTileFetcherNokia() {}
+ m_applicationId = parameters.value(QStringLiteral("app_id")).toString();
+ m_token = parameters.value(QStringLiteral("token")).toString();
+}
-bool QGeoTileFetcherNokia::init()
+QGeoTileFetcherNokia::~QGeoTileFetcherNokia()
{
- qsrand((uint)QTime::currentTime().msec());
-
- if (m_parameters.contains("app_id")) {
- m_applicationId = m_parameters.value("app_id").toString();
- }
-
- if (m_parameters.contains("token")) {
- m_token = m_parameters.value("token").toString();
- }
- return true;
}
QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
{
// TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode
QString rawRequest = getRequestString(spec);
+ if (rawRequest.isEmpty()) {
+ return new QGeoTiledMapReply(QGeoTiledMapReply::UnknownError,
+ tr("Mapping manager no longer exists"), this);
+ }
QNetworkRequest netRequest((QUrl(rawRequest))); // The extra pair of parens disambiguates this from a function declaration
netRequest.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
@@ -159,16 +127,23 @@ QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
{
+ if (!m_engineNokia)
+ return QString();
+
static const QString http("http://");
- static const QString path("/maptiler/v2/maptile/newest/");
+ static const QString path("/maptile/2.1/maptile/newest/");
static const QChar slash('/');
QString requestString = http;
- requestString += m_uriProvider->getCurrentHost();
- requestString += path;
+ const QString mapScheme = m_engineNokia->getScheme(spec.mapId());
+ if (isAerialType(mapScheme))
+ requestString += m_aerialUriProvider->getCurrentHost();
+ else
+ requestString += m_baseUriProvider->getCurrentHost();
- requestString += mapIdToStr(spec.mapId());
+ requestString += path;
+ requestString += mapScheme;
requestString += slash;
requestString += QString::number(spec.zoom());
requestString += slash;
@@ -196,35 +171,68 @@ QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
QString QGeoTileFetcherNokia::getLanguageString() const
{
- const QLocale::Language lang = m_engineNokia.data()->locale().language();
+ if (!m_engineNokia)
+ return QStringLiteral("ENG");
+
+ QLocale locale = m_engineNokia.data()->locale();
+
// English is the default, where no ln is specified. We hardcode the languages
// here even though the entire list is updated automagically from the server.
// The current languages are Arabic, Chinese, Simplified Chinese, English
// French, German, Italian, Polish, Russian and Spanish. The default is English.
// These are acually available from the same host under the URL: /maptiler/v2/info
- switch (lang) {
+ switch (locale.language()) {
case QLocale::Arabic:
- return "ARA";
+ return QStringLiteral("ARA");
case QLocale::Chinese:
- if (QLocale::TraditionalChineseScript == m_engineNokia.data()->locale().script())
- return "CHI";
+ if (locale.script() == QLocale::TraditionalChineseScript)
+ return QStringLiteral("CHI");
else
- return "CHT";
+ return QStringLiteral("CHT");
+ case QLocale::Dutch:
+ return QStringLiteral("DUT");
case QLocale::French:
- return "FRE";
+ return QStringLiteral("FRE");
case QLocale::German:
- return "GER";
+ return QStringLiteral("GER");
+ case QLocale::Gaelic:
+ return QStringLiteral("GLE");
+ case QLocale::Greek:
+ return QStringLiteral("GRE");
+ case QLocale::Hebrew:
+ return QStringLiteral("HEB");
+ case QLocale::Hindi:
+ return QStringLiteral("HIN");
+ case QLocale::Indonesian:
+ return QStringLiteral("IND");
case QLocale::Italian:
- return "ITA";
+ return QStringLiteral("ITA");
+ case QLocale::Persian:
+ return QStringLiteral("PER");
case QLocale::Polish:
- return "POL";
+ return QStringLiteral("POL");
+ case QLocale::Portuguese:
+ return QStringLiteral("POR");
case QLocale::Russian:
- return "RUS";
+ return QStringLiteral("RUS");
+ case QLocale::Sinhala:
+ return QStringLiteral("SIN");
case QLocale::Spanish:
- return "SPA";
+ return QStringLiteral("SPA");
+ case QLocale::Thai:
+ return QStringLiteral("THA");
+ case QLocale::Turkish:
+ return QStringLiteral("TUR");
+ case QLocale::Ukrainian:
+ return QStringLiteral("UKR");
+ case QLocale::Urdu:
+ return QStringLiteral("URD");
+ case QLocale::Vietnamese:
+ return QStringLiteral("VIE");
+
default:
- return "ENG";
+ return QStringLiteral("ENG");
}
// No "lg" param means that we want English.
}
@@ -253,8 +261,8 @@ void QGeoTileFetcherNokia::fetchCopyrightsData()
{
QString copyrightUrl = "http://";
- copyrightUrl += m_uriProvider->getCurrentHost();
- copyrightUrl += "/maptiler/v2/copyright/newest?output=json";
+ copyrightUrl += m_baseUriProvider->getCurrentHost();
+ copyrightUrl += "/maptile/2.1/copyright/newest?output=json";
if (!token().isEmpty()) {
copyrightUrl += "&token=";
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
index 534dfddb..a5e1801a 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
@@ -68,16 +68,10 @@ class QGeoTileFetcherNokia : public QGeoTileFetcher
Q_OBJECT
public:
- QGeoTileFetcherNokia(
- const QMap<QString, QVariant> &parameters,
- QGeoNetworkAccessManager *networkManager,
- QGeoTiledMappingManagerEngine *engine,
- const QSize &tileSize);
-
+ QGeoTileFetcherNokia(const QVariantMap &parameters, QGeoNetworkAccessManager *networkManager,
+ QGeoTiledMappingManagerEngineNokia *engine, const QSize &tileSize);
~QGeoTileFetcherNokia();
- bool init();
-
QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec);
QString token() const;
@@ -96,13 +90,13 @@ private:
QPointer<QGeoTiledMappingManagerEngineNokia> m_engineNokia;
QGeoNetworkAccessManager *m_networkManager;
- QMap<QString, QVariant> m_parameters;
QSize m_tileSize;
QString m_token;
QNetworkReply *m_copyrightsReply;
QString m_applicationId;
- QGeoUriProvider *m_uriProvider;
+ QGeoUriProvider *m_baseUriProvider;
+ QGeoUriProvider *m_aerialUriProvider;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeouriprovider.cpp b/src/plugins/geoservices/nokia/qgeouriprovider.cpp
index 0ce3611e..77c47b03 100644
--- a/src/plugins/geoservices/nokia/qgeouriprovider.cpp
+++ b/src/plugins/geoservices/nokia/qgeouriprovider.cpp
@@ -68,7 +68,7 @@ namespace
QGeoUriProvider::QGeoUriProvider(
QObject *parent,
- const QMap<QString, QVariant> & parameters,
+ const QVariantMap &parameters,
const QString &hostParameterName,
const QString &internationalHost,
const QString &localizedHost)
diff --git a/src/plugins/geoservices/nokia/qgeouriprovider.h b/src/plugins/geoservices/nokia/qgeouriprovider.h
index d9f3e570..82f2bb45 100644
--- a/src/plugins/geoservices/nokia/qgeouriprovider.h
+++ b/src/plugins/geoservices/nokia/qgeouriprovider.h
@@ -62,7 +62,7 @@ class QGeoUriProvider : public QObject
public:
QGeoUriProvider(QObject *parent,
- const QMap<QString, QVariant> & parameters,
+ const QVariantMap &parameters,
const QString &hostParameterName,
const QString &internationalHost,
const QString &localizedHost = QString());
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
index 9c2a9b85..5543d001 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -198,7 +198,7 @@ void CategoryParser::processCategory(int level, const QString &id, const QString
QPlaceManagerEngineNokiaV2::QPlaceManagerEngineNokiaV2(
QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QPlaceManagerEngine(parameters)
@@ -261,75 +261,63 @@ QPlaceDetailsReply *QPlaceManagerEngineNokiaV2::getPlaceDetails(const QString &p
return reply;
}
-QPlaceContentReply *QPlaceManagerEngineNokiaV2::getPlaceContent(const QString &placeId,
- const QPlaceContentRequest &request)
+QPlaceContentReply *QPlaceManagerEngineNokiaV2::getPlaceContent(const QPlaceContentRequest &request)
{
- QUrl requestUrl(QString::fromLatin1("http://") + m_uriProvider->getCurrentHost() +
- QLatin1String("/places/v1/places/") + placeId + QLatin1String("/media/"));
-
QNetworkReply *networkReply = 0;
- QUrlQuery queryItems;
+ if (request.contentContext().userType() == qMetaTypeId<QUrl>()) {
+ QUrl u = request.contentContext().value<QUrl>();
- switch (request.contentType()) {
- case QPlaceContent::ImageType:
- requestUrl.setPath(requestUrl.path() + QLatin1String("images"));
+ networkReply = sendRequest(u);
+ } else {
+ QUrl requestUrl(QString::fromLatin1("http://") + m_uriProvider->getCurrentHost() +
+ QLatin1String("/places/v1/places/") + request.placeId() +
+ QLatin1String("/media/"));
- queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
+ QUrlQuery queryItems;
- if (request.limit() > 0) {
- queryItems.addQueryItem(QLatin1String("size"),
- QString::number(request.limit()));
- }
- if (request.offset() > -1) {
- queryItems.addQueryItem(QLatin1String("offset"),
- QString::number(request.offset()));
- }
+ switch (request.contentType()) {
+ case QPlaceContent::ImageType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("images"));
- //queryItems.append(qMakePair<QString, QString>(QLatin1String("image_dimensions"), QLatin1String("w64-h64,w100")));
+ queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
- requestUrl.setQuery(queryItems);
+ if (request.limit() > 0)
+ queryItems.addQueryItem(QLatin1String("size"), QString::number(request.limit()));
- networkReply = sendRequest(requestUrl);
- break;
- case QPlaceContent::ReviewType:
- requestUrl.setPath(requestUrl.path() + QLatin1String("reviews"));
+ //queryItems.append(qMakePair<QString, QString>(QLatin1String("image_dimensions"), QLatin1String("w64-h64,w100")));
- queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
+ requestUrl.setQuery(queryItems);
- if (request.limit() > 0) {
- queryItems.addQueryItem(QLatin1String("size"),
- QString::number(request.limit()));
- }
- if (request.offset() > -1) {
- queryItems.addQueryItem(QLatin1String("offset"),
- QString::number(request.offset()));
- }
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::ReviewType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("reviews"));
- requestUrl.setQuery(queryItems);
+ queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
- networkReply = sendRequest(requestUrl);
- break;
- case QPlaceContent::EditorialType:
- requestUrl.setPath(requestUrl.path() + QLatin1String("editorials"));
+ if (request.limit() > 0)
+ queryItems.addQueryItem(QLatin1String("size"), QString::number(request.limit()));
- queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
+ requestUrl.setQuery(queryItems);
- if (request.limit() > 0) {
- queryItems.addQueryItem(QLatin1String("size"),
- QString::number(request.limit()));
- }
- if (request.offset() > -1) {
- queryItems.addQueryItem(QLatin1String("offset"),
- QString::number(request.offset()));
- }
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::EditorialType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("editorials"));
- requestUrl.setQuery(queryItems);
+ queryItems.addQueryItem(QLatin1String("tf"), QLatin1String("html"));
- networkReply = sendRequest(requestUrl);
- break;
- case QPlaceContent::NoType:
- ;
+ if (request.limit() > 0)
+ queryItems.addQueryItem(QLatin1String("size"), QString::number(request.limit()));
+
+ requestUrl.setQuery(queryItems);
+
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::NoType:
+ ;
+ }
}
QPlaceContentReply *reply = new QPlaceContentReplyImpl(request, networkReply, this);
@@ -379,8 +367,6 @@ QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest
unsupported |= query.visibilityScope() != QLocation::UnspecifiedVisibility &&
query.visibilityScope() != QLocation::PublicVisibility;
- unsupported |= !query.searchTerm().isEmpty() && query.offset() > 0;
-
// Both a search term and search categories are not supported.
unsupported |= !query.searchTerm().isEmpty() && !query.categories().isEmpty();
@@ -432,9 +418,6 @@ QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest
if (query.limit() > 0)
queryItems.addQueryItem(QStringLiteral("size"), QString::number(query.limit()));
- if (query.offset() > -1)
- queryItems.addQueryItem(QStringLiteral("offset"), QString::number(query.offset()));
-
u.setQuery(queryItems);
networkReply = sendRequest(u);
@@ -493,10 +476,6 @@ QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest
queryItems.addQueryItem(QLatin1String("size"),
QString::number(query.limit()));
}
- if (query.offset() > -1) {
- queryItems.addQueryItem(QLatin1String("offset"),
- QString::number(query.offset()));
- }
requestUrl.setQuery(queryItems);
@@ -518,7 +497,6 @@ QPlaceSearchSuggestionReply *QPlaceManagerEngineNokiaV2::searchSuggestions(const
unsupported |= query.visibilityScope() != QLocation::UnspecifiedVisibility &&
query.visibilityScope() != QLocation::PublicVisibility;
- unsupported |= query.offset() > 0;
unsupported |= !query.categories().isEmpty();
unsupported |= !query.recommendationId().isEmpty();
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
index 6b31e165..c186d6bd 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
@@ -78,14 +78,14 @@ class QPlaceManagerEngineNokiaV2 : public QPlaceManagerEngine
public:
QPlaceManagerEngineNokiaV2(QGeoNetworkAccessManager *networkManager,
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
~QPlaceManagerEngineNokiaV2();
QPlaceDetailsReply *getPlaceDetails(const QString &placeId);
- QPlaceContentReply *getPlaceContent(const QString &placeId, const QPlaceContentRequest &request);
+ QPlaceContentReply *getPlaceContent(const QPlaceContentRequest &request) Q_DECL_OVERRIDE;
QPlaceSearchReply *search(const QPlaceSearchRequest &query);
diff --git a/src/plugins/geoservices/nokia/uri_constants.cpp b/src/plugins/geoservices/nokia/uri_constants.cpp
index ee104a4b..83a2aafe 100644
--- a/src/plugins/geoservices/nokia/uri_constants.cpp
+++ b/src/plugins/geoservices/nokia/uri_constants.cpp
@@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE
const QString ROUTING_HOST = QLatin1String("route.nlp.nokia.com");
const QString GEOCODING_HOST = QLatin1String("loc.desktop.maps.svc.ovi.com");
const QString GEOCODING_HOST_CN = QLatin1String("pr.geo.maps.svc.nokia.com.cn");
-const QString PLACES_HOST = QLatin1String("places.nlp.nokia.com");
+const QString PLACES_HOST = QLatin1String("places.api.here.com");
const QString PLACES_HOST_CN = QLatin1String("places.nlp.nokia.com.cn");
-const QString MAP_TILES_HOST = QLatin1String("1-4.maptile.lbs.ovi.com");
-const QString MAP_TILES_HOST_CN = QLatin1String("a-k.maptile.maps.svc.nokia.com.cn");
+const QString MAP_TILES_HOST = QLatin1String("1-4.base.maps.api.here.com");
+const QString MAP_TILES_HOST_AERIAL = QLatin1String("1-4.aerial.maps.api.here.com");
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/uri_constants.h b/src/plugins/geoservices/nokia/uri_constants.h
index b89c24b7..b32f0878 100644
--- a/src/plugins/geoservices/nokia/uri_constants.h
+++ b/src/plugins/geoservices/nokia/uri_constants.h
@@ -59,7 +59,7 @@ extern const QString GEOCODING_HOST_CN;
extern const QString PLACES_HOST;
extern const QString PLACES_HOST_CN;
extern const QString MAP_TILES_HOST;
-extern const QString MAP_TILES_HOST_CN;
+extern const QString MAP_TILES_HOST_AERIAL;
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/osm.pro b/src/plugins/geoservices/osm/osm.pro
index 5767bdee..897ebbfc 100644
--- a/src/plugins/geoservices/osm/osm.pro
+++ b/src/plugins/geoservices/osm/osm.pro
@@ -1,5 +1,5 @@
TARGET = qtgeoservices_osm
-QT += location-private network
+QT += location-private positioning-private network
PLUGIN_TYPE = geoservices
load(qt_plugin)
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
index 4d8b005f..e75943b1 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
@@ -93,6 +93,9 @@ void QGeoMapReplyOsm::networkReplyFinished()
case 1:
setMapImageFormat("png");
break;
+ case 2:
+ setMapImageFormat("png");
+ break;
default:
qWarning("Unknown map id %d", tileSpec().mapId());
}
diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
index bf3487f7..9f71c0b1 100644
--- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
@@ -73,9 +73,9 @@ static QList<QGeoCoordinate> parsePolyline(const QByteArray &data)
int diff = (value & 1) ? ~(value >> 1) : (value >> 1);
if (parsingLatitude) {
- coord.setLatitude(coord.latitude() + diff/1e5);
+ coord.setLatitude(coord.latitude() + (double)diff/1e6);
} else {
- coord.setLongitude(coord.longitude() + diff/1e5);
+ coord.setLongitude(coord.longitude() + (double)diff/1e6);
path.append(coord);
}
@@ -128,46 +128,117 @@ static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString
const QString osrmInstructionText(const QString &instructionCode, const QString &wayname)
{
- if (instructionCode == QLatin1String("0"))
+ if (instructionCode == QLatin1String("0")) {
return QString();
- else if (instructionCode == QLatin1String("1"))
- return QGeoRouteReplyOsm::tr("Go straight.");
- else if (instructionCode == QLatin1String("2"))
- return QGeoRouteReplyOsm::tr("Turn slightly right onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("3"))
- return QGeoRouteReplyOsm::tr("Turn right onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("4"))
- return QGeoRouteReplyOsm::tr("Make a sharp right onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("5"))
+ } else if (instructionCode == QLatin1String("1")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Go straight.");
+ else
+ return QGeoRouteReplyOsm::tr("Go straight onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("2")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Turn slightly right.");
+ else
+ return QGeoRouteReplyOsm::tr("Turn slightly right onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("3")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Turn right.");
+ else
+ return QGeoRouteReplyOsm::tr("Turn right onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("4")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Make a sharp right.");
+ else
+ return QGeoRouteReplyOsm::tr("Make a sharp right onto %1.").arg(wayname);
+ }
+ else if (instructionCode == QLatin1String("5")) {
return QGeoRouteReplyOsm::tr("When it is safe to do so, perform a U-turn.");
- else if (instructionCode == QLatin1String("6"))
- return QGeoRouteReplyOsm::tr("Make a sharp left onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("7"))
- return QGeoRouteReplyOsm::tr("Turn left onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("8"))
- return QGeoRouteReplyOsm::tr("Turn slightly left onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("9"))
+ } else if (instructionCode == QLatin1String("6")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Make a sharp left.");
+ else
+ return QGeoRouteReplyOsm::tr("Make a sharp left onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("7")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Turn left.");
+ else
+ return QGeoRouteReplyOsm::tr("Turn left onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("8")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Turn slightly left.");
+ else
+ return QGeoRouteReplyOsm::tr("Turn slightly left onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("9")) {
return QGeoRouteReplyOsm::tr("Reached waypoint.");
- else if (instructionCode == QLatin1String("10"))
- return QGeoRouteReplyOsm::tr("Head onto %1.").arg(wayname);
- else if (instructionCode == QLatin1String("11"))
- return QGeoRouteReplyOsm::tr("Enter the round about.");
- else if (instructionCode == QLatin1String("11-1"))
- return QGeoRouteReplyOsm::tr("At the round about take the 1st exit.");
- else if (instructionCode == QLatin1String("11-2"))
- return QGeoRouteReplyOsm::tr("At the round about take the 2nd exit.");
- else if (instructionCode == QLatin1String("11-3"))
- return QGeoRouteReplyOsm::tr("At the round about take the 3rd exit.");
- else if (instructionCode == QLatin1String("12"))
- return QGeoRouteReplyOsm::tr("Leave the round about.");
- else if (instructionCode == QLatin1String("13"))
- return QGeoRouteReplyOsm::tr("Stay on the round about.");
- else if (instructionCode == QLatin1String("14"))
- return QGeoRouteReplyOsm::tr("Start at the end of the street.");
- else if (instructionCode == QLatin1String("15"))
+ } else if (instructionCode == QLatin1String("10")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Head on.");
+ else
+ return QGeoRouteReplyOsm::tr("Head onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11")) {
+ return QGeoRouteReplyOsm::tr("Enter the roundabout.");
+ } else if (instructionCode == QLatin1String("11-1")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the first exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the first exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-2")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the second exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the second exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-3")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the third exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the third exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-4")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the fourth exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the fourth exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-5")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the fifth exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the fifth exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-6")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the sixth exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the sixth exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-7")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the seventh exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the seventh exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-8")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the eighth exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the eighth exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("11-9")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("At the roundabout take the ninth exit.");
+ else
+ return QGeoRouteReplyOsm::tr("At the roundabout take the ninth exit onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("12")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Leave the roundabout.");
+ else
+ return QGeoRouteReplyOsm::tr("Leave the roundabout onto %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("13")) {
+ return QGeoRouteReplyOsm::tr("Stay on the roundabout.");
+ } else if (instructionCode == QLatin1String("14")) {
+ if (wayname.isEmpty())
+ return QGeoRouteReplyOsm::tr("Start at the end of the street.");
+ else
+ return QGeoRouteReplyOsm::tr("Start at the end of %1.").arg(wayname);
+ } else if (instructionCode == QLatin1String("15")) {
return QGeoRouteReplyOsm::tr("You have reached your destination.");
- else
+ } else {
return QGeoRouteReplyOsm::tr("Don't know what to say for '%1'").arg(instructionCode);
+ }
}
QGeoRouteReplyOsm::QGeoRouteReplyOsm(QNetworkReply *reply, const QGeoRouteRequest &request,
diff --git a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
index a07eb62e..077c55ba 100644
--- a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp
@@ -46,7 +46,7 @@
#include <QtCore/QDebug>
-QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(const QMap<QString, QVariant> &parameters,
+QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QGeoRoutingManagerEngine(parameters), m_networkManager(new QNetworkAccessManager(this))
@@ -72,6 +72,8 @@ QGeoRouteReply* QGeoRoutingManagerEngineOsm::calculateRoute(const QGeoRouteReque
QUrl url(QLatin1String("http://router.project-osrm.org/viaroute"));
QUrlQuery query;
+ query.addQueryItem(QStringLiteral("instructions"), QStringLiteral("true"));
+
foreach (const QGeoCoordinate &c, request.waypoints()) {
query.addQueryItem(QLatin1String("loc"), QString::number(c.latitude()) + QLatin1Char(',') +
QString::number(c.longitude()));
diff --git a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h
index 25016887..dd49a826 100644
--- a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h
+++ b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h
@@ -54,7 +54,7 @@ class QGeoRoutingManagerEngineOsm : public QGeoRoutingManagerEngine
Q_OBJECT
public:
- QGeoRoutingManagerEngineOsm(const QMap<QString, QVariant> &parameters,
+ QGeoRoutingManagerEngineOsm(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
~QGeoRoutingManagerEngineOsm();
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index 8e77f249..a141c239 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -60,6 +60,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
QList<QGeoMapType> mapTypes;
mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Open street map street map"), false, 1);
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Open street map satellite map"), false, 2);
setSupportedMapTypes(mapTypes);
QGeoTileFetcherOsm *tileFetcher = new QGeoTileFetcherOsm(this);
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
index d2f71b3e..e149c65f 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcherOsm::QGeoTileFetcherOsm(QGeoTiledMappingManagerEngine *parent)
+QGeoTileFetcherOsm::QGeoTileFetcherOsm(QObject *parent)
: QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)),
m_userAgent("Qt Location based application")
{
@@ -67,7 +67,14 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec)
switch (spec.mapId()) {
case 1:
// opensteetmap.org street map
- request.setUrl(QUrl(QStringLiteral("http://a.tile.openstreetmap.org/") +
+ request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/") +
+ QString::number(spec.zoom()) + QLatin1Char('/') +
+ QString::number(spec.x()) + QLatin1Char('/') +
+ QString::number(spec.y()) + QStringLiteral(".png")));
+ break;
+ case 2:
+ // opensteetmap.org satellite map
+ request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/") +
QString::number(spec.zoom()) + QLatin1Char('/') +
QString::number(spec.x()) + QLatin1Char('/') +
QString::number(spec.y()) + QStringLiteral(".png")));
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.h b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
index ae88ab97..e705a2d9 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.h
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
@@ -54,7 +54,7 @@ class QGeoTileFetcherOsm : public QGeoTileFetcher
Q_OBJECT
public:
- explicit QGeoTileFetcherOsm(QGeoTiledMappingManagerEngine *parent = 0);
+ QGeoTileFetcherOsm(QObject *parent = 0);
void setUserAgent(const QByteArray &userAgent);
diff --git a/src/plugins/position/android/android.pro b/src/plugins/position/android/android.pro
new file mode 100644
index 00000000..0dc6a3fc
--- /dev/null
+++ b/src/plugins/position/android/android.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += jar src
diff --git a/src/plugins/position/android/jar/AndroidManifest.xml b/src/plugins/position/android/jar/AndroidManifest.xml
new file mode 100644
index 00000000..2d066dbb
--- /dev/null
+++ b/src/plugins/position/android/jar/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.qt5.android.positioning"
+ android:versionCode="1"
+ android:versionName="1.0" >
+ <supports-screens android:smallScreens="true" android:largeScreens="true" android:anyDensity="true" android:normalScreens="true"/>
+</manifest>
diff --git a/src/plugins/position/android/jar/bundledjar.pro b/src/plugins/position/android/jar/bundledjar.pro
new file mode 100644
index 00000000..e7bd106d
--- /dev/null
+++ b/src/plugins/position/android/jar/bundledjar.pro
@@ -0,0 +1,3 @@
+TARGET = QtPositioning-bundled
+CONFIG += bundled_jar_file
+include(jar.pri)
diff --git a/src/plugins/position/android/jar/distributedjar.pro b/src/plugins/position/android/jar/distributedjar.pro
new file mode 100644
index 00000000..4a5faaa4
--- /dev/null
+++ b/src/plugins/position/android/jar/distributedjar.pro
@@ -0,0 +1,3 @@
+TARGET = QtPositioning
+include(jar.pri)
+
diff --git a/src/plugins/position/android/jar/jar.pri b/src/plugins/position/android/jar/jar.pri
new file mode 100644
index 00000000..9fa548ff
--- /dev/null
+++ b/src/plugins/position/android/jar/jar.pri
@@ -0,0 +1,14 @@
+load(qt_build_paths)
+
+CONFIG += java
+DESTDIR = $$MODULE_BASE_OUTDIR/jar
+
+JAVACLASSPATH += $$PWD/src
+
+JAVASOURCES += \
+ $$PWD/src/org/qtproject/qt5/android/positioning/QtPositioning.java
+
+# install
+target.path = $$[QT_INSTALL_PREFIX]/jar
+INSTALLS += target
+
diff --git a/src/plugins/position/android/jar/jar.pro b/src/plugins/position/android/jar/jar.pro
new file mode 100644
index 00000000..8d19c1b7
--- /dev/null
+++ b/src/plugins/position/android/jar/jar.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += bundledjar.pro distributedjar.pro
diff --git a/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java b/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java
new file mode 100644
index 00000000..f5725813
--- /dev/null
+++ b/src/plugins/position/android/jar/src/org/qtproject/qt5/android/positioning/QtPositioning.java
@@ -0,0 +1,543 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+package org.qtproject.qt5.android.positioning;
+
+import android.app.Activity;
+import android.content.Context;
+import android.location.GpsSatellite;
+import android.location.GpsStatus;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import android.util.Log;
+
+public class QtPositioning implements LocationListener
+{
+
+ private static final String TAG = "QtPositioning";
+ static LocationManager locationManager = null;
+ static Object m_syncObject = new Object();
+ static HashMap<Integer, QtPositioning> runningListeners = new HashMap<Integer, QtPositioning>();
+
+ /*
+ The positionInfo instance to which this
+ QtPositioning instance is attached to.
+ */
+ private int nativeClassReference = 0;
+
+ /*
+ The provider type requested by Qt
+ */
+ private int expectedProviders = 0;
+
+ public static final int QT_GPS_PROVIDER = 1;
+ public static final int QT_NETWORK_PROVIDER = 2;
+
+ /* The following values must match the corresponding error enums in the Qt API*/
+ public static final int QT_ACCESS_ERROR = 0;
+ public static final int QT_CLOSED_ERROR = 1;
+ public static final int QT_POSITION_UNKNOWN_SOURCE_ERROR = 2;
+ public static final int QT_POSITION_NO_ERROR = 3;
+ public static final int QT_SATELLITE_NO_ERROR = 2;
+ public static final int QT_SATELLITE_UNKNOWN_SOURCE_ERROR = -1;
+
+ /* True, if updates were caused by requestUpdate() */
+ private boolean isSingleUpdate = false;
+ /* The length requested for regular intervals in msec. */
+ private int updateIntervalTime = 0;
+
+ /* The last received GPS update */
+ private Location lastGps = null;
+ /* The last received network update */
+ private Location lastNetwork = null;
+ /* If true this class acts as satellite signal monitor rather than location monitor */
+ private boolean isSatelliteUpdate = false;
+
+ private PositioningLooper looperThread;
+
+ static public void setActivity(Activity activity, Object activityDelegate)
+ {
+ try {
+ locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ static private int[] providerList()
+ {
+ List<String> providers = locationManager.getAllProviders();
+ int retList[] = new int[providers.size()];
+ for (int i = 0; i < providers.size(); i++) {
+ if (providers.get(i).equals(LocationManager.GPS_PROVIDER)) {
+ //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_GPS
+ retList[i] = 0;
+ } else if (providers.get(i).equals(LocationManager.NETWORK_PROVIDER)) {
+ //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_NETWORK
+ retList[i] = 1;
+ } else if (providers.get(i).equals(LocationManager.PASSIVE_PROVIDER)) {
+ //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_PASSIVE
+ retList[i] = 2;
+ } else {
+ retList[i] = -1;
+ }
+ }
+ return retList;
+ }
+
+ static public Location lastKnownPosition(boolean fromSatelliteOnly)
+ {
+ Location gps = null;
+ Location network = null;
+ try {
+ gps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (!fromSatelliteOnly)
+ network = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ } catch(Exception e) {
+ e.printStackTrace();
+ gps = network = null;
+ }
+
+ if (gps != null && network != null) {
+ //we return the most recent location but slightly prefer GPS
+ //prefer GPS if it is max 4 hrs older than network
+ long delta = network.getTime() - gps.getTime();
+ if (delta < 4*60*60*1000) {
+ return gps;
+ } else {
+ return network;
+ }
+ } else if (gps != null ) {
+ return gps;
+ } else if (network != null) {
+ return network;
+ }
+
+ return null;
+ }
+
+ /* Returns true if at least on of the given providers is enabled. */
+ static private boolean expectedProvidersAvailable(int desiredProviders)
+ {
+ List<String> enabledProviders = locationManager.getProviders(true);
+ if ((desiredProviders & QT_GPS_PROVIDER) > 0) { //gps desired
+ if (enabledProviders.contains(LocationManager.GPS_PROVIDER)) {
+ return true;
+ }
+ }
+ if ((desiredProviders & QT_NETWORK_PROVIDER) > 0) { //network desired
+ if (enabledProviders.contains(LocationManager.NETWORK_PROVIDER)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ static public int startUpdates(int androidClassKey, int locationProvider, int updateInterval)
+ {
+ synchronized (m_syncObject) {
+ try {
+ boolean exceptionOccurred = false;
+ QtPositioning positioningListener = new QtPositioning();
+ positioningListener.setActiveLooper(true);
+ positioningListener.nativeClassReference = androidClassKey;
+ positioningListener.expectedProviders = locationProvider;
+ positioningListener.isSatelliteUpdate = false;
+
+ if (updateInterval == 0)
+ updateInterval = 1000; //don't update more often than once per second
+
+ positioningListener.updateIntervalTime = updateInterval;
+ if ((locationProvider & QT_GPS_PROVIDER) > 0) {
+ Log.d(TAG, "Regular updates using GPS");
+ try {
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
+ updateInterval, 0,
+ positioningListener,
+ positioningListener.looper());
+ } catch (SecurityException se) {
+ se.printStackTrace();
+ exceptionOccurred = true;
+ }
+ }
+
+ if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
+ Log.d(TAG, "Regular updates using network");
+ try {
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
+ updateInterval, 0,
+ positioningListener,
+ positioningListener.looper());
+ } catch (SecurityException se) {
+ se.printStackTrace();
+ exceptionOccurred = true;
+ }
+ }
+ if (exceptionOccurred) {
+ positioningListener.setActiveLooper(false);
+ locationManager.removeUpdates(positioningListener);
+ return QT_ACCESS_ERROR;
+ }
+
+ if (!expectedProvidersAvailable(locationProvider)) {
+ //all location providers unavailbe -> when they come back we resume automatically
+ return QT_CLOSED_ERROR;
+ }
+
+ runningListeners.put(androidClassKey, positioningListener);
+ } catch(Exception e) {
+ e.printStackTrace();
+ return QT_POSITION_UNKNOWN_SOURCE_ERROR;
+ }
+
+ return QT_POSITION_NO_ERROR;
+ }
+ }
+
+ static public void stopUpdates(int androidClassKey)
+ {
+ synchronized (m_syncObject) {
+ try {
+ Log.d(TAG, "Stopping updates");
+ QtPositioning listener = runningListeners.remove(androidClassKey);
+ locationManager.removeUpdates(listener);
+ listener.setActiveLooper(false);
+ } catch(Exception e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+ }
+
+ static public int requestUpdate(int androidClassKey, int locationProvider)
+ {
+ synchronized (m_syncObject) {
+ try {
+ boolean exceptionOccurred = false;
+ QtPositioning positioningListener = new QtPositioning();
+ positioningListener.setActiveLooper(true);
+ positioningListener.nativeClassReference = androidClassKey;
+ positioningListener.isSingleUpdate = true;
+ positioningListener.expectedProviders = locationProvider;
+ positioningListener.isSatelliteUpdate = false;
+
+ if ((locationProvider & QT_GPS_PROVIDER) > 0) {
+ Log.d(TAG, "Single update using GPS");
+ try {
+ locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER,
+ positioningListener,
+ positioningListener.looper());
+ } catch (SecurityException se) {
+ se.printStackTrace();
+ exceptionOccurred = true;
+ }
+ }
+
+ if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
+ Log.d(TAG, "Single update using network");
+ try {
+ locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER,
+ positioningListener,
+ positioningListener.looper());
+ } catch (SecurityException se) {
+ se.printStackTrace();
+ exceptionOccurred = true;
+ }
+ }
+ if (exceptionOccurred) {
+ positioningListener.setActiveLooper(false);
+ locationManager.removeUpdates(positioningListener);
+ return QT_ACCESS_ERROR;
+ }
+
+ if (!expectedProvidersAvailable(locationProvider)) {
+ //all location providers unavailable -> when they come back we resume automatically
+ //in the mean time return ClosedError
+ return QT_CLOSED_ERROR;
+ }
+
+ runningListeners.put(androidClassKey, positioningListener);
+ } catch(Exception e) {
+ e.printStackTrace();
+ return QT_POSITION_UNKNOWN_SOURCE_ERROR;
+ }
+
+ return QT_POSITION_NO_ERROR;
+ }
+ }
+
+ static public int startSatelliteUpdates(int androidClassKey, int updateInterval, boolean isSingleRequest)
+ {
+ synchronized (m_syncObject) {
+ try {
+ boolean exceptionOccurred = false;
+ QtPositioning positioningListener = new QtPositioning();
+ positioningListener.isSatelliteUpdate = true;
+ positioningListener.setActiveLooper(true);
+ positioningListener.nativeClassReference = androidClassKey;
+ positioningListener.expectedProviders = 1; //always satellite provider
+ positioningListener.isSingleUpdate = isSingleRequest;
+
+ if (updateInterval == 0)
+ updateInterval = 1000; //don't update more often than once per second
+
+ if (isSingleRequest)
+ Log.d(TAG, "Single update for Satellites " + updateInterval);
+ else
+ Log.d(TAG, "Regular updates for Satellites " + updateInterval);
+ try {
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
+ updateInterval, 0,
+ positioningListener,
+ positioningListener.looper());
+ } catch (SecurityException se) {
+ se.printStackTrace();
+ exceptionOccurred = true;
+ }
+
+ if (exceptionOccurred) {
+ positioningListener.setActiveLooper(false);
+ locationManager.removeUpdates(positioningListener);
+ return QT_ACCESS_ERROR;
+ }
+
+ if (!expectedProvidersAvailable(positioningListener.expectedProviders)) {
+ //all location providers unavailable -> when they come back we resume automatically
+ //in the mean time return ClosedError
+ return QT_CLOSED_ERROR;
+ }
+
+ runningListeners.put(androidClassKey, positioningListener);
+ } catch(Exception e) {
+ e.printStackTrace();
+ return QT_SATELLITE_UNKNOWN_SOURCE_ERROR;
+ }
+
+ return QT_SATELLITE_NO_ERROR;
+ }
+ }
+
+ public QtPositioning()
+ {
+ looperThread = new PositioningLooper();
+ }
+
+ public Looper looper()
+ {
+ return looperThread.looper();
+ }
+
+ private void setActiveLooper(boolean setActive)
+ {
+ try{
+ if (setActive) {
+ if (looperThread.isAlive())
+ return;
+
+ if (isSatelliteUpdate)
+ looperThread.isSatelliteListener(true);
+
+ looperThread.start();
+ while (!looperThread.isReady());
+ Thread.sleep(1000);
+ } else {
+ looperThread.quitLooper();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private class PositioningLooper extends Thread implements GpsStatus.Listener{
+ private boolean looperRunning;
+ private Looper posLooper;
+ private boolean isSatelliteLooper = false;
+ private LocationManager locManager = null;
+
+ private PositioningLooper()
+ {
+ looperRunning = false;
+ }
+
+ public void run()
+ {
+ Looper.prepare();
+ Handler handler = new Handler();
+ looperRunning = true;
+
+ if (isSatelliteLooper) {
+ try {
+ locationManager.addGpsStatusListener(this);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ posLooper = Looper.myLooper();
+ Looper.loop();
+ looperRunning = false;
+ }
+
+ public void quitLooper()
+ {
+ if (isSatelliteLooper)
+ locationManager.removeGpsStatusListener(this);
+ looper().quit();
+ }
+
+ public boolean isReady()
+ {
+ return looperRunning;
+ }
+
+ public void isSatelliteListener(boolean isListener)
+ {
+ isSatelliteLooper = isListener;
+ }
+
+ public Looper looper()
+ {
+ return posLooper;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ break;
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ GpsStatus status = locationManager.getGpsStatus(null);
+ Iterable<GpsSatellite> iterable = status.getSatellites();
+ Iterator<GpsSatellite> it = iterable.iterator();
+
+ ArrayList<GpsSatellite> list = new ArrayList<GpsSatellite>();
+ while (it.hasNext()) {
+ GpsSatellite sat = (GpsSatellite) it.next();
+ list.add(sat);
+ }
+ GpsSatellite[] sats = list.toArray(new GpsSatellite[list.size()]);
+ satelliteUpdated(sats, nativeClassReference, isSingleUpdate);
+
+ break;
+ case GpsStatus.GPS_EVENT_STARTED:
+ break;
+ case GpsStatus.GPS_EVENT_STOPPED:
+ break;
+ }
+ }
+ }
+
+
+
+ public static native void positionUpdated(Location update, int androidClassKey, boolean isSingleUpdate);
+ public static native void locationProvidersDisabled(int androidClassKey);
+ public static native void satelliteUpdated(GpsSatellite[] update, int androidClassKey, boolean isSingleUpdate);
+
+ @Override
+ public void onLocationChanged(Location location) {
+ //Log.d(TAG, "**** Position Update ****: " + location.toString() + " " + isSingleUpdate);
+ if (location == null)
+ return;
+
+ if (isSatelliteUpdate) //we are a QGeoSatelliteInfoSource -> ignore
+ return;
+
+ if (isSingleUpdate || expectedProviders < 3) {
+ positionUpdated(location, nativeClassReference, isSingleUpdate);
+ return;
+ }
+
+ /*
+ We can use GPS and Network, pick the better location provider.
+ Generally we prefer GPS data due to their higher accurancy but we
+ let Network data pass until GPS fix is available
+ */
+
+ if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) {
+ lastGps = location;
+
+ // assumption: GPS always better -> pass it on
+ positionUpdated(location, nativeClassReference, isSingleUpdate);
+ } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) {
+ lastNetwork = location;
+
+ if (lastGps == null) { //no GPS fix yet use network location
+ positionUpdated(location, nativeClassReference, isSingleUpdate);
+ return;
+ }
+
+ long delta = location.getTime() - lastGps.getTime();
+
+ // Ignore if network update is older than last GPS (delta < 0)
+ // Ignore if gps update still has time to provide next location (delta < updateInterval)
+ if (delta < updateIntervalTime)
+ return;
+
+ // Use network data -> GPS has timed out on updateInterval
+ positionUpdated(location, nativeClassReference, isSingleUpdate);
+ }
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {}
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ Log.d(TAG, "Enabled provider: " + provider);
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ Log.d(TAG, "Disabled provider: " + provider);
+ if (!expectedProvidersAvailable(expectedProviders))
+ locationProvidersDisabled(nativeClassReference);
+ }
+}
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
new file mode 100644
index 00000000..6b49b9fe
--- /dev/null
+++ b/src/plugins/position/android/src/jnipositioning.cpp
@@ -0,0 +1,568 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDateTime>
+#include <QDebug>
+#include <QMap>
+#include <QtGlobal>
+#include <android/log.h>
+#include <jni.h>
+#include <QGeoPositionInfo>
+#include "qgeopositioninfosource_android_p.h"
+#include "qgeosatelliteinfosource_android_p.h"
+
+#include "jnipositioning.h"
+
+static JavaVM *javaVM = 0;
+jclass positioningClass;
+
+static jmethodID providerListMethodId;
+static jmethodID lastKnownPositionMethodId;
+static jmethodID startUpdatesMethodId;
+static jmethodID stopUpdatesMethodId;
+static jmethodID requestUpdateMethodId;
+static jmethodID startSatelliteUpdatesMethodId;
+
+static const char logTag[] = "QtPositioning";
+static const char classErrorMsg[] = "Can't find class \"%s\"";
+static const char methodErrorMsg[] = "Can't find method \"%s%s\"";
+
+namespace AndroidPositioning {
+ typedef QMap<int, QGeoPositionInfoSourceAndroid * > PositionSourceMap;
+ typedef QMap<int, QGeoSatelliteInfoSourceAndroid * > SatelliteSourceMap;
+
+ Q_GLOBAL_STATIC(PositionSourceMap, idToPosSource)
+
+ Q_GLOBAL_STATIC(SatelliteSourceMap, idToSatSource)
+
+ struct AttachedJNIEnv
+ {
+ AttachedJNIEnv()
+ {
+ attached = false;
+ if (javaVM->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) < 0) {
+ if (javaVM->AttachCurrentThread(&jniEnv, NULL) < 0) {
+ __android_log_print(ANDROID_LOG_ERROR, logTag, "AttachCurrentThread failed");
+ jniEnv = 0;
+ return;
+ }
+ attached = true;
+ }
+ }
+
+ ~AttachedJNIEnv()
+ {
+ if (attached)
+ javaVM->DetachCurrentThread();
+ }
+ bool attached;
+ JNIEnv *jniEnv;
+ };
+
+ int registerPositionInfoSource(QObject *obj)
+ {
+ static bool firstInit = true;
+ if (firstInit) {
+ qsrand( QDateTime::currentDateTime().toTime_t() );
+ firstInit = false;
+ }
+
+ int key = -1;
+ if (obj->inherits("QGeoPositionInfoSource")) {
+ QGeoPositionInfoSourceAndroid *src = qobject_cast<QGeoPositionInfoSourceAndroid *>(obj);
+ Q_ASSERT(src);
+ do {
+ key = qrand();
+ } while (idToPosSource()->contains(key));
+
+ idToPosSource()->insert(key, src);
+ } else if (obj->inherits("QGeoSatelliteInfoSource")) {
+ QGeoSatelliteInfoSourceAndroid *src = qobject_cast<QGeoSatelliteInfoSourceAndroid *>(obj);
+ Q_ASSERT(src);
+ do {
+ key = qrand();
+ } while (idToSatSource()->contains(key));
+
+ idToSatSource()->insert(key, src);
+ }
+
+ return key;
+ }
+
+ void unregisterPositionInfoSource(int key)
+ {
+ idToPosSource()->remove(key);
+ idToSatSource()->remove(key);
+ }
+
+ enum PositionProvider
+ {
+ PROVIDER_GPS = 0,
+ PROVIDER_NETWORK = 1,
+ PROVIDER_PASSIVE = 2
+ };
+
+
+ QGeoPositionInfoSource::PositioningMethods availableProviders()
+ {
+ QGeoPositionInfoSource::PositioningMethods ret =
+ static_cast<QGeoPositionInfoSource::PositioningMethods>(0);
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return ret;
+ jintArray jProviders = static_cast<jintArray>(env.jniEnv->CallStaticObjectMethod(
+ positioningClass, providerListMethodId));
+ jint *providers = env.jniEnv->GetIntArrayElements(jProviders, 0);
+ const uint size = env.jniEnv->GetArrayLength(jProviders);
+ for (uint i = 0; i < size; i++) {
+ switch (providers[i]) {
+ case PROVIDER_GPS:
+ ret |= QGeoPositionInfoSource::SatellitePositioningMethods;
+ break;
+ case PROVIDER_NETWORK:
+ ret |= QGeoPositionInfoSource::NonSatellitePositioningMethods;
+ break;
+ case PROVIDER_PASSIVE:
+ //we ignore as Qt doesn't have interface for it right now
+ break;
+ default:
+ __android_log_print(ANDROID_LOG_INFO, logTag, "Unknown positioningMethod");
+ }
+ }
+ env.jniEnv->ReleaseIntArrayElements(jProviders, providers, 0);
+
+ return ret;
+ }
+
+ //caching originally taken from corelib/kernel/qjni.cpp
+ typedef QHash<QByteArray, jmethodID> JMethodIDHash;
+ Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID)
+
+ static jmethodID getCachedMethodID(JNIEnv *env,
+ jclass clazz,
+ const char *name,
+ const char *sig)
+ {
+ jmethodID id = 0;
+ int offset_name = qstrlen(name);
+ int offset_signal = qstrlen(sig);
+ QByteArray key(offset_name + offset_signal, Qt::Uninitialized);
+ memcpy(key.data(), name, offset_name);
+ memcpy(key.data()+offset_name, sig, offset_signal);
+ QHash<QByteArray, jmethodID>::iterator it = cachedMethodID->find(key);
+ if (it == cachedMethodID->end()) {
+ id = env->GetMethodID(clazz, name, sig);
+ if (env->ExceptionCheck()) {
+ id = 0;
+ #ifdef QT_DEBUG
+ env->ExceptionDescribe();
+ #endif // QT_DEBUG
+ env->ExceptionClear();
+ }
+
+ cachedMethodID->insert(key, id);
+ } else {
+ id = it.value();
+ }
+ return id;
+ }
+
+ QGeoPositionInfo positionInfoFromJavaLocation(JNIEnv * jniEnv, const jobject &location)
+ {
+ QGeoPositionInfo info;
+ jclass thisClass = jniEnv->GetObjectClass(location);
+ if (!thisClass)
+ return QGeoPositionInfo();
+
+ jmethodID mid = getCachedMethodID(jniEnv, thisClass, "getLatitude", "()D");
+ jdouble latitude = jniEnv->CallDoubleMethod(location, mid);
+ mid = getCachedMethodID(jniEnv, thisClass, "getLongitude", "()D");
+ jdouble longitude = jniEnv->CallDoubleMethod(location, mid);
+ QGeoCoordinate coordinate(latitude, longitude);
+
+ //altitude
+ mid = getCachedMethodID(jniEnv, thisClass, "hasAltitude", "()Z");
+ jboolean attributeExists = jniEnv->CallBooleanMethod(location, mid);
+ if (attributeExists) {
+ mid = getCachedMethodID(jniEnv, thisClass, "getAltitude", "()D");
+ jdouble value = jniEnv->CallDoubleMethod(location, mid);
+ coordinate.setAltitude(value);
+ }
+
+ info.setCoordinate(coordinate);
+
+ //time stamp
+ mid = getCachedMethodID(jniEnv, thisClass, "getTime", "()J");
+ jlong timestamp = jniEnv->CallLongMethod(location, mid);
+ info.setTimestamp(QDateTime::fromMSecsSinceEpoch(timestamp));
+
+ //accuracy
+ mid = getCachedMethodID(jniEnv, thisClass, "hasAccuracy", "()Z");
+ attributeExists = jniEnv->CallBooleanMethod(location, mid);
+ if (attributeExists) {
+ mid = getCachedMethodID(jniEnv, thisClass, "getAccuracy", "()F");
+ jfloat accuracy = jniEnv->CallFloatMethod(location, mid);
+ info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
+ }
+
+ //ground speed
+ mid = getCachedMethodID(jniEnv, thisClass, "hasSpeed", "()Z");
+ attributeExists = jniEnv->CallBooleanMethod(location, mid);
+ if (attributeExists) {
+ mid = getCachedMethodID(jniEnv, thisClass, "getSpeed", "()F");
+ jfloat speed = jniEnv->CallFloatMethod(location, mid);
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
+ }
+
+ //bearing
+ mid = getCachedMethodID(jniEnv, thisClass, "hasBearing", "()Z");
+ attributeExists = jniEnv->CallBooleanMethod(location, mid);
+ if (attributeExists) {
+ mid = getCachedMethodID(jniEnv, thisClass, "getBearing", "()F");
+ jfloat bearing = jniEnv->CallFloatMethod(location, mid);
+ info.setAttribute(QGeoPositionInfo::Direction, bearing);
+ }
+
+ return info;
+ }
+
+ QList<QGeoSatelliteInfo> satelliteInfoFromJavaLocation(JNIEnv *jniEnv,
+ jobjectArray satellites,
+ QList<QGeoSatelliteInfo>* usedInFix)
+ {
+ QList<QGeoSatelliteInfo> sats;
+ jsize length = jniEnv->GetArrayLength(satellites);
+ for (int i = 0; i<length; i++) {
+ jobject element = jniEnv->GetObjectArrayElement(satellites, i);
+ if (jniEnv->ExceptionOccurred()) {
+ qWarning() << "Cannot process all satellite data due to exception.";
+ break;
+ }
+
+ jclass thisClass = jniEnv->GetObjectClass(element);
+ if (!thisClass)
+ continue;
+
+ QGeoSatelliteInfo info;
+
+ //signal strength
+ jmethodID mid = getCachedMethodID(jniEnv, thisClass, "getSnr", "()F");
+ jfloat snr = jniEnv->CallFloatMethod(element, mid);
+ info.setSignalStrength((int)snr);
+
+ //ignore any satellite with no signal whatsoever
+ if (qFuzzyIsNull(snr))
+ continue;
+
+ //prn
+ mid = getCachedMethodID(jniEnv, thisClass, "getPrn", "()I");
+ jint prn = jniEnv->CallIntMethod(element, mid);
+ info.setSatelliteIdentifier(prn);
+
+ if (prn >= 1 && prn <= 32)
+ info.setSatelliteSystem(QGeoSatelliteInfo::GPS);
+ else if (prn >= 65 && prn <= 96)
+ info.setSatelliteSystem(QGeoSatelliteInfo::GLONASS);
+
+ //azimuth
+ mid = getCachedMethodID(jniEnv, thisClass, "getAzimuth", "()F");
+ jfloat azimuth = jniEnv->CallFloatMethod(element, mid);
+ info.setAttribute(QGeoSatelliteInfo::Azimuth, azimuth);
+
+ //elevation
+ mid = getCachedMethodID(jniEnv, thisClass, "getElevation", "()F");
+ jfloat elevation = jniEnv->CallFloatMethod(element, mid);
+ info.setAttribute(QGeoSatelliteInfo::Elevation, elevation);
+
+ //used in a fix
+ mid = getCachedMethodID(jniEnv, thisClass, "usedInFix", "()Z");
+ jboolean inFix = jniEnv->CallBooleanMethod(element, mid);
+
+ sats.append(info);
+
+ if (inFix)
+ usedInFix->append(info);
+
+ jniEnv->DeleteLocalRef(thisClass);
+ jniEnv->DeleteLocalRef(element);
+ }
+
+ return sats;
+ }
+
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly)
+ {
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return QGeoPositionInfo();
+
+ jobject location = env.jniEnv->CallStaticObjectMethod(positioningClass,
+ lastKnownPositionMethodId,
+ fromSatellitePositioningMethodsOnly);
+ if (location == 0)
+ return QGeoPositionInfo();
+
+ return positionInfoFromJavaLocation(env.jniEnv, location);
+ }
+
+ inline int positioningMethodToInt(QGeoPositionInfoSource::PositioningMethods m)
+ {
+ int providerSelection = 0;
+ if (m & QGeoPositionInfoSource::SatellitePositioningMethods)
+ providerSelection |= 1;
+ if (m & QGeoPositionInfoSource::NonSatellitePositioningMethods)
+ providerSelection |= 2;
+
+ return providerSelection;
+ }
+
+ QGeoPositionInfoSource::Error startUpdates(int androidClassKey)
+ {
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return QGeoPositionInfoSource::UnknownSourceError;
+
+ QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
+
+ if (source) {
+ int errorCode = env.jniEnv->CallStaticIntMethod(positioningClass, startUpdatesMethodId,
+ androidClassKey,
+ positioningMethodToInt(source->preferredPositioningMethods()),
+ source->updateInterval());
+ switch (errorCode) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ return static_cast<QGeoPositionInfoSource::Error>(errorCode);
+ default:
+ break;
+ }
+ }
+
+ return QGeoPositionInfoSource::UnknownSourceError;
+ }
+
+ //used for stopping regular and single updates
+ void stopUpdates(int androidClassKey)
+ {
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return;
+
+ env.jniEnv->CallStaticVoidMethod(positioningClass, stopUpdatesMethodId, androidClassKey);
+ }
+
+ QGeoPositionInfoSource::Error requestUpdate(int androidClassKey)
+ {
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return QGeoPositionInfoSource::UnknownSourceError;
+
+ QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
+
+ if (source) {
+ int errorCode = env.jniEnv->CallStaticIntMethod(positioningClass, requestUpdateMethodId,
+ androidClassKey,
+ positioningMethodToInt(source->preferredPositioningMethods()));
+ switch (errorCode) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ return static_cast<QGeoPositionInfoSource::Error>(errorCode);
+ default:
+ break;
+ }
+ }
+ return QGeoPositionInfoSource::UnknownSourceError;
+ }
+
+ QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey, bool isSingleRequest, int requestTimeout)
+ {
+ AttachedJNIEnv env;
+ if (!env.jniEnv)
+ return QGeoSatelliteInfoSource::UnknownSourceError;
+
+ QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
+
+ if (source) {
+ int interval = source->updateInterval();
+ if (isSingleRequest)
+ interval = requestTimeout;
+ int errorCode = env.jniEnv->CallStaticIntMethod(positioningClass, startSatelliteUpdatesMethodId,
+ androidClassKey,
+ interval, isSingleRequest);
+ switch (errorCode) {
+ case -1:
+ case 0:
+ case 1:
+ case 2:
+ return static_cast<QGeoSatelliteInfoSource::Error>(errorCode);
+ default:
+ qWarning() << "startSatelliteUpdates: Unknown error code " << errorCode;
+ break;
+ }
+ }
+ return QGeoSatelliteInfoSource::UnknownSourceError;
+ }
+}
+
+
+static void positionUpdated(JNIEnv *env, jobject /*thiz*/, jobject location, jint androidClassKey, jboolean isSingleUpdate)
+{
+ QGeoPositionInfo info = AndroidPositioning::positionInfoFromJavaLocation(env, location);
+
+ QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
+ if (!source) {
+ qFatal("positionUpdated: source == 0");
+ return;
+ }
+
+ //we need to invoke indirectly as the Looper thread is likely to be not the same thread
+ if (!isSingleUpdate)
+ QMetaObject::invokeMethod(source, "processPositionUpdate", Qt::AutoConnection,
+ Q_ARG(QGeoPositionInfo, info));
+ else
+ QMetaObject::invokeMethod(source, "processSinglePositionUpdate", Qt::AutoConnection,
+ Q_ARG(QGeoPositionInfo, info));
+}
+
+static void locationProvidersDisabled(JNIEnv *env, jobject /*thiz*/, jint androidClassKey)
+{
+ Q_UNUSED(env);
+ QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
+ if (!source)
+ source = AndroidPositioning::idToSatSource()->value(androidClassKey);
+ if (!source) {
+ qFatal("locationProvidersDisabled: source == 0");
+ return;
+ }
+
+ QMetaObject::invokeMethod(source, "locationProviderDisabled", Qt::AutoConnection);
+}
+
+static void satelliteUpdated(JNIEnv *env, jobject /*thiz*/, jobjectArray satellites, jint androidClassKey, jboolean isSingleUpdate)
+{
+ QList<QGeoSatelliteInfo> inUse;
+ QList<QGeoSatelliteInfo> sats = AndroidPositioning::satelliteInfoFromJavaLocation(env, satellites, &inUse);
+
+ QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
+ if (!source) {
+ qFatal("satelliteUpdated: source == 0");
+ return;
+ }
+
+ QMetaObject::invokeMethod(source, "processSatelliteUpdateInView", Qt::AutoConnection,
+ Q_ARG(QList<QGeoSatelliteInfo>, sats), Q_ARG(bool, isSingleUpdate));
+
+ QMetaObject::invokeMethod(source, "processSatelliteUpdateInUse", Qt::AutoConnection,
+ Q_ARG(QList<QGeoSatelliteInfo>, inUse), Q_ARG(bool, isSingleUpdate));
+}
+
+
+#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
+clazz = env->FindClass(CLASS_NAME); \
+if (!clazz) { \
+ __android_log_print(ANDROID_LOG_FATAL, logTag, classErrorMsg, CLASS_NAME); \
+ return JNI_FALSE; \
+}
+
+#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
+VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
+if (!VAR) { \
+ __android_log_print(ANDROID_LOG_FATAL, logTag, methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); \
+ return JNI_FALSE; \
+}
+
+static JNINativeMethod methods[] = {
+ {"positionUpdated", "(Landroid/location/Location;IZ)V", (void *)positionUpdated},
+ {"locationProvidersDisabled", "(I)V", (void *) locationProvidersDisabled},
+ {"satelliteUpdated", "([Landroid/location/GpsSatellite;IZ)V", (void *)satelliteUpdated}
+};
+
+static bool registerNatives(JNIEnv *env)
+{
+ jclass clazz;
+ FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/positioning/QtPositioning");
+ positioningClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ if (env->RegisterNatives(positioningClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "RegisterNatives failed");
+ return JNI_FALSE;
+ }
+
+ GET_AND_CHECK_STATIC_METHOD(providerListMethodId, positioningClass, "providerList", "()[I");
+ GET_AND_CHECK_STATIC_METHOD(lastKnownPositionMethodId, positioningClass, "lastKnownPosition", "(Z)Landroid/location/Location;");
+ GET_AND_CHECK_STATIC_METHOD(startUpdatesMethodId, positioningClass, "startUpdates", "(III)I");
+ GET_AND_CHECK_STATIC_METHOD(stopUpdatesMethodId, positioningClass, "stopUpdates", "(I)V");
+ GET_AND_CHECK_STATIC_METHOD(requestUpdateMethodId, positioningClass, "requestUpdate", "(II)I");
+ GET_AND_CHECK_STATIC_METHOD(startSatelliteUpdatesMethodId, positioningClass, "startSatelliteUpdates", "(IIZ)I");
+
+ return true;
+}
+
+Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
+{
+ typedef union {
+ JNIEnv *nativeEnvironment;
+ void *venv;
+ } UnionJNIEnvToVoid;
+
+ __android_log_print(ANDROID_LOG_INFO, logTag, "Positioning start");
+ UnionJNIEnvToVoid uenv;
+ uenv.venv = NULL;
+ javaVM = 0;
+
+ if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
+ return -1;
+ }
+ JNIEnv *env = uenv.nativeEnvironment;
+ if (!registerNatives(env)) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives failed");
+ return -1;
+ }
+
+ javaVM = vm;
+ return JNI_VERSION_1_4;
+}
+
diff --git a/src/plugins/position/android/src/jnipositioning.h b/src/plugins/position/android/src/jnipositioning.h
new file mode 100644
index 00000000..51341720
--- /dev/null
+++ b/src/plugins/position/android/src/jnipositioning.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JNIPOSITIONING_H
+#define JNIPOSITIONING_H
+
+#include <QGeoPositionInfoSource>
+#include <QGeoSatelliteInfoSource>
+
+namespace AndroidPositioning
+{
+ int registerPositionInfoSource(QObject *obj);
+ void unregisterPositionInfoSource(int key);
+
+ QGeoPositionInfoSource::PositioningMethods availableProviders();
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly);
+
+ QGeoPositionInfoSource::Error startUpdates(int androidClassKey);
+ void stopUpdates(int androidClassKey);
+ QGeoPositionInfoSource::Error requestUpdate(int androidClassKey);
+
+ QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey,
+ bool isSingleRequest,
+ int updateRequestTimeout);
+}
+
+#endif // JNIPOSITIONING_H
diff --git a/src/plugins/position/android/src/plugin.json b/src/plugins/position/android/src/plugin.json
new file mode 100644
index 00000000..b84fafea
--- /dev/null
+++ b/src/plugins/position/android/src/plugin.json
@@ -0,0 +1,8 @@
+{
+ "Keys": ["android"],
+ "Provider": "android",
+ "Position": true,
+ "Satellite": true,
+ "Monitor": false,
+ "Priority": 1000
+}
diff --git a/src/plugins/position/android/src/positionfactory_android.cpp b/src/plugins/position/android/src/positionfactory_android.cpp
new file mode 100644
index 00000000..047c313d
--- /dev/null
+++ b/src/plugins/position/android/src/positionfactory_android.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "positionfactory_android.h"
+#include "qgeopositioninfosource_android_p.h"
+#include "qgeosatelliteinfosource_android_p.h"
+
+QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryAndroid::positionInfoSource(QObject *parent)
+{
+ QGeoPositionInfoSourceAndroid *src = new QGeoPositionInfoSourceAndroid(parent);
+ return src;
+}
+
+QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryAndroid::satelliteInfoSource(QObject *parent)
+{
+ QGeoSatelliteInfoSourceAndroid *src = new QGeoSatelliteInfoSourceAndroid(parent);
+ return src;
+}
+
+QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryAndroid::areaMonitor(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
diff --git a/src/location/maps/qgeocoordinateinterpolator_p.h b/src/plugins/position/android/src/positionfactory_android.h
index 1b75bfb4..4b7818d4 100644
--- a/src/location/maps/qgeocoordinateinterpolator_p.h
+++ b/src/plugins/position/android/src/positionfactory_android.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtLocation module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -38,34 +38,23 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGEOCOORDINATEINTERPOLATOR_P_H
-#define QGEOCOORDINATEINTERPOLATOR_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.
-//
+#ifndef POSITIONPOLLFACTORY_H
+#define POSITIONPOLLFACTORY_H
-#include <QtPositioning/QGeoCoordinate>
-#include <QtLocation/qlocationglobal.h>
+#include <QObject>
+#include <QGeoPositionInfoSourceFactory>
-QT_BEGIN_NAMESPACE
-
-class Q_LOCATION_EXPORT QGeoCoordinateInterpolator
+class QGeoPositionInfoSourceFactoryAndroid : public QObject, public QGeoPositionInfoSourceFactory
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
+ FILE "plugin.json")
+ Q_INTERFACES(QGeoPositionInfoSourceFactory)
public:
- QGeoCoordinateInterpolator();
- virtual ~QGeoCoordinateInterpolator();
-
- virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress) = 0;
+ QGeoPositionInfoSource *positionInfoSource(QObject *parent);
+ QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitorSource *areaMonitor(QObject *parent);
};
-QT_END_NAMESPACE
-
-#endif // QGEOCOORDINATEINTERPOLATOR_P_H
+#endif // POSITIONPOLLFACTORY_H
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
new file mode 100644
index 00000000..d4a95aa3
--- /dev/null
+++ b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_android_p.h"
+#include "jnipositioning.h"
+//#include <QDebug>
+#include <QGeoPositionInfo>
+
+Q_DECLARE_METATYPE(QGeoPositionInfo)
+#define UPDATE_FROM_COLD_START 2*60*1000
+
+
+QGeoPositionInfoSourceAndroid::QGeoPositionInfoSourceAndroid(QObject *parent) :
+ QGeoPositionInfoSource(parent), updatesRunning(false), m_error(UnknownSourceError)
+{
+ qRegisterMetaType< QGeoPositionInfo >();
+ androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
+ androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
+
+ //qDebug() << "androidClassKey: " << androidClassKeyForUpdate << androidClassKeyForSingleRequest;
+ //by default use all methods
+ setPreferredPositioningMethods(AllPositioningMethods);
+
+ m_requestTimer.setSingleShot(true);
+ QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeout()));
+}
+
+QGeoPositionInfoSourceAndroid::~QGeoPositionInfoSourceAndroid()
+{
+ stopUpdates();
+
+ if (m_requestTimer.isActive()) {
+ m_requestTimer.stop();
+ AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
+ }
+
+ AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
+ AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
+}
+
+void QGeoPositionInfoSourceAndroid::setUpdateInterval(int msec)
+{
+ int previousInterval = updateInterval();
+ msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
+
+ if (msec == previousInterval)
+ return;
+
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+
+ if (updatesRunning)
+ reconfigureRunningSystem();
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceAndroid::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ return AndroidPositioning::lastKnownPosition(fromSatellitePositioningMethodsOnly);
+}
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceAndroid::supportedPositioningMethods() const
+{
+ return AndroidPositioning::availableProviders();
+}
+
+void QGeoPositionInfoSourceAndroid::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
+{
+ PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
+ QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
+ if (previousPreferredPositioningMethods == preferredPositioningMethods())
+ return;
+
+ if (updatesRunning)
+ reconfigureRunningSystem();
+}
+
+int QGeoPositionInfoSourceAndroid::minimumUpdateInterval() const
+{
+ return 1000;
+}
+
+QGeoPositionInfoSource::Error QGeoPositionInfoSourceAndroid::error() const
+{
+ return m_error;
+}
+
+void QGeoPositionInfoSourceAndroid::startUpdates()
+{
+ if (updatesRunning)
+ return;
+
+ if (preferredPositioningMethods() == 0) {
+ m_error = UnknownSourceError;
+ emit QGeoPositionInfoSource::error(m_error);
+
+ return;
+ }
+
+ updatesRunning = true;
+ QGeoPositionInfoSource::Error error = AndroidPositioning::startUpdates(androidClassKeyForUpdate);
+ //if (error != QGeoPositionInfoSource::NoError) { //TODO
+ if (error != 3) {
+ updatesRunning = false;
+ m_error = error;
+ emit QGeoPositionInfoSource::error(m_error);
+ }
+}
+
+void QGeoPositionInfoSourceAndroid::stopUpdates()
+{
+ if (!updatesRunning)
+ return;
+
+ updatesRunning = false;
+ AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
+}
+
+void QGeoPositionInfoSourceAndroid::requestUpdate(int timeout)
+{
+ if (m_requestTimer.isActive())
+ return;
+
+ if (timeout != 0 && timeout < minimumUpdateInterval()) {
+ emit updateTimeout();
+ return;
+ }
+
+ if (timeout == 0)
+ timeout = UPDATE_FROM_COLD_START;
+
+ m_requestTimer.start(timeout);
+
+ // if updates already running with interval equal to timeout
+ // then we wait for next update coming through
+ // assume that a single update will not be quicker than regular updates anyway
+ if (updatesRunning && updateInterval() <= timeout)
+ return;
+
+ QGeoPositionInfoSource::Error error = AndroidPositioning::requestUpdate(androidClassKeyForSingleRequest);
+ //if (error != QGeoPositionInfoSource::NoError) { //TODO
+ if (error != 3) {
+ m_requestTimer.stop();
+ m_error = error;
+ emit QGeoPositionInfoSource::error(m_error);
+ }
+}
+
+void QGeoPositionInfoSourceAndroid::processPositionUpdate(const QGeoPositionInfo &pInfo)
+{
+ //single update request and served as part of regular update
+ if (m_requestTimer.isActive())
+ m_requestTimer.stop();
+
+ emit positionUpdated(pInfo);
+}
+
+// Might still be called multiple times (once for each provider)
+void QGeoPositionInfoSourceAndroid::processSinglePositionUpdate(const QGeoPositionInfo &pInfo)
+{
+ //timeout but we received a late update -> ignore
+ if (!m_requestTimer.isActive())
+ return;
+
+ queuedSingleUpdates.append(pInfo);
+}
+
+void QGeoPositionInfoSourceAndroid::locationProviderDisabled()
+{
+ m_error = QGeoPositionInfoSource::ClosedError;
+ emit QGeoPositionInfoSource::error(m_error);
+}
+
+void QGeoPositionInfoSourceAndroid::requestTimeout()
+{
+ AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
+ //no queued update to process -> timeout
+ const int count = queuedSingleUpdates.count();
+
+ if (!count) {
+ emit updateTimeout();
+ return;
+ }
+
+ //pick best
+ QGeoPositionInfo best = queuedSingleUpdates[0];
+ for (int i = 1; i < count; i++) {
+ const QGeoPositionInfo info = queuedSingleUpdates[i];
+
+ //anything newer by 20s is always better
+ const int timeDelta = best.timestamp().secsTo(info.timestamp());
+ if (abs(timeDelta) > 20) {
+ if (timeDelta > 0)
+ best = info;
+ continue;
+ }
+
+ //compare accuracy
+ if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy) &&
+ info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ {
+ best = info.attribute(QGeoPositionInfo::HorizontalAccuracy) <
+ best.attribute(QGeoPositionInfo::HorizontalAccuracy) ? info : best;
+ continue;
+ }
+
+ //prefer info with accuracy information
+ if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ best = info;
+ }
+
+ queuedSingleUpdates.clear();
+ emit positionUpdated(best);
+}
+
+/*
+ Updates the system assuming that updateInterval
+ and/or preferredPositioningMethod have changed.
+ */
+void QGeoPositionInfoSourceAndroid::reconfigureRunningSystem()
+{
+ if (!updatesRunning)
+ return;
+
+ stopUpdates();
+ startUpdates();
+}
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
new file mode 100644
index 00000000..938b6564
--- /dev/null
+++ b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCE_ANDROID_P_H
+#define QGEOPOSITIONINFOSOURCE_ANDROID_P_H
+
+#include <QGeoPositionInfoSource>
+#include <QTimer>
+
+class QGeoPositionInfoSourceAndroid : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+public:
+ QGeoPositionInfoSourceAndroid(QObject *parent = 0);
+ ~QGeoPositionInfoSourceAndroid();
+
+ // From QGeoPositionInfoSource
+ void setUpdateInterval(int msec);
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
+ void setPreferredPositioningMethods(PositioningMethods methods);
+ int minimumUpdateInterval() const;
+ Error error() const;
+
+public Q_SLOTS:
+ virtual void startUpdates();
+ virtual void stopUpdates();
+
+ virtual void requestUpdate(int timeout = 0);
+
+ void processPositionUpdate(const QGeoPositionInfo& pInfo);
+ void processSinglePositionUpdate(const QGeoPositionInfo& pInfo);
+
+ void locationProviderDisabled();
+private Q_SLOTS:
+ void requestTimeout();
+
+private:
+ void reconfigureRunningSystem();
+
+ bool updatesRunning;
+ int androidClassKeyForUpdate;
+ int androidClassKeyForSingleRequest;
+ QList<QGeoPositionInfo> queuedSingleUpdates;
+ Error m_error;
+ QTimer m_requestTimer;
+};
+
+#endif // QGEOPOSITIONINFOSOURCE_ANDROID_P_H
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
new file mode 100644
index 00000000..f9e627d0
--- /dev/null
+++ b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+
+#include "qgeosatelliteinfosource_android_p.h"
+#include "jnipositioning.h"
+
+Q_DECLARE_METATYPE(QGeoSatelliteInfo)
+Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>)
+
+#define UPDATE_FROM_COLD_START 2*60*1000
+
+QGeoSatelliteInfoSourceAndroid::QGeoSatelliteInfoSourceAndroid(QObject *parent) :
+ QGeoSatelliteInfoSource(parent), m_error(NoError), updatesRunning(false)
+{
+ qRegisterMetaType< QGeoSatelliteInfo >();
+ qRegisterMetaType< QList<QGeoSatelliteInfo> >();
+ androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
+ androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
+
+ requestTimer.setSingleShot(true);
+ QObject::connect(&requestTimer, SIGNAL(timeout()),
+ this, SLOT(requestTimeout()));
+}
+
+QGeoSatelliteInfoSourceAndroid::~QGeoSatelliteInfoSourceAndroid()
+{
+ stopUpdates();
+
+ if (requestTimer.isActive()) {
+ requestTimer.stop();
+ AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
+ }
+
+ AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
+ AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
+}
+
+
+void QGeoSatelliteInfoSourceAndroid::setUpdateInterval(int msec)
+{
+ int previousInterval = updateInterval();
+ msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
+
+ if (msec == previousInterval)
+ return;
+
+ QGeoSatelliteInfoSource::setUpdateInterval(msec);
+
+ if (updatesRunning)
+ reconfigureRunningSystem();
+}
+
+int QGeoSatelliteInfoSourceAndroid::minimumUpdateInterval() const
+{
+ return 1000;
+}
+
+QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceAndroid::error() const
+{
+ return m_error;
+}
+
+void QGeoSatelliteInfoSourceAndroid::startUpdates()
+{
+ if (updatesRunning)
+ return;
+
+ updatesRunning = true;
+
+ QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
+ androidClassKeyForUpdate, false, updateInterval());
+ if (error != QGeoSatelliteInfoSource::NoError) {
+ updatesRunning = false;
+ m_error = error;
+ emit QGeoSatelliteInfoSource::error(m_error);
+ }
+}
+
+void QGeoSatelliteInfoSourceAndroid::stopUpdates()
+{
+ if (!updatesRunning)
+ return;
+
+ updatesRunning = false;
+ AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
+}
+
+void QGeoSatelliteInfoSourceAndroid::requestUpdate(int timeout)
+{
+ if (requestTimer.isActive())
+ return;
+
+ if (timeout != 0 && timeout < minimumUpdateInterval()) {
+ emit requestTimeout();
+ return;
+ }
+
+ if (timeout == 0)
+ timeout = UPDATE_FROM_COLD_START;
+
+ requestTimer.start(timeout);
+
+ // if updates already running with interval equal or less then timeout
+ // then we wait for next update coming through
+ // assume that a single update will not be quicker than regular updates anyway
+ if (updatesRunning && updateInterval() <= timeout)
+ return;
+
+ QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
+ androidClassKeyForSingleRequest, true, timeout);
+ if (error != QGeoSatelliteInfoSource::NoError) {
+ requestTimer.stop();
+ m_error = error;
+ emit QGeoSatelliteInfoSource::error(m_error);
+ }
+}
+
+void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate)
+{
+ if (!isSingleUpdate) {
+ //if requested while regular updates were running
+ if (requestTimer.isActive())
+ requestTimer.stop();
+ emit QGeoSatelliteInfoSource::satellitesInViewUpdated(satsInView);
+ return;
+ }
+
+ m_satsInView = satsInView;
+}
+
+void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate)
+{
+ if (!isSingleUpdate) {
+ //if requested while regular updates were running
+ if (requestTimer.isActive())
+ requestTimer.stop();
+ emit QGeoSatelliteInfoSource::satellitesInUseUpdated(satsInUse);
+ return;
+ }
+
+ m_satsInUse = satsInUse;
+}
+
+void QGeoSatelliteInfoSourceAndroid::requestTimeout()
+{
+ AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
+
+ const int count = m_satsInView.count();
+ if (!count) {
+ emit requestTimeout();
+ return;
+ }
+
+ emit QGeoSatelliteInfoSource::satellitesInViewUpdated(m_satsInView);
+ emit QGeoSatelliteInfoSource::satellitesInUseUpdated(m_satsInUse);
+
+ m_satsInUse.clear();
+ m_satsInView.clear();
+}
+
+/*
+ Updates the system assuming that updateInterval
+ and/or preferredPositioningMethod have changed.
+ */
+void QGeoSatelliteInfoSourceAndroid::reconfigureRunningSystem()
+{
+ if (!updatesRunning)
+ return;
+
+ stopUpdates();
+ startUpdates();
+}
+
+void QGeoSatelliteInfoSourceAndroid::locationProviderDisabled()
+{
+ m_error = QGeoSatelliteInfoSource::ClosedError;
+ emit QGeoSatelliteInfoSource::error(m_error);
+}
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
new file mode 100644
index 00000000..75711a3e
--- /dev/null
+++ b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QGEOSATELLITEINFOSOURCEANDROID_H
+#define QGEOSATELLITEINFOSOURCEANDROID_H
+
+#include <QGeoSatelliteInfoSource>
+#include <QTimer>
+
+class QGeoSatelliteInfoSourceAndroid : public QGeoSatelliteInfoSource
+{
+ Q_OBJECT
+public:
+ explicit QGeoSatelliteInfoSourceAndroid(QObject *parent = 0);
+ ~QGeoSatelliteInfoSourceAndroid();
+
+ //From QGeoSatelliteInfoSource
+ void setUpdateInterval(int msec);
+ int minimumUpdateInterval() const;
+
+ Error error() const;
+
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout = 0);
+
+ void processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate);
+ void processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate);
+
+ void locationProviderDisabled();
+private Q_SLOTS:
+ void requestTimeout();
+
+private:
+ void reconfigureRunningSystem();
+
+ Error m_error;
+ int androidClassKeyForUpdate;
+ int androidClassKeyForSingleRequest;
+ bool updatesRunning;
+
+ QTimer requestTimer;
+ QList<QGeoSatelliteInfo> m_satsInUse;
+ QList<QGeoSatelliteInfo> m_satsInView;
+
+};
+
+#endif // QGEOSATELLITEINFOSOURCEANDROID_H
diff --git a/src/plugins/position/android/src/src.pro b/src/plugins/position/android/src/src.pro
new file mode 100644
index 00000000..a61b77b5
--- /dev/null
+++ b/src/plugins/position/android/src/src.pro
@@ -0,0 +1,20 @@
+TARGET = qtposition_android
+QT = core positioning
+
+PLUGIN_TYPE = position
+load(qt_plugin)
+
+
+HEADERS = \
+ positionfactory_android.h \
+ qgeopositioninfosource_android_p.h \
+ jnipositioning.h \
+ qgeosatelliteinfosource_android_p.h
+
+SOURCES = \
+ positionfactory_android.cpp \
+ qgeopositioninfosource_android.cpp \
+ jnipositioning.cpp \
+ qgeosatelliteinfosource_android.cpp
+
+OTHER_FILES = plugin.json
diff --git a/src/plugins/position/corelocation/corelocation.pro b/src/plugins/position/corelocation/corelocation.pro
new file mode 100644
index 00000000..bc65ee5d
--- /dev/null
+++ b/src/plugins/position/corelocation/corelocation.pro
@@ -0,0 +1,23 @@
+TARGET = qtposition_cl
+QT += positioning gui
+
+PLUGIN_TYPE = position
+PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryCL
+load(qt_plugin)
+
+INCLUDEPATH += $$QT.location.includes
+
+OBJECTIVE_SOURCES += \
+ qgeopositioninfosource_cl.mm \
+ qgeopositioninfosourcefactory_cl.mm
+
+HEADERS += \
+ qgeopositioninfosource_cl_p.h \
+ qgeopositioninfosourcefactory_cl.h
+
+OTHER_FILES += \
+ plugin.json
+
+osx: LIBS += -framework Foundation
+else: ios: LIBS += -framework CoreFoundation
+LIBS += -framework CoreLocation
diff --git a/src/plugins/position/corelocation/plugin.json b/src/plugins/position/corelocation/plugin.json
new file mode 100644
index 00000000..96e5cbf1
--- /dev/null
+++ b/src/plugins/position/corelocation/plugin.json
@@ -0,0 +1,8 @@
+{
+ "Keys": ["corelocation"],
+ "Provider": "corelocation",
+ "Position": true,
+ "Satellite": false,
+ "Monitor" : false,
+ "Priority": 1000
+}
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
new file mode 100644
index 00000000..47ceb6b6
--- /dev/null
+++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTimerEvent>
+#include <QDebug>
+
+#include "qgeopositioninfosource_cl_p.h"
+
+#define MINIMUM_UPDATE_INTERVAL 1000
+
+@interface locationDelegate : NSObject <CLLocationManagerDelegate>
+{
+ QGeoPositionInfoSourceCL *m_positionInfoSource;
+}
+@end
+
+@implementation locationDelegate
+- (id)initWithInfoSource:(QGeoPositionInfoSourceCL*) positionInfoSource
+{
+ self = [super init];
+ if (self) {
+ m_positionInfoSource = positionInfoSource;
+ }
+ return self;
+}
+
+- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
+{
+ Q_UNUSED(manager)
+ Q_UNUSED(oldLocation)
+
+ // Convert location timestamp to QDateTime
+ QDateTime timeStamp;
+ NSTimeInterval locationTimeStamp = [newLocation.timestamp timeIntervalSince1970];
+ timeStamp.setTime_t((uint) locationTimeStamp);
+ timeStamp.setTime(timeStamp.time().addMSecs((uint)(locationTimeStamp * 1000) % 1000));
+
+ // Construct position info from location data
+ QGeoPositionInfo location(QGeoCoordinate(newLocation.coordinate.latitude,
+ newLocation.coordinate.longitude,
+ newLocation.altitude),
+ timeStamp);
+ location.setAttribute(QGeoPositionInfo::HorizontalAccuracy, newLocation.horizontalAccuracy);
+ location.setAttribute(QGeoPositionInfo::VerticalAccuracy, newLocation.verticalAccuracy);
+ location.setAttribute(QGeoPositionInfo::Direction, newLocation.course);
+ location.setAttribute(QGeoPositionInfo::GroundSpeed, newLocation.speed);
+
+ m_positionInfoSource->locationDataAvailable(location);
+}
+
+- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
+{
+ Q_UNUSED(manager)
+ m_positionInfoSource->setError(QGeoPositionInfoSource::AccessError);
+
+ qWarning() << QString::fromNSString([error localizedDescription]);
+}
+@end
+
+QT_BEGIN_NAMESPACE
+
+QGeoPositionInfoSourceCL::QGeoPositionInfoSourceCL(QObject *parent)
+ : QGeoPositionInfoSource(parent)
+ , m_locationManager(0)
+ , m_started(false)
+ , m_updateTimer(0)
+ , m_updateTimeout(0)
+ , m_positionError(QGeoPositionInfoSource::UnknownSourceError)
+{
+}
+
+QGeoPositionInfoSourceCL::~QGeoPositionInfoSourceCL()
+{
+ stopUpdates();
+ [m_locationManager release];
+}
+
+void QGeoPositionInfoSourceCL::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);
+
+ // Must timeout if update takes longer than specified interval
+ m_updateTimeout = msec;
+ if (m_started) setTimeoutInterval(m_updateTimeout);
+}
+
+bool QGeoPositionInfoSourceCL::enableLocationManager()
+{
+ if (!m_locationManager) {
+ m_locationManager = [[CLLocationManager alloc] init];
+ m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
+ m_locationManager.delegate = [[locationDelegate alloc] initWithInfoSource:this];
+ }
+
+ return (m_locationManager != 0);
+}
+
+void QGeoPositionInfoSourceCL::setTimeoutInterval(int msec)
+{
+ // Start timeout timer
+ if (m_updateTimer) killTimer(m_updateTimer);
+ if (msec > 0) m_updateTimer = startTimer(msec);
+ else m_updateTimer = 0;
+}
+
+void QGeoPositionInfoSourceCL::startUpdates()
+{
+ if (enableLocationManager()) {
+ [m_locationManager startUpdatingLocation];
+ m_started = true;
+
+ setTimeoutInterval(m_updateTimeout);
+ } else setError(QGeoPositionInfoSource::AccessError);
+}
+
+void QGeoPositionInfoSourceCL::stopUpdates()
+{
+ if (m_locationManager) {
+ [m_locationManager stopUpdatingLocation];
+ m_started = false;
+
+ // Stop timeout timer
+ setTimeoutInterval(0);
+ } else setError(QGeoPositionInfoSource::AccessError);
+}
+
+void QGeoPositionInfoSourceCL::requestUpdate(int timeout)
+{
+ // Get a single update within timeframe
+ if (timeout < minimumUpdateInterval() && timeout != 0)
+ emit updateTimeout();
+ else if (enableLocationManager()) {
+ // This will force LM to generate a new update
+ [m_locationManager stopUpdatingLocation];
+ [m_locationManager startUpdatingLocation];
+
+ setTimeoutInterval(timeout);
+ } else setError(QGeoPositionInfoSource::AccessError);
+}
+
+void QGeoPositionInfoSourceCL::timerEvent( QTimerEvent * event )
+{
+ // Update timed out?
+ if (event->timerId() == m_updateTimer) {
+ emit updateTimeout();
+
+ // Only timeout once since last data
+ setTimeoutInterval(0);
+
+ // Started for single update?
+ if (!m_started) stopUpdates();
+ }
+}
+
+QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceCL::supportedPositioningMethods() const
+{
+ // CoreLocation doesn't say which positioning method(s) it used
+ return QGeoPositionInfoSource::AllPositioningMethods;
+}
+
+int QGeoPositionInfoSourceCL::minimumUpdateInterval() const
+{
+ return MINIMUM_UPDATE_INTERVAL;
+}
+
+void QGeoPositionInfoSourceCL::locationDataAvailable(QGeoPositionInfo location)
+{
+ // Signal position data available
+ m_lastUpdate = location;
+ emit positionUpdated(location);
+
+ // Started for single update?
+ if (!m_started) stopUpdates();
+ // ...otherwise restart timeout timer
+ else setTimeoutInterval(m_updateTimeout);
+}
+
+QGeoPositionInfo QGeoPositionInfoSourceCL::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ Q_UNUSED(fromSatellitePositioningMethodsOnly)
+
+ return m_lastUpdate;
+}
+
+QGeoPositionInfoSource::Error QGeoPositionInfoSourceCL::error() const
+{
+ return m_positionError;
+}
+
+void QGeoPositionInfoSourceCL::setError(QGeoPositionInfoSource::Error positionError)
+{
+ m_positionError = positionError;
+ emit QGeoPositionInfoSource::error(positionError);
+}
+
+#include "moc_qgeopositioninfosource_cl_p.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapmouseevent_p.h b/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
index 34341d07..a73ce70e 100644
--- a/src/imports/location/qdeclarativegeomapmouseevent_p.h
+++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtLocation module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -39,69 +39,61 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEGEOMAPMOUSEEVENT_H
-#define QDECLARATIVEGEOMAPMOUSEEVENT_H
+#ifndef QGEOPOSITIONINFOSOURCECL_H
+#define QGEOPOSITIONINFOSOURCECL_H
-#include <QtPositioning/QGeoCoordinate>
+#import <CoreLocation/CoreLocation.h>
-#include <QtQml/qqml.h>
+#include "qgeopositioninfosource.h"
+#include "qgeopositioninfo.h"
+
+QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeGeoMapMouseEvent : public QObject
+class QGeoPositionInfoSourceCL : public QGeoPositionInfoSource
{
Q_OBJECT
+public:
+ QGeoPositionInfoSourceCL(QObject *parent = 0);
+ ~QGeoPositionInfoSourceCL();
- Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
- Q_PROPERTY(int button READ button)
- Q_PROPERTY(int buttons READ buttons)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(bool wasHeld READ wasHeld)
- Q_PROPERTY(int x READ x)
- Q_PROPERTY(int y READ y)
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate)
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
+ PositioningMethods supportedPositioningMethods() const;
-public:
- explicit QDeclarativeGeoMapMouseEvent(QObject *parent = 0);
- ~QDeclarativeGeoMapMouseEvent();
+ void setUpdateInterval(int msec);
+ int minimumUpdateInterval() const;
+ Error error() const;
- void setAccepted(bool accepted);
- bool accepted() const;
+ void locationDataAvailable(QGeoPositionInfo location);
+ void setError(QGeoPositionInfoSource::Error positionError);
- void setButton(int button);
- int button() const;
+private:
+ bool enableLocationManager();
+ void setTimeoutInterval(int msec);
- void setButtons(int buttons);
- int buttons() const;
+public Q_SLOTS:
+ void startUpdates();
+ void stopUpdates();
- void setModifiers(int modifiers);
- int modifiers() const;
+ void requestUpdate(int timeout = 0);
- void setWasHeld(bool wasHeld);
- bool wasHeld() const;
+protected:
+ virtual void timerEvent(QTimerEvent *event);
- void setX(int x);
- int x() const;
+private:
+ Q_DISABLE_COPY(QGeoPositionInfoSourceCL);
+ CLLocationManager *m_locationManager;
+ bool m_started;
- void setY(int y);
- int y() const;
+ QGeoPositionInfo m_lastUpdate;
- void setCoordinate(const QGeoCoordinate &coordinate);
- QGeoCoordinate coordinate();
+ int m_updateTimer;
+ int m_updateTimeout;
-private:
- bool accepted_;
- int button_;
- int modifiers_;
- bool wasHeld_;
- int x_;
- int y_;
- int buttons_;
- QGeoCoordinate coordinate_;
+ QGeoPositionInfoSource::Error m_positionError;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QDeclarativeGeoMapMouseEvent)
-
-#endif
+#endif // QGEOPOSITIONINFOSOURCECL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
new file mode 100644
index 00000000..2ebbe5fc
--- /dev/null
+++ b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOPOSITIONINFOSOURCEFACTORY_CL_H
+#define QGEOPOSITIONINFOSOURCEFACTORY_CL_H
+
+#include <QObject>
+#include <QGeoPositionInfoSourceFactory>
+
+class QGeoPositionInfoSourceFactoryCL : public QObject, public QGeoPositionInfoSourceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
+ FILE "plugin.json")
+ Q_INTERFACES(QGeoPositionInfoSourceFactory)
+public:
+ QGeoPositionInfoSource *positionInfoSource(QObject *parent);
+ QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitorSource *areaMonitor(QObject *parent);
+};
+
+#endif // QGEOPOSITIONINFOSOURCEFACTORY_CL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
new file mode 100644
index 00000000..6566a255
--- /dev/null
+++ b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeopositioninfosource_cl_p.h"
+#include "qgeopositioninfosourcefactory_cl.h"
+
+QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryCL::positionInfoSource(QObject *parent)
+{
+ return new QGeoPositionInfoSourceCL(parent);
+}
+
+QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryCL::satelliteInfoSource(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
+
+QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryCL::areaMonitor(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return 0;
+}
diff --git a/src/plugins/position/geoclue/qgeocluemaster.cpp b/src/plugins/position/geoclue/qgeocluemaster.cpp
index 7e05564d..a14ad896 100644
--- a/src/plugins/position/geoclue/qgeocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeocluemaster.cpp
@@ -70,6 +70,9 @@ void position_provider_changed(GeoclueMasterClient *client, char *name, char *de
QGeoclueMaster::QGeoclueMaster(QObject *handler)
: m_client(0), m_masterPosition(0), m_handler(handler)
{
+#if !defined(GLIB_VERSION_2_36)
+ g_type_init();
+#endif
}
QGeoclueMaster::~QGeoclueMaster()
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
index ad1fb4d0..259dde6d 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
@@ -280,13 +280,6 @@ void QGeoPositionInfoSourceGeoclueMaster::regularUpdateSucceeded(GeocluePosition
#endif
}
-bool QGeoPositionInfoSourceGeoclueMaster::init()
-{
- g_type_init ();
-
- return true;
-}
-
void QGeoPositionInfoSourceGeoclueMaster::cleanupPositionSource()
{
if (m_pos) {
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
index b9cc42e3..7e980317 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
@@ -78,7 +78,6 @@ public:
PositioningMethods supportedPositioningMethods() const;
void setPreferredPositioningMethods(PositioningMethods methods);
int minimumUpdateInterval() const;
- bool init();
void singleUpdateSucceeded(GeocluePositionFields fields,
int timestamp,
diff --git a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
index 7b507a86..6be7888b 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosourcefactory_geoclue.cpp
@@ -52,23 +52,13 @@ Q_DECLARE_METATYPE(QGeoPositionInfo)
QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGeoclue::positionInfoSource(QObject *parent)
{
qRegisterMetaType<QGeoPositionInfo>();
- QGeoPositionInfoSourceGeoclueMaster *src = new QGeoPositionInfoSourceGeoclueMaster(parent);
- if (!src->init()) {
- delete src;
- src = 0;
- }
- return src;
+ return new QGeoPositionInfoSourceGeoclueMaster(parent);
}
QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGeoclue::satelliteInfoSource(QObject *parent)
{
#ifdef HAS_SATELLITE
- QGeoSatelliteInfoSourceGeoclueMaster *src = new QGeoSatelliteInfoSourceGeoclueMaster(parent);
- if (!src->init()) {
- delete src;
- src = 0;
- }
- return src;
+ return new QGeoSatelliteInfoSourceGeoclueMaster(parent);
#else
Q_UNUSED(parent)
diff --git a/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.cpp
index ffa976a8..a5ef14a6 100644
--- a/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.cpp
@@ -166,13 +166,6 @@ QGeoSatelliteInfoSourceGeoclueMaster::~QGeoSatelliteInfoSourceGeoclueMaster()
cleanupSatelliteSource();
}
-bool QGeoSatelliteInfoSourceGeoclueMaster::init()
-{
- g_type_init();
-
- return true;
-}
-
int QGeoSatelliteInfoSourceGeoclueMaster::minimumUpdateInterval() const
{
return MINIMUM_UPDATE_INTERVAL;
diff --git a/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.h b/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.h
index a770ee5f..4ef1e8cf 100644
--- a/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.h
+++ b/src/plugins/position/geoclue/qgeosatelliteinfosource_geocluemaster.h
@@ -62,8 +62,6 @@ public:
explicit QGeoSatelliteInfoSourceGeoclueMaster(QObject *parent = 0);
~QGeoSatelliteInfoSourceGeoclueMaster();
- bool init();
-
int minimumUpdateInterval() const Q_DECL_OVERRIDE;
Error error() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/position/position.pro b/src/plugins/position/position.pro
index af2a5009..207b949b 100644
--- a/src/plugins/position/position.pro
+++ b/src/plugins/position/position.pro
@@ -4,6 +4,8 @@ config_geoclue:SUBDIRS += geoclue
config_gypsy:SUBDIRS += gypsy
simulator:SUBDIRS += simulator
blackberry:SUBDIRS += blackberry
+ios:SUBDIRS += corelocation
+android:SUBDIRS += android
SUBDIRS += \
positionpoll
diff --git a/src/plugins/position/positionpoll/positionpollfactory.cpp b/src/plugins/position/positionpoll/positionpollfactory.cpp
index 0f02bff1..2acafbc7 100644
--- a/src/plugins/position/positionpoll/positionpollfactory.cpp
+++ b/src/plugins/position/positionpoll/positionpollfactory.cpp
@@ -42,19 +42,19 @@
#include "positionpollfactory.h"
#include "qgeoareamonitor_polling.h"
-QGeoPositionInfoSource *PositionPollFactory::positionInfoSource(QObject *parent)
+QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryAndroid::positionInfoSource(QObject *parent)
{
Q_UNUSED(parent);
return 0;
}
-QGeoSatelliteInfoSource *PositionPollFactory::satelliteInfoSource(QObject *parent)
+QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryAndroid::satelliteInfoSource(QObject *parent)
{
Q_UNUSED(parent);
return 0;
}
-QGeoAreaMonitorSource *PositionPollFactory::areaMonitor(QObject *parent)
+QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryAndroid::areaMonitor(QObject *parent)
{
QGeoAreaMonitorPolling *ret = new QGeoAreaMonitorPolling(parent);
if (ret && ret->isValid())
diff --git a/src/plugins/position/positionpoll/positionpollfactory.h b/src/plugins/position/positionpoll/positionpollfactory.h
index 79ad85eb..4b7818d4 100644
--- a/src/plugins/position/positionpoll/positionpollfactory.h
+++ b/src/plugins/position/positionpoll/positionpollfactory.h
@@ -45,7 +45,7 @@
#include <QObject>
#include <QGeoPositionInfoSourceFactory>
-class PositionPollFactory : public QObject, public QGeoPositionInfoSourceFactory
+class QGeoPositionInfoSourceFactoryAndroid : public QObject, public QGeoPositionInfoSourceFactory
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
diff --git a/src/positioning/doc/images/example-satelliteinfo.png b/src/positioning/doc/images/example-satelliteinfo.png
new file mode 100644
index 00000000..aa9a217c
--- /dev/null
+++ b/src/positioning/doc/images/example-satelliteinfo.png
Binary files differ
diff --git a/src/positioning/doc/snippets/cpp/cppqml.cpp b/src/positioning/doc/snippets/cpp/cppqml.cpp
index 95d34b7c..605a5ed2 100644
--- a/src/positioning/doc/snippets/cpp/cppqml.cpp
+++ b/src/positioning/doc/snippets/cpp/cppqml.cpp
@@ -72,16 +72,16 @@ class MyClass : public QObject
public:
MyClass() : QObject()
{
- QGeoAreaMonitorSource *monitor = QGeoAreaMonitorSource::createDefaultMonitorSource(this);
+ QGeoAreaMonitorSource *monitor = QGeoAreaMonitorSource::createDefaultSource(this);
if (monitor) {
connect(monitor, SIGNAL(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)),
- this, SLOT(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo));
+ this, SLOT(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)));
connect(monitor, SIGNAL(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)),
this, SLOT(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)));
QGeoAreaMonitorInfo bigBen("Big Ben");
QGeoCoordinate position(51.50104, -0.124632);
- bigBen.setMonitoredArea(QGeoCircle(position, 100));
+ bigBen.setArea(QGeoCircle(position, 100));
monitor->startMonitoring(bigBen);
@@ -93,11 +93,15 @@ public:
public Q_SLOTS:
void areaEntered(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
{
+ Q_UNUSED(mon)
+
qDebug() << "Now within 100 meters, current position is" << update.coordinate();
}
void areaExited(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
{
+ Q_UNUSED(mon)
+
qDebug() << "No longer within 100 meters, current position is" << update.coordinate();
}
//! [BigBen]
diff --git a/src/positioning/doc/snippets/snippets.pro b/src/positioning/doc/snippets/snippets.pro
new file mode 100644
index 00000000..451d1c36
--- /dev/null
+++ b/src/positioning/doc/snippets/snippets.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += cpp
diff --git a/src/positioning/doc/src/examples/satelliteinfo.qdoc b/src/positioning/doc/src/examples/satelliteinfo.qdoc
new file mode 100644
index 00000000..1edb8f6c
--- /dev/null
+++ b/src/positioning/doc/src/examples/satelliteinfo.qdoc
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example satelliteinfo
+ \title SatelliteInfo (C++/QML)
+
+ \brief The SatelliteInfo example shows how the available satellites
+ at the user's current position and marks the satellites
+ currently contributing to the GPS fix as pink.
+
+ \ingroup qtpositioning-examples
+
+ Key Qt Positioning classes used in this example:
+
+ \list
+ \li \l{QGeoSatelliteInfo}
+ \li \l{QGeoSatelliteInfoSource}
+ \endlist
+
+ \image ../images/example-satelliteinfo.png
+
+ The example displays the signal strength of all satellites in view. Any satellite
+ that is currently used to calculate the GPS fix has been marked pink. The number at
+ the bottom of each signal bar is the individual satellite identifier.
+
+ The application operates in three different modes:
+
+ \table
+ \header
+ \li Application mode
+ \li Description
+ \row
+ \li running
+ \li The application continuously queries the system for satellite updates. When new data
+ is available it will be displayed.
+ \row
+ \li stopped
+ \li The application stops updating the satellite information.
+ \row
+ \li single
+ \li The application makes a single update request with a timeout of 10s. The display
+ remains empty until the request was answered by the system.
+ \endtable
+
+ If the platform does not provide satellite information the application automatically
+ switches into a demo mode whereby it continuously switches between predefined
+ sets of satellite data.
+*/
diff --git a/src/positioning/doc/src/qtpositioning.qdoc b/src/positioning/doc/src/qtpositioning.qdoc
index ea353942..091b8c77 100644
--- a/src/positioning/doc/src/qtpositioning.qdoc
+++ b/src/positioning/doc/src/qtpositioning.qdoc
@@ -115,6 +115,7 @@ such as speed and direction. This provides the fundamental location information
\list
\li \l {Flickr (QML)}
\li \l {Log File Position Source (C++)}
+ \li \l {SatelliteInfo (C++/QML)}
\li \l {Weather Info (C++/QML)}
\endlist
*/
diff --git a/src/positioning/positioning.pro b/src/positioning/positioning.pro
index 15c3b360..2e751bfb 100644
--- a/src/positioning/positioning.pro
+++ b/src/positioning/positioning.pro
@@ -4,6 +4,17 @@ QT = core-private
QMAKE_DOCS = $$PWD/doc/qtpositioning.qdocconf
OTHER_FILES += doc/src/*.qdoc # show .qdoc files in Qt Creator
+ANDROID_BUNDLED_JAR_DEPENDENCIES = \
+ jar/QtPositioning-bundled.jar:org.qtproject.qt5.android.positioning.QtPositioning
+ANDROID_JAR_DEPENDENCIES = \
+ jar/QtPositioning.jar:org.qtproject.qt5.android.positioning.QtPositioning
+ANDROID_PERMISSIONS = \
+ android.permission.ACCESS_FINE_LOCATION
+ANDROID_LIB_DEPENDENCIES = \
+ plugins/position/libqtposition_android.so
+MODULE_PLUGIN_TYPES = \
+ position
+
PUBLIC_HEADERS += \
qgeoaddress.h \
qgeoareamonitorinfo.h \
@@ -32,7 +43,10 @@ PRIVATE_HEADERS += \
qgeocoordinate_p.h \
qgeopositioninfosource_p.h \
qdeclarativegeoaddress_p.h \
- qdeclarativegeolocation_p.h
+ qdeclarativegeolocation_p.h \
+ qdoublevector2d_p.h \
+ qdoublevector3d_p.h \
+ qgeoprojection_p.h
SOURCES += \
qgeoaddress.cpp \
@@ -51,8 +65,12 @@ SOURCES += \
qnmeapositioninfosource.cpp \
qgeopositioninfosourcefactory.cpp \
qdeclarativegeoaddress.cpp \
- qdeclarativegeolocation.cpp
+ qdeclarativegeolocation.cpp \
+ qdoublevector2d.cpp \
+ qdoublevector3d.cpp \
+ qgeoprojection.cpp
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
+
load(qt_module)
diff --git a/src/location/maps/qdoublevector2d.cpp b/src/positioning/qdoublevector2d.cpp
index 589289f7..b9d707e2 100644
--- a/src/location/maps/qdoublevector2d.cpp
+++ b/src/positioning/qdoublevector2d.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -47,10 +47,9 @@
QT_BEGIN_NAMESPACE
-QDoubleVector2D::QDoubleVector2D(const QDoubleVector3D &vector)
+QDoubleVector2D::QDoubleVector2D(const QDoubleVector3D &vector) :
+ xp(vector.xp), yp(vector.yp)
{
- xp = vector.xp;
- yp = vector.yp;
}
double QDoubleVector2D::length() const
@@ -58,11 +57,6 @@ double QDoubleVector2D::length() const
return qSqrt(xp * xp + yp * yp);
}
-double QDoubleVector2D::lengthSquared() const
-{
- return xp * xp + yp * yp;
-}
-
QDoubleVector2D QDoubleVector2D::normalized() const
{
// Need some extra precision if the length is very small.
@@ -90,11 +84,6 @@ void QDoubleVector2D::normalize()
yp /= len;
}
-double QDoubleVector2D::dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return v1.xp * v2.xp + v1.yp * v2.yp;
-}
-
QDoubleVector3D QDoubleVector2D::toVector3D() const
{
return QDoubleVector3D(xp, yp, 0.0);
diff --git a/src/location/maps/qdoublevector2d_p.h b/src/positioning/qdoublevector2d_p.h
index f66a95a2..c3000f86 100644
--- a/src/location/maps/qdoublevector2d_p.h
+++ b/src/positioning/qdoublevector2d_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -53,59 +53,69 @@
// We mean it.
//
+#ifdef QT_BUILD_LOCATION_LIB
#include <QVector2D>
+#endif
+#include "qpositioningglobal.h"
#include <QtCore/qmetatype.h>
+#include <QPointF>
QT_BEGIN_NAMESPACE
class QDoubleVector3D;
-class QDoubleVector2D
+class Q_POSITIONING_EXPORT_PRIVATE QDoubleVector2D
{
public:
- QDoubleVector2D();
- explicit QDoubleVector2D(const QVector2D &vector);
- QDoubleVector2D(double xpos, double ypos);
+ Q_DECL_CONSTEXPR inline QDoubleVector2D();
+ Q_DECL_CONSTEXPR inline QDoubleVector2D(double xpos, double ypos);
+ Q_DECL_CONSTEXPR explicit inline QDoubleVector2D(const QPointF &p);
explicit QDoubleVector2D(const QDoubleVector3D &vector);
+#ifdef QT_BUILD_LOCATION_LIB
+ Q_DECL_CONSTEXPR explicit inline QDoubleVector2D(const QVector2D &vector) : xp(vector.x()), yp(vector.y()) {}
+ Q_DECL_CONSTEXPR inline operator QVector2D() const { return QVector2D(xp, yp); }
+#endif
- operator QVector2D() const;
-
- bool isNull() const;
+ Q_DECL_CONSTEXPR inline double manhattanLength() const;
+ inline bool isNull() const;
- double x() const;
- double y() const;
+ Q_DECL_CONSTEXPR inline double x() const;
+ Q_DECL_CONSTEXPR inline double y() const;
- void setX(double x);
- void setY(double y);
+ inline void setX(double x);
+ inline void setY(double y);
double length() const;
- double lengthSquared() const;
+ Q_DECL_CONSTEXPR inline double lengthSquared() const;
QDoubleVector2D normalized() const;
void normalize();
- QDoubleVector2D &operator+=(const QDoubleVector2D &vector);
- QDoubleVector2D &operator-=(const QDoubleVector2D &vector);
- QDoubleVector2D &operator*=(double factor);
- QDoubleVector2D &operator*=(const QDoubleVector2D &vector);
- QDoubleVector2D &operator/=(double divisor);
+ inline QDoubleVector2D &operator+=(const QDoubleVector2D &vector);
+ inline QDoubleVector2D &operator-=(const QDoubleVector2D &vector);
+ inline QDoubleVector2D &operator*=(double factor);
+ inline QDoubleVector2D &operator*=(const QDoubleVector2D &vector);
+ inline QDoubleVector2D &operator/=(double divisor);
+
+ Q_DECL_CONSTEXPR static inline double dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+ { return v1.xp * v2.xp + v1.yp * v2.yp; }
- static double dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector);
- friend inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor);
- friend inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend inline const QDoubleVector2D operator-(const QDoubleVector2D &vector);
- friend inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &vector);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor);
- friend inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
QDoubleVector3D toVector3D() const;
+ Q_DECL_CONSTEXPR inline QPointF toPointF() const;
private:
double xp, yp;
@@ -115,15 +125,15 @@ private:
Q_DECLARE_TYPEINFO(QDoubleVector2D, Q_MOVABLE_TYPE);
-inline QDoubleVector2D::QDoubleVector2D() : xp(0.0), yp(0.0) {}
+Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D() : xp(0.0), yp(0.0) {}
-inline QDoubleVector2D::QDoubleVector2D(const QVector2D &vector) : xp(vector.x()), yp(vector.y()) {}
+Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D(double xpos, double ypos) : xp(xpos), yp(ypos) {}
-inline QDoubleVector2D::QDoubleVector2D(double xpos, double ypos) : xp(xpos), yp(ypos) {}
+Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D(const QPointF &p) : xp(p.x()), yp(p.y()) { }
-inline QDoubleVector2D::operator QVector2D() const
+Q_DECL_CONSTEXPR inline double QDoubleVector2D::manhattanLength() const
{
- return QVector2D(xp, yp);
+ return qAbs(x())+qAbs(y());
}
inline bool QDoubleVector2D::isNull() const
@@ -131,12 +141,15 @@ inline bool QDoubleVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
-inline double QDoubleVector2D::x() const { return double(xp); }
-inline double QDoubleVector2D::y() const { return double(yp); }
+Q_DECL_CONSTEXPR inline double QDoubleVector2D::x() const { return xp; }
+Q_DECL_CONSTEXPR inline double QDoubleVector2D::y() const { return yp; }
inline void QDoubleVector2D::setX(double aX) { xp = aX; }
inline void QDoubleVector2D::setY(double aY) { yp = aY; }
+Q_DECL_CONSTEXPR inline double QDoubleVector2D::lengthSquared() const
+{ return xp * xp + yp * yp; }
+
inline QDoubleVector2D &QDoubleVector2D::operator+=(const QDoubleVector2D &vector)
{
xp += vector.xp;
@@ -172,56 +185,61 @@ inline QDoubleVector2D &QDoubleVector2D::operator/=(double divisor)
return *this;
}
-inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return v1.xp == v2.xp && v1.yp == v2.yp;
}
-inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return v1.xp != v2.xp || v1.yp != v2.yp;
}
-inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return QDoubleVector2D(v1.xp + v2.xp, v1.yp + v2.yp);
}
-inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return QDoubleVector2D(v1.xp - v2.xp, v1.yp - v2.yp);
}
-inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector)
{
return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
}
-inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor)
{
return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
}
-inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return QDoubleVector2D(v1.xp * v2.xp, v1.yp * v2.yp);
}
-inline const QDoubleVector2D operator-(const QDoubleVector2D &vector)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &vector)
{
return QDoubleVector2D(-vector.xp, -vector.yp);
}
-inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor)
+Q_DECL_CONSTEXPR inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor)
{
return QDoubleVector2D(vector.xp / divisor, vector.yp / divisor);
}
-inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
{
return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
}
+Q_DECL_CONSTEXPR inline QPointF QDoubleVector2D::toPointF() const
+{
+ return QPointF(qreal(xp), qreal(yp));
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector);
#endif
diff --git a/src/location/maps/qdoublevector3d.cpp b/src/positioning/qdoublevector3d.cpp
index d35e4848..621a2ec5 100644
--- a/src/location/maps/qdoublevector3d.cpp
+++ b/src/positioning/qdoublevector3d.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -40,27 +40,12 @@
****************************************************************************/
#include "qdoublevector3d_p.h"
-#include "qdoublevector2d_p.h"
#include <QtCore/qdatastream.h>
#include <QtCore/qmath.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector)
-{
- xp = vector.xp;
- yp = vector.yp;
- zp = 0.0;
-}
-
-QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector, double zpos)
-{
- xp = vector.xp;
- yp = vector.yp;
- zp = zpos;
-}
-
QDoubleVector3D QDoubleVector3D::normalized() const
{
// Need some extra precision if the length is very small.
@@ -91,18 +76,6 @@ void QDoubleVector3D::normalize()
zp /= len;
}
-double QDoubleVector3D::dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
-}
-
-QDoubleVector3D QDoubleVector3D::crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return QDoubleVector3D(v1.yp * v2.zp - v1.zp * v2.yp,
- v1.zp * v2.xp - v1.xp * v2.zp,
- v1.xp * v2.yp - v1.yp * v2.xp);
-}
-
QDoubleVector3D QDoubleVector3D::normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return crossProduct(v1, v2).normalized();
@@ -115,12 +88,6 @@ QDoubleVector3D QDoubleVector3D::normal
}
double QDoubleVector3D::distanceToPlane
- (const QDoubleVector3D &plane, const QDoubleVector3D &normal) const
-{
- return dotProduct(*this - plane, normal);
-}
-
-double QDoubleVector3D::distanceToPlane
(const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const
{
QDoubleVector3D n = normal(plane2 - plane1, plane3 - plane1);
@@ -136,21 +103,11 @@ double QDoubleVector3D::distanceToLine
return (*this - p).length();
}
-QDoubleVector2D QDoubleVector3D::toVector2D() const
-{
- return QDoubleVector2D(xp, yp);
-}
-
double QDoubleVector3D::length() const
{
return qSqrt(xp * xp + yp * yp + zp * zp);
}
-double QDoubleVector3D::lengthSquared() const
-{
- return xp * xp + yp * yp + zp * zp;
-}
-
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector)
diff --git a/src/location/maps/qdoublevector3d_p.h b/src/positioning/qdoublevector3d_p.h
index e237287d..75966a36 100644
--- a/src/location/maps/qdoublevector3d_p.h
+++ b/src/positioning/qdoublevector3d_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -53,52 +53,62 @@
// We mean it.
//
+#ifdef QT_BUILD_LOCATION_LIB
#include <QVector3D>
+#endif
+#include "qpositioningglobal.h"
+#include "qdoublevector2d_p.h"
#include <QtCore/qmetatype.h>
QT_BEGIN_NAMESPACE
-class QDoubleVector2D;
-
-class QDoubleVector3D
+class Q_POSITIONING_EXPORT_PRIVATE QDoubleVector3D
{
public:
- QDoubleVector3D();
- QDoubleVector3D(double xpos, double ypos, double zpos);
- explicit QDoubleVector3D(const QVector3D &vector);
- QDoubleVector3D(const QDoubleVector2D &vector);
- QDoubleVector3D(const QDoubleVector2D &vector, double zpos);
-
- operator QVector3D() const;
+ Q_DECL_CONSTEXPR inline QDoubleVector3D();
+ Q_DECL_CONSTEXPR inline QDoubleVector3D(double xpos, double ypos, double zpos);
+ Q_DECL_CONSTEXPR inline QDoubleVector3D(const QDoubleVector2D &vector);
+ Q_DECL_CONSTEXPR inline QDoubleVector3D(const QDoubleVector2D &vector, double zpos);
+
+#ifdef QT_BUILD_LOCATION_LIB
+ Q_DECL_CONSTEXPR explicit inline QDoubleVector3D(const QVector3D &vector) : xp(vector.x()), yp(vector.y()), zp(vector.z()) {}
+ Q_DECL_CONSTEXPR inline operator QVector3D() const { return QVector3D(xp, yp, zp); }
+#endif
- bool isNull() const;
+ inline bool isNull() const;
- double x() const;
- double y() const;
- double z() const;
+ Q_DECL_CONSTEXPR inline double x() const;
+ Q_DECL_CONSTEXPR inline double y() const;
+ Q_DECL_CONSTEXPR inline double z() const;
- void setX(double x);
- void setY(double y);
- void setZ(double z);
+ inline void setX(double x);
+ inline void setY(double y);
+ inline void setZ(double z);
- double get(int i) const;
- void set(int i, double value);
+ inline double get(int i) const;
+ inline void set(int i, double value);
double length() const;
- double lengthSquared() const;
+ Q_DECL_CONSTEXPR inline double lengthSquared() const;
QDoubleVector3D normalized() const;
void normalize();
- QDoubleVector3D &operator+=(const QDoubleVector3D &vector);
- QDoubleVector3D &operator-=(const QDoubleVector3D &vector);
- QDoubleVector3D &operator*=(double factor);
- QDoubleVector3D &operator*=(const QDoubleVector3D &vector);
- QDoubleVector3D &operator/=(double divisor);
+ inline QDoubleVector3D &operator+=(const QDoubleVector3D &vector);
+ inline QDoubleVector3D &operator-=(const QDoubleVector3D &vector);
+ inline QDoubleVector3D &operator*=(double factor);
+ inline QDoubleVector3D &operator*=(const QDoubleVector3D &vector);
+ inline QDoubleVector3D &operator/=(double divisor);
+
+ Q_DECL_CONSTEXPR static inline double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+ { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp; }
+
+ Q_DECL_CONSTEXPR static inline QDoubleVector3D crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+ { return QDoubleVector3D(v1.yp * v2.zp - v1.zp * v2.yp,
+ v1.zp * v2.xp - v1.xp * v2.zp,
+ v1.xp * v2.yp - v1.yp * v2.xp); }
- static double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- static QDoubleVector3D crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
static QDoubleVector3D normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
static QDoubleVector3D normal
(const QDoubleVector3D &v1, const QDoubleVector3D &v2, const QDoubleVector3D &v3);
@@ -107,19 +117,19 @@ public:
double distanceToPlane(const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const;
double distanceToLine(const QDoubleVector3D &point, const QDoubleVector3D &direction) const;
- friend inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector);
- friend inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor);
- friend const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend inline const QDoubleVector3D operator-(const QDoubleVector3D &vector);
- friend inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor);
+ friend Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &vector);
+ friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor);
- friend inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- QDoubleVector2D toVector2D() const;
+ Q_DECL_CONSTEXPR inline QDoubleVector2D toVector2D() const;
private:
double xp, yp, zp;
@@ -129,25 +139,28 @@ private:
Q_DECLARE_TYPEINFO(QDoubleVector3D, Q_MOVABLE_TYPE);
-inline QDoubleVector3D::QDoubleVector3D() : xp(0.0), yp(0.0), zp(0.0) {}
+Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D() : xp(0.0), yp(0.0), zp(0.0) {}
-inline QDoubleVector3D::QDoubleVector3D(const QVector3D &vector) : xp(vector.x()), yp(vector.y()), zp(vector.z()) {}
+Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QDoubleVector3D::QDoubleVector3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
+Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &v)
+ : xp(v.xp), yp(v.yp), zp(0.0) {}
-inline QDoubleVector3D::operator QVector3D() const
-{
- return QVector3D(xp, yp, zp);
-}
+Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &v, double zpos)
+ : xp(v.xp), yp(v.yp), zp(zpos) {}
inline bool QDoubleVector3D::isNull() const
{
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline double QDoubleVector3D::x() const { return xp; }
-inline double QDoubleVector3D::y() const { return yp; }
-inline double QDoubleVector3D::z() const { return zp; }
+Q_DECL_CONSTEXPR inline double QDoubleVector3D::x() const { return xp; }
+Q_DECL_CONSTEXPR inline double QDoubleVector3D::y() const { return yp; }
+Q_DECL_CONSTEXPR inline double QDoubleVector3D::z() const { return zp; }
+
+Q_DECL_CONSTEXPR inline double QDoubleVector3D::lengthSquared() const
+{ return xp * xp + yp * yp + zp * zp; }
+
inline void QDoubleVector3D::setX(double aX) { xp = aX; }
inline void QDoubleVector3D::setY(double aY) { yp = aY; }
@@ -224,58 +237,64 @@ inline QDoubleVector3D &QDoubleVector3D::operator/=(double divisor)
return *this;
}
-inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp;
}
-inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp;
}
-inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return QDoubleVector3D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp);
}
-inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return QDoubleVector3D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp);
}
-inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector)
{
return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
}
-inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor)
{
return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
}
-inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return QDoubleVector3D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp);
}
-inline const QDoubleVector3D operator-(const QDoubleVector3D &vector)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &vector)
{
return QDoubleVector3D(-vector.xp, -vector.yp, -vector.zp);
}
-inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor)
+Q_DECL_CONSTEXPR inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor)
{
return QDoubleVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor);
}
-inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return qFuzzyCompare(v1.xp, v2.xp) &&
qFuzzyCompare(v1.yp, v2.yp) &&
qFuzzyCompare(v1.zp, v2.zp);
}
+Q_DECL_CONSTEXPR inline QDoubleVector2D QDoubleVector3D::toVector2D() const
+{
+ return QDoubleVector2D(xp, yp);
+}
+
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector);
#endif
diff --git a/src/positioning/qgeocircle.cpp b/src/positioning/qgeocircle.cpp
index 1228ce28..b5499ea7 100644
--- a/src/positioning/qgeocircle.cpp
+++ b/src/positioning/qgeocircle.cpp
@@ -45,6 +45,8 @@
#include "qgeocoordinate.h"
#include "qnumeric.h"
+#include "qdoublevector2d_p.h"
+#include "qdoublevector3d_p.h"
QT_BEGIN_NAMESPACE
/*!
@@ -214,6 +216,17 @@ bool QGeoCirclePrivate::contains(const QGeoCoordinate &coordinate) const
}
/*!
+ Extends the circle to include \a coordinate
+*/
+void QGeoCirclePrivate::extendShape(const QGeoCoordinate &coordinate)
+{
+ if (!isValid() || !coordinate.isValid() || contains(coordinate))
+ return;
+
+ radius = center.distanceTo(coordinate);
+}
+
+/*!
Translates this geo circle by \a degreesLatitude northwards and \a degreesLongitude eastwards.
Negative values of \a degreesLatitude and \a degreesLongitude correspond to
diff --git a/src/positioning/qgeocircle_p.h b/src/positioning/qgeocircle_p.h
index e8e4a2c0..2043fdc4 100644
--- a/src/positioning/qgeocircle_p.h
+++ b/src/positioning/qgeocircle_p.h
@@ -70,6 +70,8 @@ public:
bool isEmpty() const;
bool contains(const QGeoCoordinate &coordinate) const;
+ void extendShape(const QGeoCoordinate &coordinate);
+
QGeoShapePrivate *clone() const;
bool operator==(const QGeoShapePrivate &other) const;
diff --git a/src/location/maps/qgeoprojection.cpp b/src/positioning/qgeoprojection.cpp
index 84dc5749..d2cc9243 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/positioning/qgeoprojection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtLocation module of the Qt Toolkit.
+** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -42,7 +42,6 @@
#include "qgeocoordinate.h"
-#include <QMatrix4x4>
#include <qnumeric.h>
#include <cmath>
@@ -105,4 +104,37 @@ QGeoCoordinate QGeoProjection::mercatorToCoord(const QDoubleVector2D &mercator)
return QGeoCoordinate(lat, lng, 0.0);
}
+QGeoCoordinate QGeoProjection::coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
+{
+ QDoubleVector2D s = QGeoProjection::coordToMercator(from);
+ QDoubleVector2D e = QGeoProjection::coordToMercator(to);
+
+ double x = s.x();
+
+ if (0.5 < qAbs(e.x() - s.x())) {
+ // handle dateline crossing
+ double ex = e.x();
+ double sx = s.x();
+ if (ex < sx)
+ sx -= 1.0;
+ else if (sx < ex)
+ ex -= 1.0;
+
+ x = (1.0 - progress) * sx + progress * ex;
+
+ if (!qFuzzyIsNull(x) && (x < 0.0))
+ x += 1.0;
+
+ } else {
+ x = (1.0 - progress) * s.x() + progress * e.x();
+ }
+
+ double y = (1.0 - progress) * s.y() + progress * e.y();
+
+ QGeoCoordinate result = QGeoProjection::mercatorToCoord(QDoubleVector2D(x, y));
+ result.setAltitude((1.0 - progress) * from.altitude() + progress * to.altitude());
+
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeoprojection_p.h b/src/positioning/qgeoprojection_p.h
index 4dcf8b4c..d0280030 100644
--- a/src/location/maps/qgeoprojection_p.h
+++ b/src/positioning/qgeoprojection_p.h
@@ -57,18 +57,19 @@
#endif
#include <qglobal.h>
-#include <QtLocation/qlocationglobal.h>
+#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
class QGeoCoordinate;
class QDoubleVector2D;
-class Q_LOCATION_EXPORT QGeoProjection
+class Q_POSITIONING_EXPORT_PRIVATE QGeoProjection
{
public:
static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord);
static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator);
+ static QGeoCoordinate coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
private:
static double realmod(const double a, const double b);
diff --git a/src/positioning/qgeorectangle.cpp b/src/positioning/qgeorectangle.cpp
index 063ed9e3..47877d60 100644
--- a/src/positioning/qgeorectangle.cpp
+++ b/src/positioning/qgeorectangle.cpp
@@ -44,7 +44,7 @@
#include "qgeocoordinate.h"
#include "qnumeric.h"
-
+#include <QList>
QT_BEGIN_NAMESPACE
/*!
@@ -140,6 +140,23 @@ QGeoRectangle::QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate
}
/*!
+ Constructs a new geo rectangle, of minimum size, containing all of the \a coordinates.
+*/
+QGeoRectangle::QGeoRectangle(const QList<QGeoCoordinate> &coordinates)
+{
+ if (coordinates.isEmpty()) {
+ d_ptr = new QGeoRectanglePrivate;
+ } else {
+ const QGeoCoordinate &startCoordinate = coordinates.first();
+ d_ptr = new QGeoRectanglePrivate(startCoordinate, startCoordinate);
+
+ foreach (const QGeoCoordinate &coordinate, coordinates) {
+ d_ptr->extendShape(coordinate);
+ }
+ }
+}
+
+/*!
Constructs a geo rectangle from the contents of \a other.
*/
QGeoRectangle::QGeoRectangle(const QGeoRectangle &other)
@@ -735,6 +752,54 @@ QGeoRectangle QGeoRectangle::united(const QGeoRectangle &rectangle) const
}
/*!
+ Extends the rectangle in the smallest possible way to include \a coordinate in
+ the shape.
+
+ Both the rectangle and coordinate needs to be valid. If the rectangle already covers
+ the coordinate noting happens.
+
+*/
+void QGeoRectanglePrivate::extendShape(const QGeoCoordinate &coordinate)
+{
+ if (!isValid() || !coordinate.isValid() || contains(coordinate))
+ return;
+
+ double left = topLeft.longitude();
+ double right = bottomRight.longitude();
+ double top = topLeft.latitude();
+ double bottom = bottomRight.latitude();
+
+ double inputLat = coordinate.latitude();
+ double inputLon = coordinate.longitude();
+
+ top = qMax(top, inputLat);
+ bottom = qMin(bottom, inputLat);
+
+ bool wrap = left > right;
+
+ if (wrap && inputLon > right && inputLon < left) {
+ if (qAbs(left - inputLon) < qAbs(right - inputLon))
+ left = inputLon;
+ else
+ right = inputLon;
+ } else if (!wrap) {
+ if (inputLon < left) {
+ if (360 - (right - inputLon) < left - inputLon)
+ right = inputLon;
+ else
+ left = inputLon;
+ } else if (inputLon > right) {
+ if (360 - (inputLon - left) < inputLon - right)
+ left = inputLon;
+ else
+ right = inputLon;
+ }
+ }
+ topLeft = QGeoCoordinate(top, left);
+ bottomRight = QGeoCoordinate(bottom, right);
+}
+
+/*!
\fn QGeoRectangle QGeoRectangle::operator|(const QGeoRectangle &rectangle) const
Returns the smallest geo rectangle which contains both this geo rectangle and \a rectangle.
diff --git a/src/positioning/qgeorectangle.h b/src/positioning/qgeorectangle.h
index cd91c1d7..babbe621 100644
--- a/src/positioning/qgeorectangle.h
+++ b/src/positioning/qgeorectangle.h
@@ -55,6 +55,7 @@ public:
QGeoRectangle();
QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
+ QGeoRectangle(const QList<QGeoCoordinate> &coordinates);
QGeoRectangle(const QGeoRectangle &other);
QGeoRectangle(const QGeoShape &other);
diff --git a/src/positioning/qgeorectangle_p.h b/src/positioning/qgeorectangle_p.h
index 136d4be4..2ce0250e 100644
--- a/src/positioning/qgeorectangle_p.h
+++ b/src/positioning/qgeorectangle_p.h
@@ -70,6 +70,8 @@ public:
bool isEmpty() const;
bool contains(const QGeoCoordinate &coordinate) const;
+ void extendShape(const QGeoCoordinate &coordinate);
+
QGeoShapePrivate *clone() const;
bool operator==(const QGeoShapePrivate &other) const;
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp
index d48a67f2..e79753f4 100644
--- a/src/positioning/qgeoshape.cpp
+++ b/src/positioning/qgeoshape.cpp
@@ -192,6 +192,17 @@ bool QGeoShape::contains(const QGeoCoordinate &coordinate) const
return false;
}
+/*!
+ Extends the geo shape to also cover the coordinate \a coordinate
+*/
+void QGeoShape::extendShape(const QGeoCoordinate &coordinate)
+{
+ Q_D(QGeoShape);
+
+ if (d)
+ d->extendShape(coordinate);
+}
+
/*!
Returns true if the \a other geo shape is equivalent to this geo shape, otherwise returns
diff --git a/src/positioning/qgeoshape.h b/src/positioning/qgeoshape.h
index f1cb4cf2..56dbc028 100644
--- a/src/positioning/qgeoshape.h
+++ b/src/positioning/qgeoshape.h
@@ -69,6 +69,8 @@ public:
bool isEmpty() const;
bool contains(const QGeoCoordinate &coordinate) const;
+ void extendShape(const QGeoCoordinate &coordinate);
+
bool operator==(const QGeoShape &other) const;
bool operator!=(const QGeoShape &other) const;
diff --git a/src/positioning/qgeoshape_p.h b/src/positioning/qgeoshape_p.h
index ec0b8283..f58fe1e8 100644
--- a/src/positioning/qgeoshape_p.h
+++ b/src/positioning/qgeoshape_p.h
@@ -69,6 +69,8 @@ public:
virtual bool isEmpty() const = 0;
virtual bool contains(const QGeoCoordinate &coordinate) const = 0;
+ virtual void extendShape(const QGeoCoordinate &coordinate) = 0;
+
virtual QGeoShapePrivate *clone() const = 0;
virtual bool operator==(const QGeoShapePrivate &other) const;
diff --git a/src/positioning/qlocationutils.cpp b/src/positioning/qlocationutils.cpp
index 5d6cfbb2..830ac64a 100644
--- a/src/positioning/qlocationutils.cpp
+++ b/src/positioning/qlocationutils.cpp
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -58,7 +60,8 @@ static double qlocationutils_nmeaDegreesToDecimal(double nmeaDegrees)
return deg + (min / 60.0);
}
-static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo *info, double uere,
+ bool *hasFix)
{
QByteArray sentence(data, size);
QList<QByteArray> parts = sentence.split(',');
@@ -82,6 +85,13 @@ static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo
}
}
+ if (parts.count() > 8 && !parts[8].isEmpty()) {
+ bool hasHdop = false;
+ double hdop = parts[8].toDouble(&hasHdop);
+ if (hasHdop)
+ info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
+ }
+
if (parts.count() > 9 && parts[9].count() > 0) {
bool hasAlt = false;
double alt = parts[9].toDouble(&hasAlt);
@@ -93,6 +103,29 @@ static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo
info->setCoordinate(coord);
}
+static void qlocationutils_readGsa(const char *data, int size, QGeoPositionInfo *info, double uere,
+ bool *hasFix)
+{
+ QList<QByteArray> parts = QByteArray::fromRawData(data, size).split(',');
+
+ if (hasFix && parts.count() > 2 && !parts[2].isEmpty())
+ *hasFix = parts[2].toInt() > 0;
+
+ if (parts.count() > 16 && !parts[16].isEmpty()) {
+ bool hasHdop = false;
+ double hdop = parts[16].toDouble(&hasHdop);
+ if (hasHdop)
+ info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
+ }
+
+ if (parts.count() > 17 && !parts[17].isEmpty()) {
+ bool hasVdop = false;
+ double vdop = parts[17].toDouble(&hasVdop);
+ if (hasVdop)
+ info->setAttribute(QGeoPositionInfo::VerticalAccuracy, 2 * vdop * uere);
+ }
+}
+
static void qlocationutils_readGll(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
{
QByteArray sentence(data, size);
@@ -227,7 +260,8 @@ static void qlocationutils_readZda(const char *data, int size, QGeoPositionInfo
info->setTimestamp(QDateTime(date, time, Qt::UTC));
}
-bool QLocationUtils::getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
+bool QLocationUtils::getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info,
+ double uere, bool *hasFix)
{
if (!info)
return false;
@@ -237,9 +271,23 @@ bool QLocationUtils::getPosInfoFromNmea(const char *data, int size, QGeoPosition
if (size < 6 || data[0] != '$' || !hasValidNmeaChecksum(data, size))
return false;
+ // Adjust size so that * and following characters are not parsed by the following functions.
+ for (int i = 0; i < size; ++i) {
+ if (data[i] == '*') {
+ size = i;
+ break;
+ }
+ }
+
if (data[3] == 'G' && data[4] == 'G' && data[5] == 'A') {
// "$--GGA" sentence.
- qlocationutils_readGga(data, size, info, hasFix);
+ qlocationutils_readGga(data, size, info, uere, hasFix);
+ return true;
+ }
+
+ if (data[3] == 'G' && data[4] == 'S' && data[5] == 'A') {
+ // "$--GSA" sentence.
+ qlocationutils_readGsa(data, size, info, uere, hasFix);
return true;
}
diff --git a/src/positioning/qlocationutils_p.h b/src/positioning/qlocationutils_p.h
index 4b42695c..10dd61d4 100644
--- a/src/positioning/qlocationutils_p.h
+++ b/src/positioning/qlocationutils_p.h
@@ -94,7 +94,9 @@ public:
- RMC reports date with a two-digit year so in this case the year
is assumed to be after the year 2000.
*/
- Q_AUTOTEST_EXPORT static bool getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix = 0);
+ Q_AUTOTEST_EXPORT static bool getPosInfoFromNmea(const char *data, int size,
+ QGeoPositionInfo *info, double uere,
+ bool *hasFix = 0);
/*
Returns true if the given NMEA sentence has a valid checksum.
diff --git a/src/positioning/qnmeapositioninfosource.cpp b/src/positioning/qnmeapositioninfosource.cpp
index 9ac928b2..23706a4f 100644
--- a/src/positioning/qnmeapositioninfosource.cpp
+++ b/src/positioning/qnmeapositioninfosource.cpp
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -45,6 +47,7 @@
#include <QBasicTimer>
#include <QTimerEvent>
#include <QTimer>
+#include <QtCore/QtNumeric>
QT_BEGIN_NAMESPACE
@@ -133,8 +136,7 @@ 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);
+ m_proxy->notifyNewUpdate(&pending.info, pending.hasFix);
}
processNextSentence();
@@ -173,6 +175,9 @@ void QNmeaSimulatedReader::processNextSentence()
timeToNextUpdate = prevTime.msecsTo(time);
if (timeToNextUpdate >= 0)
break;
+ } else {
+ timeToNextUpdate = 0;
+ break;
}
}
}
@@ -199,10 +204,13 @@ QNmeaPositionInfoSourcePrivate::QNmeaPositionInfoSourcePrivate(QNmeaPositionInfo
m_device(0),
m_invokedStart(false),
m_positionError(QGeoPositionInfoSource::UnknownSourceError),
+ m_userEquivalentRangeError(qQNaN()),
m_source(parent),
m_nmeaReader(0),
m_updateTimer(0),
m_requestTimer(0),
+ m_horizontalAccuracy(qQNaN()),
+ m_verticalAccuracy(qQNaN()),
m_noUpdateLastInterval(false),
m_updateTimeoutSent(false),
m_connectedReadyRead(false)
@@ -375,6 +383,17 @@ void QNmeaPositionInfoSourcePrivate::notifyNewUpdate(QGeoPositionInfo *update, b
update->setTimestamp(QDateTime(m_currentDate, time, Qt::UTC));
}
+ // Some attributes are sent in separate NMEA sentences. Save and restore the accuracy
+ // measurements.
+ if (update->hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ m_horizontalAccuracy = update->attribute(QGeoPositionInfo::HorizontalAccuracy);
+ else if (!qIsNaN(m_horizontalAccuracy))
+ update->setAttribute(QGeoPositionInfo::HorizontalAccuracy, m_horizontalAccuracy);
+ if (update->hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+ m_verticalAccuracy = update->attribute(QGeoPositionInfo::VerticalAccuracy);
+ else if (!qIsNaN(m_verticalAccuracy))
+ update->setAttribute(QGeoPositionInfo::VerticalAccuracy, m_verticalAccuracy);
+
if (hasFix && update->isValid()) {
if (m_requestTimer && m_requestTimer->isActive()) {
m_requestTimer->stop();
@@ -451,6 +470,10 @@ void QNmeaPositionInfoSourcePrivate::emitUpdated(const QGeoPositionInfo &update)
In both cases the position information is received via the positionUpdated() signal and the
last known position can be accessed with lastKnownPosition().
+
+ QNmeaPositionInfoSource supports reporting the accuracy of the horizontal and vertical position.
+ To enable position accuracy reporting an estimate of the User Equivalent Range Error associated
+ with the NMEA source must be set with setUserEquivalentRangeError().
*/
@@ -482,6 +505,41 @@ QNmeaPositionInfoSource::~QNmeaPositionInfoSource()
}
/*!
+ Sets the User Equivalent Range Error (UERE) to \a uere. The UERE is used in calculating an
+ estimate of the accuracy of the position information reported by the position info source. The
+ UERE should be set to a value appropriate for the GPS device which generated the NMEA stream.
+
+ The true UERE value is calculated from multiple error sources including errors introduced by
+ the satellites and signal propogation delays through the atmosphere as well as errors
+ introduced by the receiving GPS equipment. For details on GPS accuracy see
+ \l {http://edu-observatory.org/gps/gps_accuracy.html}.
+
+ A typical value for UERE is approximately 5.1.
+
+ \since 5.3
+
+ \sa userEquivalentRangeError()
+*/
+void QNmeaPositionInfoSource::setUserEquivalentRangeError(double uere)
+{
+ d->m_userEquivalentRangeError = uere;
+}
+
+/*!
+ Returns the current User Equivalent Range Error (UERE). The UERE is used in calculating an
+ estimate of the accuracy of the position information reported by the position info source. The
+ default value is NaN which means no accuracy information will be provided.
+
+ \since 5.3
+
+ \sa setUserEquivalentRangeError()
+*/
+double QNmeaPositionInfoSource::userEquivalentRangeError() const
+{
+ return d->m_userEquivalentRangeError;
+}
+
+/*!
Parses an NMEA sentence string into a QGeoPositionInfo.
The default implementation will parse standard NMEA sentences.
@@ -498,7 +556,8 @@ QNmeaPositionInfoSource::~QNmeaPositionInfoSource()
bool QNmeaPositionInfoSource::parsePosInfoFromNmeaData(const char *data, int size,
QGeoPositionInfo *posInfo, bool *hasFix)
{
- return QLocationUtils::getPosInfoFromNmea(data, size, posInfo, hasFix);
+ return QLocationUtils::getPosInfoFromNmea(data, size, posInfo, d->m_userEquivalentRangeError,
+ hasFix);
}
/*!
diff --git a/src/positioning/qnmeapositioninfosource.h b/src/positioning/qnmeapositioninfosource.h
index 605a5696..ae19309f 100644
--- a/src/positioning/qnmeapositioninfosource.h
+++ b/src/positioning/qnmeapositioninfosource.h
@@ -60,6 +60,9 @@ public:
explicit QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent = 0);
~QNmeaPositionInfoSource();
+ void setUserEquivalentRangeError(double uere);
+ double userEquivalentRangeError() const;
+
UpdateMode updateMode() const;
void setDevice(QIODevice *source);
diff --git a/src/positioning/qnmeapositioninfosource_p.h b/src/positioning/qnmeapositioninfosource_p.h
index ec9ebeaf..afe0b3aa 100644
--- a/src/positioning/qnmeapositioninfosource_p.h
+++ b/src/positioning/qnmeapositioninfosource_p.h
@@ -96,6 +96,7 @@ public:
QGeoPositionInfo m_lastUpdate;
bool m_invokedStart;
QGeoPositionInfoSource::Error m_positionError;
+ double m_userEquivalentRangeError;
public Q_SLOTS:
void readyRead();
@@ -120,6 +121,8 @@ private:
QGeoPositionInfo m_pendingUpdate;
QDate m_currentDate;
QTimer *m_requestTimer;
+ qreal m_horizontalAccuracy;
+ qreal m_verticalAccuracy;
bool m_noUpdateLastInterval;
bool m_updateTimeoutSent;
bool m_connectedReadyRead;
diff --git a/src/positioning/qpositioningglobal.h b/src/positioning/qpositioningglobal.h
index e0de618b..5d1c3dea 100644
--- a/src/positioning/qpositioningglobal.h
+++ b/src/positioning/qpositioningglobal.h
@@ -47,14 +47,18 @@ QT_BEGIN_NAMESPACE
#ifndef QT_STATIC
# if defined(QT_BUILD_POSITIONING_LIB)
-# define Q_POSITIONING_EXPORT Q_DECL_EXPORT
+# define Q_POSITIONING_EXPORT Q_DECL_EXPORT
+# define Q_POSITIONING_EXPORT_PRIVATE Q_DECL_EXPORT
# else
-# define Q_POSITIONING_EXPORT Q_DECL_IMPORT
+# define Q_POSITIONING_EXPORT Q_DECL_IMPORT
+# define Q_POSITIONING_EXPORT_PRIVATE Q_DECL_IMPORT
# endif
#else
# define Q_POSITIONING_EXPORT
+# define Q_POSITIONING_EXPORT_PRIVATE
#endif
+
QT_END_NAMESPACE
#endif // QPOSITIONINGGLOBAL_H
diff --git a/src/src.pro b/src/src.pro
index f6e41510..72274cdc 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,13 +1,30 @@
TEMPLATE = subdirs
-CONFIG += ordered
SUBDIRS += positioning
+plugins.depends = positioning
+SUBDIRS += plugins
+
+positioning_doc_snippets.subdir = positioning/doc/snippets
+positioning_doc_snippets.depends = positioning
+SUBDIRS += positioning_doc_snippets
+
#no point in building QtLocation without Qt3D
qtHaveModule(3d) {
- SUBDIRS += location 3rdparty
-}
+ SUBDIRS += 3rdparty
-SUBDIRS += plugins
-qtHaveModule(quick): SUBDIRS += imports
+ location.depends = positioning 3rdparty
+ SUBDIRS += location
+ plugins.depends += location
+ qtHaveModule(quick):imports.depends += location
+
+ location_doc_snippets.subdir = location/doc/snippets
+ location_doc_snippets.depends = location
+ SUBDIRS += location_doc_snippets
+}
+
+qtHaveModule(quick) {
+ imports.depends += positioning
+ SUBDIRS += imports
+}
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index d9517add..ffbd9b84 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -57,7 +57,8 @@ qtHaveModule(location) {
qgeocameratiles
qtHaveModule(quick) {
- SUBDIRS += declarative_core
+ SUBDIRS += declarative_core \
+ declarative_geoshape
!mac: SUBDIRS += declarative_ui
}
diff --git a/tests/auto/declarative_core/tst_editorialmodel.qml b/tests/auto/declarative_core/tst_editorialmodel.qml
index 9c551972..ae01b4fd 100644
--- a/tests/auto/declarative_core/tst_editorialmodel.qml
+++ b/tests/auto/declarative_core/tst_editorialmodel.qml
@@ -93,7 +93,16 @@ TestCase {
Utils.testObjectProperties(testCase, testModel, data);
}
- function test_consecutive_fetch() {
+ function test_consecutive_fetch_data() {
+ return [
+ { tag: "batchSize 1", batchSize: 1 },
+ { tag: "batchSize 2", batchSize: 2 },
+ { tag: "batchSize 5", batchSize: 5 },
+ { tag: "batchSize 10", batchSize: 10 },
+ ];
+ }
+
+ function test_consecutive_fetch(data) {
var expectedEditorials = [
{
"title": "Editorial 1",
@@ -123,7 +132,7 @@ TestCase {
]
var model = createModel();
- Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedEditorials);
+ Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedEditorials, data);
model.destroy();
}
diff --git a/tests/auto/declarative_core/tst_imagemodel.qml b/tests/auto/declarative_core/tst_imagemodel.qml
index afb596e4..31f1e448 100644
--- a/tests/auto/declarative_core/tst_imagemodel.qml
+++ b/tests/auto/declarative_core/tst_imagemodel.qml
@@ -93,7 +93,16 @@ TestCase {
Utils.testObjectProperties(testCase, testModel, data);
}
- function test_consecutive_fetch() {
+ function test_consecutive_fetch_data() {
+ return [
+ { tag: "batchSize 1", batchSize: 1 },
+ { tag: "batchSize 2", batchSize: 2 },
+ { tag: "batchSize 5", batchSize: 5 },
+ { tag: "batchSize 10", batchSize: 10 },
+ ];
+ }
+
+ function test_consecutive_fetch(data) {
var expectedImages = [
{
"url": "http://somewhere.com/image1.png",
@@ -123,7 +132,7 @@ TestCase {
]
var model = createModel();
- Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedImages);
+ Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedImages, data);
model.destroy();
}
diff --git a/tests/auto/declarative_core/tst_placesearchmodel.qml b/tests/auto/declarative_core/tst_placesearchmodel.qml
index f5223e4c..2020a4f8 100644
--- a/tests/auto/declarative_core/tst_placesearchmodel.qml
+++ b/tests/auto/declarative_core/tst_placesearchmodel.qml
@@ -101,7 +101,6 @@ TestCase {
return [
{ tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin },
{ tag: "searchArea", property: "searchArea", signal: "searchAreaChanged", value: testSearchArea, reset: QtPositioning.shape() },
- { tag: "offset", property: "offset", signal: "offsetChanged", value: 10, reset: 0 },
{ tag: "limit", property: "limit", signal: "limitChanged", value: 10, reset: -1 },
{ tag: "searchTerm", property: "searchTerm", signal: "searchTermChanged", value: "Test term", reset: "" },
diff --git a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml b/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml
index 2d661b05..51f348e3 100644
--- a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml
+++ b/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml
@@ -78,7 +78,6 @@ TestCase {
return [
{ tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin },
{ tag: "searchArea", property: "searchArea", signal: "searchAreaChanged", value: testSearchArea, reset: QtPositioning.shape() },
- { tag: "offset", property: "offset", signal: "offsetChanged", value: 10, reset: 0 },
{ tag: "limit", property: "limit", signal: "limitChanged", value: 10, reset: -1 },
{ tag: "searchTerm", property: "searchTerm", signal: "searchTermChanged", value: "Test term", reset: "" },
@@ -86,7 +85,7 @@ TestCase {
}
function test_setAndGet(data) {
- //Utils.testObjectProperties(testCase, testModel, data);
+ Utils.testObjectProperties(testCase, testModel, data);
}
SignalSpy { id: statusChangedSpy; target: testModel; signalName: "statusChanged" }
diff --git a/tests/auto/declarative_core/tst_position.qml b/tests/auto/declarative_core/tst_position.qml
index 8bb42960..07d92328 100644
--- a/tests/auto/declarative_core/tst_position.qml
+++ b/tests/auto/declarative_core/tst_position.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtPositioning 5.2
+import QtPositioning 5.3
TestCase {
id: testCase
@@ -61,6 +61,8 @@ TestCase {
SignalSpy { id: horizontalAccuracyValidSpy; target: defaultPosition; signalName: "horizontalAccuracyValidChanged" }
SignalSpy { id: verticalAccuracySpy; target: defaultPosition; signalName: "verticalAccuracyChanged" }
SignalSpy { id: verticalAccuracyValidSpy; target: defaultPosition; signalName: "verticalAccuracyValidChanged" }
+ SignalSpy { id: directionSpy; target: defaultPosition; signalName: "directionChanged" }
+ SignalSpy { id: verticalSpeedSpy; target: defaultPosition; signalName: "verticalSpeedChanged" }
function test_defaults() {
compare(defaultPosition.latitudeValid, false);
@@ -69,6 +71,10 @@ TestCase {
compare(defaultPosition.speedValid, false);
compare(defaultPosition.horizontalAccuracyValid, false);
compare(defaultPosition.verticalAccuracyValid, false);
+ verify(!defaultPosition.directionValid);
+ verify(isNaN(defaultPosition.direction));
+ verify(!defaultPosition.verticalSpeedValid);
+ verify(isNaN(defaultPosition.verticalSpeed));
}
function test_modifiers() {
@@ -83,6 +89,8 @@ TestCase {
horizontalAccuracyValidSpy.clear();
verticalAccuracySpy.clear();
verticalAccuracyValidSpy.clear();
+ directionSpy.clear();
+ verticalSpeedSpy.clear();
defaultPosition.horizontalAccuracy = 10;
compare(horizontalAccuracySpy.count, 1);
diff --git a/tests/auto/declarative_core/tst_positionsource.qml b/tests/auto/declarative_core/tst_positionsource.qml
index 6cf99d04..405c46ae 100644
--- a/tests/auto/declarative_core/tst_positionsource.qml
+++ b/tests/auto/declarative_core/tst_positionsource.qml
@@ -117,6 +117,8 @@ TestCase {
PositionSource { id: testingSource; name: "test.source"; updateInterval: 1000 }
SignalSpy { id: updateSpy; target: testingSource; signalName: "positionChanged" }
+ SignalSpy { id: directionValidSpy; target: testingSource.position; signalName: "directionValidChanged" }
+ SignalSpy { id: directionSpy; target: testingSource.position; signalName: "directionChanged" }
function test_updateInterval() {
testingSource.updateInterval = 1000;
@@ -139,20 +141,38 @@ TestCase {
function test_updates() {
updateSpy.clear();
+ compare(directionValidSpy.count, 0)
+ compare(directionSpy.count, 0)
+
testingSource.active = true;
tryCompare(updateSpy, "count", 1, 1500);
compare(testingSource.position.coordinate.longitude, 0.1);
compare(testingSource.position.coordinate.latitude, 0.1);
+ compare(directionValidSpy.count, 1)
+ compare(directionSpy.count, 1)
+ fuzzyCompare(testingSource.position.direction, 45, 0.1)
+ verify(!testingSource.position.speedValid)
+ verify(isNaN(testingSource.position.speed))
tryCompare(updateSpy, "count", 2, 1500);
compare(testingSource.position.coordinate.longitude, 0.2);
compare(testingSource.position.coordinate.latitude, 0.2);
+ compare(directionValidSpy.count, 1)
+ compare(directionSpy.count, 2)
+ fuzzyCompare(testingSource.position.direction, 45, 0.1)
+ verify(testingSource.position.speedValid)
+ verify(testingSource.position.speed > 15000)
testingSource.active = false;
wait(2500);
compare(updateSpy.count, 2);
compare(testingSource.position.coordinate.longitude, 0.2);
compare(testingSource.position.coordinate.latitude, 0.2);
+ compare(directionValidSpy.count, 1)
+ compare(directionSpy.count, 2)
+ fuzzyCompare(testingSource.position.direction, 45, 0.1)
+ verify(testingSource.position.speedValid)
+ verify(testingSource.position.speed > 15000)
}
}
diff --git a/tests/auto/declarative_core/tst_reviewmodel.qml b/tests/auto/declarative_core/tst_reviewmodel.qml
index ca195077..62a7ac5e 100644
--- a/tests/auto/declarative_core/tst_reviewmodel.qml
+++ b/tests/auto/declarative_core/tst_reviewmodel.qml
@@ -92,7 +92,16 @@ TestCase {
Utils.testObjectProperties(testCase, testModel, data);
}
- function test_consecutive_fetch() {
+ function test_consecutive_fetch_data() {
+ return [
+ { tag: "batchSize 1", batchSize: 1 },
+ { tag: "batchSize 2", batchSize: 2 },
+ { tag: "batchSize 5", batchSize: 5 },
+ { tag: "batchSize 10", batchSize: 10 },
+ ];
+ }
+
+ function test_consecutive_fetch(data) {
//Note: in javascript the months go from 0(Jan) to 11(Dec)
var expectedReviews = [
{
@@ -138,7 +147,7 @@ TestCase {
]
var model = createModel();
- Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedReviews);
+ Utils.testConsecutiveFetch(testCase, model, parkViewHotel, expectedReviews, data);
model.destroy();
}
diff --git a/tests/auto/declarative_core/tst_supplier.qml b/tests/auto/declarative_core/tst_supplier.qml
index de35e95f..a98bb79e 100644
--- a/tests/auto/declarative_core/tst_supplier.qml
+++ b/tests/auto/declarative_core/tst_supplier.qml
@@ -87,6 +87,7 @@ TestCase {
Plugin {
id: testPlugin
name: "qmlgeo.test.plugin"
+ allowExperimental: true
}
Plugin {
diff --git a/tests/auto/declarative_core/utils.js b/tests/auto/declarative_core/utils.js
index 0a659ab2..5370bab5 100644
--- a/tests/auto/declarative_core/utils.js
+++ b/tests/auto/declarative_core/utils.js
@@ -91,7 +91,7 @@ function compareObj(testCase, obj1, obj2) {
}
}
-function testConsecutiveFetch(testCase, model, place, expectedValues)
+function testConsecutiveFetch(testCase, model, place, expectedValues, data)
{
var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
signalSpy.target = model;
@@ -108,35 +108,31 @@ function testConsecutiveFetch(testCase, model, place, expectedValues)
testCase.compare(visDataModel.items.count, 0);
//perform an initial fetch with the default batch size
+ model.batchSize = data.batchSize
model.place = place;
testCase.tryCompare(signalSpy, "count", 1);
signalSpy.clear();
var totalCount = model.totalCount;
testCase.compare(totalCount, 5);
- testCase.compare(visDataModel.items.count, 1);
+ testCase.compare(visDataModel.items.count, Math.min(data.batchSize, totalCount));
compareObj(testCase, visDataModel.items.get(0).model, expectedValues[0]);
- //set a non-default batch size and fetch the next batch
- model.batchSize = 2;
- visDataModel.items.create(0); //'creating' the last item will trigger a fetch
- testCase.tryCompare(visDataModel.items, "count", 3);
- testCase.compare(signalSpy.count, 0);
- testCase.compare(model.totalCount, totalCount);
-
- compareObj(testCase, visDataModel.items.get(1).model, expectedValues[1]);
- compareObj(testCase, visDataModel.items.get(2).model, expectedValues[2]);
-
- //set a batch size greater than the number of remaining items and fetch that batch
- model.batchSize = 10;
- visDataModel.items.create(2);
- testCase.tryCompare(visDataModel.items, "count", totalCount);
- testCase.compare(signalSpy.count, 0);
- testCase.compare(model.totalCount, totalCount);
-
- compareObj(testCase, visDataModel.items.get(3).model, expectedValues[3]);
- compareObj(testCase, visDataModel.items.get(4).model, expectedValues[4]);
+ //fetch remaining items, in batchSize batches
+ while (visDataModel.items.count < totalCount) {
+ var startIndex = visDataModel.items.count
+
+ //'creating' the last item will trigger a fetch
+ visDataModel.items.create(visDataModel.items.count - 1);
+
+ testCase.tryCompare(visDataModel.items, "count", Math.min(totalCount, startIndex + data.batchSize));
+ testCase.compare(signalSpy.count, 0);
+ testCase.compare(model.totalCount, totalCount);
+
+ for (var i = startIndex; i < Math.min(totalCount, startIndex + data.batchSize); ++i)
+ compareObj(testCase, visDataModel.items.get(i).model, expectedValues[i]);
+ }
visDataModel.destroy();
signalSpy.destroy();
diff --git a/tests/auto/declarative_geoshape/declarative_geoshape.pro b/tests/auto/declarative_geoshape/declarative_geoshape.pro
new file mode 100644
index 00000000..54331c57
--- /dev/null
+++ b/tests/auto/declarative_geoshape/declarative_geoshape.pro
@@ -0,0 +1,14 @@
+# QML tests in this directory must not depend on an OpenGL context.
+
+TEMPLATE = app
+TARGET = tst_declarative_geoshape
+CONFIG += qmltestcase
+SOURCES += main.cpp
+
+QT += positioning quick
+
+OTHER_FILES = *.qml
+TESTDATA = $$OTHER_FILES
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+CONFIG+=insignificant_test # QTBUG-31798
diff --git a/src/location/maps/qgeocoordinateinterpolator.cpp b/tests/auto/declarative_geoshape/main.cpp
index d7bc3019..efc51279 100644
--- a/src/location/maps/qgeocoordinateinterpolator.cpp
+++ b/tests/auto/declarative_geoshape/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtLocation module of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -38,12 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qgeocoordinateinterpolator_p.h"
-QT_BEGIN_NAMESPACE
-
-QGeoCoordinateInterpolator::QGeoCoordinateInterpolator() {}
-
-QGeoCoordinateInterpolator::~QGeoCoordinateInterpolator() {}
-
-QT_END_NAMESPACE
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(declarative_geoshape)
diff --git a/tests/auto/declarative_core/tst_geoshape.qml b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
index fcc2b07c..b12fc710 100644
--- a/tests/auto/declarative_core/tst_geoshape.qml
+++ b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
@@ -90,11 +90,26 @@ Item {
property variant br: QtPositioning.coordinate(0, 1)
property variant ntr: QtPositioning.coordinate(3, 3)
+ property variant invalid: QtPositioning.coordinate(100, 190)
property variant inside: QtPositioning.coordinate(0.5, 0.5)
property variant outside: QtPositioning.coordinate(2, 2)
property variant box: QtPositioning.rectangle(tl, br)
+ property variant coordinates: [bl, tl, tr, br]
+ property variant coordinates2: [bl, tl, tr, br, ntr]
+ property variant coordinates3: [tr]
+ property variant coordinates4: [invalid]
+ property variant coordinates5: []
+
+ property variant listBox: QtPositioning.rectangle(coordinates)
+ property variant listBox2: QtPositioning.rectangle(coordinates2)
+ property variant listBox3: QtPositioning.rectangle(coordinates3)
+ property variant listBox4: QtPositioning.rectangle(coordinates4)
+ property variant listBox5: QtPositioning.rectangle(coordinates5)
+
+ property variant widthBox: QtPositioning.rectangle(inside, 1, 1);
+
// C++ auto test exists for basics of bounding box, testing here
// only added functionality
TestCase {
@@ -106,6 +121,17 @@ Item {
compare (box.contains(outside), false)
box.topRight = ntr
compare (box.contains(outside), true)
+
+ compare (listBox.isValid, true)
+ compare (listBox.contains(outside), false)
+ compare (listBox2.contains(outside), true)
+ compare (listBox3.isValid, true)
+ compare (listBox3.isEmpty, true)
+ compare (listBox4.isValid, false)
+ compare (listBox5.isValid, false)
+
+ compare (widthBox.contains(inside), true)
+ compare (widthBox.contains(outside), false)
}
}
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 52ad3cbb..bf17a19f 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -67,6 +67,7 @@ Item {
property variant coordinate2: QtPositioning.coordinate(12, 13)
property variant coordinate3: QtPositioning.coordinate(50, 50, 0)
property variant coordinate4: QtPositioning.coordinate(80, 80, 0)
+ property variant coordinate5: QtPositioning.coordinate(20, 180)
property variant invalidCoordinate: QtPositioning.coordinate()
property variant altitudelessCoordinate: QtPositioning.coordinate(50, 50)
@@ -102,11 +103,59 @@ Item {
map.center = coordinate2
compare(mapCenterSpy.count, 1)
+ // change center to dateline
+ mapCenterSpy.clear()
+ compare(mapCenterSpy.count, 0)
+ map.center = coordinate5
+ compare(mapCenterSpy.count, 1)
+ compare(map.center, coordinate5)
+
+ map.center = coordinate2
+
verify(isNaN(map.center.altitude));
compare(map.center.longitude, 13)
compare(map.center.latitude, 12)
}
+ function test_zoom_limits() {
+ map.center.latitude = 30
+ map.center.longitude = 60
+ map.zoomLevel = 4
+
+ //initial plugin values
+ compare(map.minimumZoomLevel, 0)
+ compare(map.maximumZoomLevel, 20)
+
+ //Higher min level than curr zoom, should change curr zoom
+ map.minimumZoomLevel = 5
+ map.maximumZoomLevel = 18
+ compare(map.zoomLevel, 5)
+ compare(map.minimumZoomLevel, 5)
+ compare(map.maximumZoomLevel, 18)
+
+ //Trying to set higher than max, max should be set.
+ map.maximumZoomLevel = 21
+ compare(map.minimumZoomLevel, 5)
+ compare(map.maximumZoomLevel, 20)
+
+ //Negative values should be ignored
+ map.minimumZoomLevel = -1
+ map.maximumZoomLevel = -2
+ compare(map.minimumZoomLevel, 5)
+ compare(map.maximumZoomLevel, 20)
+
+ //Max limit lower than curr zoom, should change curr zoom
+ map.zoomLevel = 18
+ map.maximumZoomLevel = 16
+ compare(map.zoomLevel, 16)
+
+ //reseting default
+ map.minimumZoomLevel = 0
+ map.maximumZoomLevel = 20
+ compare(map.minimumZoomLevel, 0)
+ compare(map.maximumZoomLevel, 20)
+ }
+
function test_pan() {
map.center.latitude = 30
map.center.longitude = 60
diff --git a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
new file mode 100644
index 00000000..54448973
--- /dev/null
+++ b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtLocation 5.0
+import QtPositioning 5.3
+
+Item {
+ width:100
+ height:100
+ // General-purpose elements for the test:
+ Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true }
+
+
+ property var coordinateList: []
+ property int coordinateCount: 0
+ property int animationDuration: 100
+
+ Map {id: map
+ plugin: testPlugin
+ width: 100
+ height: 100
+
+ Behavior on center {
+ id: centerBehavior
+
+ enabled: false
+ CoordinateAnimation { duration: animationDuration }
+ }
+
+ onCenterChanged: {
+ if (!coordinateList) {
+ coordinateList = []
+ }
+
+ coordinateList[coordinateCount] = {'latitude': center.latitude, 'longitude': center.longitude}
+ coordinateCount++
+ }
+ }
+
+ function toMercator(coord) {
+ var pi = Math.PI
+ var lon = coord.longitude / 360.0 + 0.5;
+
+ var lat = coord.latitude;
+ lat = 0.5 - (Math.log(Math.tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
+ lat = Math.max(0.0, lat);
+ lat = Math.min(1.0, lat);
+
+ return {'latitude': lat, 'longitude': lon};
+ }
+
+ TestCase {
+ when: windowShown
+ name: "Coordinate animation"
+
+ function test_coordinate_animation() {
+
+ coordinateList = []
+ coordinateCount = 0
+
+ var from = {'latitude': 58.0, 'longitude': 12.0}
+ var to = {'latitude': 62.0, 'longitude': 24.0}
+
+
+ var fromMerc = toMercator(from)
+ var toMerc = toMercator(to)
+
+ var delta = (toMerc.latitude - fromMerc.latitude) / (toMerc.longitude - fromMerc.longitude)
+
+ // Set from coordinate with animation disabled.
+ map.center = QtPositioning.coordinate(from.latitude, from.longitude)
+
+ // Expect only one update
+ compare(coordinateList.length, 1)
+
+ // Set to coordinate with animation enabled
+ centerBehavior.enabled = true
+ map.center = QtPositioning.coordinate(to.latitude, to.longitude)
+ wait(animationDuration * 2)
+
+ //check correct start position
+ compare(coordinateList[0].latitude, from.latitude)
+ compare(coordinateList[0].longitude, from.longitude)
+
+ //check correct end position
+ compare(coordinateList[coordinateList.length - 1].latitude, to.latitude)
+ compare(coordinateList[coordinateList.length - 1].longitude, to.longitude)
+
+ var i
+ var lastLatitude
+ for (i in coordinateList) {
+ var coordinate = coordinateList[i]
+ var mercCoordinate = toMercator(coordinate)
+
+ //check that coordinates from the animation is along a straight line between from and to
+ var estimatedLatitude = fromMerc.latitude + (mercCoordinate.longitude - fromMerc.longitude) * delta
+ verify(mercCoordinate.latitude - estimatedLatitude < 0.00000000001);
+
+ //check that each step has moved in the right direction
+ if (lastLatitude) {
+ verify(coordinate.latitude > lastLatitude)
+ }
+ lastLatitude = coordinate.latitude
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative_ui/tst_map_geocoding.qml b/tests/auto/declarative_ui/tst_map_geocoding.qml
index 5d6b33a8..1f5f508a 100644
--- a/tests/auto/declarative_ui/tst_map_geocoding.qml
+++ b/tests/auto/declarative_ui/tst_map_geocoding.qml
@@ -45,7 +45,7 @@ import QtLocation 5.0
import QtPositioning 5.2
Item {
- Plugin { id: nokiaPlugin; name: "qmlgeo.test.plugin"}
+ Plugin { id: nokiaPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true}
Plugin { id: invalidPlugin; name: "invalid"}
property variant coordinate1: QtPositioning.coordinate(51, 41)
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 6533e964..80d5d132 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -97,16 +97,15 @@ Item {
}
color: 'firebrick'
radius: 600000
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
- onClicked: console.log('ext circle clicked')
SignalSpy { id: extMapCircleClicked; target: parent; signalName: "clicked" }
}
}
MapQuickItem {
id: extMapQuickItem
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
SignalSpy { id: extMapQuickItemClicked; target: parent; signalName: "clicked" }
}
@@ -140,10 +139,11 @@ Item {
latitude: 10
longitude: 30
}
- MapMouseArea {
+ MouseArea {
id: preMapRectMa
anchors.fill: parent
drag.target: parent
+ preventStealing: true
SignalSpy { id: preMapRectClicked; target: parent; signalName: "clicked" }
SignalSpy { id: preMapRectActiveChanged; target: parent.drag; signalName: "activeChanged" }
}
@@ -159,11 +159,12 @@ Item {
latitude: 10
longitude: 30
}
- radius: 400000
- MapMouseArea {
+ radius: 10000
+ MouseArea {
id: preMapCircleMa
anchors.fill: parent
drag.target: parent
+ preventStealing: true
SignalSpy { id: preMapCircleClicked; target: parent; signalName: "clicked" }
SignalSpy { id: preMapCircleActiveChanged; target: parent.drag; signalName: "activeChanged" }
}
@@ -175,9 +176,11 @@ Item {
}
MapQuickItem {
id: preMapQuickItem
- MapMouseArea {
+ MouseArea {
+ id: preMapQuickItemMa
anchors.fill: parent
drag.target: parent
+ preventStealing: true
SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" }
SignalSpy { id: preMapQuickItemActiveChanged; target: parent.drag; signalName: "activeChanged" }
}
@@ -204,7 +207,7 @@ Item {
{ latitude: 20, longitude: 10 },
{ latitude: 15, longitude: 6 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
SignalSpy { id: preMapPolygonClicked; target: parent; signalName: "clicked" }
@@ -258,30 +261,39 @@ Item {
// precondition
compare(preMapRectClicked.count, 0)
compare(preMapCircleClicked.count, 0)
+
// click rect
+ map.center = preMapRect.topLeft
var point = map.toScreenPosition(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 1)
mouseClick(map, 1, 1) // no item hit
compare(preMapRectClicked.count, 1)
compare(preMapCircleClicked.count, 0)
+
// click circle, overlaps and is above rect
- visualInspectionPoint() // marks good visual inspection point
+ map.center = preMapCircle.center
point = map.toScreenPosition(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 1)
compare(preMapCircleClicked.count, 1)
+
// click within circle bounding rect but not inside the circle geometry
+ map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
compare(preMapRectClicked.count, 2)
compare(preMapCircleClicked.count, 1)
+
// click quick item
compare(preMapQuickItemClicked.count, 0)
+ map.center = preMapQuickItem.coordinate
point = map.toScreenPosition(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 1)
+
// click polygon
compare (preMapPolygonClicked.count, 0)
+ map.center = preMapPolygon.path[1]
point = map.toScreenPosition(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 1)
@@ -290,26 +302,31 @@ Item {
map.clearMapItems()
clear_data()
compare (map.mapItems.length, 0)
+ map.center = preMapRect.topLeft
point = map.toScreenPosition(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 0)
visualInspectionPoint()
+ map.center = preMapCircle.center
point = map.toScreenPosition(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 0)
compare(preMapCircleClicked.count, 0)
+ map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
compare(preMapRectClicked.count, 0)
compare(preMapCircleClicked.count, 0)
compare(preMapQuickItemClicked.count, 0)
+ map.center = preMapQuickItem.coordinate
point = map.toScreenPosition(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 0)
+ map.center = preMapPolygon.path[1]
point = map.toScreenPosition(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 0)
- // re-add items and verify they are back (without needing to pan map etc.)
+ // re-add items and verify they are back
// note: addition order is significant
map.addMapItem(preMapRect)
map.addMapItem(preMapCircle)
@@ -319,20 +336,25 @@ Item {
map.addMapItem(preMapRoute)
compare (map.mapItems.length, 6)
visualInspectionPoint()
+ map.center = preMapRect.topLeft
point = map.toScreenPosition(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 1)
+ map.center = preMapCircle.center
point = map.toScreenPosition(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 1)
compare(preMapCircleClicked.count, 1)
+ map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
compare(preMapRectClicked.count, 2)
compare(preMapCircleClicked.count, 1)
compare(preMapQuickItemClicked.count, 0)
+ map.center = preMapQuickItem.coordinate
point = map.toScreenPosition(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 1)
+ map.center = preMapPolygon.path[1]
point = map.toScreenPosition(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 1)
@@ -340,41 +362,45 @@ Item {
// item clips to map. not sure if this is sensible test
map.addMapItem(extMapCircle)
+ map.center = extMapCircle.center
visualInspectionPoint();
point = map.toScreenPosition(extMapCircle.center)
mouseClick(map, point.x, point.y)
compare(extMapCircleClicked.count, 1)
mouseClick(map, point.x, -5)
compare(extMapCircleClicked.count, 1)
+ map.removeMapItem(extMapCircle)
map.addMapItem(extMapQuickItem)
+ map.center = extMapQuickItem.coordinate
visualInspectionPoint();
point = map.toScreenPosition(extMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(extMapQuickItemClicked.count, 1)
mouseClick(map, map.width + 5, point.y + 5)
compare(extMapQuickItemClicked.count, 1)
+ map.removeMapItem(extMapQuickItem)
}
function test_ab_drag() {
clear_data()
// basic drags, drag rectangle
compare (preMapRectActiveChanged.count, 0)
- var i = 0
+ map.center = preMapRect.topLeft
+ var i
var point = map.toScreenPosition(preMapRect.topLeft)
+ var targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
- for (i=0; i < 50; i += 5) {
+ for (i = 0; i < 50; i += 1) {
wait(1)
mouseMove(map, point.x + 5 - i, point.y + 5 - i)
}
mouseRelease(map, point.x + 5 - i, point.y + 5 - i)
- visualInspectionPoint()
compare (preMapRectActiveChanged.count, 2)
- // coordinates update only (once) after drag has finished
- compare (preMapRectTopLeftChanged.count, 1)
- compare (preMapRectBottomRightChanged.count, 1)
- verify(fuzzy_compare(preMapRect.topLeft.latitude, 27.2, 0.1))
- verify(fuzzy_compare(preMapRect.topLeft.longitude, 12.1, 0.1))
+ verify(preMapRectTopLeftChanged.count > 1)
+ verify(preMapRectBottomRightChanged.count === preMapRectTopLeftChanged.count)
+ verify(fuzzy_compare(preMapRect.topLeft.latitude, targetCoordinate.latitude, 0.2))
+ verify(fuzzy_compare(preMapRect.topLeft.longitude, targetCoordinate.longitude, 0.2))
var latH = preMapRect.bottomRight.latitude - preMapRect.topLeft.latitude
var lonW = preMapRect.bottomRight.longitude - preMapRect.topLeft.longitude
verify(fuzzy_compare(preMapRect.bottomRight.latitude, preMapRect.topLeft.latitude + latH, 0.1))
@@ -382,34 +408,38 @@ Item {
// drag circle
compare (preMapCircleActiveChanged.count, 0)
+ map.center = preMapCircle.center
point = map.toScreenPosition(preMapCircle.center)
+ targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x, point.y)
- for (i=0; i < 50; i += 5) {
+ for (i = 0; i < 50; i += 1) {
wait(1)
mouseMove(map, point.x - i, point.y - i)
}
mouseRelease(map, point.x - i, point.y - i)
visualInspectionPoint()
- compare (preMapRectActiveChanged.count, 2)
- compare (preMapCircleCenterChanged.count, 1)
- verify(fuzzy_compare(preMapCircle.center.latitude, 17.7, 0.1))
- verify(fuzzy_compare(preMapCircle.center.longitude, 22.1, 0.1))
+ compare(preMapRectActiveChanged.count, 2)
+ compare(preMapCircleActiveChanged.count, 2)
+ verify(preMapCircleCenterChanged.count > 1)
+ verify(fuzzy_compare(preMapCircle.center.latitude, targetCoordinate.latitude, 0.2))
+ verify(fuzzy_compare(preMapCircle.center.longitude, targetCoordinate.longitude, 0.2))
// drag quick item
compare (preMapQuickItemActiveChanged.count, 0)
- i = 0
+ map.center = preMapQuickItem.coordinate
point = map.toScreenPosition(preMapQuickItem.coordinate)
+ targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
- for (i=0; i < 50; i += 5) {
+ for (i = 0; i < 50; i += 1) {
wait(1)
- mouseMove(map, point.x + i, point.y + i)
+ mouseMove(map, point.x - i, point.y - i)
}
- mouseRelease(map, point.x + i, point.y + i)
+ mouseRelease(map, point.x - i, point.y - i)
visualInspectionPoint()
- compare (preMapQuickItemActiveChanged.count, 2)
- compare (preMapQuickItemCoordinateChanged.count, 1)
- verify(fuzzy_compare(preMapQuickItem.coordinate.latitude, 29, 0.1))
- verify(fuzzy_compare(preMapQuickItem.coordinate.longitude, 10, 0.1))
+ compare(preMapQuickItemActiveChanged.count, 2)
+ verify(preMapQuickItemCoordinateChanged.count > 1)
+ verify(fuzzy_compare(preMapQuickItem.coordinate.latitude, targetCoordinate.latitude, 0.2))
+ verify(fuzzy_compare(preMapQuickItem.coordinate.longitude, targetCoordinate.longitude, 0.2))
}
function test_ac_basic_properties() {
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index ccaba322..ca7ca8c2 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -65,7 +65,7 @@ Item {
{ latitude: 25, longitude: 5 },
{ latitude: 20, longitude: 10 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
SignalSpy { id: extMapPolygonClicked; target: parent; signalName: "clicked" }
@@ -109,9 +109,10 @@ Item {
latitude: 10
longitude: -175
}
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
+ preventStealing: true
}
}
@@ -123,17 +124,19 @@ Item {
longitude: 180
}
radius: 400000
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
+ preventStealing: true
}
}
MapQuickItem {
id: extMapQuickItemDateline
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
+ preventStealing: true
}
coordinate {
latitude: 20
@@ -155,9 +158,10 @@ Item {
{ latitude: 10, longitude: -175 },
{ latitude: 10, longitude: 175 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
+ preventStealing: true
}
}
@@ -168,7 +172,7 @@ Item {
{ latitude: 20, longitude: 175 },
{ latitude: 25, longitude: -175 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -196,7 +200,7 @@ Item {
latitude: 10
longitude: -5
}
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -210,7 +214,7 @@ Item {
longitude: -15
}
radius: 400000
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -218,7 +222,7 @@ Item {
MapQuickItem {
id: extMapQuickItemEdge
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -242,7 +246,7 @@ Item {
{ latitude: 10, longitude: -5 },
{ latitude: 10, longitude: -15 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -255,7 +259,7 @@ Item {
{ latitude: 20, longitude: -15 },
{ latitude: 25, longitude: -5 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
}
@@ -322,6 +326,7 @@ Item {
clear_data()
compare (extMapPolygon.border.width, 1.0)
compare (extMapPolygonClicked.count, 0)
+ map.center = extMapPolygon.path[1]
var point = map.toScreenPosition(extMapPolygon.path[1])
map.addMapItem(extMapPolygon)
verify(extMapPolygon.path.length == 2)
@@ -429,6 +434,7 @@ Item {
extMapRectDateline.bottomRight.longitude = datelineCoordinateRight.longitude
point = map.toScreenPosition(extMapRectDateline.bottomRight)
verify(point.x > map.width / 2.0)
+ // move item edge onto dateline
extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude
point = map.toScreenPosition(extMapRectDateline.topLeft)
verify(point.x == map.width / 2.0)
@@ -448,8 +454,9 @@ Item {
// circle
map.addMapItem(extMapCircleDateline)
- verify(extMapCircleDateline.center.longitude == 180)
- var point = map.toScreenPosition(extMapCircleDateline.center)
+ verify(extMapCircleDateline.center.longitude === 180)
+ map.center = datelineCoordinate
+ point = map.toScreenPosition(extMapCircleDateline.center)
verify(point.x == map.width / 2.0)
extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude
point = map.toScreenPosition(extMapCircleDateline.center)
@@ -466,7 +473,8 @@ Item {
// quickitem
map.addMapItem(extMapQuickItemDateline)
- verify(extMapQuickItemDateline.coordinate.longitude == 175)
+ map.center = datelineCoordinate
+ verify(extMapQuickItemDateline.coordinate.longitude === 175)
point = map.toScreenPosition(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude
@@ -484,6 +492,7 @@ Item {
// polygon
map.addMapItem(extMapPolygonDateline)
+ map.center = datelineCoordinate
verify(extMapPolygonDateline.path[0].longitude == 175)
verify(extMapPolygonDateline.path[1].longitude == -175)
verify(extMapPolygonDateline.path[2].longitude == -175)
@@ -530,6 +539,7 @@ Item {
// polyline
map.addMapItem(extMapPolylineDateline)
+ map.center = datelineCoordinate
verify(extMapPolylineDateline.path[0].longitude == 175)
verify(extMapPolylineDateline.path[1].longitude == -175)
point = map.toScreenPosition(extMapPolylineDateline.path[0])
@@ -626,6 +636,7 @@ Item {
// circle
map.addMapItem(extMapCircleEdge)
+ map.center = datelineCoordinate
verify(extMapCircleEdge.center.longitude == -15)
var point = map.toScreenPosition(extMapCircleEdge.center)
verify(point.x < map.width)
@@ -647,6 +658,7 @@ Item {
// quickitem
map.addMapItem(extMapQuickItemEdge)
+ map.center = datelineCoordinate
verify(extMapQuickItemEdge.coordinate.longitude == -15)
point = map.toScreenPosition(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
@@ -666,6 +678,7 @@ Item {
map.removeMapItem(extMapQuickItemEdge)
// polygon
+ map.center = datelineCoordinate
map.addMapItem(extMapPolygonEdge)
verify(extMapPolygonEdge.path[0].longitude == -15)
verify(extMapPolygonEdge.path[1].longitude == -5)
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index ae839123..7c32fd65 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -114,6 +114,14 @@ Item {
property variant boundingBox: QtPositioning.rectangle(QtPositioning.coordinate(0, 0),
QtPositioning.coordinate(0, 0))
+ property variant fitRect: QtPositioning.rectangle(QtPositioning.coordinate(80, 80), QtPositioning.coordinate(78, 82))
+ property variant fitEmptyRect: QtPositioning.rectangle(QtPositioning.coordinate(79, 79),-1, -1)
+ property variant fitCircle: QtPositioning.circle(QtPositioning.coordinate(-50, -100), 1500)
+ property variant fitInvalidShape: QtPositioning.shape()
+
+ property variant fitCircleTopLeft: QtPositioning.coordinate(0, 0)
+ property variant fitCircleBottomRight: QtPositioning.coordinate(0, 0)
+
Map {
id: map;
x: 20; y: 20; width: 200; height: 200
@@ -127,7 +135,7 @@ Item {
border.width: 0
topLeft: preMapRectangleDefaultTopLeft
bottomRight: preMapRectangleDefaultBottomRight
- MapMouseArea {
+ MouseArea {
id: preMapRectMa
anchors.fill: parent
drag.target: parent
@@ -144,8 +152,7 @@ Item {
border.width: 0
center: preMapCircleDefaultCenter
radius: 400000
- MapMouseArea {
- id: preMapCircleMa
+ MouseArea {
anchors.fill: parent
drag.target: parent
SignalSpy { id: preMapCircleClicked; target: parent; signalName: "clicked" }
@@ -159,7 +166,7 @@ Item {
}
MapQuickItem {
id: preMapQuickItem
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" }
@@ -185,7 +192,7 @@ Item {
{ latitude: 20, longitude: 10 },
{ latitude: 15, longitude: 6 }
]
- MapMouseArea {
+ MouseArea {
anchors.fill: parent
drag.target: parent
SignalSpy { id: preMapPolygonClicked; target: parent; signalName: "clicked" }
@@ -313,6 +320,53 @@ Item {
}
}
+ function test_ad_fit_to_geoshape() {
+ reset()
+ visualInspectionPoint()
+ calculate_fit_circle_bounds()
+ //None should be visible
+ verify(!is_coord_on_screen(fitCircleTopLeft))
+ verify(!is_coord_on_screen(fitCircleBottomRight))
+ verify(!is_coord_on_screen(fitRect.topLeft))
+ verify(!is_coord_on_screen(fitRect.bottomRight))
+
+ map.fitViewportToGeoShape(fitRect)
+ visualInspectionPoint()
+ calculate_fit_circle_bounds()
+ //Rectangle should be visible, not circle
+ verify(!is_coord_on_screen(fitCircleTopLeft))
+ verify(!is_coord_on_screen(fitCircleBottomRight))
+ verify(is_coord_on_screen(fitRect.topLeft))
+ verify(is_coord_on_screen(fitRect.bottomRight))
+
+ map.fitViewportToGeoShape(fitCircle)
+ visualInspectionPoint()
+ calculate_fit_circle_bounds()
+ //Circle should be visible, not rectangle
+ verify(is_coord_on_screen(fitCircleTopLeft))
+ verify(is_coord_on_screen(fitCircleBottomRight))
+ verify(!is_coord_on_screen(fitRect.topLeft))
+ verify(!is_coord_on_screen(fitRect.bottomRight))
+
+ map.fitViewportToGeoShape(fitInvalidShape)
+ visualInspectionPoint()
+ calculate_fit_circle_bounds()
+ //Invalid shape, map should be in the same position as before
+ verify(is_coord_on_screen(fitCircleTopLeft))
+ verify(is_coord_on_screen(fitCircleBottomRight))
+ verify(!is_coord_on_screen(fitRect.topLeft))
+ verify(!is_coord_on_screen(fitRect.bottomRight))
+
+ map.fitViewportToGeoShape(fitEmptyRect)
+ visualInspectionPoint()
+ calculate_fit_circle_bounds()
+ //Empty shape, map should change centerlocation, empty rect visible
+ verify(!is_coord_on_screen(fitCircleTopLeft))
+ verify(!is_coord_on_screen(fitCircleBottomRight))
+ verify(is_coord_on_screen(fitEmptyRect.topLeft))
+ verify(is_coord_on_screen(fitEmptyRect.bottomRight))
+ }
+
/*function test_ad_visible_items_move() {
// move different individual items out of screen
// then fit viewport
@@ -413,6 +467,12 @@ Item {
preMapQuickItemSourceItemChanged.clear()
}
+ function calculate_fit_circle_bounds() {
+ var circleDiagonal = Math.sqrt(2 * fitCircle.radius * fitCircle.radius)
+ fitCircleTopLeft = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
+ fitCircleBottomRight = fitCircle.center.atDistanceAndAzimuth(circleDiagonal,135)
+ }
+
function calculate_bounds(){
var circleDiagonal = Math.sqrt(2 * preMapCircle.radius * preMapCircle.radius)
var itemTopLeft = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,-45)
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index 0f6e34da..a8bff2e8 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -46,7 +46,7 @@ import QtPositioning 5.2
import QtLocation.test 5.0
/*
- MapMouseArea setup for this test case.
+ MouseArea setup for this test case.
Map dimensions are 100 * 100
Item containing map is 120,120
@@ -82,11 +82,7 @@ Item {
width: 120
height: 120
// General-purpose elements for the test:
- Plugin { id: testPlugin; name : "qmlgeo.test.plugin";}
-
- MapMouseEvent{
- id: mapMouseEvent
- }
+ Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
function setMouseData(ma, me)
{
@@ -117,7 +113,7 @@ Item {
lastWheelAngleDeltaY = angleDelta.y;
}
- MapMouseArea {
+ MouseArea {
id: mouseUpper
objectName: "mouseUpper"
x: 0; y: 20; width: 100; height: 29
@@ -130,14 +126,17 @@ Item {
property bool lastIsClick: false
property bool lastAccepted: false;
- onClicked: { page.setMouseData(mouseUpper, mouse); }
- onDoubleClicked: { page.setMouseData(mouseUpper, mouse); }
- onPressed: { page.setMouseData(mouseUpper, mouse); }
- onReleased: { page.setMouseData(mouseUpper, mouse); }
- onPositionChanged: { page.setMouseData(mouseUpper, mouse); }
- onPressAndHold: { page.setMouseData(mouseUpper, mouse); }
+ preventStealing: true
+
+ // The following signal handlers use arguments[0] instead of mouse due to QTBUG-36560
+ onClicked: page.setMouseData(mouseUpper, arguments[0])
+ onDoubleClicked: page.setMouseData(mouseUpper, arguments[0])
+ onPressed: page.setMouseData(mouseUpper, arguments[0])
+ onReleased: page.setMouseData(mouseUpper, arguments[0])
+ onPositionChanged: page.setMouseData(mouseUpper, arguments[0])
+ onPressAndHold: page.setMouseData(mouseUpper, arguments[0])
}
- MapMouseArea {
+ MouseArea {
id: mouseLower
objectName: "mouseLower"
x: 0; y: 50; width: 100; height: 50
@@ -149,14 +148,16 @@ Item {
property bool lastWasHeld: false;
property bool lastIsClick: false
property bool lastAccepted: false;
- onClicked: { page.setMouseData(mouseLower, mouse); }
- onDoubleClicked: { page.setMouseData(mouseLower, mouse); }
- onPressed: { page.setMouseData(mouseLower, mouse); }
- onReleased: { page.setMouseData(mouseLower, mouse); }
- onPositionChanged: { page.setMouseData(mouseLower, mouse); }
- onPressAndHold: { page.setMouseData(mouseLower, mouse); }
+
+ // The following signal handlers use arguments[0] instead of mouse due to QTBUG-36560
+ onClicked: page.setMouseData(mouseLower, arguments[0])
+ onDoubleClicked: page.setMouseData(mouseLower, arguments[0])
+ onPressed: page.setMouseData(mouseLower, arguments[0])
+ onReleased: page.setMouseData(mouseLower, arguments[0])
+ onPositionChanged: page.setMouseData(mouseLower, arguments[0])
+ onPressAndHold: page.setMouseData(mouseLower, arguments[0])
}
- MapMouseArea {
+ MouseArea {
id: mouseOverlapper
objectName: "mouseOverlapper"
x: 50; y: 0; width: 50; height: 100
@@ -168,17 +169,19 @@ Item {
property bool lastWasHeld: false;
property bool lastIsClick: false
property bool lastAccepted: false;
- onClicked: { page.setMouseData(mouseOverlapper, mouse); }
- onDoubleClicked: { page.setMouseData(mouseOverlapper, mouse); }
- onPressed: { page.setMouseData(mouseOverlapper, mouse); }
- onReleased: { page.setMouseData(mouseOverlapper, mouse); }
- onPositionChanged: { page.setMouseData(mouseOverlapper, mouse); }
- onPressAndHold: { page.setMouseData(mouseOverlapper, mouse); }
+
+ // The following signal handlers use arguments[0] instead of mouse due to QTBUG-36560
+ onClicked: page.setMouseData(mouseOverlapper, arguments[0])
+ onDoubleClicked: page.setMouseData(mouseOverlapper, arguments[0])
+ onPressed: page.setMouseData(mouseOverlapper, arguments[0])
+ onReleased: page.setMouseData(mouseOverlapper, arguments[0])
+ onPositionChanged: page.setMouseData(mouseOverlapper, arguments[0])
+ onPressAndHold: page.setMouseData(mouseOverlapper, arguments[0])
}
}
TestCase {
- name: "MapMouseArea"
+ name: "MouseArea"
when: windowShown
SignalSpy {id: mouseUpperClickedSpy; target: mouseUpper; signalName: "clicked"}
SignalSpy {id: mouseLowerClickedSpy; target: mouseLower; signalName: "clicked"}
@@ -353,15 +356,6 @@ Item {
compare(mouseUpperClickedSpy.count, 1)
}
- function test_aab_event_basic_properties() {
- compare(mapMouseEvent.accepted, false)
- compare(mapMouseEvent.button, Qt.NoButton)
- compare(mapMouseEvent.modifiers, Qt.NoModifier)
- compare(mapMouseEvent.wasHeld, false)
- compare(mapMouseEvent.x, 0)
- compare(mapMouseEvent.y, 0)
- }
-
function test_basic_position_changed() {
// tests basic position changed/move when button is being pressed
clear_data();
diff --git a/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml b/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml
index 965da57c..4b46674f 100644
--- a/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml
@@ -785,7 +785,7 @@ Item {
// 16. moving center
clear_data()
pinchGenerator.pinch(Qt.point(0, 50), Qt.point(50,100), Qt.point(50,0), Qt.point(100, 50))
- tryCompare(pinchStartedSpy.count, 1)
+ tryCompare(pinchStartedSpy, "count", 1)
compare(map.lastPinchEvent.center.x, (map.lastPinchEvent.point1.x + map.lastPinchEvent.point2.x) /2)
compare(map.lastPinchEvent.center.x, (map.lastPinchEvent.point1.y + map.lastPinchEvent.point2.y) /2)
tryCompare(pinchFinishedSpy, "count", 1)
diff --git a/tests/auto/doublevectors/doublevectors.pro b/tests/auto/doublevectors/doublevectors.pro
index 98899218..aa42120d 100644
--- a/tests/auto/doublevectors/doublevectors.pro
+++ b/tests/auto/doublevectors/doublevectors.pro
@@ -1,11 +1,8 @@
TEMPLATE = app
CONFIG += testcase
TARGET = tst_doublevectors
-INCLUDEPATH += ../../../src/location/maps
-SOURCES += tst_doublevectors.cpp \
- ../../../src/location/maps/qdoublevector3d.cpp \
- ../../../src/location/maps/qdoublevector2d.cpp
+SOURCES += tst_doublevectors.cpp
-QT += location testlib
+QT += positioning-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/doublevectors/tst_doublevectors.cpp b/tests/auto/doublevectors/tst_doublevectors.cpp
index 9ca1ec17..79fe3a88 100644
--- a/tests/auto/doublevectors/tst_doublevectors.cpp
+++ b/tests/auto/doublevectors/tst_doublevectors.cpp
@@ -42,8 +42,8 @@
#include <QtCore/QString>
#include <QtTest/QtTest>
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qdoublevector3d_p.h>
QT_USE_NAMESPACE
diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro
index 3737414e..2519b7d0 100644
--- a/tests/auto/geotestplugin/geotestplugin.pro
+++ b/tests/auto/geotestplugin/geotestplugin.pro
@@ -1,5 +1,5 @@
TARGET = qtgeoservices_qmltestplugin
-QT += location-private testlib
+QT += location-private positioning-private testlib
PLUGIN_TYPE = geoservices
load(qt_plugin)
diff --git a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
index 29058c83..b48c0bb0 100644
--- a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
@@ -82,7 +82,7 @@ class QGeoCodingManagerEngineTest: public QGeoCodingManagerEngine
{
Q_OBJECT
public:
- QGeoCodingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoCodingManagerEngineTest(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) :
QGeoCodingManagerEngine(parameters),
validateWellKnownValues_(false),
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index ebdd3fa7..b9612ba9 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -83,7 +83,7 @@ class QGeoRoutingManagerEngineTest: public QGeoRoutingManagerEngine
QString errorString_;
public:
- QGeoRoutingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoRoutingManagerEngineTest(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) :
QGeoRoutingManagerEngine(parameters),
routeReply_(0),
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
index b902d75c..5e770475 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
@@ -56,15 +56,15 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
}
QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine(
- const QMap<QString, QVariant> & parameters,
- QGeoServiceProvider::Error * error, QString *errorString) const
+ const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoRoutingManagerEngineTest(parameters, error, errorString);
}
QGeoCodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerEngine(
- const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error,
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error,
QString *errorString) const
{
return new QGeoCodingManagerEngineTest(parameters, error, errorString);
@@ -72,14 +72,14 @@ QGeoCodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerE
QGeoMappingManagerEngine* QGeoServiceProviderFactoryTest::createMappingManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoTiledMappingManagerEngineTest(parameters, error, errorString);
}
QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
{
Q_UNUSED(error);
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
index 84939133..3b62850b 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
@@ -59,16 +59,16 @@ public:
~QGeoServiceProviderFactoryTest();
QGeoMappingManagerEngine* createMappingManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
QGeoRoutingManagerEngine* createRoutingManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString ) const;
QGeoCodingManagerEngine* createGeocodingManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
QPlaceManagerEngine* createPlaceManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
};
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
index 5e166544..1a499792 100644
--- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -58,7 +58,7 @@ class QGeoTiledMappingManagerEngineTest: public QGeoTiledMappingManagerEngine
{
Q_OBJECT
public:
- QGeoTiledMappingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoTiledMappingManagerEngineTest(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) :
QGeoTiledMappingManagerEngine()
{
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index 7affbc69..71ae8601 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -78,17 +78,15 @@ class QGeoTileFetcherTest: public QGeoTileFetcher
{
Q_OBJECT
public:
- QGeoTileFetcherTest(QGeoTiledMappingManagerEngine *engine, QObject *parent = 0)
- : QGeoTileFetcher(engine, parent),
- finishRequestImmediately_(false),
- mappingReply_(0),
- timerId_(0),
- errorCode_(QGeoTiledMapReply::NoError) {}
+ QGeoTileFetcherTest(QObject *parent = 0)
+ : QGeoTileFetcher(parent), finishRequestImmediately_(false), mappingReply_(0),
+ errorCode_(QGeoTiledMapReply::NoError)
+ {
+ }
bool init()
{
- if (parameters_.contains("finishRequestImmediately"))
- finishRequestImmediately_ = parameters_.value("finishRequestImmediately").toBool();
+
return true;
}
@@ -125,14 +123,16 @@ public:
mappingReply_->callSetMapImageData(bytes);
mappingReply_->callSetMapImageFormat("png");
- mappingReply_->callSetFinished(true);
+
+ timer_.start(500, this);
return mappingReply_;
}
- void setParams(const QMap<QString, QVariant> &parameters)
+ void setParams(const QVariantMap &parameters)
{
- parameters_ = parameters;
+ if (parameters.contains(QStringLiteral("finishRequestImmediately")))
+ finishRequestImmediately_ = parameters.value(QStringLiteral("finishRequestImmediately")).toBool();
}
void setTileSize(QSize tileSize)
@@ -143,38 +143,36 @@ public:
public Q_SLOTS:
void requestAborted()
{
- if (timerId_) {
- killTimer(timerId_);
- timerId_ = 0;
- }
- errorString_ = "";
+ timer_.stop();
+ errorString_.clear();
errorCode_ = QGeoTiledMapReply::NoError;
}
protected:
void timerEvent(QTimerEvent *event)
{
- Q_ASSERT(timerId_ == event->timerId());
+ if (event->timerId() != timer_.timerId()) {
+ QGeoTileFetcher::timerEvent(event);
+ return;
+ }
+
Q_ASSERT(mappingReply_);
- killTimer(timerId_);
- timerId_ = 0;
+ timer_.stop();
if (errorCode_) {
mappingReply_->callSetError(errorCode_, errorString_);
emit tileError(mappingReply_->tileSpec(), errorString_);
- } else {
+ } else {
mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error");
mappingReply_->callSetFinished(true);
}
- // emit finished(mappingReply_); todo tileFinished
}
private:
bool finishRequestImmediately_;
TiledMapReplyTest* mappingReply_;
- int timerId_;
+ QBasicTimer timer_;
QGeoTiledMapReply::Error errorCode_;
QString errorString_;
- QMap<QString, QVariant> parameters_;
QSize tileSize_;
};
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 6096ffe1..edcf09b7 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -208,7 +208,7 @@ class QPlaceManagerEngineTest : public QPlaceManagerEngine
{
Q_OBJECT
public:
- QPlaceManagerEngineTest(const QMap<QString, QVariant> &parameters)
+ QPlaceManagerEngineTest(const QVariantMap &parameters)
: QPlaceManagerEngine(parameters)
{
m_locales << QLocale();
@@ -363,10 +363,10 @@ public:
return reply;
}
- QPlaceContentReply *getPlaceContent(const QString &placeId, const QPlaceContentRequest &query)
+ QPlaceContentReply *getPlaceContent(const QPlaceContentRequest &query) Q_DECL_OVERRIDE
{
ContentReply *reply = new ContentReply(this);
- if (placeId.isEmpty() || !m_places.contains(placeId)) {
+ if (query.placeId().isEmpty() || !m_places.contains(query.placeId())) {
reply->setError(QPlaceReply::PlaceDoesNotExistError, tr("Place does not exist"));
QMetaObject::invokeMethod(reply, "emitError", Qt::QueuedConnection);
@@ -375,31 +375,33 @@ public:
int totalCount = 0;
switch (query.contentType()) {
case QPlaceContent::ReviewType:
- totalCount = m_placeReviews.value(placeId).count();
+ totalCount = m_placeReviews.value(query.placeId()).count();
break;
case QPlaceContent::ImageType:
- totalCount = m_placeImages.value(placeId).count();
+ totalCount = m_placeImages.value(query.placeId()).count();
break;
case QPlaceContent::EditorialType:
- totalCount = m_placeEditorials.value(placeId).count();
+ totalCount = m_placeEditorials.value(query.placeId()).count();
default:
//do nothing
break;
}
- int offset = qMax(query.offset(), 0);
+ QVariantMap context = query.contentContext().toMap();
+
+ int offset = context.value(QStringLiteral("offset"), 0).toInt();
int max = (query.limit() == -1) ? totalCount
: qMin(offset + query.limit(), totalCount);
for (int i = offset; i < max; ++i) {
switch (query.contentType()) {
case QPlaceContent::ReviewType:
- collection.insert(i, m_placeReviews.value(placeId).at(i));
+ collection.insert(i, m_placeReviews.value(query.placeId()).at(i));
break;
case QPlaceContent::ImageType:
- collection.insert(i, m_placeImages.value(placeId).at(i));
+ collection.insert(i, m_placeImages.value(query.placeId()).at(i));
break;
case QPlaceContent::EditorialType:
- collection.insert(i, m_placeEditorials.value(placeId).at(i));
+ collection.insert(i, m_placeEditorials.value(query.placeId()).at(i));
default:
//do nothing
break;
@@ -408,6 +410,21 @@ public:
reply->setContent(collection);
reply->setTotalCount(totalCount);
+
+ if (max != totalCount) {
+ context.clear();
+ context.insert(QStringLiteral("offset"), offset + query.limit());
+ QPlaceContentRequest request = query;
+ request.setContentContext(context);
+ reply->setNextPageRequest(request);
+ }
+ if (offset > 0) {
+ context.clear();
+ context.insert(QStringLiteral("offset"), qMin(0, offset - query.limit()));
+ QPlaceContentRequest request = query;
+ request.setContentContext(context);
+ reply->setPreviousPageRequest(request);
+ }
}
QMetaObject::invokeMethod(reply, "emitFinished", Qt::QueuedConnection);
diff --git a/tests/auto/nokia_services/places_semiauto/tst_places.cpp b/tests/auto/nokia_services/places_semiauto/tst_places.cpp
index e6e7859f..a0170144 100644
--- a/tests/auto/nokia_services/places_semiauto/tst_places.cpp
+++ b/tests/auto/nokia_services/places_semiauto/tst_places.cpp
@@ -90,7 +90,7 @@ private:
QList<QPlaceReply::Error> *errors,
QList<ExpectedResults> *results);
- static const QLatin1String AuvergneEmbassyId;
+ static const QLatin1String ValidKnownPlaceId;
static const QLatin1String ProxyEnv;
static const QLatin1String AppIdEnv;
static const QLatin1String TokenEnv;
@@ -100,7 +100,10 @@ private:
Q_DECLARE_METATYPE(tst_QPlaceManagerNokia::ExpectedResults)
-const QLatin1String tst_QPlaceManagerNokia::AuvergneEmbassyId("250u09tv-be16478e55314b338c551aab2651c9d3");
+// ValidKnownPlaceId is the id of a place with a full complement of place content. Editorials,
+// reviews, images, recommendations. If it disappears these tests will fail.
+// Currently it is set to an Eiffel Tower tourist office.
+const QLatin1String tst_QPlaceManagerNokia::ValidKnownPlaceId("250u09tu-4561b8da952f4fd79c4e1998c3fcf032");
const QLatin1String tst_QPlaceManagerNokia::ProxyEnv("NOKIA_PLUGIN_PROXY");
const QLatin1String tst_QPlaceManagerNokia::AppIdEnv("NOKIA_APP_ID");
@@ -335,7 +338,7 @@ void tst_QPlaceManagerNokia::recommendations_data()
eatDrinkCat.setCategoryId(QStringLiteral("eat-drink"));
QTest::newRow("search recommendations with valid id")
- << QString(AuvergneEmbassyId)
+ << QString(ValidKnownPlaceId)
<< QString()
<< QGeoShape()
<< QList<QPlaceCategory>()
@@ -349,28 +352,28 @@ void tst_QPlaceManagerNokia::recommendations_data()
<< QPlaceReply::PlaceDoesNotExistError;
QTest::newRow("search for recommendations with id and search term")
- << QString(AuvergneEmbassyId)
+ << QString(ValidKnownPlaceId)
<< QStringLiteral("sushi")
<< QGeoShape()
<< QList<QPlaceCategory>()
<< QPlaceReply::BadArgumentError;
QTest::newRow("search for recommendations with an id and category")
- << QString(AuvergneEmbassyId)
+ << QString(ValidKnownPlaceId)
<< QString()
<< QGeoShape()
<< (QList<QPlaceCategory>() << eatDrinkCat)
<< QPlaceReply::BadArgumentError;
QTest::newRow("search for recommendations with id, search term and category")
- << QString(AuvergneEmbassyId)
+ << QString(ValidKnownPlaceId)
<< QStringLiteral("sushi")
<< QGeoShape()
<< (QList<QPlaceCategory>() << eatDrinkCat)
<< QPlaceReply::BadArgumentError;
QTest::newRow("search for recommendations with an id and search area")
- << QString(AuvergneEmbassyId)
+ << QString(ValidKnownPlaceId)
<< QString()
<< static_cast<QGeoShape>(QGeoCircle(QGeoCoordinate(-27.5, 153)))
<< QList<QPlaceCategory>()
@@ -381,7 +384,7 @@ void tst_QPlaceManagerNokia::details()
{
//fetch the details of a valid place
QPlace place;
- QVERIFY(doFetchDetails(AuvergneEmbassyId, &place));
+ QVERIFY(doFetchDetails(ValidKnownPlaceId, &place));
QVERIFY(!place.name().isEmpty());
QVERIFY(!place.icon().url().isEmpty());
QStringList contactTypes = place.contactTypes();
@@ -515,17 +518,9 @@ void tst_QPlaceManagerNokia::suggestions_data()
void tst_QPlaceManagerNokia::suggestionsMisc()
{
- //check providing an offset
+ //check providing a distance relevancy hint (should be ignored)
QPlaceSearchRequest searchRequest;
- searchRequest.setSearchArea(QGeoCircle(QGeoCoordinate(-27.5, 153)));
- searchRequest.setSearchTerm(QStringLiteral("sus"));
- searchRequest.setOffset(5);
QStringList results;
- QVERIFY(doSearchSuggestions(searchRequest, &results, QPlaceReply::BadArgumentError));
- QCOMPARE(results.count(), 0);
- searchRequest.clear();
-
- //check porviding a distance relevancy hint (should be ignored)
searchRequest.setSearchArea(QGeoCircle(QGeoCoordinate(-27.5, 153)));
searchRequest.setSearchTerm(QStringLiteral("sus"));
searchRequest.setRelevanceHint(QPlaceSearchRequest::DistanceHint);
@@ -586,11 +581,11 @@ void tst_QPlaceManagerNokia::locale()
//check that setting a locale will affect place detail fetches.
QPlace place;
placeManager->setLocale(QLocale("en"));
- QVERIFY(doFetchDetails(AuvergneEmbassyId,
+ QVERIFY(doFetchDetails(ValidKnownPlaceId,
&place));
QString englishName = place.name();
placeManager->setLocale(QLocale("fr"));
- QVERIFY(doFetchDetails(AuvergneEmbassyId,
+ QVERIFY(doFetchDetails(ValidKnownPlaceId,
&place));
QVERIFY(englishName != place.name());
}
@@ -602,9 +597,9 @@ void tst_QPlaceManagerNokia::content()
//check fetching of content
QPlaceContentRequest request;
request.setContentType(type);
+ request.setPlaceId(ValidKnownPlaceId);
QPlaceContent::Collection results;
- QVERIFY(doFetchContent(AuvergneEmbassyId,
- request, &results));
+ QVERIFY(doFetchContent(request, &results));
QVERIFY(results.count() > 0);
@@ -638,39 +633,18 @@ void tst_QPlaceManagerNokia::content()
}
//check total count
- QPlaceContentReply *contentReply =
- placeManager->getPlaceContent(AuvergneEmbassyId,
- request);
+ QPlaceContentReply *contentReply = placeManager->getPlaceContent(request);
QSignalSpy contentSpy(contentReply, SIGNAL(finished()));
QTRY_VERIFY_WITH_TIMEOUT(contentSpy.count() ==1, Timeout);
QVERIFY(contentReply->totalCount() > 0);
if (contentReply->totalCount() >= 2) {
- //try testing with an offset
- request.setOffset(1);
- QPlaceContent::Collection newResults;
- QVERIFY(doFetchContent(AuvergneEmbassyId,
- request, &newResults));
- QVERIFY(!newResults.keys().contains(0));
- QCOMPARE(newResults.value(1), results.value(1));
-
//try testing with a limit
- request.setOffset(0);
request.setLimit(1);
- QVERIFY(doFetchContent(AuvergneEmbassyId,
- request, &newResults));
+ QPlaceContent::Collection newResults;
+ QVERIFY(doFetchContent(request, &newResults));
QCOMPARE(newResults.count(), 1);
QCOMPARE(newResults.values().first(), results.value(0));
-
- //try testing both limit and offset
- if (contentReply->totalCount() >= 3) {
- request.setLimit(1);
- request.setOffset(1);
- QVERIFY(doFetchContent(AuvergneEmbassyId,
- request, &newResults));
- QCOMPARE(newResults.count(), 1);
- QCOMPARE(newResults.values().first(), results.value(1));
- }
}
}
diff --git a/tests/auto/nokia_services/routing/optim-economic.xml b/tests/auto/nokia_services/routing/optim-economic.xml
deleted file mode 100644
index 4e61fec8..00000000
--- a/tests/auto/nokia_services/routing/optim-economic.xml
+++ /dev/null
@@ -1,402 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<rtcr:CalculateRoute xmlns:rtcr="http://www.navteq.com/lbsp/Routing-CalculateRoute/4">
- <Response>
- <MetaInfo>
- <Timestamp>2012-04-26T14:57:55.085Z</Timestamp>
- <AdditionalData key="CurrentTrafficLastUpdate">2012-04-26T14:56:01.116+0000</AdditionalData>
- <AdditionalData key="CurrentTrafficElementsCount">5094983</AdditionalData>
- <AdditionalData key="LongTermClosureLastUpdate">2012-04-26T14:56:03.396+0000</AdditionalData>
- <AdditionalData key="LongTermClosureElementsCount">12223</AdditionalData>
- <AdditionalData key="ShortTermClosureLastUpdate">2012-04-26T14:56:03.396+0000</AdditionalData>
- <AdditionalData key="ShortTermClosureElementsCount">506</AdditionalData>
- <AdditionalData key="Map0">2011Q3</AdditionalData>
- <AdditionalData key="Module0">routeserver,9.2-2012.02.20-hotfix6.2.13.1</AdditionalData>
- <AdditionalData key="Module0ExecTime">17</AdditionalData>
- <AdditionalData key="Service">routing-route-service,6.2.13.1</AdditionalData>
- </MetaInfo>
- <Route>
- <RouteId>REMvFQUAAAB4tdyZCURKQJROJJhqxipAAAAAYAlESkAAAADAasYqQAAAAAAAAPB_AAAAAAAA8H-XVzADV_SHZp4MKQHNgLOULCerAAEAAICiDCkBAQAAADAnqwABAAAAAADA_wEAAAAAAMD_HY0-83dwYQCu</RouteId>
- <Waypoint>
- <LinkId>+53499799</LinkId>
- <MappedPosition>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.531543</Latitude>
- <Longitude>13.387532</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Waypoint>
- <Waypoint>
- <LinkId>-53501113</LinkId>
- <MappedPosition>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.524646</Latitude>
- <Longitude>13.394128</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Waypoint>
- <Mode>
- <Type>economic</Type>
- <TransportModes>car</TransportModes>
- </Mode>
- <Shape>52.5315361,13.3875332 52.5315819,13.3880997 52.5316582,13.3889303 52.5317612,13.3896999 52.5316315,13.3899002 52.5302505,13.3916502 52.5300598,13.3919001 52.5286217,13.3937197 52.5285416,13.3938799 52.5282288,13.3924398 52.5276604,13.3927898 52.5274887,13.39293 52.5264091,13.3935404 52.5262985,13.3935604 52.5254402,13.3931103 52.5249786,13.3928604 52.5246773,13.3941345</Shape>
- <BoundingBox>
- <TopLeft>
- <Latitude>52.5317612</Latitude>
- <Longitude>13.3875332</Longitude>
- </TopLeft>
- <BottomRight>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </BottomRight>
- </BoundingBox>
- <Leg>
- <Start>
- <LinkId>+53499799</LinkId>
- <MappedPosition>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.531543</Latitude>
- <Longitude>13.387532</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Start>
- <End>
- <LinkId>-53501113</LinkId>
- <MappedPosition>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.524646</Latitude>
- <Longitude>13.394128</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </End>
- <Length>1177.0</Length>
- <TravelTime>237.7</TravelTime>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M1">
- <Position>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </Position>
- <Instruction>Head toward Borsigstraße on Invalidenstraße. Go for 500 feet.</Instruction>
- <TravelTime>15.2</TravelTime>
- <Length>148.0</Length>
- <ToLink>+53499799</ToLink>
- <Direction>forward</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M2">
- <Position>
- <Latitude>52.5317612</Latitude>
- <Longitude>13.3896999</Longitude>
- </Position>
- <Instruction>Turn right onto Gartenstraße. Go for 0.3 miles.</Instruction>
- <TravelTime>90.8</TravelTime>
- <Length>454.0</Length>
- <ToLink>-811854188</ToLink>
- <Direction>right</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M3">
- <Position>
- <Latitude>52.5285416</Latitude>
- <Longitude>13.3938799</Longitude>
- </Position>
- <Instruction>Turn right onto Torstraße. Go for 350 feet.</Instruction>
- <TravelTime>28.4</TravelTime>
- <Length>103.0</Length>
- <ToLink>-53499981</ToLink>
- <Direction>right</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M4">
- <Position>
- <Latitude>52.5282288</Latitude>
- <Longitude>13.3924398</Longitude>
- </Position>
- <Instruction>Turn left onto Tucholskystraße. Go for 0.2 miles.</Instruction>
- <TravelTime>72.4</TravelTime>
- <Length>380.0</Length>
- <ToLink>-53500024</ToLink>
- <Direction>left</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M5">
- <Position>
- <Latitude>52.5249786</Latitude>
- <Longitude>13.3928604</Longitude>
- </Position>
- <Instruction>Turn left onto Oranienburger Straße. Go for 300 feet.</Instruction>
- <TravelTime>30.9</TravelTime>
- <Length>92.0</Length>
- <ToLink>-53501113</ToLink>
- <Direction>left</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M6">
- <Position>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </Position>
- <Instruction>Your destination on Oranienburger Straße is on the right. The trip takes 0.7 miles and 4 mins.</Instruction>
- <TravelTime>0.0</TravelTime>
- <Length>0.0</Length>
- <Direction>forward</Direction>
- </Maneuver>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>+53499799</LinkId>
- <Shape>52.5315361,13.3875332 52.5315819,13.3880997</Shape>
- <Length>38.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>7.77</TrafficSpeed>
- <TrafficTime>4.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>3.9</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Invalidenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Invalidenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>+53499788</LinkId>
- <Shape>52.5315819,13.3880997 52.5316582,13.3889303 52.5317612,13.3896999</Shape>
- <Length>110.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>7.77</TrafficSpeed>
- <TrafficTime>14.1</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>11.3</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Invalidenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Invalidenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-811854188</LinkId>
- <Shape>52.5317612,13.3896999 52.5316315,13.3899002</Shape>
- <Length>19.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.0</TrafficSpeed>
- <TrafficTime>3.8</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>2.7</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-811854187</LinkId>
- <Shape>52.5316315,13.3899002 52.5302505,13.3916502</Shape>
- <Length>193.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>36.6</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>27.8</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499878</LinkId>
- <Shape>52.5302505,13.3916502 52.5300598,13.3919001</Shape>
- <Length>27.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>5.1</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>3.9</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499960</LinkId>
- <Shape>52.5300598,13.3919001 52.5286217,13.3937197 52.5285416,13.3938799</Shape>
- <Length>215.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>40.7</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>31.0</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499981</LinkId>
- <Shape>52.5285416,13.3938799 52.5282288,13.3924398</Shape>
- <Length>103.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>8.33</TrafficSpeed>
- <TrafficTime>12.4</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>14.8</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Torstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Torstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53500024</LinkId>
- <Shape>52.5282288,13.3924398 52.5276604,13.3927898 52.5274887,13.39293</Shape>
- <Length>88.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.72</TrafficSpeed>
- <TrafficTime>18.6</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>9.1</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53500091</LinkId>
- <Shape>52.5274887,13.39293 52.5264091,13.3935404</Shape>
- <Length>126.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.72</TrafficSpeed>
- <TrafficTime>26.7</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>13.0</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-844906239</LinkId>
- <Shape>52.5264091,13.3935404 52.5262985,13.3935604 52.5254402,13.3931103</Shape>
- <Length>112.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.17</TrafficSpeed>
- <TrafficTime>26.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>11.5</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-844906238</LinkId>
- <Shape>52.5254402,13.3931103 52.5249786,13.3928604</Shape>
- <Length>54.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>3.89</TrafficSpeed>
- <TrafficTime>13.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>5.6</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53501113</LinkId>
- <Shape>52.5249786,13.3928604 52.5246773,13.3941345</Shape>
- <Length>92.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>8.61</TrafficSpeed>
- <TrafficTime>10.7</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>9.5</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Oranienburger Straße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Oranienburger Straße</Street>
- </Address>
- </Link>
- </Leg>
- <Summary>
- <Distance>1177.0</Distance>
- <TrafficTime>309.0</TrafficTime>
- <BaseTime>237.0</BaseTime>
- </Summary>
- </Route>
- </Response>
-</rtcr:CalculateRoute> \ No newline at end of file
diff --git a/tests/auto/nokia_services/routing/optim-scenic.xml b/tests/auto/nokia_services/routing/optim-scenic.xml
deleted file mode 100644
index af4ca6f7..00000000
--- a/tests/auto/nokia_services/routing/optim-scenic.xml
+++ /dev/null
@@ -1,402 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<rtcr:CalculateRoute xmlns:rtcr="http://www.navteq.com/lbsp/Routing-CalculateRoute/4">
- <Response>
- <MetaInfo>
- <Timestamp>2012-04-26T14:58:19.456Z</Timestamp>
- <AdditionalData key="CurrentTrafficLastUpdate">2012-04-26T14:56:00.026+0000</AdditionalData>
- <AdditionalData key="CurrentTrafficElementsCount">5094983</AdditionalData>
- <AdditionalData key="LongTermClosureLastUpdate">2012-04-26T14:56:02.404+0000</AdditionalData>
- <AdditionalData key="LongTermClosureElementsCount">12223</AdditionalData>
- <AdditionalData key="ShortTermClosureLastUpdate">2012-04-26T14:56:02.404+0000</AdditionalData>
- <AdditionalData key="ShortTermClosureElementsCount">506</AdditionalData>
- <AdditionalData key="Map0">2011Q3</AdditionalData>
- <AdditionalData key="Module0">routeserver,9.2-2012.02.20-hotfix6.2.13.1</AdditionalData>
- <AdditionalData key="Module0ExecTime">31</AdditionalData>
- <AdditionalData key="Service">routing-route-service,6.2.13.1</AdditionalData>
- </MetaInfo>
- <Route>
- <RouteId>REMvFQUAAAB4tdyZCURKQJROJJhqxipAAAAAYAlESkAAAADAasYqQAAAAAAAAPB_AAAAAAAA8H-XVzADV_SHZp4MKQHNgLOULCerAAEAAICiDCkBAQAAADAnqwABAAAAAADA_wEAAAAAAMD_HY0-83dwYQCu</RouteId>
- <Waypoint>
- <LinkId>+53499799</LinkId>
- <MappedPosition>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.531543</Latitude>
- <Longitude>13.387532</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Waypoint>
- <Waypoint>
- <LinkId>-53501113</LinkId>
- <MappedPosition>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.524646</Latitude>
- <Longitude>13.394128</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Waypoint>
- <Mode>
- <Type>scenic</Type>
- <TransportModes>car</TransportModes>
- </Mode>
- <Shape>52.5315361,13.3875332 52.5315819,13.3880997 52.5316582,13.3889303 52.5317612,13.3896999 52.5316315,13.3899002 52.5302505,13.3916502 52.5300598,13.3919001 52.5286217,13.3937197 52.5285416,13.3938799 52.5282288,13.3924398 52.5276604,13.3927898 52.5274887,13.39293 52.5264091,13.3935404 52.5262985,13.3935604 52.5254402,13.3931103 52.5249786,13.3928604 52.5246773,13.3941345</Shape>
- <BoundingBox>
- <TopLeft>
- <Latitude>52.5317612</Latitude>
- <Longitude>13.3875332</Longitude>
- </TopLeft>
- <BottomRight>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </BottomRight>
- </BoundingBox>
- <Leg>
- <Start>
- <LinkId>+53499799</LinkId>
- <MappedPosition>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.531543</Latitude>
- <Longitude>13.387532</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </Start>
- <End>
- <LinkId>-53501113</LinkId>
- <MappedPosition>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </MappedPosition>
- <OriginalPosition>
- <Latitude>52.524646</Latitude>
- <Longitude>13.394128</Longitude>
- </OriginalPosition>
- <Type>stopOver</Type>
- </End>
- <Length>1177.0</Length>
- <TravelTime>237.7</TravelTime>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M1">
- <Position>
- <Latitude>52.5315361</Latitude>
- <Longitude>13.3875332</Longitude>
- </Position>
- <Instruction>Head toward Borsigstraße on Invalidenstraße. Go for 500 feet.</Instruction>
- <TravelTime>15.2</TravelTime>
- <Length>148.0</Length>
- <ToLink>+53499799</ToLink>
- <Direction>forward</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M2">
- <Position>
- <Latitude>52.5317612</Latitude>
- <Longitude>13.3896999</Longitude>
- </Position>
- <Instruction>Turn right onto Gartenstraße. Go for 0.3 miles.</Instruction>
- <TravelTime>90.8</TravelTime>
- <Length>454.0</Length>
- <ToLink>-811854188</ToLink>
- <Direction>right</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M3">
- <Position>
- <Latitude>52.5285416</Latitude>
- <Longitude>13.3938799</Longitude>
- </Position>
- <Instruction>Turn right onto Torstraße. Go for 350 feet.</Instruction>
- <TravelTime>28.4</TravelTime>
- <Length>103.0</Length>
- <ToLink>-53499981</ToLink>
- <Direction>right</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M4">
- <Position>
- <Latitude>52.5282288</Latitude>
- <Longitude>13.3924398</Longitude>
- </Position>
- <Instruction>Turn left onto Tucholskystraße. Go for 0.2 miles.</Instruction>
- <TravelTime>72.4</TravelTime>
- <Length>380.0</Length>
- <ToLink>-53500024</ToLink>
- <Direction>left</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M5">
- <Position>
- <Latitude>52.5249786</Latitude>
- <Longitude>13.3928604</Longitude>
- </Position>
- <Instruction>Turn left onto Oranienburger Straße. Go for 300 feet.</Instruction>
- <TravelTime>30.9</TravelTime>
- <Length>92.0</Length>
- <ToLink>-53501113</ToLink>
- <Direction>left</Direction>
- </Maneuver>
- <Maneuver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportManeuverType" id="M6">
- <Position>
- <Latitude>52.5246773</Latitude>
- <Longitude>13.3941345</Longitude>
- </Position>
- <Instruction>Your destination on Oranienburger Straße is on the right. The trip takes 0.7 miles and 4 mins.</Instruction>
- <TravelTime>0.0</TravelTime>
- <Length>0.0</Length>
- <Direction>forward</Direction>
- </Maneuver>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>+53499799</LinkId>
- <Shape>52.5315361,13.3875332 52.5315819,13.3880997</Shape>
- <Length>38.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>7.77</TrafficSpeed>
- <TrafficTime>4.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>3.9</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Invalidenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Invalidenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>+53499788</LinkId>
- <Shape>52.5315819,13.3880997 52.5316582,13.3889303 52.5317612,13.3896999</Shape>
- <Length>110.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>7.77</TrafficSpeed>
- <TrafficTime>14.1</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>11.3</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Invalidenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Invalidenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-811854188</LinkId>
- <Shape>52.5317612,13.3896999 52.5316315,13.3899002</Shape>
- <Length>19.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.0</TrafficSpeed>
- <TrafficTime>3.8</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>2.7</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-811854187</LinkId>
- <Shape>52.5316315,13.3899002 52.5302505,13.3916502</Shape>
- <Length>193.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>36.6</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>27.8</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499878</LinkId>
- <Shape>52.5302505,13.3916502 52.5300598,13.3919001</Shape>
- <Length>27.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>5.1</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>3.9</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499960</LinkId>
- <Shape>52.5300598,13.3919001 52.5286217,13.3937197 52.5285416,13.3938799</Shape>
- <Length>215.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>5.28</TrafficSpeed>
- <TrafficTime>40.7</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>31.0</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Gartenstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Gartenstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53499981</LinkId>
- <Shape>52.5285416,13.3938799 52.5282288,13.3924398</Shape>
- <Length>103.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>8.33</TrafficSpeed>
- <TrafficTime>12.4</TrafficTime>
- <BaseSpeed>6.94</BaseSpeed>
- <BaseTime>14.8</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Torstraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Torstraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53500024</LinkId>
- <Shape>52.5282288,13.3924398 52.5276604,13.3927898 52.5274887,13.39293</Shape>
- <Length>88.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.72</TrafficSpeed>
- <TrafficTime>18.6</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>9.1</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53500091</LinkId>
- <Shape>52.5274887,13.39293 52.5264091,13.3935404</Shape>
- <Length>126.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.72</TrafficSpeed>
- <TrafficTime>26.7</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>13.0</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-844906239</LinkId>
- <Shape>52.5264091,13.3935404 52.5262985,13.3935604 52.5254402,13.3931103</Shape>
- <Length>112.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>4.17</TrafficSpeed>
- <TrafficTime>26.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>11.5</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-844906238</LinkId>
- <Shape>52.5254402,13.3931103 52.5249786,13.3928604</Shape>
- <Length>54.0</Length>
- <DynamicSpeedInfo>
- <TrafficSpeed>3.89</TrafficSpeed>
- <TrafficTime>13.9</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>5.6</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Tucholskystraße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Tucholskystraße</Street>
- </Address>
- </Link>
- <Link xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rtc="http://www.navteq.com/lbsp/Routing-Common/4" xsi:type="rtc:PrivateTransportLinkType">
- <LinkId>-53501113</LinkId>
- <Shape>52.5249786,13.3928604 52.5246773,13.3941345</Shape>
- <Length>92.0</Length>
- <SpeedLimit>13.89</SpeedLimit>
- <DynamicSpeedInfo>
- <TrafficSpeed>8.61</TrafficSpeed>
- <TrafficTime>10.7</TrafficTime>
- <BaseSpeed>9.72</BaseSpeed>
- <BaseTime>9.5</BaseTime>
- </DynamicSpeedInfo>
- <Address>
- <Label>Oranienburger Straße</Label>
- <Country>DE</Country>
- <State>Berlin</State>
- <County>Berlin</County>
- <City>Berlin</City>
- <District>Mitte</District>
- <Street>Oranienburger Straße</Street>
- </Address>
- </Link>
- </Leg>
- <Summary>
- <Distance>1177.0</Distance>
- <TrafficTime>309.0</TrafficTime>
- <BaseTime>237.0</BaseTime>
- </Summary>
- </Route>
- </Response>
-</rtcr:CalculateRoute> \ No newline at end of file
diff --git a/tests/auto/nokia_services/routing/tst_routing.cpp b/tests/auto/nokia_services/routing/tst_routing.cpp
index b64202a6..95d034da 100644
--- a/tests/auto/nokia_services/routing/tst_routing.cpp
+++ b/tests/auto/nokia_services/routing/tst_routing.cpp
@@ -335,7 +335,7 @@ void tst_nokia_routing::initTestCase()
m_networkManager = new MockGeoNetworkAccessManager();
- QMap<QString, QVariant> parameters;
+ QVariantMap parameters;
parameters.insert(QStringLiteral("nam"), QVariant::fromValue<void*>(m_networkManager));
parameters.insert(QStringLiteral("app_id"), "stub");
parameters.insert(QStringLiteral("token"), "stub");
@@ -410,11 +410,10 @@ void tst_nokia_routing::can_compute_route_for_all_supported_travel_modes_data()
void tst_nokia_routing::can_compute_route_for_all_supported_optimizations()
{
QFETCH(int, optimization);
- Q_UNUSED(optimization);
QFETCH(QString, file);
QFETCH(qreal, distance);
QFETCH(int, duration);
-
+ m_dummyRequest.setRouteOptimization((QGeoRouteRequest::RouteOptimization)optimization);
loadReply(file);
calculateRoute();
QList<QGeoRoute> routes = m_reply->routes();
@@ -434,11 +433,8 @@ void tst_nokia_routing::can_compute_route_for_all_supported_optimizations_data()
QTest::newRow("Shortest") << (int)QGeoRouteRequest::ShortestRoute << QString("optim-shortest.xml") << qreal(1177.0) << 309;
QTest::newRow("Fastest") << (int)QGeoRouteRequest::FastestRoute << QString("optim-fastest.xml") << qreal(1271.0) << 243;
- QTest::newRow("Most Econonic") << (int)QGeoRouteRequest::MostEconomicRoute << QString("optim-economic.xml") << qreal(1177.0) << 309;
- QTest::newRow("Most Scenic") << (int)QGeoRouteRequest::MostScenicRoute << QString("optim-scenic.xml") << qreal(1177.0) << 309;
}
-
void tst_nokia_routing::can_handle_multiple_routes_in_response()
{
loadReply(QStringLiteral("multiple-routes-in-response.xml"));
diff --git a/tests/auto/placemanager_utils/placemanager_utils.cpp b/tests/auto/placemanager_utils/placemanager_utils.cpp
index 8934790a..205d0c39 100644
--- a/tests/auto/placemanager_utils/placemanager_utils.cpp
+++ b/tests/auto/placemanager_utils/placemanager_utils.cpp
@@ -244,13 +244,12 @@ bool PlaceManagerUtils::doFetchCategory(QPlaceManager *manager,
}
bool PlaceManagerUtils::doFetchContent(QPlaceManager *manager,
- const QString &placeId,
const QPlaceContentRequest &request,
QPlaceContent::Collection *results,
QPlaceReply::Error expectedError)
{
Q_ASSERT(results);
- QPlaceContentReply *reply = manager->getPlaceContent(placeId, request);
+ QPlaceContentReply *reply = manager->getPlaceContent(request);
bool isSuccessful = checkSignals(reply, expectedError, manager);
*results = reply->content();
diff --git a/tests/auto/placemanager_utils/placemanager_utils.h b/tests/auto/placemanager_utils/placemanager_utils.h
index 88a857e0..a8edede4 100644
--- a/tests/auto/placemanager_utils/placemanager_utils.h
+++ b/tests/auto/placemanager_utils/placemanager_utils.h
@@ -128,7 +128,6 @@ public:
QPlaceReply::Error expectedError = QPlaceReply::NoError);
static bool doFetchContent(QPlaceManager *manager,
- const QString &placeId,
const QPlaceContentRequest &request,
QPlaceContent::Collection *results,
QPlaceReply::Error expectedError = QPlaceReply::NoError);
@@ -219,13 +218,11 @@ protected:
category, expectedError);
}
- bool doFetchContent(const QString &placeId,
- const QPlaceContentRequest &request,
+ bool doFetchContent(const QPlaceContentRequest &request,
QPlaceContent::Collection *results,
QPlaceReply::Error expectedError = QPlaceReply::NoError)
{
- return doFetchContent(placeManager, placeId,
- request, results, expectedError);
+ return doFetchContent(placeManager, request, results, expectedError);
}
bool doMatch(const QPlaceMatchRequest &request,
diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
index 710fb97b..20c88d27 100644
--- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
@@ -53,7 +53,7 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
}
QPlaceManagerEngine *QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
{
Q_UNUSED(error);
diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
index 210ac7cc..66869947 100644
--- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
@@ -57,7 +57,7 @@ public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QPlaceManagerEngine *createPlaceManagerEngine(const QMap<QString, QVariant> &parameters,
+ QPlaceManagerEngine *createPlaceManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
};
diff --git a/tests/auto/positionplugin/plugin.cpp b/tests/auto/positionplugin/plugin.cpp
index a213bbb1..3d6f23ed 100644
--- a/tests/auto/positionplugin/plugin.cpp
+++ b/tests/auto/positionplugin/plugin.cpp
@@ -71,6 +71,7 @@ private:
QTimer *timeoutTimer;
QTimer *singleTimer;
QGeoPositionInfo lastPosition;
+ QDateTime lastUpdateTime;
private slots:
void updatePosition();
@@ -165,9 +166,20 @@ void DummySource::updatePosition()
{
timeoutTimer->stop();
singleTimer->stop();
+
+ const QDateTime now = QDateTime::currentDateTime();
+
QGeoCoordinate coord(lastPosition.coordinate().latitude() + 0.1,
lastPosition.coordinate().longitude() + 0.1);
- QGeoPositionInfo info(coord, QDateTime::currentDateTime());
+
+ QGeoPositionInfo info(coord, now);
+ info.setAttribute(QGeoPositionInfo::Direction, lastPosition.coordinate().azimuthTo(coord));
+ if (lastUpdateTime.isValid()) {
+ double speed = lastPosition.coordinate().distanceTo(coord) / lastUpdateTime.msecsTo(now);
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, 1000 * speed);
+ }
+
+ lastUpdateTime = now;
lastPosition = info;
emit positionUpdated(info);
}
diff --git a/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro b/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
index db13ac9b..ec406d8b 100644
--- a/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
+++ b/tests/auto/qgeocameracapabilities/qgeocameracapabilities.pro
@@ -6,5 +6,5 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameracapabilities.cpp
-QT += location testlib
+QT += location positioning-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qgeocameradata/qgeocameradata.pro b/tests/auto/qgeocameradata/qgeocameradata.pro
index f01d0f34..39f154d2 100644
--- a/tests/auto/qgeocameradata/qgeocameradata.pro
+++ b/tests/auto/qgeocameradata/qgeocameradata.pro
@@ -6,5 +6,5 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameradata.cpp
-QT += location testlib
+QT += location positioning-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qgeocameradata/tst_qgeocameradata.cpp b/tests/auto/qgeocameradata/tst_qgeocameradata.cpp
index 3147f057..e273711a 100644
--- a/tests/auto/qgeocameradata/tst_qgeocameradata.cpp
+++ b/tests/auto/qgeocameradata/tst_qgeocameradata.cpp
@@ -46,21 +46,6 @@
QT_USE_NAMESPACE
-// For testing the setters and getters of the QGeoCoordinateInterpolator shared pointer
-class QGeoCoordinateInterpolatorTest : public QGeoCoordinateInterpolator
-{
-public:
- QGeoCoordinateInterpolatorTest(){}
- ~QGeoCoordinateInterpolatorTest(){}
- QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress){
- Q_UNUSED(start);
- Q_UNUSED(end);
- Q_UNUSED(progress);
- return QGeoCoordinate();
- }
-};
-
-
class tst_QGeoCameraData : public QObject
{
Q_OBJECT
@@ -79,7 +64,6 @@ private Q_SLOTS:
void tiltTest();
void rollTest();
void zoomLevelTest();
- void coordinateInterpolatorTest();
void operatorsTest_data();
void operatorsTest();
};
@@ -198,14 +182,6 @@ void tst_QGeoCameraData::zoomLevelTest(){
QCOMPARE(cameraData2.zoomLevel(),8.0);
}
-void tst_QGeoCameraData::coordinateInterpolatorTest(){
- QGeoCameraData cameraData;
- QVERIFY2(cameraData.coordinateInterpolator().isNull(), "Default coordinate interpolator shared point is not null");
- QSharedPointer<QGeoCoordinateInterpolator> testPointer = QSharedPointer<QGeoCoordinateInterpolator>(new QGeoCoordinateInterpolatorTest());
- cameraData.setCoordinateInterpolator(testPointer);
- QVERIFY2(!cameraData.coordinateInterpolator().isNull(), "Coordinate interpolator shared point is null");
-}
-
void tst_QGeoCameraData::operatorsTest_data(){
populateCameraData();
}
diff --git a/tests/auto/qgeocameratiles/qgeocameratiles.pro b/tests/auto/qgeocameratiles/qgeocameratiles.pro
index 35f188eb..1c53e627 100644
--- a/tests/auto/qgeocameratiles/qgeocameratiles.pro
+++ b/tests/auto/qgeocameratiles/qgeocameratiles.pro
@@ -5,5 +5,5 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameratiles.cpp
-QT += location testlib 3d
+QT += location positioning-private testlib 3d
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
index fb666424..2aa55f49 100644
--- a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
+++ b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
@@ -44,10 +44,10 @@
#include "qgeotilespec_p.h"
#include "qgeocameratiles_p.h"
#include "qgeocameradata_p.h"
-#include "qgeoprojection_p.h"
-#include "qdoublevector2d_p.h"
#include "qgeomaptype_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
#include <qtest.h>
#include <QList>
diff --git a/tests/auto/qgeocircle/tst_qgeocircle.cpp b/tests/auto/qgeocircle/tst_qgeocircle.cpp
index dde256bd..db8cde66 100644
--- a/tests/auto/qgeocircle/tst_qgeocircle.cpp
+++ b/tests/auto/qgeocircle/tst_qgeocircle.cpp
@@ -73,6 +73,9 @@ private slots:
void contains_data();
void contains();
+ void extendShape();
+ void extendShape_data();
+
void areaComparison();
void areaComparison_data();
@@ -313,6 +316,55 @@ void tst_QGeoCircle::contains()
QCOMPARE(area.contains(probe), result);
}
+void tst_QGeoCircle::extendShape()
+{
+ QFETCH(QGeoCircle, circle);
+ QFETCH(QGeoCoordinate, coord);
+ QFETCH(bool, containsFirst);
+ QFETCH(bool, containsExtended);
+
+ QCOMPARE(circle.contains(coord), containsFirst);
+ circle.extendShape(coord);
+ QCOMPARE(circle.contains(coord), containsExtended);
+
+}
+
+void tst_QGeoCircle::extendShape_data()
+{
+ QTest::addColumn<QGeoCircle>("circle");
+ QTest::addColumn<QGeoCoordinate>("coord");
+ QTest::addColumn<bool>("containsFirst");
+ QTest::addColumn<bool>("containsExtended");
+
+ QGeoCoordinate co1(20.0, 20.0);
+
+ QTest::newRow("own center")
+ << QGeoCircle(co1, 100)
+ << QGeoCoordinate(20.0, 20.0)
+ << true
+ << true;
+ QTest::newRow("inside")
+ << QGeoCircle(co1, 100)
+ << QGeoCoordinate(20.0001, 20.0001)
+ << true
+ << true;
+ QTest::newRow("far away")
+ << QGeoCircle(co1, 100)
+ << QGeoCoordinate(50.0001, 50.0001)
+ << false
+ << true;
+ QTest::newRow("invalid circle")
+ << QGeoCircle()
+ << QGeoCoordinate(20.0, 20.0)
+ << false
+ << false;
+ QTest::newRow("invalid coordinate")
+ << QGeoCircle(co1, 100)
+ << QGeoCoordinate(99.0, 190.0)
+ << false
+ << false;
+}
+
void tst_QGeoCircle::areaComparison_data()
{
QTest::addColumn<QGeoShape>("area");
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
index c1c17b1b..ada63803 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
+++ b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
@@ -73,7 +73,7 @@ class QGeoCodingManagerEngineTest: public QGeoCodingManagerEngine
{
Q_OBJECT
public:
- QGeoCodingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoCodingManagerEngineTest(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) :
QGeoCodingManagerEngine(parameters)
{
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
index d16ba32e..878c0fa1 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
@@ -53,7 +53,7 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
}
QGeoCodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerEngine(
- const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error,
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error,
QString *errorString) const
{
return new QGeoCodingManagerEngineTest(parameters, error, errorString);
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
index c49e90bb..fe442b4f 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
@@ -59,7 +59,7 @@ public:
~QGeoServiceProviderFactoryTest();
QGeoCodingManagerEngine* createGeocodingManagerEngine(
- const QMap<QString, QVariant> &parameters,
+ const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
};
diff --git a/tests/auto/qgeomapcontroller/qgeomapcontroller.pro b/tests/auto/qgeomapcontroller/qgeomapcontroller.pro
index 352960b7..8f5827b9 100644
--- a/tests/auto/qgeomapcontroller/qgeomapcontroller.pro
+++ b/tests/auto/qgeomapcontroller/qgeomapcontroller.pro
@@ -13,5 +13,5 @@ HEADERS += ../geotestplugin/qgeoserviceproviderplugin_test.h \
SOURCES += tst_qgeomapcontroller.cpp
SOURCES += ../geotestplugin/qgeoserviceproviderplugin_test.cpp
-QT += location-private testlib
+QT += location-private positioning-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qgeomapcontroller/tst_qgeomapcontroller.cpp b/tests/auto/qgeomapcontroller/tst_qgeomapcontroller.cpp
index 564b5a3c..7b7f8b98 100644
--- a/tests/auto/qgeomapcontroller/tst_qgeomapcontroller.cpp
+++ b/tests/auto/qgeomapcontroller/tst_qgeomapcontroller.cpp
@@ -81,8 +81,6 @@ private Q_SLOTS:
void rollTest();
void panTest();
void zoomTest();
-
- void animatableCoordinateTest();
};
tst_QGeoMapController::tst_QGeoMapController()
@@ -93,7 +91,7 @@ tst_QGeoMapController::tst_QGeoMapController()
QGeoServiceProviderFactoryTest serviceProviderTest; // empty constructor
// TODO: check whether the default constructors of these objects allow the create to work
- QMap<QString, QVariant> parameterMap;
+ QVariantMap parameterMap;
QGeoServiceProvider::Error mappingError;
QString mappingErrorString;
@@ -102,7 +100,7 @@ tst_QGeoMapController::tst_QGeoMapController()
map_->resize(100, 100);
- signalCenterChanged_ = new QSignalSpy(map_->mapController(), SIGNAL(centerChanged(AnimatableCoordinate)));
+ signalCenterChanged_ = new QSignalSpy(map_->mapController(), SIGNAL(centerChanged(QGeoCoordinate)));
signalBearingChanged_ = new QSignalSpy(map_->mapController(), SIGNAL(bearingChanged(qreal)));
signalTiltChanged_ = new QSignalSpy(map_->mapController(), SIGNAL(tiltChanged(qreal)));
signalRollChanged_ = new QSignalSpy(map_->mapController(), SIGNAL(rollChanged(qreal)));
@@ -166,13 +164,12 @@ void tst_QGeoMapController::constructorTest()
cameraData.setRoll(roll);
cameraData.setZoomLevel(zoom);
map_->setCameraData(cameraData);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
// make sure the values come out the same
// also make sure the values match what they were actually set to
- QCOMPARE(mapController.center().coordinate(), cameraData.center());
- QCOMPARE(mapController.center().coordinate(), center);
+ QCOMPARE(mapController.center(), cameraData.center());
+ QCOMPARE(mapController.center(), center);
QCOMPARE(mapController.zoom(), cameraData.zoomLevel());
QCOMPARE(mapController.zoom(), zoom);
@@ -192,14 +189,13 @@ void tst_QGeoMapController::constructorTest()
void tst_QGeoMapController::centerTest()
{
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
QGeoCameraData cameraData;
cameraData.setCenter(QGeoCoordinate(10.0,-20.4,30.8));
map_->setCameraData(cameraData);
- QGeoMapController mapController(map_, coordinateInterpolator);
- QCOMPARE(mapController.center().coordinate(),QGeoCoordinate(10.0,-20.4,30.8));
+ QGeoMapController mapController(map_);
+ QCOMPARE(mapController.center(),QGeoCoordinate(10.0,-20.4,30.8));
- AnimatableCoordinate coord(QGeoCoordinate(10.0,20.4,30.8), coordinateInterpolator);
+ QGeoCoordinate coord(10.0,20.4,30.8);
clearSignalSpies();
mapController.setCenter(coord);
@@ -210,10 +206,10 @@ void tst_QGeoMapController::centerTest()
QCOMPARE(signalRollChanged_->count(),0);
QCOMPARE(signalZoomChanged_->count(),0);
- QCOMPARE(mapController.center().coordinate(),QGeoCoordinate(10.0,20.4,30.8));
+ QCOMPARE(mapController.center(),QGeoCoordinate(10.0,20.4,30.8));
- mapController.setCenter(AnimatableCoordinate(QGeoCoordinate(10.0,20.4,30.9), coordinateInterpolator));
- QCOMPARE(mapController.center().coordinate(),QGeoCoordinate(10.0,20.4,30.9));
+ mapController.setCenter(QGeoCoordinate(10.0,20.4,30.9));
+ QCOMPARE(mapController.center(),QGeoCoordinate(10.0,20.4,30.9));
}
void tst_QGeoMapController::bearingTest()
@@ -224,8 +220,7 @@ void tst_QGeoMapController::bearingTest()
QGeoCameraData cameraData;
cameraData.setBearing(bearing);
map_->setCameraData(cameraData);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
QCOMPARE(mapController.bearing(),bearing);
clearSignalSpies();
@@ -249,8 +244,7 @@ void tst_QGeoMapController::tiltTest()
QGeoCameraData cameraData;
cameraData.setTilt(tilt);
map_->setCameraData(cameraData);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
QCOMPARE(mapController.tilt(),tilt);
tilt = map_->cameraCapabilities().minimumTilt();
@@ -275,8 +269,7 @@ void tst_QGeoMapController::rollTest()
QGeoCameraData cameraData;
cameraData.setRoll(roll);
map_->setCameraData(cameraData);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
QCOMPARE(mapController.roll(),roll);
clearSignalSpies();
@@ -294,16 +287,15 @@ void tst_QGeoMapController::rollTest()
void tst_QGeoMapController::panTest()
{
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
- mapController.setCenter(AnimatableCoordinate(QGeoCoordinate(-1.0,-2.4,3.8), coordinateInterpolator));
+ mapController.setCenter(QGeoCoordinate(-1.0,-2.4,3.8));
// check that pan of zero leaves the camera centre unaltered
mapController.pan(0, 0);
- QCOMPARE(mapController.center().coordinate().altitude(), 3.8);
- QCOMPARE(mapController.center().coordinate().latitude(), -1.0);
- QCOMPARE(mapController.center().coordinate().longitude(), -2.4);
+ QCOMPARE(mapController.center().altitude(), 3.8);
+ QCOMPARE(mapController.center().latitude(), -1.0);
+ QCOMPARE(mapController.center().longitude(), -2.4);
qreal dx = 13.1;
qreal dy = -9.3;
@@ -312,9 +304,9 @@ void tst_QGeoMapController::panTest()
// rather than verify the exact new position, we check that the position has changed and the altitude
// is unaffected
- QCOMPARE(mapController.center().coordinate().altitude(), 3.8);
- QVERIFY(qFuzzyCompare(mapController.center().coordinate().latitude(), -1.0) == false);
- QVERIFY(qFuzzyCompare(mapController.center().coordinate().longitude(), -2.4) == false);
+ QCOMPARE(mapController.center().altitude(), 3.8);
+ QVERIFY(qFuzzyCompare(mapController.center().latitude(), -1.0) == false);
+ QVERIFY(qFuzzyCompare(mapController.center().longitude(), -2.4) == false);
// check correct signal is triggered
QCOMPARE(signalCenterChanged_->count(),1);
@@ -329,8 +321,7 @@ void tst_QGeoMapController::zoomTest()
QGeoCameraData cameraData;
cameraData.setZoomLevel(1.4);
map_->setCameraData(cameraData);
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
- QGeoMapController mapController(map_, coordinateInterpolator);
+ QGeoMapController mapController(map_);
QCOMPARE(mapController.zoom(),1.4);
mapController.setZoom(1.4);
@@ -347,23 +338,6 @@ void tst_QGeoMapController::zoomTest()
QCOMPARE(signalZoomChanged_->count(),1);
}
-void tst_QGeoMapController::animatableCoordinateTest()
-{
- QSharedPointer<QGeoCoordinateInterpolator> coordinateInterpolator;
-
- // modifier tests
- AnimatableCoordinate animCoordinate;
- animCoordinate.setCoordinate(QGeoCoordinate(-1.0,-2.4,3.8));
- QCOMPARE(animCoordinate.coordinate(), QGeoCoordinate(-1.0,-2.4,3.8));
-
- animCoordinate.setInterpolator(coordinateInterpolator);
- QCOMPARE(animCoordinate.interpolator(), coordinateInterpolator);
-
- // constructor test
- AnimatableCoordinate animCoordinateB(QGeoCoordinate(-1.0,-2.4,3.8), coordinateInterpolator);
- QCOMPARE(animCoordinateB.coordinate(), QGeoCoordinate(-1.0,-2.4,3.8));
- QCOMPARE(animCoordinateB.interpolator(), coordinateInterpolator);
-}
QTEST_APPLESS_MAIN(tst_QGeoMapController)
diff --git a/tests/auto/qgeomapscene/qgeomapscene.pro b/tests/auto/qgeomapscene/qgeomapscene.pro
index c7e984e4..a1bacb05 100644
--- a/tests/auto/qgeomapscene/qgeomapscene.pro
+++ b/tests/auto/qgeomapscene/qgeomapscene.pro
@@ -5,5 +5,5 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeomapscene.cpp
-QT += location 3d testlib
+QT += location positioning-private 3d testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
index eac628c4..4303dd0f 100644
--- a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
+++ b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
@@ -45,10 +45,11 @@
#include "qgeomapscene_p.h"
#include "qgeocameratiles_p.h"
#include "qgeocameradata_p.h"
-#include "qgeoprojection_p.h"
-#include "qdoublevector2d_p.h"
#include "qgeotilecache_p.h"
+#include <QtPositioning/private/qgeoprojection_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+
#include <Qt3D/qglscenenode.h>
#include <Qt3D/qgltexture2d.h>
@@ -345,7 +346,7 @@ class tst_QGeoMapScene : public QObject
mapGeometry.setCameraData(camera);
mapGeometry.setVisibleTiles(ct.tiles());
- QPointF point(screenX,screenY);
+ QDoubleVector2D point(screenX,screenY);
QDoubleVector2D mecartorPos = mapGeometry.screenPositionToMercator(point);
QCOMPARE(mecartorPos.x(),mercatorX);
@@ -386,7 +387,7 @@ class tst_QGeoMapScene : public QObject
mapGeometry.setVisibleTiles(ct.tiles());
QDoubleVector2D mercatorPos(mercatorX, mercatorY);
- QPointF point = mapGeometry.mercatorToScreenPosition(mercatorPos);
+ QPointF point = mapGeometry.mercatorToScreenPosition(mercatorPos).toPointF();
QCOMPARE(point.x(), screenX);
QCOMPARE(point.y(), screenY);
diff --git a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
index d0c9672d..7abc6c4c 100644
--- a/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
+++ b/tests/auto/qgeorectangle/tst_qgeorectangle.cpp
@@ -56,6 +56,7 @@ private slots:
void default_constructor();
void center_constructor();
void corner_constructor();
+ void list_constructor();
void copy_constructor();
void assignment();
void destructor();
@@ -95,6 +96,9 @@ private slots:
void unite();
void unite_data();
+ void extendShape();
+ void extendShape_data();
+
void areaComparison();
void areaComparison_data();
@@ -126,6 +130,23 @@ void tst_QGeoRectangle::corner_constructor()
QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));
}
+void tst_QGeoRectangle::list_constructor()
+{
+ QList<QGeoCoordinate> coordinates;
+ QGeoRectangle b1 = QGeoRectangle(coordinates);
+ QCOMPARE(b1.isValid(), false);
+
+ coordinates << QGeoCoordinate(10.0, 0.0);
+ b1 = QGeoRectangle(coordinates);
+ QCOMPARE(b1.isValid(), true);
+ QCOMPARE(b1.isEmpty(), true);
+
+ coordinates << QGeoCoordinate(0.0, 10.0) << QGeoCoordinate(0.0, 5.0);
+ b1 = QGeoRectangle(coordinates);
+ QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0,0.0));
+ QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));
+}
+
void tst_QGeoRectangle::copy_constructor()
{
QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0),
@@ -2190,6 +2211,95 @@ void tst_QGeoRectangle::unite_data()
QGeoCoordinate(-30.0, 180.0));
}
+
+void tst_QGeoRectangle::extendShape()
+{
+ QFETCH(QGeoRectangle, box);
+ QFETCH(QGeoCoordinate, coord);
+ QFETCH(QGeoRectangle, out);
+
+ box.extendShape(coord);
+ QCOMPARE(box, out);
+}
+
+void tst_QGeoRectangle::extendShape_data()
+{
+ QTest::addColumn<QGeoRectangle>("box");
+ QTest::addColumn<QGeoCoordinate>("coord");
+ QTest::addColumn<QGeoRectangle>("out");
+
+ QTest::newRow("valid rect - invalid coordinate")
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20.0))
+ << QGeoCoordinate(100.0, 190.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20));
+ QTest::newRow("invalid rect - valid coordinate")
+ << QGeoRectangle()
+ << QGeoCoordinate(10.0, 10.0)
+ << QGeoRectangle();
+ QTest::newRow("inside rect - not wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20.0))
+ << QGeoCoordinate(10.0, 10.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20));
+ QTest::newRow("lat outside rect - not wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20.0))
+ << QGeoCoordinate(40.0, 10.0)
+ << QGeoRectangle(QGeoCoordinate(40.0, -20.0),
+ QGeoCoordinate(-30.0, 20));
+ QTest::newRow("positive lon outside rect - not wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20.0))
+ << QGeoCoordinate(10.0, 40.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 40));
+ QTest::newRow("negative lon outside rect - not wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
+ QGeoCoordinate(-30.0, 20.0))
+ << QGeoCoordinate(10.0, -40.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, -40.0),
+ QGeoCoordinate(-30.0, 20.0));
+ QTest::newRow("inside rect - wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -160.0))
+ << QGeoCoordinate(10.0, -170.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -160.0));
+ QTest::newRow("lat outside rect - wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -160.0))
+ << QGeoCoordinate(-40.0, -170.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-40.0, -160.0));
+ QTest::newRow("positive lon outside rect - wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -160.0))
+ << QGeoCoordinate(10.0, 140.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 140.0),
+ QGeoCoordinate(-30.0, -160.0));
+ QTest::newRow("negative lon outside rect - wrapped")
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -160.0))
+ << QGeoCoordinate(10.0, -140.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
+ QGeoCoordinate(-30.0, -140.0));
+ QTest::newRow("extending over 180 degree line eastward")
+ << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
+ QGeoCoordinate(-30.0, 160.0))
+ << QGeoCoordinate(10.0, -170.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
+ QGeoCoordinate(-30.0, -170));
+ QTest::newRow("extending over -180 degree line westward")
+ << QGeoRectangle(QGeoCoordinate(30.0, -160.0),
+ QGeoCoordinate(-30.0, -130.0))
+ << QGeoCoordinate(10.0, 170.0)
+ << QGeoRectangle(QGeoCoordinate(30.0, 170.0),
+ QGeoCoordinate(-30.0, -130));
+}
+
void tst_QGeoRectangle::areaComparison_data()
{
QTest::addColumn<QGeoShape>("area");
diff --git a/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp b/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
index 7cfd3ff0..bb40fb02 100644
--- a/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
+++ b/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
@@ -170,7 +170,6 @@ void tst_QGeoRouteRequest::numberAlternativeRoutes()
qgeorouterequest->setNumberAlternativeRoutes(-12);
- QEXPECT_FAIL("", "numberAlternativeRoutes accepts -ve values", Continue);
QCOMPARE(qgeorouterequest->numberAlternativeRoutes(), 0);
}
diff --git a/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp b/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp
index 64aa4ff5..9fb51cc6 100644
--- a/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp
+++ b/tests/auto/qgeoroutexmlparser/tst_qgeoroutexmlparser.cpp
@@ -96,7 +96,6 @@ private slots:
QCOMPARE(first.instructionText(), QLatin1String("Head toward Logan Rd (95) on Padstow Rd (56). Go for 0.3 miles."));
QCOMPARE(first.position(), QGeoCoordinate(-27.5752144, 153.0879669));
- QEXPECT_FAIL("", "Maneuver timeToNextInstruction is not populated", Continue);
QCOMPARE(first.timeToNextInstruction(), 24);
QCOMPARE(first.distanceToNextInstruction(), 403.0);
@@ -105,7 +104,6 @@ private slots:
QVERIFY(secondLast.instructionText().contains("Turn right onto Bartley St"));
QCOMPARE(secondLast.position(), QGeoCoordinate(-27.4655991, 153.0231628));
QCOMPARE(secondLast.distanceToNextInstruction(), 181.0);
- QEXPECT_FAIL("", "Maneuver timeToNextInstruction is not populated", Continue);
QCOMPARE(secondLast.timeToNextInstruction(), 41);
QGeoManeuver last = segments.at(7).maneuver();
diff --git a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
index cfff7bd2..f8315348 100644
--- a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
+++ b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
@@ -104,17 +104,21 @@ void tst_QGeoRoutingManager::supports()
void tst_QGeoRoutingManager::locale()
{
- QLocale *german = new QLocale(QLocale::German, QLocale::Germany);
- QLocale *english = new QLocale(QLocale::C, QLocale::AnyCountry);
+ QLocale german = QLocale(QLocale::German, QLocale::Germany);
+ QLocale english = QLocale(QLocale::C, QLocale::AnyCountry);
- qgeoroutingmanager->setLocale(*german);
+ qgeoroutingmanager->setLocale(german);
- QCOMPARE(qgeoroutingmanager->locale(), *german);
+ QCOMPARE(qgeoroutingmanager->locale(), german);
- QVERIFY(qgeoroutingmanager->locale() != *english);
+ QVERIFY(qgeoroutingmanager->locale() != english);
- delete german;
- delete english;
+ QLocale en_UK = QLocale(QLocale::English, QLocale::UnitedKingdom);
+ qgeoroutingmanager->setLocale(en_UK);
+ QCOMPARE(qgeoroutingmanager->measurementSystem(), en_UK.measurementSystem());
+ qgeoroutingmanager->setMeasurementSystem(QLocale::MetricSystem);
+ QCOMPARE(qgeoroutingmanager->measurementSystem(), QLocale::MetricSystem);
+ QVERIFY(qgeoroutingmanager->locale().measurementSystem() != qgeoroutingmanager->measurementSystem());
}
void tst_QGeoRoutingManager::name()
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
index 7bfb506c..33dfba4a 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
@@ -55,7 +55,7 @@ class QGeoRoutingManagerEngineTest: public QGeoRoutingManagerEngine
{
Q_OBJECT
public:
- QGeoRoutingManagerEngineTest(const QMap<QString, QVariant> &parameters,
+ QGeoRoutingManagerEngineTest(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) :
QGeoRoutingManagerEngine(parameters)
{
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
index 1f3a1b50..8079ed21 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
@@ -52,8 +52,9 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
{
}
-QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine(const QMap<
- QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine(
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+ QString *errorString) const
{
return new QGeoRoutingManagerEngineTest(parameters, error, errorString);
}
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
index 1d6ceb96..bb4ac7ee 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
@@ -58,7 +58,7 @@ public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QGeoRoutingManagerEngine* createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
+ QGeoRoutingManagerEngine* createRoutingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
};
diff --git a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
index 4b5f4ff6..c0a57535 100644
--- a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
+++ b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -43,6 +45,8 @@
#include "tst_qnmeapositioninfosource.h"
+#include <QtCore/QtNumeric>
+
#ifdef Q_OS_WIN
// Windows seems to require longer timeouts and step length
@@ -103,6 +107,14 @@ void tst_QNmeaPositionInfoSource::minimumUpdateInterval()
QCOMPARE(source.minimumUpdateInterval(), 100);
}
+void tst_QNmeaPositionInfoSource::userEquivalentRangeError()
+{
+ QNmeaPositionInfoSource source(m_mode);
+ QVERIFY(qIsNaN(source.userEquivalentRangeError()));
+ source.setUserEquivalentRangeError(5.1);
+ QVERIFY(qFuzzyCompare(source.userEquivalentRangeError(), 5.1));
+}
+
void tst_QNmeaPositionInfoSource::setUpdateInterval_delayedUpdate()
{
// If an update interval is set, and an update is not available at a
@@ -348,8 +360,11 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime()
QFETCH(QByteArray, bytes);
QFETCH(QList<QDateTime>, dateTimes);
+ QFETCH(QList<bool>, expectHorizontalAccuracy);
+ QFETCH(QList<bool>, expectVerticalAccuracy);
QNmeaPositionInfoSource source(m_mode);
+ source.setUserEquivalentRangeError(5.1);
QNmeaPositionInfoSourceProxyFactory factory;
QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source));
@@ -359,14 +374,33 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime()
proxy->feedBytes(bytes);
QTRY_COMPARE(spy.count(), dateTimes.count());
- for (int i=0; i<spy.count(); i++)
- QCOMPARE(spy[i][0].value<QGeoPositionInfo>().timestamp(), dateTimes[i]);
+ for (int i=0; i<spy.count(); i++) {
+ QGeoPositionInfo pInfo = spy[i][0].value<QGeoPositionInfo>();
+
+ QCOMPARE(pInfo.timestamp(), dateTimes[i]);
+
+ // Generated GGA/GSA sentences have hard coded HDOP of 3.5, which corrisponds to a
+ // horizontal accuracy of 35.7, for the user equivalent range error of 5.1 set above.
+ QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy),
+ expectHorizontalAccuracy[i]);
+ if (pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::HorizontalAccuracy), 35.7));
+
+ // Generate GSA sentences have hard coded VDOP of 4.0, which corrisponds to a vertical
+ // accuracy of 40.8, for the user equivalent range error of 5.1 set above.
+ QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy),
+ expectVerticalAccuracy[i]);
+ if (pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+ QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::VerticalAccuracy), 40.8));
+ }
}
void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
{
QTest::addColumn<QByteArray>("bytes");
QTest::addColumn<QList<QDateTime> >("dateTimes");
+ QTest::addColumn<QList<bool> >("expectHorizontalAccuracy");
+ QTest::addColumn<QList<bool> >("expectVerticalAccuracy");
QDateTime dt = QDateTime::currentDateTime().toUTC();
QByteArray bytes;
@@ -376,7 +410,9 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(2)).toLatin1();
bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
QTest::newRow("Feed GGA,RMC,GGA; expect RMC, second GGA only")
- << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3));
+ << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3))
+ << (QList<bool>() << true << true)
+ << (QList<bool>() << false << false);
// should not receive ZDA (has no coordinates) but should get the GGA
// sentence after it since it got the date/time from ZDA
@@ -385,7 +421,20 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createZdaSentence(dt.addSecs(2)).toLatin1();
bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
QTest::newRow("Feed GGA,ZDA,GGA; expect second GGA only")
- << bytes << (QList<QDateTime>() << dt.addSecs(3));
+ << bytes << (QList<QDateTime>() << dt.addSecs(3))
+ << (QList<bool>() << true)
+ << (QList<bool>() << false);
+
+ // Feed ZDA,GGA,GSA,GGA; expect vertical accuracy from second GGA.
+ bytes.clear();
+ bytes += QLocationTestUtils::createZdaSentence(dt.addSecs(1)).toLatin1();
+ bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(2).time()).toLatin1();
+ bytes += QLocationTestUtils::createGsaSentence().toLatin1();
+ bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
+ QTest::newRow("Feed ZDA,GGA,GSA,GGA; expect vertical accuracy from second GGA")
+ << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3))
+ << (QList<bool>() << true << true)
+ << (QList<bool>() << false << true);
if (m_mode == QNmeaPositionInfoSource::SimulationMode) {
// In sim m_mode, should ignore sentence with a date/time before the known date/time
@@ -395,7 +444,9 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(-2)).toLatin1();
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(2)).toLatin1();
QTest::newRow("Feed good RMC, RMC with bad date/time, good RMC; expect first and third RMC only")
- << bytes << (QList<QDateTime>() << dt.addSecs(1) << dt.addSecs(2));
+ << bytes << (QList<QDateTime>() << dt.addSecs(1) << dt.addSecs(2))
+ << (QList<bool>() << false << false)
+ << (QList<bool>() << false << false);
}
}
diff --git a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
index d541465d..9d837933 100644
--- a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
+++ b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
@@ -96,6 +96,8 @@ private slots:
void minimumUpdateInterval();
+ void userEquivalentRangeError();
+
void setUpdateInterval_delayedUpdate();
void lastKnownPosition();
diff --git a/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp b/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp
index 13bc2998..c5b72e35 100644
--- a/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp
+++ b/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp
@@ -66,25 +66,20 @@ void tst_QPlaceContentRequest::contentTest()
{
QPlaceContentRequest req;
QCOMPARE(req.limit(), -1);
- QCOMPARE(req.offset(), 0);
QCOMPARE(req.contentType(), QPlaceContent::NoType);
//check that we can set the request fields
req.setLimit(100);
- req.setOffset(5);
req.setContentType(QPlaceContent::ImageType);
QCOMPARE(req.limit(), 100);
- QCOMPARE(req.offset(), 5);
QCOMPARE(req.contentType(), QPlaceContent::ImageType);
//check that we assignment works correctly
QPlaceContentRequest otherReq;
otherReq.setLimit(10);
- otherReq.setOffset(15);
otherReq.setContentType(QPlaceContent::ReviewType);
req = otherReq;
QCOMPARE(req.limit(), 10);
- QCOMPARE(req.offset(), 15);
QCOMPARE(req.contentType(), QPlaceContent::ReviewType);
QCOMPARE(req, otherReq);
@@ -98,11 +93,9 @@ void tst_QPlaceContentRequest::clearTest()
QPlaceContentRequest req;
req.setContentType(QPlaceContent::ReviewType);
req.setLimit(9000);
- req.setOffset(1);
req.clear();
QVERIFY(req.contentType() == QPlaceContent::NoType);
QVERIFY(req.limit() == -1);
- QVERIFY(req.offset() == 0);
}
QTEST_APPLESS_MAIN(tst_QPlaceContentRequest)
diff --git a/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp b/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
index 74c33d86..c8128925 100644
--- a/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
+++ b/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
@@ -91,7 +91,7 @@ void tst_QPlaceManagerNokia::initTestCase()
QStringList providers = QGeoServiceProvider::availableServiceProviders();
- QMap<QString, QVariant> params;
+ QVariantMap params;
params.insert("app_id", "stub");
params.insert("token", "stub");
provider = new QGeoServiceProvider("nokia", params);
diff --git a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
index f1615536..ad14db1e 100644
--- a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
+++ b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
@@ -149,7 +149,7 @@ void tst_QPlaceManagerUnsupported::testGetPlaceDetails()
void tst_QPlaceManagerUnsupported::testGetPlaceContent()
{
- QPlaceContentReply *reply = m_manager->getPlaceContent(QString(), QPlaceContentRequest());
+ QPlaceContentReply *reply = m_manager->getPlaceContent(QPlaceContentRequest());
if (!checkSignals(reply, QPlaceReply::UnsupportedError))
return;
}
diff --git a/tests/auto/qplacesearchreply/tst_qplacesearchreply.cpp b/tests/auto/qplacesearchreply/tst_qplacesearchreply.cpp
index 24a76bc7..43638334 100644
--- a/tests/auto/qplacesearchreply/tst_qplacesearchreply.cpp
+++ b/tests/auto/qplacesearchreply/tst_qplacesearchreply.cpp
@@ -42,9 +42,11 @@
#include <QtCore/QString>
#include <QtTest/QtTest>
+#include <QtPositioning/QGeoCircle>
+#include <QtLocation/QPlaceSearchRequest>
#include <QtLocation/QPlaceSearchReply>
#include <QtLocation/QPlaceResult>
-#include <QtPositioning/QGeoCircle>
+
QT_USE_NAMESPACE
@@ -101,7 +103,6 @@ void tst_QPlaceSearchReply::requestTest()
TestSearchReply *reply = new TestSearchReply(this);
QPlaceSearchRequest request;
request.setLimit(10);
- request.setOffset(50);
QGeoCircle circle;
circle.setCenter(QGeoCoordinate(10,20));
diff --git a/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp b/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
index 318e8353..bd7589dd 100644
--- a/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
+++ b/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
@@ -268,16 +268,14 @@ void tst_QPlaceSearchRequest::clearTest()
category.setName("Fast Food");
req.setCategory(category);
req.setLimit(100);
- req.setOffset(5);
req.clear();
QVERIFY(req.searchTerm().isEmpty());
QVERIFY(req.searchArea() == QGeoShape());
QVERIFY(req.categories().isEmpty());
QVERIFY(req.limit() == -1);
- QVERIFY(req.offset() == 0);
}
-QTEST_APPLESS_MAIN(tst_QPlaceSearchRequest);
+QTEST_APPLESS_MAIN(tst_QPlaceSearchRequest)
#include "tst_qplacesearchrequest.moc"
diff --git a/tests/auto/utils/qlocationtestutils.cpp b/tests/auto/utils/qlocationtestutils.cpp
index 97e4f8d9..d5eed344 100644
--- a/tests/auto/utils/qlocationtestutils.cpp
+++ b/tests/auto/utils/qlocationtestutils.cpp
@@ -93,3 +93,8 @@ QString QLocationTestUtils::createZdaSentence(const QDateTime &dt)
.arg(time).arg(dt.toString("dd")).arg(dt.toString("MM")).arg(dt.toString("yyyy"));
return addNmeaChecksumAndBreaks(nmea);
}
+
+QString QLocationTestUtils::createGsaSentence()
+{
+ return addNmeaChecksumAndBreaks(QStringLiteral("$GPGSA,A,3,,,,,,,,,,,,,3.0,3.5,4.0*"));
+}
diff --git a/tests/auto/utils/qlocationtestutils_p.h b/tests/auto/utils/qlocationtestutils_p.h
index 2c827d41..6ed5de38 100644
--- a/tests/auto/utils/qlocationtestutils_p.h
+++ b/tests/auto/utils/qlocationtestutils_p.h
@@ -57,6 +57,7 @@ namespace QLocationTestUtils
QString createGgaSentence(const QTime &time);
QString createGgaSentence(int lat, int lng, const QTime &time);
QString createZdaSentence(const QDateTime &dt);
+ QString createGsaSentence();
//The purpose of compareEquality() is to test equality
//operators where it is expected that A == B.