Marble

RouteSyncManager.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Utku Aydın <utkuaydin34@gmail.com>
4//
5
6#ifndef ROUTESYNCMANAGER_H
7#define ROUTESYNCMANAGER_H
8
9#include "marble_export.h"
10
11#include <QObject>
12
13namespace Marble
14{
15
16class CloudSyncManager;
17class RoutingManager;
18class CloudRouteModel;
19class RouteItem;
20
21class MARBLE_EXPORT RouteSyncManager : public QObject
22{
23 Q_OBJECT
24
25 Q_PROPERTY(bool routeSyncEnabled READ isRouteSyncEnabled WRITE setRouteSyncEnabled NOTIFY routeSyncEnabledChanged)
26
27public:
28 explicit RouteSyncManager(CloudSyncManager *cloudSyncManager);
29 ~RouteSyncManager() override;
30
31 void setRoutingManager(RoutingManager *routingManager);
32
33 /**
34 * Checks if the user enabled route synchronization.
35 * @return true if route synchronization enabled
36 */
37 bool isRouteSyncEnabled() const;
38
39 /**
40 * Setter for enabling/disabling route synchronization.
41 * @param enabled Status of route synchronization
42 */
43 void setRouteSyncEnabled(bool enabled);
44
45 /**
46 * Returns CloudRouteModel associated with RouteSyncManager instance
47 * @return CloudRouteModel associated with RouteSyncManager instance
48 */
49 CloudRouteModel *model();
50
51 /**
52 * Generates a timestamp which will be used as an unique identifier.
53 * @return A timestamp.
54 */
55 QString generateTimestamp() const;
56
57 /**
58 * Saves the route displayed in Marble's routing widget to local cache directory.
59 * Uses the RoutingManager passed as a parameter to the constructor.
60 * @return Filename of saved file.
61 */
62 QString saveDisplayedToCache() const;
63
64 /**
65 * Uploads currently displayed route to cloud.
66 * Initiates necessary methods of backends.
67 * Note that, this also runs saveDisplayedToCache() method.
68 */
69 void uploadRoute();
70
71 /**
72 * Gathers data from local cache directory and returns a route list.
73 * @return Routes stored in local cache
74 */
75 QList<RouteItem> cachedRouteList() const;
76
77public Q_SLOTS:
78 /**
79 * Uploads the route with given timestamp.
80 * @param timestamp Timestamp of the route which will be uploaded.
81 */
82 void uploadRoute(const QString &timestamp);
83
84 /**
85 * Starts preparing a route list by downloading
86 * a list of the routes on the cloud and adding
87 * the ones on the
88 */
89 void prepareRouteList();
90
91 /**
92 * Starts the download of specified route.
93 * @param timestamp Timestamp of the route that will be downloaded.
94 * @see RouteSyncManager::saveDownloadedToCache()
95 */
96 void downloadRoute(const QString &timestamp);
97
98 /**
99 * Opens route.
100 * @param timestamp Timestamp of the route that will be opened.
101 */
102 void openRoute(const QString &timestamp);
103
104 /**
105 * Deletes route from cloud.
106 * @param timestamp Timestamp of the route that will be deleted.
107 */
108 void deleteRoute(const QString &timestamp);
109
110 /**
111 * Removes route from cache.
112 * @param timestamp Timestamp of the route that will be removed.
113 */
114 void removeRouteFromCache(const QString &timestamp);
115
116 /**
117 * Updates upload progressbar.
118 * @param sent Bytes sent.
119 * @param total Total bytes.
120 */
121 void updateUploadProgressbar(qint64 sent, qint64 total);
122
123private Q_SLOTS:
124 /**
125 * Appends downloaded route list to RouteSyncManager's private list
126 * and then forwards the list to CloudRouteModel
127 * @param routeList Downloaded route list
128 */
129 void setRouteModelItems(const QList<RouteItem> &routeList);
130
131Q_SIGNALS:
132 void routeSyncEnabledChanged(bool enabled);
133 void routeListDownloadProgress(qint64 received, qint64 total);
134 void routeUploadProgress(qint64 sent, qint64 total);
135
136private:
137 class Private;
138 Private *const d;
139};
140
141}
142
143#endif // ROUTESYNCMANAGER_H
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 4 2024 16:37:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.