Lomiri
Loading...
Searching...
No Matches
applicationsfiltermodel.h
1/*
2 * Copyright (C) 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef APPLICATIONSFILTERMODEL_H
18#define APPLICATIONSFILTERMODEL_H
19
20#include <QSortFilterProxyModel>
21
22namespace lomiri {
23namespace shell {
24namespace application {
25class ApplicationManagerInterface;
26class ApplicationInfoInterface;
27}
28}
29}
30using namespace lomiri::shell::application;
31
32class ApplicationsFilterModel: public QSortFilterProxyModel
33{
34 Q_OBJECT
35
36 Q_PROPERTY(lomiri::shell::application::ApplicationManagerInterface* applicationsModel READ applicationsModel WRITE setApplicationsModel NOTIFY applicationsModelChanged)
37 Q_PROPERTY(bool filterTouchApps READ filterTouchApps WRITE setFilterTouchApps NOTIFY filterTouchAppsChanged)
38 Q_PROPERTY(bool filterLegacyApps READ filterLegacyApps WRITE setFilterLegacyApps NOTIFY filterLegacyAppsChanged)
39
40 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
41public:
42 ApplicationsFilterModel(QObject *parent = 0);
43
44 ApplicationManagerInterface* applicationsModel() const;
45 void setApplicationsModel(ApplicationManagerInterface* applicationsModel);
46
47 bool filterTouchApps() const;
48 void setFilterTouchApps(bool filterTouchApps);
49
50 bool filterLegacyApps() const;
51 void setFilterLegacyApps(bool filterLegacyApps);
52
53 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
54
55 Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface* get(int index) const;
56
57Q_SIGNALS:
58 void applicationsModelChanged();
59 void filterTouchAppsChanged();
60 void filterLegacyAppsChanged();
61 void countChanged();
62
63private:
64 ApplicationManagerInterface* m_appModel;
65 bool m_filterTouchApps;
66 bool m_filterLegacyApps;
67};
68
69#endif