Unity 8
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 
22 namespace unity {
23 namespace shell {
24 namespace application {
25 class ApplicationManagerInterface;
26 class ApplicationInfoInterface;
27 }
28 }
29 }
30 using namespace unity::shell::application;
31 
32 class ApplicationsFilterModel: public QSortFilterProxyModel
33 {
34  Q_OBJECT
35 
36  Q_PROPERTY(unity::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)
41 public:
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 unity::shell::application::ApplicationInfoInterface* get(int index) const;
56 
57 Q_SIGNALS:
58  void applicationsModelChanged();
59  void filterTouchAppsChanged();
60  void filterLegacyAppsChanged();
61  void countChanged();
62 
63 private:
64  ApplicationManagerInterface* m_appModel;
65  bool m_filterTouchApps;
66  bool m_filterLegacyApps;
67 };
68 
69 #endif