From 95f8804ecaed79792a57b1fe3580266bfbbf7590 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 18 Nov 2016 19:02:36 +0100 Subject: Renaming QGeoMapPrivate::changeMapSize to changeViewportSize The current name of this method generate confusion, as what it does is changing the size of the final element in the application, and not the actual map size. This patch renames this method to changeDisplaySize It also renames QGeoMap::setSize to setViewportSize, as well as ::size to viewportSize , width to viewportWidth and height to viewportHeight, to make everything consistent and self-explanatory. Finally it also renames minimumZoomAtMapSize to minimumZoomAtViewportSize. Change-Id: I7c1ca8bb3ca3d6f6b0fe6fc881b9300db7110527 Reviewed-by: Alex Blasche --- src/imports/location/qdeclarativecirclemapitem.cpp | 6 +++--- src/imports/location/qdeclarativegeomap.cpp | 14 +++++++------- src/imports/location/qdeclarativepolygonmapitem.cpp | 4 ++-- src/imports/location/qdeclarativepolylinemapitem.cpp | 4 ++-- src/imports/location/qgeomapitemgeometry.cpp | 4 ++-- src/imports/location/qquickgeomapgesturearea.cpp | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/imports') diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp index f6b3c14f..6890703b 100644 --- a/src/imports/location/qdeclarativecirclemapitem.cpp +++ b/src/imports/location/qdeclarativecirclemapitem.cpp @@ -144,7 +144,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map) if (!screenDirty_) return; - if (map.width() == 0 || map.height() == 0) { + if (map.viewportWidth() == 0 || map.viewportHeight() == 0) { clear(); return; } @@ -176,7 +176,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map) geoDistance += 360.0; double mapWidth = 360.0 / geoDistance; - qreal leftOffset = origin.x() - (map.width()/2.0 - mapWidth/2.0) - firstPointOffset_.x(); + qreal leftOffset = origin.x() - (map.viewportWidth()/2.0 - mapWidth/2.0) - firstPointOffset_.x(); qreal topOffset = origin.y() - (midPoint.y() - mapWidth/2.0) - firstPointOffset_.y(); QPainterPath ppiBorder; ppiBorder.moveTo(QPointF(-leftOffset, -topOffset)); @@ -613,7 +613,7 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList(mapWidth), map()->width()); + mapWidth = qMin(static_cast(mapWidth), map()->viewportWidth()); QDoubleVector2D prev = map()->coordinateToItemPosition(path.at(0), false); // find the points in path where wrapping occurs for (int i = 1; i <= path.count(); ++i) { diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index 0f54929b..1cdde85c 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -306,7 +306,7 @@ void QDeclarativeGeoMap::initialize() // try to keep center change signal in the end bool centerHasChanged = false; - setMinimumZoomLevel(m_map->minimumZoomAtMapSize(width(), height())); + setMinimumZoomLevel(m_map->minimumZoomAtViewportSize(width(), height())); // set latitude bundary check m_maximumViewportLatitude = m_map->maximumCenterLatitudeAtZoom(m_cameraData.zoomLevel()); @@ -559,7 +559,7 @@ void QDeclarativeGeoMap::mappingManagerInitialized() // after this has been called at least once, after creation. if (!m_initialized && width() > 0 && height() > 0) { - m_map->setSize(QSize(width(), height())); + m_map->setViewportSize(QSize(width(), height())); initialize(); } @@ -615,7 +615,7 @@ void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel) if (m_map) { minimumZoomLevel = qBound(qreal(m_map->cameraCapabilities().minimumZoomLevel()), minimumZoomLevel, maximumZoomLevel()); - double minimumViewportZoomLevel = m_map->minimumZoomAtMapSize(width(),height()); + double minimumViewportZoomLevel = m_map->minimumZoomAtViewportSize(width(),height()); if (minimumZoomLevel < minimumViewportZoomLevel) minimumZoomLevel = minimumViewportZoomLevel; } @@ -1035,8 +1035,8 @@ void QDeclarativeGeoMap::pan(int dx, int dy) if (dx == 0 && dy == 0) return; QGeoCoordinate coord = m_map->itemPositionToCoordinate( - QDoubleVector2D(m_map->width() / 2 + dx, - m_map->height() / 2 + dy)); + QDoubleVector2D(m_map->viewportWidth() / 2 + dx, + m_map->viewportHeight() / 2 + dy)); setCenter(coord); } @@ -1307,12 +1307,12 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF if (!m_map || !newGeometry.size().isValid()) return; - m_map->setSize(newGeometry.size().toSize()); + m_map->setViewportSize(newGeometry.size().toSize()); if (!m_initialized) initialize(); else - setMinimumZoomLevel(m_map->minimumZoomAtMapSize(newGeometry.width(), newGeometry.height())); + setMinimumZoomLevel(m_map->minimumZoomAtViewportSize(newGeometry.width(), newGeometry.height())); /*! The fitViewportTo*() functions depend on a valid map geometry. diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp index a42892b7..32dbb206 100644 --- a/src/imports/location/qdeclarativepolygonmapitem.cpp +++ b/src/imports/location/qdeclarativepolygonmapitem.cpp @@ -214,7 +214,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map) if (!screenDirty_) return; - if (map.width() == 0 || map.height() == 0) { + if (map.viewportWidth() == 0 || map.viewportHeight() == 0) { clear(); return; } @@ -223,7 +223,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map) // Create the viewport rect in the same coordinate system // as the actual points - QRectF viewport(0, 0, map.width(), map.height()); + QRectF viewport(0, 0, map.viewportWidth(), map.viewportHeight()); viewport.translate(-1 * origin.toPointF()); QPainterPath vpPath; diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp index c44ef129..2153b036 100644 --- a/src/imports/location/qdeclarativepolylinemapitem.cpp +++ b/src/imports/location/qdeclarativepolylinemapitem.cpp @@ -202,7 +202,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map, QDoubleVector2D origin, lastAddedPoint; - const double mapWidthHalf = map.width()/2.0; + const double mapWidthHalf = map.viewportWidth()/2.0; double unwrapBelowX = 0; if (preserveGeometry_) unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x(); @@ -400,7 +400,7 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map, // Create the viewport rect in the same coordinate system // as the actual points - QRectF viewport(0, 0, map.width(), map.height()); + QRectF viewport(0, 0, map.viewportWidth(), map.viewportHeight()); viewport.adjust(-strokeWidth, -strokeWidth, strokeWidth, strokeWidth); viewport.translate(-1 * origin); diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp index c8168f67..a22be0af 100644 --- a/src/imports/location/qgeomapitemgeometry.cpp +++ b/src/imports/location/qgeomapitemgeometry.cpp @@ -125,7 +125,7 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map, // Do not wrap around half the globe Q_ASSERT(!qFuzzyCompare(fromCoord.longitude(), toCoord.longitude())); - QGeoCoordinate mapMid = map.itemPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0)); + QGeoCoordinate mapMid = map.itemPositionToCoordinate(QDoubleVector2D(map.viewportWidth()/2.0, 0)); double halfGeoDist = toCoord.longitude() - fromCoord.longitude(); if (toCoord.longitude() < fromCoord.longitude()) halfGeoDist += 360; @@ -133,7 +133,7 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map, QGeoCoordinate geoDelta = QGeoCoordinate(0, QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist)); QDoubleVector2D halfScreenDist = map.coordinateToItemPosition(geoDelta, false) - - QDoubleVector2D(map.width()/2.0, 0); + - QDoubleVector2D(map.viewportWidth()/2.0, 0); return halfScreenDist.x() * 2.0; } diff --git a/src/imports/location/qquickgeomapgesturearea.cpp b/src/imports/location/qquickgeomapgesturearea.cpp index ccf360aa..0baaf98e 100644 --- a/src/imports/location/qquickgeomapgesturearea.cpp +++ b/src/imports/location/qquickgeomapgesturearea.cpp @@ -702,7 +702,7 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event) { qreal dx = postZoomPoint.x() - preZoomPoint.x(); qreal dy = postZoomPoint.y() - preZoomPoint.y(); - QPointF mapCenterPoint(m_map->width() / 2.0 + dx, m_map->height() / 2.0 + dy); + QPointF mapCenterPoint(m_map->viewportWidth() / 2.0 + dx, m_map->viewportHeight() / 2.0 + dy); QGeoCoordinate mapCenterCoordinate = m_map->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false); m_declarativeMap->setCenter(mapCenterCoordinate); @@ -1148,8 +1148,8 @@ void QQuickGeoMapGestureArea::updatePan() int dx = static_cast(m_sceneCenter.x() - startPoint.x()); int dy = static_cast(m_sceneCenter.y() - startPoint.y()); QPointF mapCenterPoint; - mapCenterPoint.setY(m_map->height() / 2.0 - dy); - mapCenterPoint.setX(m_map->width() / 2.0 - dx); + mapCenterPoint.setY(m_map->viewportHeight() / 2.0 - dy); + mapCenterPoint.setX(m_map->viewportWidth() / 2.0 - dx); QGeoCoordinate animationStartCoordinate = m_map->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false); m_declarativeMap->setCenter(animationStartCoordinate); } -- cgit v1.2.1