1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36 
37 #ifndef QNAVIGATIONMANAGERENGINE_H
38 #define QNAVIGATIONMANAGERENGINE_H
39 
40 //
41 //  W A R N I N G
42 //  -------------
43 //
44 // This file is not part of the Qt API.  It exists purely as an
45 // implementation detail.  This header file may change from version to
46 // version without notice, or even be removed.
47 //
48 // We mean it.
49 //
50 
51 #include <QtLocation/private/qlocationglobal_p.h>
52 #include <QObject>
53 #include <QLocale>
54 #include <QGeoCoordinate>
55 
56 QT_BEGIN_NAMESPACE
57 
58 class QAbstractNavigatorPrivate;
59 class QGeoMap;
60 class QGeoMapParameter;
61 class QMapRouteObject;
62 class QGeoRoute;
63 class QGeoRouteLeg;
64 class QNavigationManager;
65 class QNavigationManagerEnginePrivate;
66 class QDeclarativeNavigatorParams;
67 class QDeclarativeGeoWaypoint;
68 class QDeclarativeGeoRouteLeg;
69 class QDeclarativeGeoRoute;
70 
71 /*
72     This class is not supposed to react on QDeclarativeNavigator properties changes.
73     This class is meant to react only on start, stop and setTrackPosition.
74     Upon start(), it is supposed to fetch all info from the QDeclarativeNavigatorParams that the engine is supposed
75     to inject.
76 */
77 class Q_LOCATION_PRIVATE_EXPORT QAbstractNavigator: public QObject
78 {
79     Q_OBJECT
80 public:
81     QAbstractNavigator(QObject *parent = nullptr);
82     ~QAbstractNavigator() override;
83     virtual void setLocale(const QLocale &locale);
84     virtual QLocale locale() const;
85     virtual void setMeasurementSystem(QLocale::MeasurementSystem system);
86     virtual QLocale::MeasurementSystem measurementSystem() const;
87     virtual bool active() const = 0;
88     virtual bool ready() const = 0;
89 
90     virtual QVariant nextManeuverIcon() const;
91     virtual double distanceToNextManeuver() const;
92     virtual int timeToNextManeuver() const;
93     virtual int remainingTravelTime() const;
94     virtual double remainingTravelDistance() const;
95     virtual int remainingTravelTimeToNextWaypoint() const;
96     virtual double remainingTravelDistanceToNextWaypoint() const;
97     virtual double traveledDistance() const;
98     virtual int traveledTime() const;
99     virtual QGeoRoute currentRoute() const;
100     virtual QGeoRouteLeg currentRouteLeg() const;
101     virtual QList<QGeoRoute> alternativeRoutes() const = 0;
102     virtual int currentSegment() const;
103     virtual void setAutomaticReroutingEnabled(bool autoRerouting) = 0;
104     virtual bool automaticReroutingEnabled() const = 0; // configured via navigation params at construction time
105     virtual bool isOnRoute() = 0;
106     virtual void recalculateRoutes() = 0;
107 
108 public slots:
109     virtual bool start() = 0;
110     virtual bool stop() = 0;
111     virtual void setTrackPosition(bool trackPosition) = 0;
112 
113 signals:
114     // These must be emitted by the engine
115     void activeChanged(bool active);
116     void waypointReached(const QDeclarativeGeoWaypoint *pos);
117     void destinationReached();
118     void currentRouteChanged();
119     void currentRouteLegChanged();
120     void currentSegmentChanged();
121 
122     void nextManeuverIconChanged();
123     void progressInformationChanged();
124     void isOnRouteChanged();
125     void alternativeRoutesChanged();
126 
127 private:
128     QScopedPointer<QAbstractNavigatorPrivate> d;
129 };
130 
131 class Q_LOCATION_PRIVATE_EXPORT QNavigationManagerEngine : public QObject
132 {
133     Q_OBJECT
134 public:
135     explicit QNavigationManagerEngine(const QVariantMap &parameters, QObject *parent = nullptr);
136     ~QNavigationManagerEngine() override;
137 
138     void setManagerName(const QString &name);
139     QString managerName() const;
140     void setManagerVersion(int version);
141     int managerVersion() const;
142     virtual void setLocale(const QLocale &locale);
143     virtual QLocale locale() const;
144     virtual void setMeasurementSystem(QLocale::MeasurementSystem system);
145     virtual QLocale::MeasurementSystem measurementSystem() const;
146 
147     virtual bool isInitialized() const;
148     virtual QAbstractNavigator *createNavigator(const QSharedPointer<QDeclarativeNavigatorParams> &navigator) = 0;
149 
150 signals:
151     void initialized();
152 
153 protected:
154     /*!
155         Marks the engine as initialized. Subclasses of QGeoMappingManagerEngine are to
156         call this method after performing implementation-specific initialization within
157         the constructor.
158     */
159     virtual void engineInitialized();
160 
161     QScopedPointer<QNavigationManagerEnginePrivate> d;
162 };
163 
164 QT_END_NAMESPACE
165 
166 #endif // QNAVIGATIONMANAGERENGINE_H
167