Marble

NewstuffModel.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#ifndef MARBLE_NEWSTUFFMODEL_H
7#define MARBLE_NEWSTUFFMODEL_H
8
9#include "marble_export.h"
10
11#include <QAbstractListModel>
12
13class QNetworkReply;
14
15namespace Marble
16{
17
18class NewstuffModelPrivate;
19
20class MARBLE_EXPORT NewstuffModel : public QAbstractListModel
21{
22 Q_OBJECT
23
24 Q_PROPERTY(int count READ count NOTIFY countChanged)
25 Q_PROPERTY(QString provider READ provider WRITE setProvider NOTIFY providerChanged)
26 Q_PROPERTY(QString targetDirectory READ targetDirectory WRITE setTargetDirectory NOTIFY targetDirectoryChanged)
27 Q_PROPERTY(QString registryFile READ registryFile WRITE setRegistryFile NOTIFY registryFileChanged)
28
29public:
30 enum NewstuffRoles {
31 Name = Qt::UserRole + 1,
32 Author,
33 License,
34 Summary,
35 Version,
36 ReleaseDate,
37 Preview,
38 Payload,
39 InstalledVersion,
40 InstalledReleaseDate,
41 InstalledFiles,
42 IsInstalled,
43 IsUpgradable,
45 IsTransitioning,
46 PayloadSize,
47 DownloadedSize
48 };
49
50 enum IdTag {
51 PayloadTag,
52 NameTag
53 };
54
55 /** Constructor */
56 explicit NewstuffModel(QObject *parent = nullptr);
57
58 /** Destructor */
59 ~NewstuffModel() override;
60
61 /** Overload of QAbstractListModel */
62 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
63
64 /** Overload of QAbstractListModel */
65 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
66
67 /** Overload of QAbstractListModel */
68 QHash<int, QByteArray> roleNames() const override;
69
70 /** @todo FIXME https://bugreports.qt-project.org/browse/QTCOMPONENTS-1206 */
71 int count() const;
72
73 /**
74 * Add a newstuff provider
75 */
76 void setProvider(const QString &downloadUrl);
77
78 QString provider() const;
79
80 void setTargetDirectory(const QString &targetDirectory);
81
82 QString targetDirectory() const;
83
84 void setRegistryFile(const QString &registryFile, IdTag idTag = PayloadTag);
85
86 QString registryFile() const;
87
88public Q_SLOTS:
89 void install(int index);
90
91 void uninstall(int index);
92
93 void cancel(int index);
94
95Q_SIGNALS:
96 void countChanged();
97
98 void providerChanged();
99
100 void targetDirectoryChanged();
101
102 void registryFileChanged();
103
104 void installationProgressed(int newstuffindex, qreal progress);
105
106 void installationFinished(int newstuffindex);
107
108 void installationFailed(int newstuffindex, const QString &error);
109
110 void uninstallationFinished(int newstuffindex);
111
112private Q_SLOTS:
113 void updateProgress(qint64 bytesReceived, qint64 bytesTotal);
114
115 void retrieveData();
116
117 void mapInstalled(int exitStatus);
118
119 void mapUninstalled();
120
121 void contentsListed(int exitStatus);
122
123private:
124 NewstuffModelPrivate *const d;
125 friend class NewstuffModelPrivate;
126
127 Q_PRIVATE_SLOT(d, void handleProviderData(QNetworkReply *))
128};
129
130}
131
132#endif // MARBLE_NEWSTUFFMODEL_H
KGuiItem cancel()
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 Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.