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 
41  Q_PROPERTY(QString navigationId READ navigationId NOTIFY navigationIdChanged)
42 
43 
46  Q_PROPERTY(QString label READ label NOTIFY labelChanged)
47 
51  Q_PROPERTY(QString allLabel READ allLabel NOTIFY allLabelChanged)
52 
56  Q_PROPERTY(QString parentNavigationId READ parentNavigationId NOTIFY parentNavigationIdChanged)
57 
61  Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
62 
66  Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
67 
71  Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
72 
76  Q_PROPERTY(bool hidden READ hidden NOTIFY hiddenChanged)
77 
81  Q_PROPERTY(int count READ count NOTIFY countChanged)
82 
83 protected:
85  explicit NavigationInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
87 
88 public:
92  enum Roles {
93  RoleNavigationId,
94  RoleLabel,
95  RoleAllLabel,
96  RoleHasChildren,
97  RoleIsActive
98  };
99  Q_ENUM(Roles)
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[RoleAllLabel] = "allLabel";
117  roles[RoleHasChildren] = "hasChildren";
118  roles[RoleIsActive] = "isActive";
119  return roles;
120  }
121  // @endcond
122 
123 Q_SIGNALS:
124  // @cond
125  void navigationIdChanged();
126  void labelChanged();
127  void allLabelChanged();
128  void parentNavigationIdChanged();
129  void parentLabelChanged();
130  void loadedChanged();
131  void isRootChanged();
132  void hiddenChanged();
133  void countChanged();
134  // @endcond
135 };
136 
137 }
138 }
139 }
140 
142 
143 #endif
unity::shell::scopes::NavigationInterface::Roles
Roles
The roles supported by this model.
Definition: NavigationInterface.h:92
unity
Top-level namespace for all things Unity-related.
Definition: Version.h:37
unity::shell::scopes::NavigationInterface
Object representing department instance, which exposes model(s) with results.
Definition: NavigationInterface.h:34