My Project
NavigationInterface.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_NAVIGATIONINTERFACE_H
18 #define UNITY_SHELL_SCOPES_NAVIGATIONINTERFACE_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 NavigationInterface : public QAbstractListModel
35 {
36  Q_OBJECT
37 
38  Q_ENUMS(Roles)
39 
40 
43  Q_PROPERTY(QString navigationId READ navigationId NOTIFY navigationIdChanged)
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 parentNavigationId READ parentNavigationId NOTIFY parentNavigationIdChanged)
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(bool hidden READ hidden NOTIFY hiddenChanged)
79 
83  Q_PROPERTY(int count READ count NOTIFY countChanged)
84 
85 protected:
87  explicit NavigationInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
89 
90 public:
94  enum Roles {
95  RoleNavigationId,
96  RoleLabel,
97  RoleHasChildren,
98  RoleIsActive
99  };
100 
101  // @cond
102  virtual QString navigationId() const = 0;
103  virtual QString label() const = 0;
104  virtual QString allLabel() const = 0;
105  virtual QString parentNavigationId() const = 0;
106  virtual QString parentLabel() const = 0;
107  virtual bool loaded() const = 0;
108  virtual bool isRoot() const = 0;
109  virtual bool hidden() const = 0;
110  virtual int count() const = 0;
111  QHash<int, QByteArray> roleNames() const override
112  {
113  QHash<int, QByteArray> roles;
114  roles[RoleNavigationId] = "navigationId";
115  roles[RoleLabel] = "label";
116  roles[RoleHasChildren] = "hasChildren";
117  roles[RoleIsActive] = "isActive";
118  return roles;
119  }
120  // @endcond
121 
122 Q_SIGNALS:
123  // @cond
124  void navigationIdChanged();
125  void labelChanged();
126  void allLabelChanged();
127  void parentNavigationIdChanged();
128  void parentLabelChanged();
129  void loadedChanged();
130  void isRootChanged();
131  void hiddenChanged();
132  void countChanged();
133  // @endcond
134 };
135 
136 }
137 }
138 }
139 
141 
142 #endif
Roles
The roles supported by this model.
Definition: NavigationInterface.h:94
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Object representing department instance, which exposes model(s) with results.
Definition: NavigationInterface.h:34