My Project
SettingsModelInterface.h
1 /*
2  * Copyright (C) 2014 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 UNITY_SHELL_SCOPES_SETTINGSMODELINTERFACE_H
18 #define UNITY_SHELL_SCOPES_SETTINGSMODELINTERFACE_H
19 
20 #include <unity/SymbolExport.h>
21 
22 #include <QAbstractListModel>
23 
24 namespace unity
25 {
26 namespace shell
27 {
28 namespace scopes
29 {
30 
31 class UNITY_API SettingsModelInterface: public QAbstractListModel
32 {
33 Q_OBJECT
34 
35 Q_ENUMS(Roles)
36 
37 
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
41 
42 protected:
44  explicit SettingsModelInterface(QObject* parent = 0)
45  : QAbstractListModel(parent)
46  {
47  }
49 
50 public:
51  virtual ~SettingsModelInterface() = default;
52 
53  virtual int count() const = 0;
54 
58  enum Roles
59  {
60  RoleSettingId,
61  RoleDisplayName,
62  RoleType,
63  RoleProperties,
64  RoleValue
65  };
66 
67  // @cond
68  QHash<int, QByteArray> roleNames() const override
69  {
70  QHash<int, QByteArray> roles;
71  roles[RoleSettingId] = "settingId";
72  roles[RoleDisplayName] = "displayName";
73  roles[RoleType] = "type";
74  roles[RoleProperties] = "properties";
75  roles[RoleValue] = "value";
76  return roles;
77  }
78  // @endcond
79 
80 Q_SIGNALS:
81  // @cond
82  void countChanged();
83  // @endcond
84 };
85 
86 }
87 }
88 }
89 
91 
92 #endif /* UNITY_SHELL_SCOPES_SETTINGSMODELINTERFACE_H */
Definition: SettingsModelInterface.h:31
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Roles
The roles supported by this model.
Definition: SettingsModelInterface.h:58