Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/resources/SourcesModel.h
Show All 26 Lines | |||||
27 | #include "discovercommon_export.h" | 27 | #include "discovercommon_export.h" | ||
28 | 28 | | |||
29 | class QAction; | 29 | class QAction; | ||
30 | class AbstractSourcesBackend; | 30 | class AbstractSourcesBackend; | ||
31 | class DISCOVERCOMMON_EXPORT SourcesModel : public QAbstractListModel | 31 | class DISCOVERCOMMON_EXPORT SourcesModel : public QAbstractListModel | ||
32 | { | 32 | { | ||
33 | Q_OBJECT | 33 | Q_OBJECT | ||
34 | Q_PROPERTY(int count READ rowCount NOTIFY sourcesChanged) | 34 | Q_PROPERTY(int count READ rowCount NOTIFY sourcesChanged) | ||
35 | Q_PROPERTY(QList<QObject*> actions READ actions NOTIFY sourcesChanged) | | |||
36 | public: | 35 | public: | ||
37 | enum Roles { | 36 | enum Roles { | ||
38 | SourceBackend = Qt::UserRole+1 | 37 | SourceBackend = Qt::UserRole+1 | ||
39 | }; | 38 | }; | ||
40 | explicit SourcesModel(QObject* parent = nullptr); | 39 | explicit SourcesModel(QObject* parent = nullptr); | ||
41 | ~SourcesModel() override; | 40 | ~SourcesModel() override; | ||
42 | 41 | | |||
43 | static SourcesModel* global(); | 42 | static SourcesModel* global(); | ||
44 | 43 | | |||
45 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 44 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
46 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 45 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
47 | void addSourcesBackend(AbstractSourcesBackend* sources); | 46 | void addSourcesBackend(AbstractSourcesBackend* sources); | ||
48 | QHash<int, QByteArray> roleNames() const override; | 47 | QHash<int, QByteArray> roleNames() const override; | ||
49 | 48 | | |||
50 | QList<QObject*> actions() const; | 49 | public Q_SLOTS: | ||
50 | QObject* backendForSection(const QString &status) const; | ||||
51 | 51 | | |||
52 | Q_SIGNALS: | 52 | Q_SIGNALS: | ||
53 | void sourcesChanged(); | 53 | void sourcesChanged(); | ||
54 | 54 | | |||
55 | private: | 55 | private: | ||
56 | QList<AbstractSourcesBackend*> m_sources; | 56 | QList<AbstractSourcesBackend*> m_sources; | ||
57 | }; | 57 | }; | ||
58 | 58 | | |||
59 | #endif // SOURCESMODEL_H | 59 | #endif // SOURCESMODEL_H |