My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
DepartmentInterface.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_DEPARTMENTINTERFACE_H
18 #define UNITY_SHELL_SCOPES_DEPARTMENTINTERFACE_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 
34 class UNITY_API DepartmentInterface : public QAbstractListModel
35 {
36  Q_OBJECT
37 
38  Q_ENUMS(Roles)
39 
40 
43  Q_PROPERTY(QString departmentId READ departmentId NOTIFY departmentIdChanged)
44 
48  Q_PROPERTY(QString label READ label NOTIFY labelChanged)
49 
53  Q_PROPERTY(QString allLabel READ allLabel NOTIFY allLabelChanged)
54 
58  Q_PROPERTY(QString parentDepartmentId READ parentDepartmentId NOTIFY parentDepartmentIdChanged)
59 
63  Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
64 
68  Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
69 
73  Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
74 
78  Q_PROPERTY(int count READ count NOTIFY countChanged)
79 
80 protected:
82  explicit DepartmentInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
84 
85 public:
89  enum Roles {
90  RoleDepartmentId,
91  RoleLabel,
92  RoleHasChildren,
93  RoleIsActive
94  };
95 
96  // @cond
97  virtual QString departmentId() const = 0;
98  virtual QString label() const = 0;
99  virtual QString allLabel() const = 0;
100  virtual QString parentDepartmentId() const = 0;
101  virtual QString parentLabel() const = 0;
102  virtual bool loaded() const = 0;
103  virtual bool isRoot() const = 0;
104  virtual int count() const = 0;
105  QHash<int, QByteArray> roleNames() const override
106  {
107  QHash<int, QByteArray> roles;
108  roles[RoleDepartmentId] = "departmentId";
109  roles[RoleLabel] = "label";
110  roles[RoleHasChildren] = "hasChildren";
111  roles[RoleIsActive] = "isActive";
112  return roles;
113  }
114  // @endcond
115 
116 Q_SIGNALS:
117  // @cond
118  void departmentIdChanged();
119  void labelChanged();
120  void allLabelChanged();
121  void parentDepartmentIdChanged();
122  void parentLabelChanged();
123  void loadedChanged();
124  void isRootChanged();
125  void countChanged();
126  // @endcond
127 };
128 
129 }
130 }
131 }
132 
134 
135 #endif
Object representing department instance, which exposes model(s) with results.
Definition: DepartmentInterface.h:34
Roles
The roles supported by this model.
Definition: DepartmentInterface.h:89