summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-04-20 10:58:37 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-04-20 10:58:37 +0200
commit40c1af321a2210fea29d46964fad8c9efaa912dc (patch)
treecc067a3e01057cf4aa8a6e26730d7ee281374393
parent1171ee5fbd7f05d01d1e0f2594f0801b761d2496 (diff)
parent40b9692ba98b93da50e7a3d35c178c41853c3d0a (diff)
downloadqtlocation-40c1af321a2210fea29d46964fad8c9efaa912dc.tar.gz
Merge 5.11 into 5.11.0
Change-Id: I93bd8e6bdd86795e5a52a9fc6e65fd3f0b9fc6ba
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp49
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem_p.h5
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem.cpp6
-rw-r--r--src/location/declarativemaps/qgeomapitemgeometry_p.h2
-rw-r--r--src/location/labs/qsg/qmapcircleobjectqsg.cpp2
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg.cpp2
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp6
8 files changed, 41 insertions, 33 deletions
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 44f9b3a1..dffec4d5 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -519,7 +519,8 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
\internal
*/
void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
- qreal strokeWidth)
+ qreal strokeWidth,
+ bool adjustTranslation)
{
if (!screenDirty_)
return;
@@ -531,20 +532,14 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
return;
}
- // Create the viewport rect in the same coordinate system
- // as the actual points
- QRectF viewport(0, 0, map.viewportWidth(), map.viewportHeight());
- viewport.adjust(-strokeWidth, -strokeWidth, strokeWidth, strokeWidth);
- viewport.translate(-1 * origin);
-
// The geometry has already been clipped against the visible region projection in wrapped mercator space.
QVector<qreal> points = srcPoints_;
QVector<QPainterPath::ElementType> types = srcPointTypes_;
QVectorPath vp(points.data(), types.size(), types.data());
QTriangulatingStroker ts;
- // viewport is not used in the call below.
- ts.process(vp, QPen(QBrush(Qt::black), strokeWidth), viewport, QPainter::Qt4CompatiblePainting);
+ // As of Qt5.11, the clip argument is not actually used, in the call below.
+ ts.process(vp, QPen(QBrush(Qt::black), strokeWidth), QRectF(), QPainter::Qt4CompatiblePainting);
clear();
@@ -583,7 +578,8 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
}
screenBounds_ = bb;
- this->translate( -1 * sourceBounds_.topLeft() + QPointF(strokeWidth, strokeWidth));
+ const QPointF strokeOffset = (adjustTranslation) ? QPointF(strokeWidth, strokeWidth) : QPointF();
+ this->translate( -1 * sourceBounds_.topLeft() + strokeOffset);
}
void QGeoMapPolylineGeometry::clearSource()
@@ -592,6 +588,24 @@ void QGeoMapPolylineGeometry::clearSource()
srcPointTypes_.clear();
}
+bool QGeoMapPolylineGeometry::contains(const QPointF &point) const
+{
+ // screenOutline_.contains(screenPoint) doesn't work, as, it appears, that
+ // screenOutline_ for QGeoMapPolylineGeometry is empty (QRectF(0,0 0x0))
+ const QVector<QPointF> &verts = vertices();
+ QPolygonF tri;
+ for (int i = 0; i < verts.size(); ++i) {
+ tri << verts[i];
+ if (tri.size() == 3) {
+ if (tri.containsPoint(point,Qt::OddEvenFill))
+ return true;
+ tri.remove(0);
+ }
+ }
+
+ return false;
+}
+
QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent)
: QDeclarativeGeoMapItemBase(parent), line_(this), dirtyMaterial_(true), updatingGeometry_(false)
{
@@ -948,7 +962,7 @@ void QDeclarativePolylineMapItem::updatePolish()
setWidth(geometry_.sourceBoundingBox().width() + 2 * line_.width());
setHeight(geometry_.sourceBoundingBox().height() + 2 * line_.width());
- setPositionOnMap(geometry_.origin(), -1 * geometry_.sourceBoundingBox().topLeft());
+ setPositionOnMap(geometry_.origin(), -1 * geometry_.sourceBoundingBox().topLeft() + QPointF(line_.width(), line_.width()));
}
void QDeclarativePolylineMapItem::markSourceDirtyAndUpdate()
@@ -982,18 +996,7 @@ QSGNode *QDeclarativePolylineMapItem::updateMapItemPaintNode(QSGNode *oldNode, U
bool QDeclarativePolylineMapItem::contains(const QPointF &point) const
{
- QVector<QPointF> vertices = geometry_.vertices();
- QPolygonF tri;
- for (int i = 0; i < vertices.size(); ++i) {
- tri << vertices[i];
- if (tri.size() == 3) {
- if (tri.containsPoint(point,Qt::OddEvenFill))
- return true;
- tri.remove(0);
- }
- }
-
- return false;
+ return geometry_.contains(point);
}
const QGeoShape &QDeclarativePolylineMapItem::geoShape() const
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
index 61439097..ca01de12 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
@@ -95,10 +95,13 @@ public:
const QGeoCoordinate geoLeftBound);
void updateScreenPoints(const QGeoMap &map,
- qreal strokeWidth);
+ qreal strokeWidth,
+ bool adjustTranslation = true);
void clearSource();
+ bool contains(const QPointF &point) const override;
+
QList<QList<QDoubleVector2D> > clipPath(const QGeoMap &map,
const QList<QDoubleVector2D> &path,
QDoubleVector2D &leftBoundWrapped);
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
index 9e32c427..e90c0596 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
@@ -290,7 +290,7 @@ void QDeclarativeRectangleMapItem::updatePolish()
geometry_.setPreserveGeometry(true, rectangle_.topLeft());
geometry_.updateSourcePoints(*map(), pathMercator_);
- geometry_.updateScreenPoints(*map());
+ geometry_.updateScreenPoints(*map(), border_.width());
QList<QGeoMapItemGeometry *> geoms;
geoms << &geometry_;
@@ -320,8 +320,8 @@ void QDeclarativeRectangleMapItem::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(), geometry_.firstPointOffset());
}
diff --git a/src/location/declarativemaps/qgeomapitemgeometry_p.h b/src/location/declarativemaps/qgeomapitemgeometry_p.h
index 1011cd0c..ab81ff0b 100644
--- a/src/location/declarativemaps/qgeomapitemgeometry_p.h
+++ b/src/location/declarativemaps/qgeomapitemgeometry_p.h
@@ -95,7 +95,7 @@ public:
return screenOutline_;
}
- inline bool contains(const QPointF &screenPoint) const {
+ virtual bool contains(const QPointF &screenPoint) const {
return screenOutline_.contains(screenPoint);
}
diff --git a/src/location/labs/qsg/qmapcircleobjectqsg.cpp b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
index 10110eab..9fe3ee0a 100644
--- a/src/location/labs/qsg/qmapcircleobjectqsg.cpp
+++ b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
@@ -131,7 +131,7 @@ void QMapCircleObjectPrivateQSG::updateGeometry()
if (clippedPaths.size()) {
borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin);
m_borderGeometry.pathToScreen(*m_map, clippedPaths, borderLeftBoundWrapped);
- m_borderGeometry.updateScreenPoints(*m_map, borderWidth());
+ m_borderGeometry.updateScreenPoints(*m_map, borderWidth(), false);
} else {
m_borderGeometry.clear();
}
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
index 4000c08f..27dcc80f 100644
--- a/src/location/labs/qsg/qmappolygonobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
@@ -198,7 +198,7 @@ void QMapPolygonObjectPrivateQSG::updateGeometry()
if (clippedPaths.size()) {
borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin);
m_borderGeometry.pathToScreen(*m_map.data(), clippedPaths, borderLeftBoundWrapped);
- m_borderGeometry.updateScreenPoints(*m_map.data(), borderWidth());
+ m_borderGeometry.updateScreenPoints(*m_map.data(), borderWidth(), false);
} else {
m_borderGeometry.clear();
}
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg.cpp b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
index fe6fbec6..c0c3854e 100644
--- a/src/location/labs/qsg/qmappolylineobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
@@ -90,7 +90,7 @@ void QMapPolylineObjectPrivateQSG::updateGeometry()
const QList<QDoubleVector2D> &geopathProjected = projectPath();
m_geometry.setPreserveGeometry(true, m_geoPath.boundingGeoRectangle().topLeft());
m_geometry.updateSourcePoints(*m_map.data(), geopathProjected, m_geoPath.boundingGeoRectangle().topLeft());
- m_geometry.updateScreenPoints(*m_map.data(), width());
+ m_geometry.updateScreenPoints(*m_map.data(), width(), false);
QPointF origin = m_map->geoProjection().coordinateToItemPosition(m_geometry.origin(), false).toPointF();
m_geometry.translate(origin - m_geometry.firstPointOffset());
diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
index a6654e81..a79af1cb 100644
--- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
@@ -51,6 +51,8 @@
#include <QtLocation/QPlaceSearchRequest>
#include <QtLocation/QPlaceContactDetail>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
namespace {
@@ -204,11 +206,11 @@ void QPlaceSearchReplyMapbox::onReplyFinished()
}
if (request().relevanceHint() == QPlaceSearchRequest::DistanceHint) {
- qSort(results.begin(), results.end(), [](const QPlaceResult &a, const QPlaceResult &b) -> bool {
+ std::sort(results.begin(), results.end(), [](const QPlaceResult &a, const QPlaceResult &b) -> bool {
return a.distance() < b.distance();
});
} else if (request().relevanceHint() == QPlaceSearchRequest::LexicalPlaceNameHint) {
- qSort(results.begin(), results.end(), [](const QPlaceResult &a, const QPlaceResult &b) -> bool {
+ std::sort(results.begin(), results.end(), [](const QPlaceResult &a, const QPlaceResult &b) -> bool {
return a.place().name() < b.place().name();
});
}