Marble

OfflineDataModel.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_DECLARATIVE_OFFLINEDATAMODEL_H
7#define MARBLE_DECLARATIVE_OFFLINEDATAMODEL_H
8
9#include "NewstuffModel.h"
10
11#include <QSortFilterProxyModel>
12
13class OfflineDataModel : public QSortFilterProxyModel
14{
16
17 Q_PROPERTY( int count READ count NOTIFY countChanged )
18
19 Q_FLAGS(VehicleType VehicleTypes)
20
21public:
22 enum VehicleType {
23 None = 0x0,
24 Motorcar = 0x1,
25 Bicycle = 0x2,
26 Pedestrian = 0x4,
27 Any = Motorcar | Bicycle | Pedestrian
28 };
29
30 Q_DECLARE_FLAGS(VehicleTypes, VehicleType)
31
32 explicit OfflineDataModel( QObject* parent = nullptr );
33
34 /** @todo FIXME https://bugreports.qt-project.org/browse/QTCOMPONENTS-1206 */
35 int count() const;
36
37 QHash<int, QByteArray> roleNames() const override;
38
39 QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
40
41public Q_SLOTS:
42 void setVehicleTypeFilter( VehicleTypes filter );
43
44 void install( int index );
45
46 void uninstall( int index );
47
48 void cancel( int index );
49
51 void countChanged();
52
53 void installationProgressed( int newstuffindex, qreal progress );
54
55 void installationFinished( int newstuffindex );
56
57 void installationFailed( int newstuffindex, const QString &error );
58
59 void uninstallationFinished( int newstuffindex );
60
61protected:
62 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
63
64private Q_SLOTS:
65 void handleInstallationProgress( int index, qreal progress );
66
67 void handleInstallationFinished( int index );
68
69 void handleInstallationFailed( int index, const QString &error );
70
71 void handleUninstallationFinished( int index );
72
73private:
74 int fromSource( int idx ) const;
75
76 int toSource( int idx ) const;
77
78 Marble::NewstuffModel m_newstuffModel;
79
80 VehicleTypes m_vehicleTypeFilter;
81
82 QHash<int, QByteArray> m_roleNames;
83};
84
85#endif
Q_FLAGS(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
T qobject_cast(QObject *object)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
DisplayRole
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.