summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-01-19 18:52:14 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-04-17 11:16:59 +0000
commit6909660b73b40681211493a039e72a701d5b4462 (patch)
tree85d3d59e8e2123f3b26c0dbe5cd23785ae7539ef
parent6c6a9e787c2e1443fc4318482504e672a6ca386e (diff)
downloadqtlocation-6909660b73b40681211493a039e72a701d5b4462.tar.gz
Introduce Navigator QML type
A new QML type, Navigator, is introduced in Qt.labs.location Its intended purpose is to be a front-end for the functionalities offered by NavigationManagerEngines. Change-Id: Ic93bed0bfaaf32453e759b12a348fa6ef1ae2c93 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/imports/locationlabs/locationlabs.cpp8
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp286
-rw-r--r--src/location/labs/qdeclarativenavigator_p.h146
-rw-r--r--src/location/labs/qdeclarativenavigator_p_p.h82
-rw-r--r--src/location/maps/qnavigationmanager.cpp42
-rw-r--r--src/location/maps/qnavigationmanager_p.h27
-rw-r--r--src/location/maps/qnavigationmanagerengine.cpp8
-rw-r--r--src/location/maps/qnavigationmanagerengine_p.h14
8 files changed, 597 insertions, 16 deletions
diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp
index 83deb27e..56924b80 100644
--- a/src/imports/locationlabs/locationlabs.cpp
+++ b/src/imports/locationlabs/locationlabs.cpp
@@ -40,6 +40,7 @@
#include <QtLocation/private/qmapcircleobject_p.h>
#include <QtLocation/private/qmappolygonobject_p.h>
#include <QtLocation/private/qmappolylineobject_p.h>
+#include <QtLocation/private/qdeclarativenavigator_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
@@ -69,16 +70,17 @@ public:
if (QLatin1String(uri) == QLatin1String("Qt.labs.location")) {
// @uri QtLocationLabs
- int major = 5;
- int minor = 11;
+ int major = 1;
+ int minor = 0;
- // Register the 5.11 types
+ // Register the 1.0 labs types
qmlRegisterType<QMapIconObject>(uri, major, minor, "MapIconObject");
qmlRegisterType<QMapObjectView>(uri, major, minor, "MapObjectView");
qmlRegisterType<QMapRouteObject>(uri, major, minor, "MapRouteObject");
qmlRegisterType<QMapCircleObject>(uri, major, minor, "MapCircleObject");
qmlRegisterType<QMapPolygonObject>(uri, major, minor, "MapPolygonObject");
qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject");
+ qmlRegisterType<QDeclarativeNavigator>(uri, major, minor, "Navigator");
// Register the latest Qt version as QML type version
qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR);
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
new file mode 100644
index 00000000..d0131006
--- /dev/null
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativenavigator_p.h"
+#include "qdeclarativenavigator_p_p.h"
+#include <QtLocation/private/qdeclarativegeomap_p.h>
+#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
+#include <QtLocation/private/qnavigationmanager_p.h>
+#include <QtLocation/private/qnavigationmanagerengine_p.h>
+#include <QtLocation/private/qgeomapparameter_p.h>
+#include <QtLocation/private/qdeclarativegeoroute_p.h>
+#include <QtLocation/private/qdeclarativegeoroutemodel_p.h>
+#include <QtLocation/private/qdeclarativegeoroutesegment_p.h>
+#include <QtQml/qqmlinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Navigator
+ \instantiates QDeclarativeNavigator
+ \inqmlmodule Qt.labs.location
+ \ingroup qml-QtLocation5-maps
+
+ \brief The Navigator type takes control of a \l Map to perform turn-by-turn navigation.
+
+ Its purpose is to include a plugin's turn-by-turn navigation implementation in a QML mapping application
+ in a seamless manner.
+ This may include controlling the map position, orientation, tilting and zoom, as well as changing
+ the map style, elements on the map such as direction information, as well as restricting interaction
+ with the Map and the items on it.
+*/
+
+
+QDeclarativeNavigator::QDeclarativeNavigator(QObject *parent)
+ : QParameterizableObject(parent), d_ptr(new QDeclarativeNavigatorPrivate)
+{
+}
+
+QDeclarativeNavigator::~QDeclarativeNavigator()
+{
+}
+
+void QDeclarativeNavigator::classBegin()
+{
+}
+
+void QDeclarativeNavigator::componentComplete()
+{
+ d_ptr->m_completed = true;
+ // Children have been completed
+ d_ptr->m_parameters = quickChildren<QGeoMapParameter>();
+ if (d_ptr->m_plugin && d_ptr->m_plugin->isAttached())
+ pluginReady();
+}
+
+QDeclarativeGeoServiceProvider *QDeclarativeNavigator::plugin() const
+{
+ return d_ptr->m_plugin;
+}
+
+void QDeclarativeNavigator::setMap(QDeclarativeGeoMap *map)
+{
+ if (d_ptr->m_map) // set once prop
+ return;
+
+ d_ptr->m_map = map;
+ emit mapChanged();
+ updateReadyState();
+}
+
+QDeclarativeGeoMap *QDeclarativeNavigator::map() const
+{
+ return d_ptr->m_map;
+}
+
+void QDeclarativeNavigator::setRoute(QDeclarativeGeoRoute *route)
+{
+ if (d_ptr->m_route == route) // This isn't set-once
+ return;
+
+ const bool isReady = d_ptr->m_navigationManager && d_ptr->m_navigationManager->ready();
+ const bool isActive = active();
+ if (isReady && isActive)
+ setActive(false); // Stop current session
+
+ d_ptr->m_route = route;
+ emit routeChanged();
+ updateReadyState();
+}
+
+QDeclarativeGeoRoute *QDeclarativeNavigator::route() const
+{
+ return d_ptr->m_route;
+}
+
+void QDeclarativeNavigator::setPositionSource(QDeclarativePositionSource *positionSource)
+{
+ if (d_ptr->m_positionSource) // set once prop
+ return;
+
+ d_ptr->m_positionSource = positionSource;
+ emit positionSourceChanged();
+ updateReadyState();
+}
+
+QDeclarativePositionSource *QDeclarativeNavigator::positionSource() const
+{
+ return d_ptr->m_positionSource;
+}
+
+QNavigationManager *QDeclarativeNavigator::navigationManager() const
+{
+ return d_ptr->m_navigationManager;
+}
+
+bool QDeclarativeNavigator::navigatorReady() const
+{
+ if (d_ptr->m_navigationManager)
+ return d_ptr->m_navigationManager->ready();
+ return d_ptr->m_ready;
+}
+
+QDeclarativeGeoRoute *QDeclarativeNavigator::currentRoute() const
+{
+ if (!d_ptr->m_ready || !d_ptr->m_navigationManager->active())
+ return d_ptr->m_route;
+ return d_ptr->m_currentRoute;
+}
+
+int QDeclarativeNavigator::currentSegment() const
+{
+ if (!d_ptr->m_ready || !d_ptr->m_navigationManager->active())
+ return 0;
+ return d_ptr->m_currentSegment;
+}
+
+bool QDeclarativeNavigator::active() const
+{
+ return d_ptr->m_active;
+}
+
+void QDeclarativeNavigator::setPlugin(QDeclarativeGeoServiceProvider *plugin)
+{
+ if (d_ptr->m_plugin)
+ return; // set once property.
+
+ d_ptr->m_plugin = plugin;
+ emit pluginChanged();
+
+ if (d_ptr->m_plugin->isAttached()) {
+ pluginReady();
+ } else {
+ connect(d_ptr->m_plugin, &QDeclarativeGeoServiceProvider::attached,
+ this, &QDeclarativeNavigator::pluginReady);
+ }
+}
+
+void QDeclarativeNavigator::setActive(bool active)
+{
+ if (d_ptr->m_active == active)
+ return;
+
+ d_ptr->m_active = active;
+ if (!d_ptr->m_plugin)
+ return;
+
+ if (active)
+ start();
+ else
+ stop();
+}
+
+void QDeclarativeNavigator::start()
+{
+ if (!d_ptr->m_ready) {
+ qmlWarning(this) << QStringLiteral("Navigation manager not ready.");
+ return;
+ }
+
+ if (d_ptr->m_active)
+ return;
+
+ d_ptr->m_active = d_ptr->m_navigationManager->start();
+}
+
+void QDeclarativeNavigator::stop()
+{
+ if (!ensureEngine()) { // If somebody re-set route to null or something, this may become !d_ptr->m_ready
+ qmlWarning(this) << QStringLiteral("Navigation manager not ready.");
+ return;
+ }
+
+ if (!d_ptr->m_active)
+ return;
+
+ d_ptr->m_active = d_ptr->m_navigationManager->stop();
+}
+
+void QDeclarativeNavigator::pluginReady()
+{
+ if (!d_ptr->m_completed)
+ return;
+
+ ensureEngine();
+ updateReadyState();
+ if (d_ptr->m_active)
+ start();
+}
+
+bool QDeclarativeNavigator::ensureEngine()
+{
+ if (d_ptr->m_navigationManager)
+ return true;
+ if (!d_ptr->m_completed || !d_ptr->m_plugin->isAttached())
+ return false;
+
+ d_ptr->m_navigationManager = d_ptr->m_plugin->sharedGeoServiceProvider()->navigationManager();
+ if (d_ptr->m_navigationManager) {
+ d_ptr->m_navigationManager->setNavigator(d_ptr.data());
+ d_ptr->m_navigationManager->setParameters(d_ptr->m_parameters);
+ connect(d_ptr->m_navigationManager, &QNavigationManager::waypointReached, this, &QDeclarativeNavigator::waypointReached);
+ connect(d_ptr->m_navigationManager, &QNavigationManager::destinationReached, this, &QDeclarativeNavigator::destinationReached);
+ connect(d_ptr->m_navigationManager, &QNavigationManager::currentRouteChanged, this, &QDeclarativeNavigator::onCurrentRouteChanged);
+ connect(d_ptr->m_navigationManager, &QNavigationManager::currentSegmentChanged, this, &QDeclarativeNavigator::onCurrentSegmentChanged);
+ connect(d_ptr->m_navigationManager, &QNavigationManager::activeChanged, this, [this](bool active){
+ d_ptr->m_active = active;
+ emit activeChanged(active);
+ });
+ emit navigatorReadyChanged(true);
+ return true;
+ }
+ return false;
+}
+
+void QDeclarativeNavigator::updateReadyState() {
+ const bool oldReady = d_ptr->m_ready;
+ if (!d_ptr->m_navigationManager)
+ d_ptr->m_ready = false;
+ else
+ d_ptr->m_ready = d_ptr->m_navigationManager->ready();
+
+ if (oldReady != d_ptr->m_ready)
+ emit navigatorReadyChanged(d_ptr->m_ready);
+}
+
+void QDeclarativeNavigator::onCurrentRouteChanged(const QGeoRoute &route)
+{
+ if (d_ptr->m_currentRoute)
+ d_ptr->m_currentRoute->deleteLater();
+ d_ptr->m_currentRoute = new QDeclarativeGeoRoute(route, this);
+ emit currentRouteChanged();
+}
+
+void QDeclarativeNavigator::onCurrentSegmentChanged(int segment)
+{
+ d_ptr->m_currentSegment = segment;
+ emit currentSegmentChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qdeclarativenavigator_p.h b/src/location/labs/qdeclarativenavigator_p.h
new file mode 100644
index 00000000..3c9a4653
--- /dev/null
+++ b/src/location/labs/qdeclarativenavigator_p.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVENAVIGATOR_P_H
+#define QDECLARATIVENAVIGATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtQml/qqml.h>
+#include <QSharedPointer>
+#include <QtLocation/private/qparameterizableobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGeoServiceProvider;
+class QDeclarativeGeoMap;
+class QNavigationManager;
+class QDeclarativeGeoRoute;
+class QDeclarativePositionSource;
+class QDeclarativeGeoWaypoint;
+class QGeoRoute;
+class QGeoRouteSegment;
+class QDeclarativeNavigatorPrivate;
+class QDeclarativeGeoRouteSegment;
+
+class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigator : public QParameterizableObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
+ Q_PROPERTY(QDeclarativeGeoMap *map READ map WRITE setMap NOTIFY mapChanged)
+ Q_PROPERTY(QDeclarativeGeoRoute *route READ route WRITE setRoute NOTIFY routeChanged)
+ Q_PROPERTY(QDeclarativePositionSource *positionSource READ positionSource WRITE setPositionSource NOTIFY positionSourceChanged)
+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(bool navigatorReady READ navigatorReady NOTIFY navigatorReadyChanged)
+ Q_PROPERTY(QDeclarativeGeoRoute *currentRoute READ currentRoute NOTIFY currentRouteChanged)
+ Q_PROPERTY(int currentSegment READ currentSegment NOTIFY currentSegmentChanged)
+ Q_INTERFACES(QQmlParserStatus)
+
+public:
+ explicit QDeclarativeNavigator(QObject *parent = nullptr);
+ ~QDeclarativeNavigator();
+
+ // QQmlParserStatus interface
+ void classBegin() override;
+ void componentComplete() override;
+
+ // QDeclarativeNavigator
+ void start();
+ void stop();
+
+ void setActive(bool active);
+ bool active() const;
+
+ void setPlugin(QDeclarativeGeoServiceProvider * plugin);
+ QDeclarativeGeoServiceProvider *plugin() const;
+
+ void setMap(QDeclarativeGeoMap *map);
+ QDeclarativeGeoMap * map() const;
+
+ void setRoute(QDeclarativeGeoRoute *route);
+ QDeclarativeGeoRoute *route() const;
+
+ void setPositionSource(QDeclarativePositionSource *positionSource);
+ QDeclarativePositionSource *positionSource() const;
+
+ QNavigationManager *navigationManager() const;
+ bool navigatorReady() const;
+
+ QDeclarativeGeoRoute *currentRoute() const;
+ int currentSegment() const;
+
+signals:
+ void navigatorReadyChanged(bool ready);
+ void activeChanged(bool active);
+ void waypointReached(const QDeclarativeGeoWaypoint *pos);
+ void destinationReached();
+
+ void pluginChanged();
+ void mapChanged();
+ void routeChanged();
+ void positionSourceChanged();
+ void currentRouteChanged();
+ void currentSegmentChanged();
+
+private:
+ void pluginReady();
+ bool ensureEngine();
+ void updateReadyState();
+
+private slots:
+ void onCurrentRouteChanged(const QGeoRoute &route);
+ void onCurrentSegmentChanged(int segment);
+
+private:
+ QScopedPointer<QDeclarativeNavigatorPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeNavigator)
+
+
+#endif // QDECLARATIVENAVIGATOR_P_H
diff --git a/src/location/labs/qdeclarativenavigator_p_p.h b/src/location/labs/qdeclarativenavigator_p_p.h
new file mode 100644
index 00000000..291fa3a4
--- /dev/null
+++ b/src/location/labs/qdeclarativenavigator_p_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVENAVIGATOR_P_P_H
+#define QDECLARATIVENAVIGATOR_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qlist.h>
+#include <QtLocation/private/qlocationglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGeoServiceProvider;
+class QDeclarativeGeoMap;
+class QNavigationManager;
+class QDeclarativeGeoRoute;
+class QDeclarativePositionSource;
+class QGeoMapParameter;
+class QDeclarativeGeoRouteSegment;
+
+class Q_LOCATION_PRIVATE_EXPORT QDeclarativeNavigatorPrivate
+{
+public:
+ QNavigationManager *m_navigationManager = nullptr;
+ QDeclarativeGeoServiceProvider *m_plugin = nullptr;
+ QDeclarativeGeoMap *m_map = nullptr;
+ QDeclarativeGeoRoute *m_route = nullptr;
+ QDeclarativePositionSource *m_positionSource = nullptr;
+ QDeclarativeGeoRoute *m_currentRoute = nullptr;
+ QList<QGeoMapParameter *> m_parameters;
+ int m_currentSegment = 0;
+ bool m_active = false;
+ bool m_completed = false;
+ bool m_ready = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVENAVIGATOR_P_P_H
diff --git a/src/location/maps/qnavigationmanager.cpp b/src/location/maps/qnavigationmanager.cpp
index 1e83b2c9..5372e3a5 100644
--- a/src/location/maps/qnavigationmanager.cpp
+++ b/src/location/maps/qnavigationmanager.cpp
@@ -46,6 +46,8 @@ public:
~QNavigationManagerPrivate();
QNavigationManagerEngine *engine = nullptr;
+ QDeclarativeNavigatorPrivate *navigator = nullptr;
+ QList<QGeoMapParameter *> parameters;
private:
Q_DISABLE_COPY(QNavigationManagerPrivate)
@@ -87,6 +89,16 @@ bool QNavigationManager::isInitialized() const
return d_ptr->engine->isInitialized();
}
+void QNavigationManager::setNavigator(QDeclarativeNavigatorPrivate *navigator)
+{
+ d_ptr->navigator = navigator;
+}
+
+QDeclarativeNavigatorPrivate *QNavigationManager::declarativeNavigator() const
+{
+ return d_ptr->navigator;
+}
+
void QNavigationManager::setLocale(const QLocale &locale)
{
d_ptr->engine->setLocale(locale);
@@ -97,6 +109,36 @@ QLocale QNavigationManager::locale() const
return d_ptr->engine->locale();
}
+void QNavigationManager::setParameters(const QList<QGeoMapParameter *> &parameters)
+{
+ d_ptr->parameters = parameters;
+}
+
+QList<QGeoMapParameter *> QNavigationManager::parameters() const
+{
+ return d_ptr->parameters;
+}
+
+bool QNavigationManager::ready() const
+{
+ return d_ptr->engine->ready(*d_ptr->navigator, d_ptr->parameters);
+}
+
+bool QNavigationManager::start()
+{
+ return d_ptr->engine->start(*d_ptr->navigator, d_ptr->parameters);
+}
+
+bool QNavigationManager::stop()
+{
+ return d_ptr->engine->stop(*d_ptr->navigator);
+}
+
+bool QNavigationManager::active() const
+{
+ return d_ptr->engine->active(*d_ptr->navigator);
+}
+
QNavigationManager::QNavigationManager(QNavigationManagerEngine *engine, QObject *parent) : QObject(parent),
d_ptr(new QNavigationManagerPrivate)
{
diff --git a/src/location/maps/qnavigationmanager_p.h b/src/location/maps/qnavigationmanager_p.h
index e461bcf1..1d8c1722 100644
--- a/src/location/maps/qnavigationmanager_p.h
+++ b/src/location/maps/qnavigationmanager_p.h
@@ -52,11 +52,17 @@
#include <QSize>
#include <QPair>
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeomapparameter_p.h>
QT_BEGIN_NAMESPACE
class QNavigationManagerEngine;
class QNavigationManagerPrivate;
+class QDeclarativeNavigatorPrivate;
+class QDeclarativeGeoWaypoint;
+class QGeoRoute;
+class QGeoRouteSegment;
+
class Q_LOCATION_PRIVATE_EXPORT QNavigationManager : public QObject
{
Q_OBJECT
@@ -66,16 +72,33 @@ public:
QString managerName() const;
int managerVersion() const;
-
QNavigationManagerEngine *engine();
-
bool isInitialized() const;
+
+ void setNavigator(QDeclarativeNavigatorPrivate *navigator);
+ QDeclarativeNavigatorPrivate *declarativeNavigator() const;
+
void setLocale(const QLocale &locale);
QLocale locale() const;
+ void setParameters(const QList<QGeoMapParameter *> &parameters);
+ QList<QGeoMapParameter *> parameters() const;
+
+ bool ready() const;
+ bool start();
+ bool stop();
+ bool active() const;
+
Q_SIGNALS:
void initialized();
+ // These must be emitted by the engine
+ void activeChanged(bool active);
+ void waypointReached(const QDeclarativeGeoWaypoint *pos);
+ void destinationReached();
+ void currentRouteChanged(const QGeoRoute &route);
+ void currentSegmentChanged(int segment);
+
protected:
QNavigationManager(QNavigationManagerEngine *engine, QObject *parent = 0);
diff --git a/src/location/maps/qnavigationmanagerengine.cpp b/src/location/maps/qnavigationmanagerengine.cpp
index 265237ee..b9191e74 100644
--- a/src/location/maps/qnavigationmanagerengine.cpp
+++ b/src/location/maps/qnavigationmanagerengine.cpp
@@ -105,14 +105,14 @@ bool QNavigationManagerEngine::isInitialized() const
return d_ptr->initialized;
}
-bool QNavigationManagerEngine::start(const QList<QGeoMapParameter*> &navigationParams, const QMapRouteObject &route)
+// Subclasses are supposed to emit activeChanged from here.
+bool QNavigationManagerEngine::start(QDeclarativeNavigatorPrivate & /*navigator*/, const QList<QGeoMapParameter*> & /*navigationParams*/)
{
- Q_UNUSED(navigationParams);
- Q_UNUSED(route);
+
return false;
}
-bool QNavigationManagerEngine::stop()
+bool QNavigationManagerEngine::stop(QDeclarativeNavigatorPrivate & /*navigator*/) // navigator needed to find the right navi session to stop.
{
return false;
}
diff --git a/src/location/maps/qnavigationmanagerengine_p.h b/src/location/maps/qnavigationmanagerengine_p.h
index 0aa5509e..803050c5 100644
--- a/src/location/maps/qnavigationmanagerengine_p.h
+++ b/src/location/maps/qnavigationmanagerengine_p.h
@@ -59,6 +59,7 @@ class QGeoMap;
class QGeoMapParameter;
class QMapRouteObject;
class QNavigationManagerEnginePrivate;
+class QDeclarativeNavigatorPrivate;
class Q_LOCATION_PRIVATE_EXPORT QNavigationManagerEngine : public QObject
{
@@ -76,17 +77,16 @@ public:
virtual QLocale locale() const;
virtual void setMeasurementSystem(QLocale::MeasurementSystem system);
virtual QLocale::MeasurementSystem measurementSystem() const;
- bool isInitialized() const;
+ virtual bool isInitialized() const;
+ virtual bool ready(const QDeclarativeNavigatorPrivate &navigator, const QList<QGeoMapParameter*> &navigationParams) = 0;
+ virtual bool active(const QDeclarativeNavigatorPrivate &navigator) = 0;
signals:
- void activeChanged(bool active);
- void waypointReached(const QGeoCoordinate &pos);
- void destinationReached();
void initialized();
public slots:
- virtual bool start(const QList<QGeoMapParameter*> &navigationParams, const QMapRouteObject &route);
- virtual bool stop();
+ virtual bool start(QDeclarativeNavigatorPrivate &navigator, const QList<QGeoMapParameter*> &navigationParams);
+ virtual bool stop(QDeclarativeNavigatorPrivate &navigator);
protected:
/*!
@@ -94,7 +94,7 @@ protected:
call this method after performing implementation-specific initialization within
the constructor.
*/
- void engineInitialized();
+ virtual void engineInitialized();
QScopedPointer<QNavigationManagerEnginePrivate> d_ptr;
};