Marble

RoutingManager.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#ifndef MARBLE_ROUTINGMANAGER_H
7#define MARBLE_ROUTINGMANAGER_H
8
9#include "RoutingProfile.h"
10#include "marble_export.h"
11
12namespace Marble
13{
14
15class RoutingManagerPrivate;
16class RoutingModel;
17class RouteRequest;
18class MarbleModel;
19class GeoDataDocument;
20class AlternativeRoutesModel;
21class RoutingProfilesModel;
22
23/**
24 * Delegates data retrieval and model updates to the appropriate
25 * routing provider.
26 */
27class MARBLE_EXPORT RoutingManager : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY(State state READ state NOTIFY stateChanged)
31 Q_PROPERTY(bool guidanceModeEnabled READ guidanceModeEnabled WRITE setGuidanceModeEnabled NOTIFY guidanceModeEnabledChanged)
32
33public:
34 enum State {
35 Downloading, // A new route is downloaded in the background
36 Retrieved // No download in progress
37 };
38 Q_ENUM(State);
39
40 /** Constructor */
41 explicit RoutingManager(MarbleModel *marbleModel, QObject *parent = nullptr);
42
43 /** Destructor */
44 ~RoutingManager() override;
45
46 /**
47 * Provides access to the model which contains all possible routing profiles
48 */
49 RoutingProfilesModel *profilesModel();
50
51 /**
52 * Provides access to the routing model which contains a list
53 * of routing instructions describing steps to get from the
54 * source to the destination.
55 * @see retrieveDirections
56 */
57 RoutingModel *routingModel();
58
59 const RoutingModel *routingModel() const;
60
61 /**
62 * Provides access to the model which contains a list of
63 * alternative routes
64 */
65 AlternativeRoutesModel *alternativeRoutesModel();
66
67 /**
68 * Returns the current route request
69 */
70 RouteRequest *routeRequest();
71
72 /**
73 * @brief Returns whether a route is being downloaded
74 * @return
75 */
76 State state() const;
77
78 /**
79 * Saves the current route request and the current route to disk
80 */
81 void writeSettings() const;
82
83 /**
84 * Restores a previously saved route request and route from disk, if any
85 */
86 void readSettings();
87
88 /**
89 * Saves the current route to the file with the given filename. Existing files
90 * will be overwritten. The route is saved in kml format.
91 */
92 void saveRoute(const QString &filename) const;
93
94 /**
95 * Opens the given filename (kml format) and loads the route contained in it
96 */
97 void loadRoute(const QString &filename);
98
99 /**
100 * Generates a routing profile with default settings for the given transport type
101 */
102 RoutingProfile defaultProfile(RoutingProfile::TransportType transportType) const;
103
104 /**
105 * Set whether a warning message should be shown to the user before
106 * starting guidance mode.
107 */
108 void setShowGuidanceModeStartupWarning(bool show);
109
110 /**
111 * Returns true (default) if a warning is shown to the user when starting guidance
112 * mode.
113 */
114 bool showGuidanceModeStartupWarning() const;
115
116 /**
117 * Set last directory the user opened a route from.
118 */
119 void setLastOpenPath(const QString &path);
120
121 /**
122 * Return last directory the user opened a route from.
123 */
124 QString lastOpenPath() const;
125
126 /**
127 * Set last directory the user saved a route to.
128 */
129 void setLastSavePath(const QString &path);
130
131 /**
132 * Return last directory the user saved a route to.
133 */
134 QString lastSavePath() const;
135
136 /**
137 * Set color for standard route rendering
138 */
139 void setRouteColorStandard(const QColor &color);
140
141 /**
142 * Get color for standard route rendering
143 */
144 QColor routeColorStandard() const;
145
146 /**
147 * Set color for highlighted route rendering
148 */
149 void setRouteColorHighlighted(const QColor &color);
150
151 /**
152 * Get color for highlighted route rendering
153 */
154 QColor routeColorHighlighted() const;
155
156 /**
157 * Set color for alternative route rendering
158 */
159 void setRouteColorAlternative(const QColor &color);
160
161 /**
162 * Get color for alternative route rendering
163 */
164 QColor routeColorAlternative() const;
165
166 bool guidanceModeEnabled() const;
167
168public Q_SLOTS:
169 /** Reverse the previously requested route, i.e. swap start and destination (and via points, if any) */
170 void reverseRoute();
171
172 /** Retrieve a route suiting the routeRequest */
173 void retrieveRoute();
174
175 /** Clear all via points */
176 void clearRoute();
177
178 /** Toggle turn by turn navigation mode */
179 void setGuidanceModeEnabled(bool enabled);
180
181Q_SIGNALS:
182 /**
183 * Directions and waypoints for the given route are being downloaded or have
184 * been retrieved -- newState tells which of both
185 */
186 void stateChanged(RoutingManager::State newState);
187
188 void routeRetrieved(GeoDataDocument *route);
189
190 void guidanceModeEnabledChanged(bool enabled);
191
192private:
193 Q_PRIVATE_SLOT(d, void addRoute(GeoDataDocument *route))
194
195 Q_PRIVATE_SLOT(d, void routingFinished())
196
197 Q_PRIVATE_SLOT(d, void setCurrentRoute(const GeoDataDocument *route))
198
199 Q_PRIVATE_SLOT(d, void recalculateRoute(bool deviated))
200
201private:
202 friend class RoutingManagerPrivate;
203 RoutingManagerPrivate *const d;
204};
205
206} // namespace Marble
207
208#endif
A container for Features, Styles and in the future Schemas.
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition MarbleModel.h:84
Points to be included in a route.
Delegates data retrieval and model updates to the appropriate routing provider.
void stateChanged(RoutingManager::State newState)
Directions and waypoints for the given route are being downloaded or have been retrieved – newState t...
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.