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 PreviewModelInterface;
34 class NavigationInterface;
35 class SettingsModelInterface;
36 class FiltersInterface;
37 class FilterBaseInterface;
38 
42 class UNITY_API ScopeInterface : public QObject
43 {
44  Q_OBJECT
45 
46  Q_ENUMS(Status)
47 
48 
51  Q_PROPERTY(QString id READ id NOTIFY idChanged)
52 
56  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
57 
61  Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
62 
66  Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
67 
71  Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
72 
76  Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
77 
81  Q_PROPERTY(bool activationInProgress READ activationInProgress NOTIFY activationInProgressChanged)
82 
86  Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
90  Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
91 
95  Q_PROPERTY(unity::shell::scopes::CategoriesInterface* categories READ categories NOTIFY categoriesChanged)
96 
100  Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
101 
105  Q_PROPERTY(unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter READ primaryNavigationFilter NOTIFY primaryNavigationFilterChanged)
106 
112  Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
113 
117  Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
118 
126  Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
127 
131  Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
132 
136  Q_PROPERTY(QString currentNavigationId READ currentNavigationId NOTIFY currentNavigationIdChanged)
137 
141  Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
142 
146  Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
147 
151  Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
152 
156  Q_PROPERTY(unity::shell::scopes::FiltersInterface* filters READ filters NOTIFY filtersChanged)
157 
161  Q_PROPERTY(QString primaryNavigationTag READ primaryNavigationTag NOTIFY primaryNavigationTagChanged)
162 
166  Q_PROPERTY(int activeFiltersCount READ activeFiltersCount NOTIFY activeFiltersCountChanged)
167 
168 protected:
170  explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
172 
173 public:
177  enum class Status
178  {
179  Okay, // Everything is fine
180  NoInternet, // No Internet access
181  NoLocationData, // No location data available
182  Unknown, // A code unknown to the run-time was used
183  };
184 
185  // @cond
186  virtual QString id() const = 0;
187  virtual QString name() const = 0;
188  virtual QString iconHint() const = 0;
189  virtual QString description() const = 0;
190  virtual QString searchHint() const = 0;
191  virtual QString shortcut() const = 0;
192  virtual bool searchInProgress() const = 0;
193  virtual bool activationInProgress() const = 0;
194  virtual bool favorite() const = 0;
195  virtual CategoriesInterface* categories() const = 0;
196  virtual SettingsModelInterface* settings() const = 0;
197  virtual FilterBaseInterface* primaryNavigationFilter() const = 0;
198  virtual QString searchQuery() const = 0;
199  virtual QString noResultsHint() const = 0;
200  virtual QString formFactor() const = 0;
201  virtual bool isActive() const = 0;
202  virtual QString currentNavigationId() const = 0;
203  virtual bool hasNavigation() const = 0;
204  virtual Status status() const = 0;
205  virtual QVariantMap customizations() const = 0;
206  virtual FiltersInterface* filters() const = 0;
207  virtual QString primaryNavigationTag() const = 0;
208  virtual int activeFiltersCount() const = 0;
209 
210  /* setters */
211  virtual void setSearchQuery(const QString& search_query) = 0;
212  virtual void setNoResultsHint(const QString& hint) = 0;
213  virtual void setFormFactor(const QString& form_factor) = 0;
214  virtual void setActive(const bool) = 0;
215  virtual void setFavorite(const bool) = 0;
216  // @endcond
217 
221  Q_INVOKABLE virtual void activate(QVariant const& result, QString const& categoryId) = 0;
222 
229  Q_INVOKABLE virtual unity::shell::scopes::PreviewModelInterface* preview(QVariant const& result, QString const& categoryId) = 0;
230 
234  Q_INVOKABLE virtual void cancelActivation() = 0;
235 
239  Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
240 
244  Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
245 
249  Q_INVOKABLE virtual void setNavigationState(QString const& navId) = 0;
250 
254  Q_INVOKABLE virtual void performQuery(QString const& cannedQuery) = 0;
255 
259  Q_INVOKABLE virtual void refresh() = 0;
260 
264  Q_INVOKABLE virtual void resetPrimaryNavigationTag() = 0;
265 
269  Q_INVOKABLE virtual void resetFilters() = 0;
270 
271  /*
272  * @brief Method used to activate an action of a result.
273  */
274  Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;
275 
276 Q_SIGNALS:
277  // @cond
278  void idChanged();
279  void nameChanged();
280  void iconHintChanged();
281  void descriptionChanged();
282  void searchHintChanged();
283  void searchInProgressChanged();
284  void activationInProgressChanged();
285  void favoriteChanged();
286  void shortcutChanged();
287  void categoriesChanged();
288  void settingsChanged();
289  void searchQueryChanged();
290  void noResultsHintChanged();
291  void formFactorChanged();
292  void isActiveChanged();
293  void hasNavigationChanged();
294  void currentNavigationIdChanged();
295  void customizationsChanged();
296  void statusChanged();
297  void detailsChanged();
298  void filtersChanged();
299  void primaryNavigationTagChanged();
300  void activeFiltersCountChanged();
301  void primaryNavigationFilterChanged();
302  // @endcond
303 
304  // signals triggered by activate(..) or preview(..) requests.
310  void showDash();
311 
317  void hideDash();
318 
324  void gotoUri(QString const& uri);
325 
331  void previewRequested(QVariant const& result);
332 
336  void gotoScope(QString const& scopeId);
337 
341  void openScope(unity::shell::scopes::ScopeInterface* scope);
342 };
343 
344 }
345 }
346 }
347 
348 Q_DECLARE_METATYPE(unity::shell::scopes::ScopeInterface*)
349 
350 #endif
Definition: FilterBaseInterface.h:30
Definition: FiltersInterface.h:31
Definition: SettingsModelInterface.h:31
A list of PreviewWidgetModelInterface instances.
Definition: PreviewModelInterface.h:37
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:42
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:177
A list of categories for a particular search.
Definition: CategoriesInterface.h:37