summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2019-01-29 18:56:06 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2019-02-01 14:09:50 +0000
commit265f2b75b86337287880290593b3c411ad5fa7a1 (patch)
tree40d5152fa2899cc0478d034a7dc3628c34ba9d84
parent587b8812c9b2fc7ed7ad4ab35d27114ee98eafc6 (diff)
downloadqtlocation-265f2b75b86337287880290593b3c411ad5fa7a1.tar.gz
Expose QAbstractNavigator
This change exposes the QAbstractNavigator instantiated by QDeclarativeNavigator. By doing so, it is possible to expose to the user engine-specific features and data via properties, signals and methods added to the QAbstractNavigator subclass. However, while this approach greatly simplifies the exposure of such features, it also leads to writing non-cross-plugin code. Change-Id: I03be9b6d0868d940dc0ac80520f3b507bec2953a Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
-rw-r--r--src/imports/locationlabs/locationlabs.cpp2
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp15
-rw-r--r--src/location/labs/qdeclarativenavigator_p.h3
3 files changed, 20 insertions, 0 deletions
diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp
index bb511318..c90993eb 100644
--- a/src/imports/locationlabs/locationlabs.cpp
+++ b/src/imports/locationlabs/locationlabs.cpp
@@ -42,6 +42,7 @@
#include <QtLocation/private/qmappolylineobject_p.h>
#include <QtLocation/private/qdeclarativenavigator_p.h>
#include <QtLocation/private/qdeclarativenavigator_p_p.h>
+#include <QtLocation/private/qnavigationmanagerengine_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
@@ -76,6 +77,7 @@ public:
qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject");
qmlRegisterType<QDeclarativeNavigationBasicDirections>();
qmlRegisterType<QDeclarativeNavigator>(uri, major, minor, "Navigator");
+ qmlRegisterType<QAbstractNavigator>();
} 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 2fab9144..5dfdfdbe 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -297,6 +297,21 @@ QString QDeclarativeNavigator::errorString() const
return d_ptr->m_errorString;
}
+/* !NOT DOCUMENTED YET!
+ \qmlproperty QAbstractNavigator *Qt.labs.location::Navigator::engineHandle
+
+ This property returns a handle to the navigation object created by the engine.
+ This object can carry engine-specific properties, signals and methods, to expose
+ engine-specific features and data.
+
+ \note Using this property leads to writing code that won't work with different plugins.
+*/
+QAbstractNavigator *QDeclarativeNavigator::abstractNavigator() const
+{
+ return d_ptr->m_navigator.data();
+
+}
+
bool QDeclarativeNavigator::active() const
{
return d_ptr->m_active;
diff --git a/src/location/labs/qdeclarativenavigator_p.h b/src/location/labs/qdeclarativenavigator_p.h
index 17f8e687..e12d6ba4 100644
--- a/src/location/labs/qdeclarativenavigator_p.h
+++ b/src/location/labs/qdeclarativenavigator_p.h
@@ -69,6 +69,7 @@ class QGeoRouteSegment;
class QDeclarativeNavigatorPrivate;
class QDeclarativeGeoRouteSegment;
class QDeclarativeNavigationBasicDirections;
+class QAbstractNavigator;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigator : public QParameterizableObject, public QQmlParserStatus
{
@@ -83,6 +84,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigator : public QParameterizableO
Q_PROPERTY(QDeclarativeNavigationBasicDirections *directions READ directions CONSTANT)
Q_PROPERTY(NavigationError error READ error NOTIFY errorChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_PROPERTY(QAbstractNavigator *engineHandle READ abstractNavigator CONSTANT)
Q_INTERFACES(QQmlParserStatus)
@@ -133,6 +135,7 @@ public:
bool trackPositionSource() const;
QDeclarativeNavigationBasicDirections *directions() const;
+ QAbstractNavigator *abstractNavigator() const;
NavigationError error() const;
QString errorString() const;