summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-04-17 13:21:58 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-04-18 14:15:50 +0000
commitf9b9f578f6e7e1ba572a7f098d53d3a0b0fd4a97 (patch)
tree8e35af7f0103fa516f321b796086ce0ecc37495a
parentfce2ba1910a6cac05d8af39fe6114998490ed28f (diff)
downloadqtlocation-f9b9f578f6e7e1ba572a7f098d53d3a0b0fd4a97.tar.gz
Fix MapPolygon being drawn misplaced and moving as it gets clipped
This patch fixes a regression introduced with commit f0bc0db15ed262a8f31bb07b3b46a5cdf9277e79 Change-Id: Ie974b7a95d8ecd5f6affafc070848d289f7afa06 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp13
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem_p.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index b019a073..9e96f3c6 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -246,7 +246,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
/*!
\internal
*/
-void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
+void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map, qreal strokeWidth)
{
if (!screenDirty_)
return;
@@ -310,6 +310,8 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
}
screenBounds_ = ppi.boundingRect();
+ if (strokeWidth != 0.0)
+ this->translate(QPointF(strokeWidth, strokeWidth));
}
QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
@@ -515,7 +517,7 @@ void QDeclarativePolygonMapItem::updatePolish()
updatingGeometry_ = true;
geometry_.updateSourcePoints(*map(), geopathProjected_);
- geometry_.updateScreenPoints(*map());
+ geometry_.updateScreenPoints(*map(), border_.width());
QList<QGeoMapItemGeometry *> geoms;
geoms << &geometry_;
@@ -546,10 +548,11 @@ void QDeclarativePolygonMapItem::updatePolish()
}
QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms);
- setWidth(combined.width());
- setHeight(combined.height());
+ setWidth(combined.width() + 2 * border_.width());
+ setHeight(combined.height() + 2 * border_.width());
- setPositionOnMap(geometry_.origin(), -1 * geometry_.sourceBoundingBox().topLeft());
+ setPositionOnMap(geometry_.origin(), -1 * geometry_.sourceBoundingBox().topLeft()
+ + QPointF(border_.width(), border_.width()));
}
void QDeclarativePolygonMapItem::markSourceDirtyAndUpdate()
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
index 1e2a91c9..febeb751 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
@@ -70,7 +70,7 @@ public:
void updateSourcePoints(const QGeoMap &map,
const QList<QDoubleVector2D> &path);
- void updateScreenPoints(const QGeoMap &map);
+ void updateScreenPoints(const QGeoMap &map, qreal strokeWidth = 0.0);
protected:
QPainterPath srcPath_;