My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
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 
69 protected:
71  ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
72  {
73  m_roleNames.insert(RoleAppId, "appId");
74  m_roleNames.insert(RoleName, "name");
75  m_roleNames.insert(RoleComment, "comment");
76  m_roleNames.insert(RoleIcon, "icon");
77  m_roleNames.insert(RoleStage, "stage");
78  m_roleNames.insert(RoleState, "state");
79  m_roleNames.insert(RoleFocused, "focused");
80  m_roleNames.insert(RoleScreenshot, "screenshot");
81 
82  connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
83  connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
84  connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
85  connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged()));
86  }
88 
89 public:
95  enum Roles {
96  RoleAppId = Qt::UserRole,
97  RoleName,
98  RoleComment,
99  RoleIcon,
100  RoleStage,
101  RoleState,
102  RoleFocused,
103  RoleScreenshot,
104  };
105 
107  virtual ~ApplicationManagerInterface() {}
108 
109  virtual QHash<int, QByteArray> roleNames() const
110  {
111  return m_roleNames;
112  }
113 
114  int count() const {
115  return rowCount();
116  }
117 
118  virtual QString focusedApplicationId() const = 0;
119 
120  virtual bool suspended() const = 0;
121  virtual void setSuspended(bool suspended) = 0;
123 
132  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
133 
142  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
143 
152  Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
153 
164  Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
165 
169  Q_INVOKABLE virtual void unfocusCurrentApplication() = 0;
170 
178  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
179 
186  Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
187 
198  Q_INVOKABLE virtual bool updateScreenshot(const QString &appId) = 0;
199 
200 Q_SIGNALS:
202  void countChanged();
204 
211  void focusRequested(const QString &appId);
212 
216  void focusedApplicationIdChanged();
217 
221  void suspendedChanged();
222 
228  void applicationAdded(const QString &appId);
229 
235  void applicationRemoved(const QString &appId);
236 
237 protected:
239  QHash<int, QByteArray> m_roleNames;
241 };
242 
243 } // namespace application
244 } // namespace shell
245 } // namespace unity
246 
247 #endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFO_H
The Application manager.
Definition: ApplicationManagerInterface.h:43
Roles
The Roles supported by the model.
Definition: ApplicationManagerInterface.h:95
A class that holds information about applications.
Definition: ApplicationInfoInterface.h:42