From 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 11 Feb 2016 23:55:16 +0100 Subject: launchpad ~mzanetti/rockwork/trunk r87 --- rockwork/applicationsfiltermodel.h | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 rockwork/applicationsfiltermodel.h (limited to 'rockwork/applicationsfiltermodel.h') 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 + +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 -- cgit v1.2.3