summaryrefslogtreecommitdiff
path: root/rockwork/applicationsfiltermodel.h
blob: 96c3b5cca2eb593a17d273564001c6879ce2b3b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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