diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-06-23 15:48:28 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-06-24 14:10:26 +0000 |
commit | 24ecdc6c962ff40096782bffc24b7d6623c4a87e (patch) | |
tree | fbbf6a2c35a6643ea99d97729fd7f6e6bc0fd612 /src/imports | |
parent | 93e4645cde4ad8ca00c2bcdacd6150d80f81bc1c (diff) | |
download | qtlocation-24ecdc6c962ff40096782bffc24b7d6623c4a87e.tar.gz |
A fix for not working setVisibleRegion
Setting the visibleRegion, than changing the map
center or zoom and than setting it again does not work.
Fix the issue by invalidating the region on
the zoom or center change.
Task-number: QTBUG-54141
Change-Id: I4e680f146312e3a3aa90e27fae213042cc2b2a42
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 19 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomap_p.h | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index 2ef5d79d..7647a70b 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -182,7 +182,8 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent) m_componentCompleted(false), m_mappingManagerInitialized(false), m_color(QColor::fromRgbF(0.9, 0.9, 0.9)), - m_pendingFitViewport(false) + m_pendingFitViewport(false), + m_validRegion(false) { setAcceptHoverEvents(false); setAcceptedMouseButtons(Qt::LeftButton); @@ -503,7 +504,7 @@ void QDeclarativeGeoMap::mappingManagerInitialized() connect(m_map->mapController(), SIGNAL(centerChanged(QGeoCoordinate)), this, - SIGNAL(centerChanged(QGeoCoordinate))); + SLOT(mapCenterChanged(QGeoCoordinate))); connect(m_map->mapController(), SIGNAL(zoomChanged(qreal)), this, @@ -646,6 +647,8 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel) return; m_zoomLevel = zoomLevel; + m_validRegion = false; + if (m_mappingManagerInitialized) m_map->mapController()->setZoom(m_zoomLevel); emit zoomLevelChanged(zoomLevel); @@ -676,6 +679,7 @@ void QDeclarativeGeoMap::setCenter(const QGeoCoordinate ¢er) return; m_center = center; + m_validRegion = false; if (m_center.isValid() && m_mappingManagerInitialized) { m_map->mapController()->setCenter(m_center); @@ -714,7 +718,7 @@ QGeoCoordinate QDeclarativeGeoMap::center() const */ void QDeclarativeGeoMap::setVisibleRegion(const QGeoShape &shape) { - if (shape == m_region) + if (shape == m_region && m_validRegion) return; m_region = shape; @@ -822,6 +826,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape() newZoom = std::floor(qMax(minimumZoomLevel(), (m_map->mapController()->zoom() + newZoom))); setProperty("zoomLevel", QVariant::fromValue(newZoom)); + + m_validRegion = true; } /*! @@ -832,9 +838,16 @@ void QDeclarativeGeoMap::mapZoomLevelChanged(qreal zoom) if (zoom == m_zoomLevel) return; m_zoomLevel = zoom; + m_validRegion = false; emit zoomLevelChanged(m_zoomLevel); } +void QDeclarativeGeoMap::mapCenterChanged(const QGeoCoordinate ¢er) +{ + m_validRegion = false; + emit centerChanged(center); +} + /*! \qmlproperty list<MapType> QtLocation::Map::supportedMapTypes diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h index fb36104a..ca1b7a62 100644 --- a/src/imports/location/qdeclarativegeomap_p.h +++ b/src/imports/location/qdeclarativegeomap_p.h @@ -167,6 +167,7 @@ protected: private Q_SLOTS: void mappingManagerInitialized(); void mapZoomLevelChanged(qreal zoom); + void mapCenterChanged(const QGeoCoordinate ¢er); void pluginReady(); void onMapChildrenChanged(); @@ -198,6 +199,7 @@ private: QGeoShape m_region; QColor m_color; bool m_pendingFitViewport; + bool m_validRegion; friend class QDeclarativeGeoMapItem; friend class QDeclarativeGeoMapItemView; |