Marble

OfflineDataModel.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <[email protected]>
4 //
5 
6 #ifndef MARBLE_DECLARATIVE_OFFLINEDATAMODEL_H
7 #define MARBLE_DECLARATIVE_OFFLINEDATAMODEL_H
8 
9 #include "NewstuffModel.h"
10 
11 #include <QSortFilterProxyModel>
12 
13 class OfflineDataModel : public QSortFilterProxyModel
14 {
15  Q_OBJECT
16 
17  Q_PROPERTY( int count READ count NOTIFY countChanged )
18 
19  Q_FLAGS(VehicleType VehicleTypes)
20 
21 public:
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 
41 public 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 
50 Q_SIGNALS:
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 
61 protected:
62  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
63 
64 private 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 
73 private:
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_OBJECTQ_OBJECT
Q_PROPERTY(...)
DisplayRole
Q_SLOTSQ_SLOTS
KGuiItem cancel()
virtual QHash< int, QByteArray > roleNames() const const
Q_SIGNALSQ_SIGNALS
Q_FLAGS(...)
virtual QVariant data(const QModelIndex &index, int role) const const override
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 04:09:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.