My Project
ScopeInterface.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_SCOPEINTERFACE_H
18 #define UNITY_SHELL_SCOPES_SCOPEINTERFACE_H
19 
20 #include <unity/SymbolExport.h>
21 
22 #include <QObject>
23 #include <QVariantMap>
24 
25 namespace unity
26 {
27 namespace shell
28 {
29 namespace scopes
30 {
31 
32 class CategoriesInterface;
33 class PreviewStackInterface;
34 class NavigationInterface;
35 class SettingsModelInterface;
36 
40 class UNITY_API ScopeInterface : public QObject
41 {
42  Q_OBJECT
43 
44  Q_ENUMS(Status)
45 
46 
49  Q_PROPERTY(QString id READ id NOTIFY idChanged)
50 
54  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
55 
59  Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
60 
64  Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
65 
69  Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
70 
74  Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
75 
79  Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
83  Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
84 
88  Q_PROPERTY(unity::shell::scopes::CategoriesInterface* categories READ categories NOTIFY categoriesChanged)
89 
93  Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
94 
100  Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
101 
105  Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
106 
114  Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
115 
119  Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
120 
124  Q_PROPERTY(QString currentNavigationId READ currentNavigationId NOTIFY currentNavigationIdChanged)
125 
129  Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
130 
134  Q_PROPERTY(QString currentAltNavigationId READ currentAltNavigationId NOTIFY currentAltNavigationIdChanged)
135 
139  Q_PROPERTY(bool hasAltNavigation READ hasAltNavigation NOTIFY hasAltNavigationChanged)
140 
144  Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
145 
149  Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
150 
151 protected:
153  explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
155 
156 public:
160  enum class Status
161  {
162  Okay, // Everything is fine
163  NoInternet, // No Internet access
164  NoLocationData, // No location data available
165  Unknown, // A code unknown to the run-time was used
166  };
167 
168  // @cond
169  virtual QString id() const = 0;
170  virtual QString name() const = 0;
171  virtual QString iconHint() const = 0;
172  virtual QString description() const = 0;
173  virtual QString searchHint() const = 0;
174  virtual QString shortcut() const = 0;
175  virtual bool searchInProgress() const = 0;
176  virtual bool favorite() const = 0;
177  virtual CategoriesInterface* categories() const = 0;
178  virtual SettingsModelInterface* settings() const = 0;
179  virtual QString searchQuery() const = 0;
180  virtual QString noResultsHint() const = 0;
181  virtual QString formFactor() const = 0;
182  virtual bool isActive() const = 0;
183  virtual QString currentNavigationId() const = 0;
184  virtual bool hasNavigation() const = 0;
185  virtual QString currentAltNavigationId() const = 0;
186  virtual bool hasAltNavigation() const = 0;
187  virtual Status status() const = 0;
188  virtual QVariantMap customizations() const = 0;
189 
190  /* setters */
191  virtual void setSearchQuery(const QString& search_query) = 0;
192  virtual void setNoResultsHint(const QString& hint) = 0;
193  virtual void setFormFactor(const QString& form_factor) = 0;
194  virtual void setActive(const bool) = 0;
195  virtual void setFavorite(const bool) = 0;
196  // @endcond
197 
201  Q_INVOKABLE virtual void activate(QVariant const& result, QString const& categoryId) = 0;
202 
209  Q_INVOKABLE virtual unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result, QString const& categoryId) = 0;
210 
214  Q_INVOKABLE virtual void cancelActivation() = 0;
215 
219  Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
220 
224  Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
225 
229  Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) = 0;
230 
234  Q_INVOKABLE virtual void setNavigationState(QString const& navId, bool altNavigation) = 0;
235 
239  Q_INVOKABLE virtual void performQuery(QString const& cannedQuery) = 0;
240 
244  Q_INVOKABLE virtual void refresh() = 0;
245 
246 Q_SIGNALS:
247  // @cond
248  void idChanged();
249  void nameChanged();
250  void iconHintChanged();
251  void descriptionChanged();
252  void searchHintChanged();
253  void searchInProgressChanged();
254  void favoriteChanged();
255  void shortcutChanged();
256  void categoriesChanged();
257  void settingsChanged();
258  void searchQueryChanged();
259  void noResultsHintChanged();
260  void formFactorChanged();
261  void isActiveChanged();
262  void hasNavigationChanged();
263  void currentNavigationIdChanged();
264  void hasAltNavigationChanged();
265  void currentAltNavigationIdChanged();
266  void customizationsChanged();
267  void statusChanged();
268  void detailsChanged();
269  // @endcond
270 
271  // signals triggered by activate(..) or preview(..) requests.
277  void showDash();
278 
284  void hideDash();
285 
291  void gotoUri(QString const& uri);
292 
298  void previewRequested(QVariant const& result);
299 
303  void gotoScope(QString const& scopeId);
304 
308  void openScope(unity::shell::scopes::ScopeInterface* scope);
309 };
310 
311 }
312 }
313 }
314 
315 Q_DECLARE_METATYPE(unity::shell::scopes::ScopeInterface*)
316 
317 #endif
Definition: SettingsModelInterface.h:31
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Object representing scope instance, which exposes model(s) with results.
Definition: ScopeInterface.h:40
A master model for previews.
Definition: PreviewStackInterface.h:40
Object representing department instance, which exposes model(s) with results.
Definition: NavigationInterface.h:34
Status
Status info code following the last operation.
Definition: ScopeInterface.h:160
A list of categories for a particular search.
Definition: CategoriesInterface.h:37