summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-02-12 13:10:02 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-02-12 14:31:02 +0000
commitcc3a5a926db8d07c8282407a7b010b4ab2289592 (patch)
tree18b62fa079b15e3c773d01483ec42b71e4b6945a
parent108442eeae16dfcdbdbe3e73a45e6128b7839fe8 (diff)
downloadqtlocation-cc3a5a926db8d07c8282407a7b010b4ab2289592.tar.gz
Fix zoomLevel being emitted when the value has not changed
Map.setZoomLevel currently clamps the user-set value to a valid range. The current implementation emits zoomLevelChanged every time the user-set value is different from the current value. This patch restrict emission to when the actual value has really changed. Change-Id: I2096b666d2a5b1849c9022cad028b826cfee2a78 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index d7f93d14..fefffeb6 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -916,7 +916,8 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel)
*/
void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel, bool overzoom)
{
- if (m_cameraData.zoomLevel() == zoomLevel || zoomLevel < 0)
+ const qreal oldZoom = m_cameraData.zoomLevel();
+ if (oldZoom == zoomLevel || zoomLevel < 0)
return;
//small optimization to avoid double setCameraData
@@ -940,7 +941,8 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel, bool overzoom)
if (centerHasChanged)
emit centerChanged(m_cameraData.center());
- emit zoomLevelChanged(m_cameraData.zoomLevel());
+ if (oldZoom != m_cameraData.zoomLevel())
+ emit zoomLevelChanged(m_cameraData.zoomLevel());
}
qreal QDeclarativeGeoMap::zoomLevel() const