Marble

CloudRouteModel.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 CLOUDROUTEMODEL_H
7#define CLOUDROUTEMODEL_H
8
9#include "marble_export.h"
10
11#include <QModelIndex>
12#include <QAbstractListModel>
13
14class QNetworkReply;
15
16namespace Marble
17{
18
19class RouteItem;
20
21class MARBLE_EXPORT CloudRouteModel : public QAbstractListModel
22{
23 Q_OBJECT
24
25public:
26 enum RouteRoles {
27 Timestamp = Qt::UserRole + 1,
28 Name,
29 PreviewUrl,
30 Distance,
32 IsCached,
33 IsDownloading,
34 IsOnCloud
35 };
36
37 explicit CloudRouteModel( QObject *parent = nullptr );
38 ~CloudRouteModel() override;
39
40 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
41 int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
42
43 /** Overload of QAbstractListModel */
44 QHash<int, QByteArray> roleNames() const override;
45
46 /**
47 * Sets the list of routes that will show up in CloudRoutesDialog.
48 * @param items List of routes.
49 */
50 void setItems( const QVector<RouteItem> &items );
51
52 /**
53 * Checks if specified route exists in the local cache.
54 * @param index Index of the route.
55 * @return true, if exists.
56 */
57 bool isCached( const QModelIndex &index ) const;
58
59 /**
60 * Getter for the item currently being downloaded.
61 * @return Model for the item currently being downloaded
62 */
63 QPersistentModelIndex downloadingItem() const;
64
65 /**
66 * Marks the route at given index as being downloaded.
67 * @param index Index of the route.
68 */
69 void setDownloadingItem( const QPersistentModelIndex &index );
70
71 /**
72 * Checks if route is being downloaded.
73 * @param index Index of the route.
74 * @return true, if downloading.
75 */
76 bool isDownloading( const QModelIndex &index ) const;
77
78 /**
79 * Total size of the item currently being downloaded.
80 * @return Total size of the item, -1 if no route is being downloaded
81 */
82 qint64 totalSize() const;
83
84 /**
85 * Returns how much of the route are downloaded as bytes
86 * @return Downloaded bytes
87 */
88 qint64 downloadedSize() const;
89
90 /**
91 * Checks whether a preview for the route available and
92 * returns or downloads the preview
93 * @param index Index of the item whose preview is requested
94 * @return Route's preview as QIcon
95 */
96 QIcon preview( const QModelIndex &index ) const;
97
98public Q_SLOTS:
99 void updateProgress( qint64 currentSize, qint64 totalSize );
100 void setPreview( QNetworkReply *reply );
101
102private:
103 class Private;
104 Private *d;
105};
106}
107
108#endif // CLOUDROUTEMODEL_H
Binds a QML item to a specific geodetic location in screen coordinates.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.