diff options
Diffstat (limited to 'rockwork/applicationsfiltermodel.h')
| -rw-r--r-- | rockwork/applicationsfiltermodel.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/rockwork/applicationsfiltermodel.h b/rockwork/applicationsfiltermodel.h new file mode 100644 index 0000000..96c3b5c --- /dev/null +++ b/rockwork/applicationsfiltermodel.h @@ -0,0 +1,54 @@ +#ifndef APPLICATIONSFILTERMODEL_H +#define APPLICATIONSFILTERMODEL_H + +#include <QSortFilterProxyModel> + +class ApplicationsModel; +class AppItem; + +class ApplicationsFilterModel : public QSortFilterProxyModel +{ + Q_OBJECT + Q_PROPERTY(ApplicationsModel* model READ appsModel WRITE setAppsModel NOTIFY appsModelChanged) + Q_PROPERTY(bool showWatchApps READ showWatchApps WRITE setShowWatchApps NOTIFY showWatchAppsChanged) + Q_PROPERTY(bool showWatchFaces READ showWatchFaces WRITE setShowWatchFaces NOTIFY showWatchFacesChanged) + Q_PROPERTY(bool sortByGroupId READ sortByGroupId WRITE setSortByGroupId NOTIFY sortByGroupIdChanged) + +public: + ApplicationsFilterModel(QObject *parent = nullptr); + + ApplicationsModel *appsModel() const; + void setAppsModel(ApplicationsModel *model); + + bool showWatchApps() const; + void setShowWatchApps(bool showWatchApps); + + bool showWatchFaces() const; + void setShowWatchFaces(bool showWatchFaces); + + bool sortByGroupId() const; + void setSortByGroupId(bool sortByGroupId); + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override; + + Q_INVOKABLE AppItem *get(int index) const; + + Q_INVOKABLE void move(int from, int to); +signals: + void appsModelChanged(); + void showWatchAppsChanged(); + void showWatchFacesChanged(); + void sortByGroupIdChanged(); + +public slots: + +private: + ApplicationsModel *m_appsModel; + + bool m_showWatchApps = true; + bool m_showWatchFaces = true; + bool m_sortByGroupId = true; +}; + +#endif // APPLICATIONSFILTERMODEL_H |
