diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-04-08 14:03:14 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-04-10 12:22:34 +0000 |
commit | c5311b1e937320f78fdd752704b6a34b34a522ca (patch) | |
tree | 59db97baf21a19af765a26ec7a3adfcc03a214f7 | |
parent | de39034175f6187d3d29786f467d11e985bf0cac (diff) | |
download | qtlocation-c5311b1e937320f78fdd752704b6a34b34a522ca.tar.gz |
Add notification signal to Map.visibleRegion property
[ChangeLog] Added notification signal to Map.visibleRegion property.
Change-Id: I77d5e1f086a94a677d452644bb82ada1b765c617
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/imports/location/location.cpp | 3 | ||||
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomap.cpp | 26 | ||||
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomap_p.h | 3 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 45087751..422b4c72 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -200,6 +200,9 @@ public: qmlRegisterType<QDeclarativeGeoRoute, 13>(uri, major, minor, "Route"); qmlRegisterType<QDeclarativeGeoRouteQuery, 13>(uri, major, minor, "RouteQuery"); + minor = 14; + qmlRegisterType<QDeclarativeGeoMap, 14>(uri, major, minor, "Map"); + // Register the latest Qt version as QML type version qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR); diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 997f8465..31935faa 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -880,8 +880,10 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel, bool overzoom) } else { const bool zlHasChanged = zoomLevel != m_cameraData.zoomLevel(); m_cameraData.setZoomLevel(zoomLevel); - if (zlHasChanged) + if (zlHasChanged) { emit zoomLevelChanged(zoomLevel); + emit visibleRegionChanged(); + } } } @@ -964,8 +966,10 @@ void QDeclarativeGeoMap::setBearing(qreal bearing) } else { const bool bearingHasChanged = bearing != m_cameraData.bearing(); m_cameraData.setBearing(bearing); - if (bearingHasChanged) + if (bearingHasChanged) { emit bearingChanged(bearing); + emit visibleRegionChanged(); + } } } @@ -1029,8 +1033,10 @@ void QDeclarativeGeoMap::setTilt(qreal tilt) } else { const bool tiltHasChanged = tilt != m_cameraData.tilt(); m_cameraData.setTilt(tilt); - if (tiltHasChanged) + if (tiltHasChanged) { emit tiltChanged(tilt); + emit visibleRegionChanged(); + } } } @@ -1087,8 +1093,10 @@ void QDeclarativeGeoMap::setFieldOfView(qreal fieldOfView) } else { const bool fovChanged = fieldOfView != m_cameraData.fieldOfView(); m_cameraData.setFieldOfView(fieldOfView); - if (fovChanged) + if (fovChanged) { emit fieldOfViewChanged(fieldOfView); + emit visibleRegionChanged(); + } } } @@ -1254,8 +1262,10 @@ void QDeclarativeGeoMap::setCenter(const QGeoCoordinate ¢er) } else { const bool centerHasChanged = center != m_cameraData.center(); m_cameraData.setCenter(center); - if (centerHasChanged) + if (centerHasChanged) { emit centerChanged(center); + emit visibleRegionChanged(); + } } } @@ -1297,15 +1307,18 @@ void QDeclarativeGeoMap::setVisibleRegion(const QGeoShape &shape) // shape invalidated -> nothing to fit anymore m_visibleRegion = QGeoRectangle(); m_pendingFitViewport = false; + emit visibleRegionChanged(); return; } if (!m_map || !width() || !height()) { m_pendingFitViewport = true; + emit visibleRegionChanged(); return; } fitViewportToGeoShape(m_visibleRegion); + emit visibleRegionChanged(); } QGeoShape QDeclarativeGeoMap::visibleRegion() const @@ -1743,6 +1756,9 @@ void QDeclarativeGeoMap::onCameraDataChanged(const QGeoCameraData &cameraData) emit tiltChanged(m_cameraData.tilt()); if (fovHasChanged) emit fieldOfViewChanged(m_cameraData.fieldOfView()); + if (centerHasChanged || zoomHasChanged || bearingHasChanged + || tiltHasChanged || fovHasChanged) + emit visibleRegionChanged(); } /*! diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h index 55751365..c97c3622 100644 --- a/src/location/declarativemaps/qdeclarativegeomap_p.h +++ b/src/location/declarativemaps/qdeclarativegeomap_p.h @@ -97,7 +97,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMap : public QQuickItem Q_PROPERTY(QList<QObject *> mapParameters READ mapParameters) Q_PROPERTY(QGeoServiceProvider::Error error READ error NOTIFY errorChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) - Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion) + Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion NOTIFY visibleRegionChanged) Q_PROPERTY(bool copyrightsVisible READ copyrightsVisible WRITE setCopyrightsVisible NOTIFY copyrightsVisibleChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(bool mapReady READ mapReady NOTIFY mapReadyChanged) @@ -233,6 +233,7 @@ Q_SIGNALS: void mapReadyChanged(bool ready); Q_REVISION(11) void mapObjectsChanged(); void visibleAreaChanged(); + Q_REVISION(14) void visibleRegionChanged(); protected: void mousePressEvent(QMouseEvent *event) override ; |