My Project
LauncherModelInterface.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 LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
21 #define LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
22 
23 #include <lomiri/SymbolExport.h>
24 
25 #include <lomiri/shell/application/ApplicationManagerInterface.h>
26 
27 #include <QtCore/QAbstractListModel>
28 
29 namespace lomiri
30 {
31 namespace shell
32 {
33 namespace launcher
34 {
35 
37 
43 class LOMIRI_API LauncherModelInterface: public QAbstractListModel
44 {
45  Q_OBJECT
46 
54  Q_PROPERTY(lomiri::shell::application::ApplicationManagerInterface* applicationManager
55  READ applicationManager WRITE setApplicationManager NOTIFY applicationManagerChanged)
56 
57 
60  Q_PROPERTY(bool onlyPinned READ onlyPinned WRITE setOnlyPinned NOTIFY onlyPinnedChanged)
61 
62 protected:
64  LauncherModelInterface(QObject *parent = 0): QAbstractListModel(parent) {
65  m_roleNames.insert(RoleAppId, "appId");
66  m_roleNames.insert(RoleName, "name");
67  m_roleNames.insert(RoleIcon, "icon");
68  m_roleNames.insert(RolePinned, "pinned");
69  m_roleNames.insert(RoleRunning, "running");
70  m_roleNames.insert(RoleRecent, "recent");
71  m_roleNames.insert(RoleProgress, "progress");
72  m_roleNames.insert(RoleCount, "count");
73  m_roleNames.insert(RoleCountVisible, "countVisible");
74  m_roleNames.insert(RoleFocused, "focused");
75  m_roleNames.insert(RoleAlerting, "alerting");
76  m_roleNames.insert(RoleSurfaceCount, "surfaceCount");
77  }
79 
80 public:
86  enum Roles {
87  RoleAppId = Qt::UserRole,
88  RoleName,
89  RoleIcon,
90  RolePinned,
91  RoleRunning,
92  RoleRecent,
93  RoleProgress,
94  RoleCount,
95  RoleCountVisible,
96  RoleFocused,
97  RoleAlerting,
98  RoleSurfaceCount
99  };
100 
101  virtual ~LauncherModelInterface() {}
102 
109  Q_INVOKABLE virtual void move(int oldIndex, int newIndex) = 0;
110 
119  Q_INVOKABLE virtual lomiri::shell::launcher::LauncherItemInterface *get(int index) const = 0;
120 
134  Q_INVOKABLE virtual void pin(const QString &appId, int index = -1) = 0;
135 
143  Q_INVOKABLE virtual void requestRemove(const QString &appId) = 0;
144 
145 
152  Q_INVOKABLE virtual void quickListActionInvoked(const QString &appId, int actionIndex) = 0;
153 
154 
160  Q_INVOKABLE virtual void setUser(const QString &username) = 0;
161 
163  virtual lomiri::shell::application::ApplicationManagerInterface *applicationManager() const = 0;
164  virtual void setApplicationManager(lomiri::shell::application::ApplicationManagerInterface *applicationManager) = 0;
165 
166  virtual bool onlyPinned() const = 0;
167  virtual void setOnlyPinned(bool onlyPinned) = 0;
168 
169  QHash<int, QByteArray> roleNames() const override
170  {
171  return m_roleNames;
172  }
174 
175 Q_SIGNALS:
177  void applicationManagerChanged();
178  void onlyPinnedChanged();
180 
185  void hint();
186 
187 protected:
189  QHash<int, QByteArray> m_roleNames;
191 
192 };
193 
194 } // namespace launcher
195 } // namespace shell
196 } // namespace lomiri
197 
198 #endif // LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
The Application manager.
Definition: ApplicationManagerInterface.h:45
An item presented in the launcher.
Definition: LauncherItemInterface.h:41
A list of launcher items to be displayed.
Definition: LauncherModelInterface.h:44
Roles
The Roles supported by the model.
Definition: LauncherModelInterface.h:86
virtual Q_INVOKABLE void requestRemove(const QString &appId)=0
Request removal of an item from the model.
virtual Q_INVOKABLE lomiri::shell::launcher::LauncherItemInterface * get(int index) const =0
Get a launcher item.
virtual Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex)=0
Trigger an action from the QuickList.
void hint()
Emitted when the launcher should hint itself to the user, e.g. to indicate a change the user should b...
virtual Q_INVOKABLE void pin(const QString &appId, int index=-1)=0
Pin an item to the launcher.
virtual Q_INVOKABLE void move(int oldIndex, int newIndex)=0
Move an item in the model.
virtual Q_INVOKABLE void setUser(const QString &username)=0
Set the user for which the launcher should display items.
Top-level namespace for all things Lomiri-related.
Definition: Version.h:38