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 "marble_export.h"
10#include "RoutingProfile.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
39 /** Constructor */
40 explicit RoutingManager( MarbleModel *marbleModel, QObject *parent = nullptr );
41
42 /** Destructor */
43 ~RoutingManager() override;
44
45 /**
46 * Provides access to the model which contains all possible routing profiles
47 */
48 RoutingProfilesModel *profilesModel();
49
50 /**
51 * Provides access to the routing model which contains a list
52 * of routing instructions describing steps to get from the
53 * source to the destination.
54 * @see retrieveDirections
55 */
56 RoutingModel *routingModel();
57
58 const RoutingModel *routingModel() const;
59
60 /**
61 * Provides access to the model which contains a list of
62 * alternative routes
63 */
64 AlternativeRoutesModel* alternativeRoutesModel();
65
66 /**
67 * Returns the current route request
68 */
69 RouteRequest* routeRequest();
70
71 /**
72 * @brief Returns whether a route is being downloaded
73 * @return
74 */
75 State state() const;
76
77 /**
78 * Saves the current route request and the current route to disk
79 */
80 void writeSettings() const;
81
82 /**
83 * Restores a previously saved route request and route from disk, if any
84 */
85 void readSettings();
86
87 /**
88 * Saves the current route to the file with the given filename. Existing files
89 * will be overwritten. The route is saved in kml format.
90 */
91 void saveRoute( const QString &filename ) const;
92
93 /**
94 * Opens the given filename (kml format) and loads the route contained in it
95 */
96 void loadRoute( const QString &filename );
97
98 /**
99 * Generates a routing profile with default settings for the given transport type
100 */
101 RoutingProfile defaultProfile( RoutingProfile::TransportType transportType ) const;
102
103 /**
104 * Set whether a warning message should be shown to the user before
105 * starting guidance mode.
106 */
107 void setShowGuidanceModeStartupWarning( bool show );
108
109 /**
110 * Returns true (default) if a warning is shown to the user when starting guidance
111 * mode.
112 */
113 bool showGuidanceModeStartupWarning() const;
114
115 /**
116 * Set last directory the user opened a route from.
117 */
118 void setLastOpenPath( const QString &path );
119
120 /**
121 * Return last directory the user opened a route from.
122 */
123 QString lastOpenPath() const;
124
125 /**
126 * Set last directory the user saved a route to.
127 */
128 void setLastSavePath( const QString &path );
129
130 /**
131 * Return last directory the user saved a route to.
132 */
133 QString lastSavePath() const;
134
135 /**
136 * Set color for standard route rendering
137 */
138 void setRouteColorStandard( const QColor& color );
139
140 /**
141 * Get color for standard route rendering
142 */
143 QColor routeColorStandard() const;
144
145 /**
146 * Set color for highlighted route rendering
147 */
148 void setRouteColorHighlighted( const QColor& color );
149
150 /**
151 * Get color for highlighted route rendering
152 */
153 QColor routeColorHighlighted() const;
154
155 /**
156 * Set color for alternative route rendering
157 */
158 void setRouteColorAlternative( const QColor& color );
159
160 /**
161 * Get color for alternative route rendering
162 */
163 QColor routeColorAlternative() const;
164
165 bool guidanceModeEnabled() const;
166
167public Q_SLOTS:
168 /** Reverse the previously requested route, i.e. swap start and destination (and via points, if any) */
169 void reverseRoute();
170
171 /** Retrieve a route suiting the routeRequest */
172 void retrieveRoute();
173
174 /** Clear all via points */
175 void clearRoute();
176
177 /** Toggle turn by turn navigation mode */
178 void setGuidanceModeEnabled( bool enabled );
179
180Q_SIGNALS:
181 /**
182 * Directions and waypoints for the given route are being downloaded or have
183 * been retrieved -- newState tells which of both
184 */
185 void stateChanged( RoutingManager::State newState );
186
187 void routeRetrieved( GeoDataDocument* route );
188
189 void guidanceModeEnabledChanged( bool enabled );
190
191private:
192 Q_PRIVATE_SLOT( d, void addRoute( GeoDataDocument* route ) )
193
194 Q_PRIVATE_SLOT( d, void routingFinished() )
195
196 Q_PRIVATE_SLOT(d, void setCurrentRoute(const GeoDataDocument *route))
197
198 Q_PRIVATE_SLOT( d, void recalculateRoute( bool deviated ) )
199
200private:
201 friend class RoutingManagerPrivate;
202 RoutingManagerPrivate *const d;
203};
204
205} // namespace Marble
206
207#endif
A container for Features, Styles and in the future Schemas.
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition MarbleModel.h:87
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 Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.