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 
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
39 
40 protected:
42  explicit SettingsModelInterface(QObject* parent = 0)
43  : QAbstractListModel(parent)
44  {
45  }
47 
48 public:
49  virtual ~SettingsModelInterface() = default;
50 
51  virtual int count() const = 0;
52 
56  enum Roles
57  {
58  RoleSettingId,
59  RoleDisplayName,
60  RoleType,
61  RoleProperties,
62  RoleValue
63  };
64  Q_ENUM(Roles)
65 
66  // @cond
67  QHash<int, QByteArray> roleNames() const override
68  {
69  QHash<int, QByteArray> roles;
70  roles[RoleSettingId] = "settingId";
71  roles[RoleDisplayName] = "displayName";
72  roles[RoleType] = "type";
73  roles[RoleProperties] = "properties";
74  roles[RoleValue] = "value";
75  return roles;
76  }
77  // @endcond
78 
79 Q_SIGNALS:
80  // @cond
81  void countChanged();
82  // @endcond
83 };
84 
85 }
86 }
87 }
88 
90 
91 #endif /* UNITY_SHELL_SCOPES_SETTINGSMODELINTERFACE_H */
unity
Top-level namespace for all things Unity-related.
Definition: Version.h:37
unity::shell::scopes::SettingsModelInterface
Definition: SettingsModelInterface.h:31
unity::shell::scopes::SettingsModelInterface::Roles
Roles
The roles supported by this model.
Definition: SettingsModelInterface.h:56