diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-03-08 16:17:33 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-03-19 10:19:53 +0000 |
commit | 295db9e4a4c3a99199c030b0da8c7506cc39de28 (patch) | |
tree | b818ec6e9246b7e61b1e74853646fcdab4c2801d | |
parent | d3fbfd5ee7f88b9daace41b3932eb83943e9ed2a (diff) | |
download | qtlocation-295db9e4a4c3a99199c030b0da8c7506cc39de28.tar.gz |
API Fix: expose the RouteQuery used to produce a Route
Currently, Route is intended to be a one-way interface
to push data into a route request.
With the upcoming navigation support, there is need for this to become
also a way to report to the user the updated request info,
for example when, Navigator.currentRoute changes.
This patch introduces a RouteQuery read-only qml property so it would
be possible to access the related query data in a route, and use it in
the UI.
Change-Id: Ibea8cb724313606feae614c61736ee14105d1045
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeoroute.cpp | 15 | ||||
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeoroute_p.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoroute.cpp b/src/location/declarativemaps/qdeclarativegeoroute.cpp index aab59dc2..816d0f39 100644 --- a/src/location/declarativemaps/qdeclarativegeoroute.cpp +++ b/src/location/declarativemaps/qdeclarativegeoroute.cpp @@ -38,6 +38,7 @@ #include "locationvaluetypehelper_p.h" #include <QtLocation/private/qgeomap_p.h> #include <QtLocation/private/qgeoroute_p.h> +#include <QtLocation/private/qdeclarativegeoroutemodel_p.h> #include <QtQml/QQmlEngine> #include <QtQml/qqmlinfo.h> @@ -306,4 +307,18 @@ const QGeoRoute &QDeclarativeGeoRoute::route() const return route_; } +/*! + \qmlproperty RouteQuery routeQuery + + Returns the route query associated with this route. + + \since 5.11 +*/ +QDeclarativeGeoRouteQuery *QDeclarativeGeoRoute::routeQuery() +{ + if (!routeQuery_) + routeQuery_ = new QDeclarativeGeoRouteQuery(route_.request(), this); + return routeQuery_; +} + QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qdeclarativegeoroute_p.h b/src/location/declarativemaps/qdeclarativegeoroute_p.h index 2be3d3f1..5fe29862 100644 --- a/src/location/declarativemaps/qdeclarativegeoroute_p.h +++ b/src/location/declarativemaps/qdeclarativegeoroute_p.h @@ -56,6 +56,7 @@ #include <QtLocation/QGeoRoute> QT_BEGIN_NAMESPACE +class QDeclarativeGeoRouteQuery; class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRoute : public QObject { @@ -66,6 +67,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRoute : public QObject Q_PROPERTY(qreal distance READ distance CONSTANT) Q_PROPERTY(QJSValue path READ path WRITE setPath NOTIFY pathChanged) Q_PROPERTY(QQmlListProperty<QDeclarativeGeoRouteSegment> segments READ segments CONSTANT) + Q_PROPERTY(QDeclarativeGeoRouteQuery *routeQuery READ routeQuery) public: explicit QDeclarativeGeoRoute(QObject *parent = 0); @@ -86,6 +88,7 @@ public: int segmentsCount() const; const QGeoRoute &route() const; + QDeclarativeGeoRouteQuery *routeQuery(); Q_SIGNALS: void pathChanged(); @@ -100,6 +103,7 @@ private: QList<QGeoCoordinate> routePath(); QGeoRoute route_; + QDeclarativeGeoRouteQuery *routeQuery_ = nullptr; QList<QDeclarativeGeoRouteSegment *> segments_; bool segmentsDirty_; friend class QDeclarativeRouteMapItem; |