diff options
author | Wolfgang Bremer <wolfgang@w-bremer.de> | 2014-08-05 01:54:11 +0200 |
---|---|---|
committer | Wolfgang Bremer <wbremer@blackberry.com> | 2014-08-11 16:43:38 +0200 |
commit | 09f68b95b125cef0c8e93092b0aad3a3e794913f (patch) | |
tree | d2dbbd7388fd1016205b9d3346672645f7ad734c | |
parent | dadf66728911c9e6a1b8251e5b7f00fa2c77e43c (diff) | |
download | qtlocation-09f68b95b125cef0c8e93092b0aad3a3e794913f.tar.gz |
Fix fitViewportToMapItemsRefine
The item counter was broken. Therefore the bounding box calculation
only worked under certain circumstances.
This commit removes the circle special case calculation, which is
superfluous, and treats all map items the same way.
Change-Id: Ida0a6cf695fb151132bc867eb30ecb834a5bf6c5
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index b627da29..6263ed33 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -1088,13 +1088,13 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine) double bottomRightY = 0; // find bounds of all map items - QGeoCoordinate geoCenter; - QDoubleVector2D centerPt; int itemCount = 0; for (int i = 0; i < mapItems_.count(); ++i) { if (!mapItems_.at(i)) continue; QDeclarativeGeoMapItemBase *item = mapItems_.at(i).data(); + if (!item) + continue; // skip quick items in the first pass and refine the fit later if (refine) { @@ -1104,26 +1104,11 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine) continue; } - // account for the special case - circle - QDeclarativeCircleMapItem *circleItem = - qobject_cast<QDeclarativeCircleMapItem *>(item); + topLeftX = item->position().x(); + topLeftY = item->position().y(); + bottomRightX = topLeftX + item->width(); + bottomRightY = topLeftY + item->height(); - if ((!circleItem || !circleItem->center().isValid()) && !item) - continue; - if (circleItem) { - geoCenter = circleItem->center(); - centerPt = map_->coordinateToScreenPosition(geoCenter, false); - topLeftX = centerPt.x() - circleItem->width() / 2.0; - topLeftY = centerPt.y() - circleItem->height() / 2.0; - bottomRightX = centerPt.x() + circleItem->width() / 2.0; - bottomRightY = centerPt.y() + circleItem->height() / 2.0; - } else if (item) { - topLeftX = item->position().x(); - topLeftY = item->position().y(); - bottomRightX = topLeftX + item->width(); - bottomRightY = topLeftY + item->height(); - ++itemCount; - } if (itemCount == 0) { minX = topLeftX; maxX = bottomRightX; |