summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-12-05 08:43:49 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2019-02-01 14:09:46 +0000
commit8e923d801b460ccc6fdc92d4a7bc8750410ad042 (patch)
tree83a8adb0dc109b9784191dad5bab00e12bbb9aa3
parent1ac41150501d3c5cc4a9a6ed9c93729687666553 (diff)
downloadqtlocation-8e923d801b460ccc6fdc92d4a7bc8750410ad042.tar.gz
Provide additional navigation information via Navigator
With this patch, Navigator becomes able to expose additional running navigation information such as distance to next maneuver, traveled distance, and so on. This information must be made available by the engines by emitting the related signals and implement the related methods, in QAbstractNavigator subclasses. This patch also groups all navigation read-only progress information into a property group inside Navigator, called directions. Change-Id: I00baf64bafe88cd21d4fef06dae0e7331a40ff70 Fixes: QTBUG-70238 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
-rw-r--r--src/imports/locationlabs/locationlabs.cpp2
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp293
-rw-r--r--src/location/labs/qdeclarativenavigator_p.h21
-rw-r--r--src/location/labs/qdeclarativenavigator_p_p.h63
-rw-r--r--src/location/maps/qnavigationmanagerengine.cpp60
-rw-r--r--src/location/maps/qnavigationmanagerengine_p.h24
6 files changed, 325 insertions, 138 deletions
diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp
index 21c63622..bb511318 100644
--- a/src/imports/locationlabs/locationlabs.cpp
+++ b/src/imports/locationlabs/locationlabs.cpp
@@ -41,6 +41,7 @@
#include <QtLocation/private/qmappolygonobject_p.h>
#include <QtLocation/private/qmappolylineobject_p.h>
#include <QtLocation/private/qdeclarativenavigator_p.h>
+#include <QtLocation/private/qdeclarativenavigator_p_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
@@ -73,6 +74,7 @@ public:
qmlRegisterType<QMapCircleObject>(uri, major, minor, "MapCircleObject");
qmlRegisterType<QMapPolygonObject>(uri, major, minor, "MapPolygonObject");
qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject");
+ qmlRegisterType<QDeclarativeNavigationBasicDirections>();
qmlRegisterType<QDeclarativeNavigator>(uri, major, minor, "Navigator");
} else {
qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri);
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
index dd3eaabf..2fab9144 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -140,54 +140,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty Route Qt.labs.location::Navigator::currentRoute
-
- 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
- off route, the navigation engine might recalculate and start following a
- new route.
-
- \sa Route
-*/
-
-/*!
- \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.
-
- \sa RouteSegment
-*/
-
-/*!
- \qmlsignal Qt.labs.location::Navigator::waypointReached(Waypoint waypoint)
-
- This signal is emitted when the waypoint \e waypoint has been reached.
-
- \sa Waypoint
-*/
-
-/*!
- \qmlsignal Qt.labs.location::Navigator::destinationReached()
-
- This signal is emitted when the last waypoint of the route, the destination,
- has been reached.
-*/
-
-/*!
\qmlproperty enumeration Qt.labs.location::Navigator::error
This read-only property holds the latest error value of the geocoding request.
@@ -205,37 +157,10 @@ QT_BEGIN_NAMESPACE
*/
QDeclarativeNavigatorPrivate::QDeclarativeNavigatorPrivate(QParameterizableObject *q_)
- : q(q_), m_params(new QDeclarativeNavigatorParams)
+ : q(q_), m_params(new QDeclarativeNavigatorParams), m_basicDirections(static_cast<QDeclarativeNavigator *>(q_))
{
}
-void QDeclarativeNavigatorPrivate::clearCachedData()
-{
- const bool routeChanged = !m_currentRoute.isNull();
- const bool routeLegChanged = !m_currentRouteLeg.isNull();
- const bool segmentChanged = m_currentSegment != 0;
-
- if (m_currentRoute)
- m_currentRoute->deleteLater();
- m_currentRoute = nullptr;
-
- if (m_currentRouteLeg)
- m_currentRouteLeg->deleteLater();
- m_currentRouteLeg = nullptr;
-
- m_currentSegment = 0;
-
- QDeclarativeNavigator *qq = qobject_cast<QDeclarativeNavigator *>(q);
- if (routeChanged)
- qq->currentRouteChanged();
- if (routeLegChanged)
- qq->currentRouteLegChanged();
- if (segmentChanged)
- qq->currentSegmentChanged();
-}
-
-
-
QDeclarativeNavigator::QDeclarativeNavigator(QObject *parent)
: QParameterizableObject(parent), d_ptr(new QDeclarativeNavigatorPrivate(this))
{
@@ -357,25 +282,9 @@ void QDeclarativeNavigator::setTrackPositionSource(bool trackPositionSource)
emit trackPositionSourceChanged(trackPositionSource);
}
-QDeclarativeGeoRoute *QDeclarativeNavigator::currentRoute() const
+QDeclarativeNavigationBasicDirections *QDeclarativeNavigator::directions() const
{
- if (!d_ptr->m_ready || !d_ptr->m_navigator->active())
- return d_ptr->m_params->m_route.data();
- return d_ptr->m_currentRoute.data();
-}
-
-QDeclarativeGeoRouteLeg *QDeclarativeNavigator::currentRouteLeg() const
-{
- if (!d_ptr->m_ready || !d_ptr->m_navigator->active())
- return nullptr;
- return d_ptr->m_currentRouteLeg.data();
-}
-
-int QDeclarativeNavigator::currentSegment() const
-{
- if (!d_ptr->m_ready || !d_ptr->m_navigator->active())
- return 0;
- return d_ptr->m_currentSegment;
+ return &d_ptr->m_basicDirections;
}
QDeclarativeNavigator::NavigationError QDeclarativeNavigator::error() const
@@ -445,8 +354,9 @@ void QDeclarativeNavigator::stop()
if (d_ptr->m_navigator->active())
d_ptr->m_active = d_ptr->m_navigator->stop();
- // clear cached data
- d_ptr->clearCachedData();
+ // Cached data are cleared in response to signals emitted by m_navigator upon stop().
+ // For example, m_navigator emits currentRouteChanged with an empty route,
+ // and QDeclarativeNavigationBasicDirections reacts by clearing the declarative route.
}
void QDeclarativeNavigator::pluginReady()
@@ -505,16 +415,29 @@ bool QDeclarativeNavigator::ensureEngine()
d_ptr->m_navigator->setLocale(manager->locale());
d_ptr->m_navigator->setMeasurementSystem(manager->measurementSystem());
- 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;
emit activeChanged(active);
});
connect(this, &QDeclarativeNavigator::trackPositionSourceChanged, d_ptr->m_navigator.get(), &QAbstractNavigator::setTrackPosition);
+
+ // read-only progress info updates
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::waypointReached,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::waypointReached);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::destinationReached,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::destinationReached);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentRouteChanged,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::onCurrentRouteChanged);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentRouteLegChanged,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::onCurrentRouteLegChanged);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::currentSegmentChanged,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::currentSegmentChanged);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::nextManeuverIconChanged,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::nextManeuverIconChanged);
+ connect(d_ptr->m_navigator.get(), &QAbstractNavigator::progressInformationChanged,
+ &d_ptr->m_basicDirections, &QDeclarativeNavigationBasicDirections::progressInformationChanged);
+
emit navigatorReadyChanged(true);
return true;
}
@@ -537,26 +460,168 @@ void QDeclarativeNavigator::setError(QDeclarativeNavigator::NavigationError erro
emit errorChanged();
}
-void QDeclarativeNavigator::onCurrentRouteChanged(const QGeoRoute &route)
+QDeclarativeNavigationBasicDirections::QDeclarativeNavigationBasicDirections(QDeclarativeNavigator *parent)
+: QObject(parent), m_navigator(parent)
{
- if (d_ptr->m_currentRoute)
- d_ptr->m_currentRoute->deleteLater();
- d_ptr->m_currentRoute = new QDeclarativeGeoRoute(route, this);
- emit currentRouteChanged();
+ if (m_navigator)
+ m_navigatorPrivate = m_navigator->d_ptr.data();
+}
+
+/*!
+ \qmlpropertygroup Qt.labs.location::Navigator::directions
+ \qmlproperty Variant Qt.labs.location::Navigator::directions.nextManeuverIcon
+ \qmlproperty real Qt.labs.location::Navigator::directions.distanceToNextManeuver
+ \qmlproperty real Qt.labs.location::Navigator::directions.remainingTravelDistance
+ \qmlproperty real Qt.labs.location::Navigator::directions.remainingTravelDistanceToNextWaypoint
+ \qmlproperty real Qt.labs.location::Navigator::directions.traveledDistance
+ \qmlproperty int Qt.labs.location::Navigator::directions.timeToNextManeuver
+ \qmlproperty int Qt.labs.location::Navigator::directions.remainingTravelTime
+ \qmlproperty int Qt.labs.location::Navigator::directions.remainingTravelTimeToNextWaypoint
+ \qmlproperty int Qt.labs.location::Navigator::directions.traveledTime
+ \qmlproperty Route Qt.labs.location::Navigator::directions.currentRoute
+ \qmlproperty RouteLeg Qt.labs.location::Navigator::directions.currentRouteLeg
+ \qmlproperty int Qt.labs.location::Navigator::directions.currentSegment
+
+ \qmlsignal Qt.labs.location::Navigator::directions.waypointReached(Waypoint waypoint)
+ \qmlsignal Qt.labs.location::Navigator::directions.destinationReached()
+
+ These read-only properties are part of the directions property group.
+ The directions property group holds the navigation progress information
+ that can be used to access the route data and to extract directions.
+
+ \note specific backends might not provide (some of) these information.
+
+ \list
+ \li The \l nextManeuverIcon property holds the next turn icon.
+ \li The \l distanceToNextManeuver property holds the distance to the next maneuver, in meters.
+ \li The \l remainingTravelDistance property holds the remaining travel distance, in meters.
+ \li The \l remainingTravelDistanceToNextWaypoint property holds the remaining travel distance to the next waypoint, in meters.
+ \li The \l traveledDistance property holds the traveled distance, in meters.
+ \li The \l timeToNextManeuver property holds the time to the next maneuver, in milliseconds.
+ \li The \l remainingTravelTime property holds the remaining travel time, in milliseconds.
+ \li The \l remainingTravelTimeToNextWaypoint property holds the remaining travel time to the next waypoint, in milliseconds.
+ \li The \l traveledTime property holds the traveled time, in milliseconds.
+ \li The \l currentRoute property olds 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
+ off route, the navigation engine might recalculate and start following a
+ new route.
+ \li The \l currentRouteSegment 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.
+ \li The \l currentSegment property holds the index of the current RouteSegment in the \l currentRoute.
+ \li The \l waypointReached signal is emitted when the waypoint \e waypoint has been reached.
+ \li The \l destinationReached signal is emitted when the last waypoint of the route, the destination,
+ has been reached.
+ \endlist
+
+ \sa Route, RouteLeg, RouteSegment, Waypoint
+*/
+
+QVariant QDeclarativeNavigationBasicDirections::nextManeuverIcon() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->nextManeuverIcon();
+ return QVariant();
}
-void QDeclarativeNavigator::onCurrentRouteLegChanged(const QGeoRouteLeg &routeLeg)
+qreal QDeclarativeNavigationBasicDirections::distanceToNextManeuver() const
{
- if (d_ptr->m_currentRoute)
- d_ptr->m_currentRouteLeg->deleteLater();
- d_ptr->m_currentRouteLeg = new QDeclarativeGeoRouteLeg(routeLeg, this);
- emit currentRouteLegChanged();
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->distanceToNextManeuver();
+ return qQNaN();
+}
+
+qreal QDeclarativeNavigationBasicDirections::remainingTravelDistance() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->remainingTravelDistance();
+ return qQNaN();
+}
+
+qreal QDeclarativeNavigationBasicDirections::remainingTravelDistanceToNextWaypoint() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->remainingTravelDistanceToNextWaypoint();
+ return qQNaN();
+}
+
+qreal QDeclarativeNavigationBasicDirections::traveledDistance() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->traveledDistance();
+ return 0;
+}
+
+int QDeclarativeNavigationBasicDirections::timeToNextManeuver() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->timeToNextManeuver();
+ return -1;
+}
+
+int QDeclarativeNavigationBasicDirections::remainingTravelTime() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->remainingTravelTime();
+ return -1;
+}
+
+int QDeclarativeNavigationBasicDirections::remainingTravelTimeToNextWaypoint() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->remainingTravelTimeToNextWaypoint();
+ return -1;
+}
+
+int QDeclarativeNavigationBasicDirections::traveledTime() const
+{
+ if (m_navigatorPrivate->m_navigator)
+ return m_navigatorPrivate->m_navigator->traveledTime();
+ return 0;
+}
+
+QDeclarativeGeoRoute *QDeclarativeNavigationBasicDirections::currentRoute() const
+{
+ if (!m_navigatorPrivate->m_ready
+ || !m_navigatorPrivate->m_navigator
+ || !m_navigatorPrivate->m_navigator->active())
+ return m_navigatorPrivate->m_params->m_route.data(); // the user-specified route, if any
+ return m_currentRoute;
+}
+
+QDeclarativeGeoRouteLeg *QDeclarativeNavigationBasicDirections::currentRouteLeg() const
+{
+ if (!m_navigatorPrivate->m_ready
+ || !m_navigatorPrivate->m_navigator
+ || !m_navigatorPrivate->m_navigator->active())
+ return nullptr;
+ return m_currentRouteLeg;
+}
+
+int QDeclarativeNavigationBasicDirections::currentSegment() const
+{
+ if (!m_navigatorPrivate->m_ready
+ || !m_navigatorPrivate->m_navigator
+ || !m_navigatorPrivate->m_navigator->active())
+ return 0;
+ return m_navigatorPrivate->m_navigator->currentSegment();
}
-void QDeclarativeNavigator::onCurrentSegmentChanged(int segment)
+void QDeclarativeNavigationBasicDirections::onCurrentRouteChanged()
{
- d_ptr->m_currentSegment = segment;
- emit currentSegmentChanged();
+ if (m_currentRoute)
+ m_currentRoute->deleteLater();
+ m_currentRoute = new QDeclarativeGeoRoute(m_navigatorPrivate->m_navigator->currentRoute(), this);
+ emit currentRouteChanged();
+}
+
+void QDeclarativeNavigationBasicDirections::onCurrentRouteLegChanged()
+{
+ if (m_currentRouteLeg)
+ m_currentRouteLeg->deleteLater();
+ m_currentRouteLeg = new QDeclarativeGeoRouteLeg(m_navigatorPrivate->m_navigator->currentRouteLeg(), this);
+ emit currentRouteLegChanged();
}
QT_END_NAMESPACE
+
diff --git a/src/location/labs/qdeclarativenavigator_p.h b/src/location/labs/qdeclarativenavigator_p.h
index b9949431..17f8e687 100644
--- a/src/location/labs/qdeclarativenavigator_p.h
+++ b/src/location/labs/qdeclarativenavigator_p.h
@@ -68,6 +68,7 @@ class QGeoRouteLeg;
class QGeoRouteSegment;
class QDeclarativeNavigatorPrivate;
class QDeclarativeGeoRouteSegment;
+class QDeclarativeNavigationBasicDirections;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigator : public QParameterizableObject, public QQmlParserStatus
{
@@ -79,11 +80,10 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigator : public QParameterizableO
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool navigatorReady READ navigatorReady NOTIFY navigatorReadyChanged)
Q_PROPERTY(bool trackPositionSource READ trackPositionSource WRITE setTrackPositionSource NOTIFY trackPositionSourceChanged)
- Q_PROPERTY(QDeclarativeGeoRoute *currentRoute READ currentRoute NOTIFY currentRouteChanged)
- Q_PROPERTY(QDeclarativeGeoRouteLeg *currentRouteLeg READ currentRouteLeg NOTIFY currentRouteChanged)
- Q_PROPERTY(int currentSegment READ currentSegment NOTIFY currentSegmentChanged)
+ Q_PROPERTY(QDeclarativeNavigationBasicDirections *directions READ directions CONSTANT)
Q_PROPERTY(NavigationError error READ error NOTIFY errorChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+
Q_INTERFACES(QQmlParserStatus)
public:
@@ -132,9 +132,7 @@ public:
void setTrackPositionSource(bool trackPositionSource);
bool trackPositionSource() const;
- QDeclarativeGeoRoute *currentRoute() const;
- QDeclarativeGeoRouteLeg *currentRouteLeg() const;
- int currentSegment() const;
+ QDeclarativeNavigationBasicDirections *directions() const;
NavigationError error() const;
QString errorString() const;
@@ -143,16 +141,11 @@ signals:
void navigatorReadyChanged(bool ready);
void trackPositionSourceChanged(bool trackPositionSource);
void activeChanged(bool active);
- void waypointReached(const QDeclarativeGeoWaypoint *pos);
- void destinationReached();
void pluginChanged();
void mapChanged();
void routeChanged();
void positionSourceChanged();
- void currentRouteChanged();
- void currentRouteLegChanged();
- void currentSegmentChanged();
void errorChanged();
protected:
@@ -161,15 +154,11 @@ protected:
void updateReadyState();
void setError(NavigationError error, const QString &errorString);
-protected slots:
- void onCurrentRouteChanged(const QGeoRoute &route);
- void onCurrentRouteLegChanged(const QGeoRouteLeg &routeLeg);
- void onCurrentSegmentChanged(int segment);
-
private:
QScopedPointer<QDeclarativeNavigatorPrivate> d_ptr;
friend class QDeclarativeNavigatorPrivate;
+ friend class QDeclarativeNavigationBasicDirections;
};
QT_END_NAMESPACE
diff --git a/src/location/labs/qdeclarativenavigator_p_p.h b/src/location/labs/qdeclarativenavigator_p_p.h
index 74bc3a19..77fe2ff2 100644
--- a/src/location/labs/qdeclarativenavigator_p_p.h
+++ b/src/location/labs/qdeclarativenavigator_p_p.h
@@ -67,6 +67,62 @@ class QDeclarativeGeoRouteSegment;
class QParameterizableObject;
class QAbstractNavigator;
+class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigationBasicDirections : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVariant nextManeuverIcon READ nextManeuverIcon NOTIFY nextManeuverIconChanged)
+ Q_PROPERTY(qreal distanceToNextManeuver READ distanceToNextManeuver NOTIFY progressInformationChanged)
+ Q_PROPERTY(qreal remainingTravelDistance READ remainingTravelDistance NOTIFY progressInformationChanged)
+ Q_PROPERTY(qreal remainingTravelDistanceToNextWaypoint READ remainingTravelDistanceToNextWaypoint NOTIFY progressInformationChanged)
+ Q_PROPERTY(qreal traveledDistance READ traveledDistance NOTIFY progressInformationChanged)
+ Q_PROPERTY(int timeToNextManeuver READ timeToNextManeuver NOTIFY progressInformationChanged)
+ Q_PROPERTY(int remainingTravelTime READ remainingTravelTime NOTIFY progressInformationChanged)
+ Q_PROPERTY(int remainingTravelTimeToNextWaypoint READ remainingTravelTimeToNextWaypoint NOTIFY progressInformationChanged)
+ Q_PROPERTY(int traveledTime READ traveledTime NOTIFY progressInformationChanged)
+ Q_PROPERTY(QDeclarativeGeoRoute *currentRoute READ currentRoute NOTIFY currentRouteChanged)
+ Q_PROPERTY(QDeclarativeGeoRouteLeg *currentRouteLeg READ currentRouteLeg NOTIFY currentRouteChanged)
+ Q_PROPERTY(int currentSegment READ currentSegment NOTIFY currentSegmentChanged)
+
+public:
+ explicit QDeclarativeNavigationBasicDirections(QDeclarativeNavigator *parent);
+
+ QVariant nextManeuverIcon() const;
+ qreal distanceToNextManeuver() const;
+ qreal remainingTravelDistance() const;
+ qreal remainingTravelDistanceToNextWaypoint() const;
+ qreal traveledDistance() const;
+ int timeToNextManeuver() const;
+ int remainingTravelTime() const;
+ int remainingTravelTimeToNextWaypoint() const;
+ int traveledTime() const;
+
+ QDeclarativeGeoRoute *currentRoute() const;
+ QDeclarativeGeoRouteLeg *currentRouteLeg() const;
+ int currentSegment() const;
+
+Q_SIGNALS:
+ void progressInformationChanged();
+ void nextManeuverIconChanged();
+ void currentRouteChanged();
+ void currentRouteLegChanged();
+ void currentSegmentChanged();
+ void waypointReached(const QDeclarativeGeoWaypoint *pos);
+ void destinationReached();
+
+protected slots:
+ void onCurrentRouteChanged();
+ void onCurrentRouteLegChanged();
+
+protected:
+ QDeclarativeNavigator *m_navigator;
+ QDeclarativeNavigatorPrivate *m_navigatorPrivate;
+ QPointer<QDeclarativeGeoRoute> m_currentRoute;
+ QPointer<QDeclarativeGeoRouteLeg> m_currentRouteLeg;
+
+ friend class QDeclarativeNavigator;
+};
+
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigatorParams
{
public:
@@ -83,15 +139,12 @@ class QDeclarativeNavigatorPrivate
public:
QDeclarativeNavigatorPrivate(QParameterizableObject *q_);
- void clearCachedData();
-
QParameterizableObject *q = nullptr;
QSharedPointer<QDeclarativeNavigatorParams> m_params;
QScopedPointer<QAbstractNavigator> m_navigator;
QDeclarativeGeoServiceProvider *m_plugin = nullptr;
- QPointer<QDeclarativeGeoRoute> m_currentRoute;
- QPointer<QDeclarativeGeoRouteLeg> m_currentRouteLeg;
- int m_currentSegment = 0;
+ QDeclarativeNavigationBasicDirections m_basicDirections;
+
bool m_active = false;
bool m_completed = false;
bool m_ready = false;
diff --git a/src/location/maps/qnavigationmanagerengine.cpp b/src/location/maps/qnavigationmanagerengine.cpp
index d0f8418e..8837e5c6 100644
--- a/src/location/maps/qnavigationmanagerengine.cpp
+++ b/src/location/maps/qnavigationmanagerengine.cpp
@@ -86,6 +86,66 @@ QLocale::MeasurementSystem QAbstractNavigator::measurementSystem() const
return d->measurementSystem;
}
+QVariant QAbstractNavigator::nextManeuverIcon() const
+{
+ return QVariant();
+}
+
+double QAbstractNavigator::distanceToNextManeuver() const
+{
+ return qQNaN();
+}
+
+int QAbstractNavigator::timeToNextManeuver() const
+{
+ return -1;
+}
+
+int QAbstractNavigator::remainingTravelTime() const
+{
+ return -1;
+}
+
+double QAbstractNavigator::remainingTravelDistance() const
+{
+ return qQNaN();
+}
+
+int QAbstractNavigator::remainingTravelTimeToNextWaypoint() const
+{
+ return -1;
+}
+
+double QAbstractNavigator::remainingTravelDistanceToNextWaypoint() const
+{
+ return qQNaN();
+}
+
+double QAbstractNavigator::traveledDistance() const
+{
+ return 0;
+}
+
+int QAbstractNavigator::traveledTime() const
+{
+ return 0;
+}
+
+QGeoRoute QAbstractNavigator::currentRoute() const
+{
+ return QGeoRoute();
+}
+
+QGeoRouteLeg QAbstractNavigator::currentRouteLeg() const
+{
+ return QGeoRouteLeg();
+}
+
+int QAbstractNavigator::currentSegment() const
+{
+ return 0;
+}
+
QNavigationManagerEngine::QNavigationManagerEngine(const QVariantMap &parameters, QObject *parent)
: QObject(parent)
, d(new QNavigationManagerEnginePrivate)
diff --git a/src/location/maps/qnavigationmanagerengine_p.h b/src/location/maps/qnavigationmanagerengine_p.h
index e7b3876c..331df64f 100644
--- a/src/location/maps/qnavigationmanagerengine_p.h
+++ b/src/location/maps/qnavigationmanagerengine_p.h
@@ -65,6 +65,8 @@ class QNavigationManager;
class QNavigationManagerEnginePrivate;
class QDeclarativeNavigatorParams;
class QDeclarativeGeoWaypoint;
+class QDeclarativeGeoRouteLeg;
+class QDeclarativeGeoRoute;
/*
This class is not supposed to react on QDeclarativeNavigator properties changes.
@@ -85,6 +87,19 @@ public:
virtual bool active() const = 0;
virtual bool ready() const = 0;
+ virtual QVariant nextManeuverIcon() const;
+ virtual double distanceToNextManeuver() const;
+ virtual int timeToNextManeuver() const;
+ virtual int remainingTravelTime() const;
+ virtual double remainingTravelDistance() const;
+ virtual int remainingTravelTimeToNextWaypoint() const;
+ virtual double remainingTravelDistanceToNextWaypoint() const;
+ virtual double traveledDistance() const;
+ virtual int traveledTime() const;
+ virtual QGeoRoute currentRoute() const;
+ virtual QGeoRouteLeg currentRouteLeg() const;
+ virtual int currentSegment() const;
+
public slots:
virtual bool start() = 0;
virtual bool stop() = 0;
@@ -95,9 +110,12 @@ signals:
void activeChanged(bool active);
void waypointReached(const QDeclarativeGeoWaypoint *pos);
void destinationReached();
- void currentRouteChanged(const QGeoRoute &route);
- void currentRouteLegChanged(const QGeoRouteLeg &route);
- void currentSegmentChanged(int segment);
+ void currentRouteChanged();
+ void currentRouteLegChanged();
+ void currentSegmentChanged();
+
+ void nextManeuverIconChanged();
+ void progressInformationChanged();
private:
QScopedPointer<QAbstractNavigatorPrivate> d;