summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp23
-rw-r--r--src/location/labs/qdeclarativenavigator_p.h3
-rw-r--r--src/location/labs/qdeclarativenavigator_p_p.h2
-rw-r--r--src/location/maps/qnavigationmanagerengine_p.h2
4 files changed, 29 insertions, 1 deletions
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
index b06681d9..770f0dd3 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -141,7 +141,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlproperty Route Qt.labs.location::Navigator::currentRoute
- This read-only property holds the current route the navigator following.
+ This read-only property holds the current route the navigator is following.
This can be the same as \l route, or can be different, if the navigator
cannot follow the user-specified route.
For example if the position coming from \l positionSource is considerably
@@ -152,6 +152,18 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \qmlproperty RouteLeg Qt.labs.location::Navigator::currentRouteLeg
+
+ This read-only property holds the current route leg the navigator is following.
+ This is always a part of \l currentRoute, and so the property \l RouteLeg::overallRoute
+ of currentRouteLeg will hold the same route as \l currentRoute.
+
+ \sa RouteLeg
+
+ \since 5.13
+*/
+
+/*!
\qmlproperty int Qt.labs.location::Navigator::currentSegment
This read-only property holds the index of the current RouteSegment in the \l currentRoute.
@@ -409,6 +421,7 @@ bool QDeclarativeNavigator::ensureEngine()
connect(d_ptr->m_navigator.get(), &QAbstractNavigator::waypointReached, this, &QDeclarativeNavigator::waypointReached);
connect(d_ptr->m_navigator.get(), &QAbstractNavigator::destinationReached, this, &QDeclarativeNavigator::destinationReached);
connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentRouteChanged, this, &QDeclarativeNavigator::onCurrentRouteChanged);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentRouteLegChanged, this, &QDeclarativeNavigator::onCurrentRouteLegChanged);
connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentSegmentChanged, this, &QDeclarativeNavigator::onCurrentSegmentChanged);
connect(d_ptr->m_navigator.get(), &QAbstractNavigator::activeChanged, this, [this](bool active){
d_ptr->m_active = active;
@@ -439,6 +452,14 @@ void QDeclarativeNavigator::onCurrentRouteChanged(const QGeoRoute &route)
emit currentRouteChanged();
}
+void QDeclarativeNavigator::onCurrentRouteLegChanged(const QGeoRouteLeg &routeLeg)
+{
+ if (d_ptr->m_currentRoute)
+ d_ptr->m_currentRouteLeg->deleteLater();
+ d_ptr->m_currentRouteLeg = new QDeclarativeGeoRouteLeg(routeLeg, this);
+ emit currentRouteLegChanged();
+}
+
void QDeclarativeNavigator::onCurrentSegmentChanged(int segment)
{
d_ptr->m_currentSegment = segment;
diff --git a/src/location/labs/qdeclarativenavigator_p.h b/src/location/labs/qdeclarativenavigator_p.h
index 13884c41..1401333b 100644
--- a/src/location/labs/qdeclarativenavigator_p.h
+++ b/src/location/labs/qdeclarativenavigator_p.h
@@ -62,6 +62,7 @@ class QDeclarativeGeoRoute;
class QDeclarativePositionSource;
class QDeclarativeGeoWaypoint;
class QGeoRoute;
+class QGeoRouteLeg;
class QGeoRouteSegment;
class QDeclarativeNavigatorPrivate;
class QDeclarativeGeoRouteSegment;
@@ -127,6 +128,7 @@ signals:
void routeChanged();
void positionSourceChanged();
void currentRouteChanged();
+ void currentRouteLegChanged();
void currentSegmentChanged();
private:
@@ -136,6 +138,7 @@ private:
private slots:
void onCurrentRouteChanged(const QGeoRoute &route);
+ void onCurrentRouteLegChanged(const QGeoRouteLeg &routeLeg);
void onCurrentSegmentChanged(int segment);
private:
diff --git a/src/location/labs/qdeclarativenavigator_p_p.h b/src/location/labs/qdeclarativenavigator_p_p.h
index 6c07a0ca..2ac6806b 100644
--- a/src/location/labs/qdeclarativenavigator_p_p.h
+++ b/src/location/labs/qdeclarativenavigator_p_p.h
@@ -59,6 +59,7 @@ class QDeclarativeGeoServiceProvider;
class QDeclarativeGeoMap;
class QNavigationManager;
class QDeclarativeGeoRoute;
+class QDeclarativeGeoRouteLeg;
class QDeclarativePositionSource;
class QGeoMapParameter;
class QDeclarativeGeoRouteSegment;
@@ -86,6 +87,7 @@ public:
QScopedPointer<QAbstractNavigator> m_navigator;
QDeclarativeGeoServiceProvider *m_plugin = nullptr;
QPointer<QDeclarativeGeoRoute> m_currentRoute;
+ QPointer<QDeclarativeGeoRouteLeg> m_currentRouteLeg;
int m_currentSegment = 0;
bool m_active = false;
bool m_completed = false;
diff --git a/src/location/maps/qnavigationmanagerengine_p.h b/src/location/maps/qnavigationmanagerengine_p.h
index 62d9eb87..d43e4842 100644
--- a/src/location/maps/qnavigationmanagerengine_p.h
+++ b/src/location/maps/qnavigationmanagerengine_p.h
@@ -60,6 +60,7 @@ class QGeoMap;
class QGeoMapParameter;
class QMapRouteObject;
class QGeoRoute;
+class QGeoRouteLeg;
class QNavigationManager;
class QNavigationManagerEnginePrivate;
class QDeclarativeNavigatorParams;
@@ -88,6 +89,7 @@ signals:
void waypointReached(const QDeclarativeGeoWaypoint *pos);
void destinationReached();
void currentRouteChanged(const QGeoRoute &route);
+ void currentRouteLegChanged(const QGeoRouteLeg &route);
void currentSegmentChanged(int segment);
private: