diff options
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; |