summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/labs/labs.pri1
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp37
-rw-r--r--src/location/labs/qdeclarativenavigator_p.h2
-rw-r--r--src/location/labs/qdeclarativenavigator_p_p.h13
-rw-r--r--src/location/maps/qgeoroute.cpp4
-rw-r--r--src/location/maps/qgeorouterequest.cpp5
-rw-r--r--src/src.pro2
7 files changed, 51 insertions, 13 deletions
diff --git a/src/location/labs/labs.pri b/src/location/labs/labs.pri
index 2da5e90d..79a22700 100644
--- a/src/location/labs/labs.pri
+++ b/src/location/labs/labs.pri
@@ -1,3 +1,4 @@
+QT += positioningquick-private
INCLUDEPATH += labs
PRIVATE_HEADERS += $$files($$PWD/*.h) $$files($$PWD/qsg/*.h)
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
index bcb74c90..5fe36bb8 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -37,6 +37,7 @@
#include <QtLocation/private/qdeclarativegeoroute_p.h>
#include <QtLocation/private/qdeclarativegeoroutemodel_p.h>
#include <QtLocation/private/qdeclarativegeoroutesegment_p.h>
+#include <QtPositioningQuick/private/qdeclarativepositionsource_p.h>
#include <QtQml/qqmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -165,6 +166,12 @@ QDeclarativeNavigatorPrivate::QDeclarativeNavigatorPrivate(QParameterizableObjec
{
}
+void QDeclarativeNavigatorPrivate::updateReadyState()
+{
+ qobject_cast<QDeclarativeNavigator *>(q)->updateReadyState();
+}
+
+
QDeclarativeNavigator::QDeclarativeNavigator(QObject *parent)
: QParameterizableObject(parent), d_ptr(new QDeclarativeNavigatorPrivate(this))
@@ -195,10 +202,16 @@ QDeclarativeGeoServiceProvider *QDeclarativeNavigator::plugin() const
void QDeclarativeNavigator::setMap(QDeclarativeGeoMap *map)
{
- if (d_ptr->m_map) // set once prop
+ if (d_ptr->m_map || !map) // set once prop
return;
d_ptr->m_map = map;
+ QDeclarativeNavigatorPrivate *dptr = d_ptr.data();
+ connect(map, &QObject::destroyed,
+ [this, dptr]() {
+ this->mapChanged();
+ dptr->updateReadyState();
+ });
emit mapChanged();
updateReadyState();
}
@@ -219,6 +232,15 @@ void QDeclarativeNavigator::setRoute(QDeclarativeGeoRoute *route)
setActive(false); // Stop current session
d_ptr->m_route = route;
+ d_ptr->m_geoRoute = route ? route->route() : QGeoRoute();
+ if (route) {
+ connect(route, &QObject::destroyed,
+ [this]() {
+ // Do not stop navigation if route disappears. d_ptr->m_geoRoute will still be valid.
+ // Engines can stop navigation if desired.
+ this->routeChanged();
+ });
+ }
emit routeChanged();
updateReadyState();
}
@@ -230,10 +252,17 @@ QDeclarativeGeoRoute *QDeclarativeNavigator::route() const
void QDeclarativeNavigator::setPositionSource(QDeclarativePositionSource *positionSource)
{
- if (d_ptr->m_positionSource) // set once prop
+ if (d_ptr->m_positionSource || !positionSource) // set once prop
return;
d_ptr->m_positionSource = positionSource;
+ QDeclarativeNavigatorPrivate *dptr = d_ptr.data();
+ QObject::connect(positionSource, &QObject::destroyed,
+ [this, dptr]() {
+ this->positionSourceChanged();
+ dptr->updateReadyState();
+ }
+ );
emit positionSourceChanged();
updateReadyState();
}
@@ -258,8 +287,8 @@ bool QDeclarativeNavigator::navigatorReady() const
QDeclarativeGeoRoute *QDeclarativeNavigator::currentRoute() const
{
if (!d_ptr->m_ready || !d_ptr->m_navigationManager->active())
- return d_ptr->m_route;
- return d_ptr->m_currentRoute;
+ return d_ptr->m_route.data();
+ return d_ptr->m_currentRoute.data();
}
int QDeclarativeNavigator::currentSegment() const
diff --git a/src/location/labs/qdeclarativenavigator_p.h b/src/location/labs/qdeclarativenavigator_p.h
index 3c9a4653..0373bf57 100644
--- a/src/location/labs/qdeclarativenavigator_p.h
+++ b/src/location/labs/qdeclarativenavigator_p.h
@@ -136,6 +136,8 @@ private slots:
private:
QScopedPointer<QDeclarativeNavigatorPrivate> d_ptr;
+
+ friend class QDeclarativeNavigatorPrivate;
};
QT_END_NAMESPACE
diff --git a/src/location/labs/qdeclarativenavigator_p_p.h b/src/location/labs/qdeclarativenavigator_p_p.h
index 0485ee69..c4198714 100644
--- a/src/location/labs/qdeclarativenavigator_p_p.h
+++ b/src/location/labs/qdeclarativenavigator_p_p.h
@@ -50,6 +50,8 @@
#include <QtCore/qlist.h>
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtCore/qpointer.h>
+#include <QtLocation/qgeoroute.h>
QT_BEGIN_NAMESPACE
@@ -67,13 +69,16 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigatorPrivate
public:
QDeclarativeNavigatorPrivate(QParameterizableObject *q_);
+ void updateReadyState();
+
QParameterizableObject *q = nullptr;
QNavigationManager *m_navigationManager = nullptr;
QDeclarativeGeoServiceProvider *m_plugin = nullptr;
- QDeclarativeGeoMap *m_map = nullptr;
- QDeclarativeGeoRoute *m_route = nullptr;
- QDeclarativePositionSource *m_positionSource = nullptr;
- QDeclarativeGeoRoute *m_currentRoute = nullptr;
+ QPointer<QDeclarativeGeoMap> m_map;
+ QPointer<QDeclarativeGeoRoute> m_route;
+ QGeoRoute m_geoRoute;
+ QPointer<QDeclarativePositionSource> m_positionSource;
+ QPointer<QDeclarativeGeoRoute> m_currentRoute;
QList<QGeoMapParameter *> m_parameters;
int m_currentSegment = 0;
bool m_active = false;
diff --git a/src/location/maps/qgeoroute.cpp b/src/location/maps/qgeoroute.cpp
index 979c1667..8d62dceb 100644
--- a/src/location/maps/qgeoroute.cpp
+++ b/src/location/maps/qgeoroute.cpp
@@ -340,8 +340,8 @@ bool QGeoRoutePrivate::equals(const QGeoRoutePrivate &other) const
&& (travelTime() == other.travelTime())
&& (distance() == other.distance())
&& (travelMode() == other.travelMode())
- && (path() == other.path()))
- && (metadata() == other.metadata());
+ && (path() == other.path())
+ && (metadata() == other.metadata()));
}
void QGeoRoutePrivate::setId(const QString &id)
diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp
index a252b101..57fbe207 100644
--- a/src/location/maps/qgeorouterequest.cpp
+++ b/src/location/maps/qgeorouterequest.cpp
@@ -263,7 +263,8 @@ QGeoRouteRequest &QGeoRouteRequest::operator= (const QGeoRouteRequest & other)
*/
bool QGeoRouteRequest::operator ==(const QGeoRouteRequest &other) const
{
- return (d_ptr.constData() == other.d_ptr.constData());
+ return ( (d_ptr.constData() == other.d_ptr.constData())
+ || (*d_ptr) == (*other.d_ptr));
}
/*!
@@ -271,7 +272,7 @@ bool QGeoRouteRequest::operator ==(const QGeoRouteRequest &other) const
*/
bool QGeoRouteRequest::operator !=(const QGeoRouteRequest &other) const
{
- return (d_ptr.constData() != other.d_ptr.constData());
+ return !(operator==(other));
}
/*!
diff --git a/src/src.pro b/src/src.pro
index 87ea7983..417e2272 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -17,7 +17,7 @@ positioning.depends = clip2tri
qtHaveModule(quick) {
SUBDIRS += positioningquick location
positioningquick.depends += positioning
- location.depends += positioning clip2tri
+ location.depends += positioningquick clip2tri
plugins.depends += location