diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-26 14:25:06 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-26 14:25:06 +0100 |
commit | c6a28570a7300788127117378eb7cd36dcd0953f (patch) | |
tree | b8e56b1bd18fb4438de171004d588d12dbf7abec /src/imports | |
parent | e9ead74ec4169d483de0b711986b5b560bbb730a (diff) | |
parent | 24e50e40caaa2f2e057180b8ed8179795e605e2a (diff) | |
download | qtlocation-c6a28570a7300788127117378eb7cd36dcd0953f.tar.gz |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I23c874c5dcd0452142c3cf8abff65415ad31a1e7
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 12 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomap_p.h | 1 | ||||
-rw-r--r-- | src/imports/location/qdeclarativepolylinemapitem.cpp | 126 | ||||
-rw-r--r-- | src/imports/location/qdeclarativepolylinemapitem_p.h | 6 |
4 files changed, 137 insertions, 8 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index 67f723b9..8fbe6e32 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -944,6 +944,18 @@ void QDeclarativeGeoMap::prefetchData() } /*! + \qmlmethod void QtLocation::Map::clearData() + + Clears map data collected by the currently selected plugin. + \note This method will delete cached files. + \sa plugin +*/ +void QDeclarativeGeoMap::clearData() +{ + m_map->clearData(); +} + +/*! \qmlproperty string QtLocation::Map::errorString This read-only property holds the textual presentation of the latest mapping provider error. diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h index 69d4687d..06c39640 100644 --- a/src/imports/location/qdeclarativegeomap_p.h +++ b/src/imports/location/qdeclarativegeomap_p.h @@ -131,6 +131,7 @@ public: Q_INVOKABLE void fitViewportToMapItems(); Q_INVOKABLE void pan(int dx, int dy); Q_INVOKABLE void prefetchData(); // optional hint for prefetch + Q_INVOKABLE void clearData(); QString errorString() const; QGeoServiceProvider::Error error() const; diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp index 71a205d3..f2373abf 100644 --- a/src/imports/location/qdeclarativepolylinemapitem.cpp +++ b/src/imports/location/qdeclarativepolylinemapitem.cpp @@ -199,6 +199,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map, QDoubleVector2D origin, lastPoint, lastAddedPoint; + const double mapWidthHalf = map.width()/2.0; double unwrapBelowX = 0; if (preserveGeometry_) unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x(); @@ -219,7 +220,8 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map, // unwrap x to preserve geometry if moved to border of map if (preserveGeometry_ && point.x() < unwrapBelowX && !qFuzzyCompare(geoLeftBound_.longitude(), coord.longitude()) - && !qFuzzyCompare(point.x(), unwrapBelowX)) + && !qFuzzyCompare(point.x(), unwrapBelowX) + && !qFuzzyCompare(mapWidthHalf, point.x())) point.setX(unwrapBelowX + geoDistanceToScreenWidth(map, geoLeftBound_, coord)); if (!foundValid) { @@ -534,7 +536,6 @@ void QDeclarativePolylineMapItem::setPath(const QJSValue &value) setPathFromGeoList(pathList); } - /*! \internal */ @@ -551,13 +552,26 @@ void QDeclarativePolylineMapItem::setPathFromGeoList(const QList<QGeoCoordinate> } /*! - \qmlmethod void MapPolyline::addCoordinate(coordinate) + \qmlmethod int MapPolyline::pathLength() + + Returns the number of coordinates of the polyline. - Adds a coordinate to the path. + \since Qt Location 5.6 - \sa removeCoordinate, path + \sa path */ +int QDeclarativePolylineMapItem::pathLength() const +{ + return path_.size(); +} + +/*! + \qmlmethod void MapPolyline::addCoordinate(coordinate) + + Adds a coordinate to the end of the path. + \sa insertCoordinate, removeCoordinate, path +*/ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate) { path_.append(coordinate); @@ -568,6 +582,78 @@ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate } /*! + \qmlmethod void MapPolyline::insertCoordinate(index, coordinate) + + Inserts a \a coordinate to the path at the given \a index. + + \since Qt Location 5.6 + + \sa addCoordinate, removeCoordinate, path +*/ +void QDeclarativePolylineMapItem::insertCoordinate(int index, const QGeoCoordinate &coordinate) +{ + if (index < 0 || index > path_.size()) + return; + + path_.insert(index, coordinate); + + geometry_.markSourceDirty(); + polishAndUpdate(); + emit pathChanged(); +} + +/*! + \qmlmethod void MapPolyline::replaceCoordinate(index, coordinate) + + Replaces the coordinate in the current path at the given \a index + with the new \a coordinate. + + \since Qt Location 5.6 + + \sa addCoordinate, insertCoordinate, removeCoordinate, path +*/ +void QDeclarativePolylineMapItem::replaceCoordinate(int index, const QGeoCoordinate &coordinate) +{ + if (index < 0 || index >= path_.size()) + return; + + path_[index] = coordinate; + + geometry_.markSourceDirty(); + polishAndUpdate(); + emit pathChanged(); +} + +/*! + \qmlmethod coordinate MapPolyline::coordinateAt(index) + + Gets the coordinate of the polyline at the given \a index. + If the index is outside the path's bounds then an invalid + coordinate is returned. + + \since Qt Location 5.6 +*/ +QGeoCoordinate QDeclarativePolylineMapItem::coordinateAt(int index) const +{ + if (index < 0 || index >= path_.size()) + return QGeoCoordinate(); + + return path_.at(index); +} + +/*! + \qmlmethod coordinate MapPolyline::containsCoordinate(coordinate) + + Returns true if the given \a coordinate is part of the path. + + \since Qt Location 5.6 +*/ +bool QDeclarativePolylineMapItem::containsCoordinate(const QGeoCoordinate &coordinate) +{ + return path_.indexOf(coordinate) > -1; +} + +/*! \qmlmethod void MapPolyline::removeCoordinate(coordinate) Removes \a coordinate from the path. If there are multiple instances of the @@ -575,7 +661,7 @@ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate If \a coordinate is not in the path this method does nothing. - \sa addCoordinate, path + \sa addCoordinate, insertCoordinate, path */ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordinate) { @@ -591,6 +677,29 @@ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordin } /*! + \qmlmethod void MapPolyline::removeCoordinate(index) + + Removes a coordinate from the path at the given \a index. + + If \a index is invalid then this method does nothing. + + \since Qt Location 5.6 + + \sa addCoordinate, insertCoordinate, path +*/ +void QDeclarativePolylineMapItem::removeCoordinate(int index) +{ + if (index < 0 || index >= path_.size()) + return; + + path_.removeAt(index); + + geometry_.markSourceDirty(); + polishAndUpdate(); + emit pathChanged(); +} + +/*! \qmlpropertygroup Location::MapPolyline::line \qmlproperty int MapPolyline::line.width \qmlproperty color MapPolyline::line.color @@ -736,9 +845,10 @@ 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 < geometry_.vertices().size(); ++i) { - tri << geometry_.vertices()[i]; + for (int i = 0; i < vertices.size(); ++i) { + tri << vertices[i]; if (tri.size() == 3) { if (tri.containsPoint(point,Qt::OddEvenFill)) return true; diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h index a7b7f167..298dc3bc 100644 --- a/src/imports/location/qdeclarativepolylinemapitem_p.h +++ b/src/imports/location/qdeclarativepolylinemapitem_p.h @@ -116,8 +116,14 @@ public: //from QuickItem virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + Q_INVOKABLE int pathLength() const; Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate); + Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate); + Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate); + Q_INVOKABLE QGeoCoordinate coordinateAt(int index) const; + Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate); Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate); + Q_INVOKABLE void removeCoordinate(int index); QJSValue path() const; virtual void setPath(const QJSValue &value); |