diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-10-10 17:00:47 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-11-01 14:09:34 +0000 |
commit | 499f14e91e34ca78c073079f43910811d9408252 (patch) | |
tree | b4dbd45a0c90a51012b38e79d4945e384a4dd594 /src/location/labs/qdeclarativenavigator.cpp | |
parent | a7d1e0bd6d4bf7c1035e32acd95daeef8af9edc8 (diff) | |
download | qtlocation-499f14e91e34ca78c073079f43910811d9408252.tar.gz |
Add Navigator.currentRouteLeg
Change-Id: I9027afac6143784b14879889ffd4180ad8269cc4
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/labs/qdeclarativenavigator.cpp')
-rw-r--r-- | src/location/labs/qdeclarativenavigator.cpp | 23 |
1 files changed, 22 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; |