My Project
ApplicationManagerInterface.h
1 /*
2  * Copyright 2013 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authors:
17  * Michael Zanetti <michael.zanetti@canonical.com>
18  */
19 
20 #ifndef UNITY_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
21 #define UNITY_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
22 
23 #include <unity/SymbolExport.h>
24 
25 #include <QtCore/QObject>
26 #include <QtCore/QAbstractListModel>
27 
28 namespace unity
29 {
30 namespace shell
31 {
32 namespace application
33 {
34 
35 class ApplicationInfoInterface;
36 
43 class UNITY_API ApplicationManagerInterface: public QAbstractListModel
44 {
45  Q_OBJECT
46  Q_ENUMS(Roles)
47 
48 
53  Q_PROPERTY(int count READ count NOTIFY countChanged)
54 
60  Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
61 
67  Q_PROPERTY(bool suspended READ suspended WRITE setSuspended NOTIFY suspendedChanged)
68 
74  Q_PROPERTY(bool forceDashActive READ forceDashActive WRITE setForceDashActive NOTIFY forceDashActiveChanged)
75 
76 protected:
78  ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
79  {
80  m_roleNames.insert(RoleAppId, "appId");
81  m_roleNames.insert(RoleName, "name");
82  m_roleNames.insert(RoleComment, "comment");
83  m_roleNames.insert(RoleIcon, "icon");
84  m_roleNames.insert(RoleStage, "stage");
85  m_roleNames.insert(RoleState, "state");
86  m_roleNames.insert(RoleFocused, "focused");
87 
88  connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
89  connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
90  connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
91  connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged()));
92  }
94 
95 public:
101  enum Roles {
102  RoleAppId = Qt::UserRole,
103  RoleName,
104  RoleComment,
105  RoleIcon,
106  RoleStage,
107  RoleState,
108  RoleFocused,
109  };
110 
112  virtual ~ApplicationManagerInterface() {}
113 
114  virtual QHash<int, QByteArray> roleNames() const
115  {
116  return m_roleNames;
117  }
118 
119  int count() const {
120  return rowCount();
121  }
122 
123  virtual QString focusedApplicationId() const = 0;
124 
125  virtual bool suspended() const = 0;
126  virtual void setSuspended(bool suspended) = 0;
127 
128  virtual bool forceDashActive() const = 0;
129  virtual void setForceDashActive(bool forceDashActive) = 0;
131 
140  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
141 
150  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
151 
160  Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
161 
172  Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
173 
177  Q_INVOKABLE virtual void unfocusCurrentApplication() = 0;
178 
186  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
187 
194  Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
195 
196 Q_SIGNALS:
198  void countChanged();
200 
207  void focusRequested(const QString &appId);
208 
212  void focusedApplicationIdChanged();
213 
217  void suspendedChanged();
218 
222  void forceDashActiveChanged();
223 
229  void applicationAdded(const QString &appId);
230 
236  void applicationRemoved(const QString &appId);
237 
238 protected:
240  QHash<int, QByteArray> m_roleNames;
242 };
243 
244 } // namespace application
245 } // namespace shell
246 } // namespace unity
247 
248 #endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFO_H
The Application manager.
Definition: ApplicationManagerInterface.h:43
Roles
The Roles supported by the model.
Definition: ApplicationManagerInterface.h:101
Top-level namespace for all things Unity-related.
Definition: Version.h:37
A class that holds information about applications.
Definition: ApplicationInfoInterface.h:44