Loading...
Searching...
No Matches
ScopeInterface.h
/*
* Copyright (C) 2014 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UNITY_SHELL_SCOPES_SCOPEINTERFACE_H
#define UNITY_SHELL_SCOPES_SCOPEINTERFACE_H
#include <unity/SymbolExport.h>
#include <QObject>
#include <QVariantMap>
namespace unity
{
namespace shell
{
namespace scopes
{
class CategoriesInterface;
class PreviewModelInterface;
class NavigationInterface;
class SettingsModelInterface;
class FiltersInterface;
class FilterBaseInterface;
class UNITY_API ScopeInterface : public QObject
{
Q_OBJECT
Q_PROPERTY(QString id READ id NOTIFY idChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
Q_PROPERTY(bool activationInProgress READ activationInProgress NOTIFY activationInProgressChanged)
Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
Q_PROPERTY(unity::shell::scopes::CategoriesInterface* categories READ categories NOTIFY categoriesChanged)
Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
Q_PROPERTY(unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter READ primaryNavigationFilter NOTIFY primaryNavigationFilterChanged)
Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
Q_PROPERTY(QString currentNavigationId READ currentNavigationId NOTIFY currentNavigationIdChanged)
Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
Q_PROPERTY(unity::shell::scopes::FiltersInterface* filters READ filters NOTIFY filtersChanged)
Q_PROPERTY(QString primaryNavigationTag READ primaryNavigationTag NOTIFY primaryNavigationTagChanged)
Q_PROPERTY(int activeFiltersCount READ activeFiltersCount NOTIFY activeFiltersCountChanged)
protected:
explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
public:
enum class Status
{
Okay, // Everything is fine
NoInternet, // No Internet access
NoLocationData, // No location data available
Unknown, // A code unknown to the run-time was used
};
Q_ENUM(Status)
// @cond
virtual QString id() const = 0;
virtual QString name() const = 0;
virtual QString iconHint() const = 0;
virtual QString description() const = 0;
virtual QString searchHint() const = 0;
virtual QString shortcut() const = 0;
virtual bool searchInProgress() const = 0;
virtual bool activationInProgress() const = 0;
virtual bool favorite() const = 0;
virtual CategoriesInterface* categories() const = 0;
virtual SettingsModelInterface* settings() const = 0;
virtual FilterBaseInterface* primaryNavigationFilter() const = 0;
virtual QString searchQuery() const = 0;
virtual QString noResultsHint() const = 0;
virtual QString formFactor() const = 0;
virtual bool isActive() const = 0;
virtual QString currentNavigationId() const = 0;
virtual bool hasNavigation() const = 0;
virtual Status status() const = 0;
virtual QVariantMap customizations() const = 0;
virtual FiltersInterface* filters() const = 0;
virtual QString primaryNavigationTag() const = 0;
virtual int activeFiltersCount() const = 0;
/* setters */
virtual void setSearchQuery(const QString& search_query) = 0;
virtual void setNoResultsHint(const QString& hint) = 0;
virtual void setFormFactor(const QString& form_factor) = 0;
virtual void setActive(const bool) = 0;
virtual void setFavorite(const bool) = 0;
// @endcond
Q_INVOKABLE virtual void activate(QVariant const& result, QString const& categoryId) = 0;
Q_INVOKABLE virtual unity::shell::scopes::PreviewModelInterface* preview(QVariant const& result, QString const& categoryId) = 0;
Q_INVOKABLE virtual void cancelActivation() = 0;
Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
Q_INVOKABLE virtual void setNavigationState(QString const& navId) = 0;
Q_INVOKABLE virtual void performQuery(QString const& cannedQuery) = 0;
Q_INVOKABLE virtual void refresh() = 0;
Q_INVOKABLE virtual void resetPrimaryNavigationTag() = 0;
Q_INVOKABLE virtual void resetFilters() = 0;
/*
* @brief Method used to activate an action of a result.
*/
Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;
Q_SIGNALS:
// @cond
void idChanged();
void nameChanged();
void iconHintChanged();
void descriptionChanged();
void searchHintChanged();
void searchInProgressChanged();
void activationInProgressChanged();
void favoriteChanged();
void shortcutChanged();
void categoriesChanged();
void settingsChanged();
void searchQueryChanged();
void noResultsHintChanged();
void formFactorChanged();
void isActiveChanged();
void hasNavigationChanged();
void currentNavigationIdChanged();
void customizationsChanged();
void statusChanged();
void detailsChanged();
void filtersChanged();
void primaryNavigationTagChanged();
void activeFiltersCountChanged();
void primaryNavigationFilterChanged();
// @endcond
// signals triggered by activate(..) or preview(..) requests.
void showDash();
void hideDash();
void gotoUri(QString const& uri);
void previewRequested(QVariant const& result);
void gotoScope(QString const& scopeId);
void openScope(unity::shell::scopes::ScopeInterface* scope);
};
}
}
}
Q_DECLARE_METATYPE(unity::shell::scopes::ScopeInterface*)
#endif
unity::shell::scopes::CategoriesInterface
A list of categories for a particular search.
Definition CategoriesInterface.h:38
unity::shell::scopes::FilterBaseInterface
Definition FilterBaseInterface.h:31
unity::shell::scopes::FiltersInterface
Definition FiltersInterface.h:32
unity::shell::scopes::PreviewModelInterface
A list of PreviewWidgetModelInterface instances.
Definition PreviewModelInterface.h:38
unity::shell::scopes::ScopeInterface
Object representing scope instance, which exposes model(s) with results.
Definition ScopeInterface.h:43
unity::shell::scopes::ScopeInterface::noResultsHint
QString noResultsHint
Message to display when there are no results after a search.
Definition ScopeInterface.h:115
unity::shell::scopes::ScopeInterface::cancelActivation
virtual Q_INVOKABLE void cancelActivation()=0
Cancels the current activation.
unity::shell::scopes::ScopeInterface::searchHint
QString searchHint
Hint to display in the search field.
Definition ScopeInterface.h:69
unity::shell::scopes::ScopeInterface::resetFilters
virtual Q_INVOKABLE void resetFilters()=0
Reset filters to default values.
unity::shell::scopes::ScopeInterface::settings
unity::shell::scopes::SettingsModelInterface * settings
Settings model for the scope.
Definition ScopeInterface.h:98
unity::shell::scopes::ScopeInterface::showDash
void showDash()
Signal requesting to show the dash.
unity::shell::scopes::ScopeInterface::hideDash
void hideDash()
Signal requesting to hide the dash.
unity::shell::scopes::ScopeInterface::shortcut
QString shortcut
Keyboard shortcut used to summon the scope.
Definition ScopeInterface.h:88
unity::shell::scopes::ScopeInterface::gotoUri
void gotoUri(QString const &uri)
Signal requesting to open a uri.
unity::shell::scopes::ScopeInterface::preview
virtual Q_INVOKABLE unity::shell::scopes::PreviewModelInterface * preview(QVariant const &result, QString const &categoryId)=0
Method used to preview a result.
unity::shell::scopes::ScopeInterface::searchQuery
QString searchQuery
Current search query.
Definition ScopeInterface.h:110
unity::shell::scopes::ScopeInterface::iconHint
QString iconHint
URI to scope's icon.
Definition ScopeInterface.h:59
unity::shell::scopes::ScopeInterface::openScope
void openScope(unity::shell::scopes::ScopeInterface *scope)
Signal requesting to show a temporary scope.
unity::shell::scopes::ScopeInterface::getNavigation
virtual Q_INVOKABLE unity::shell::scopes::NavigationInterface * getNavigation(QString const &navigationId)=0
Get a NavigationInterface instance for the passed navigationId.
unity::shell::scopes::ScopeInterface::categories
unity::shell::scopes::CategoriesInterface * categories
Categories model for scope's results.
Definition ScopeInterface.h:93
unity::shell::scopes::ScopeInterface::status
unity::shell::scopes::ScopeInterface::Status status
Enum representing the status of the scope.
Definition ScopeInterface.h:149
unity::shell::scopes::ScopeInterface::hasNavigation
bool hasNavigation
Boolean specifying whether current query has departments.
Definition ScopeInterface.h:139
unity::shell::scopes::ScopeInterface::activationInProgress
bool activationInProgress
Boolean specifying whether an activation request is currently running.
Definition ScopeInterface.h:79
unity::shell::scopes::ScopeInterface::searchInProgress
bool searchInProgress
Boolean specifying whether a search is currently running.
Definition ScopeInterface.h:74
unity::shell::scopes::ScopeInterface::performQuery
virtual Q_INVOKABLE void performQuery(QString const &cannedQuery)=0
Execute canned query.
unity::shell::scopes::ScopeInterface::closeScope
virtual Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface *scope)=0
Closes the temporary scope which got opened when openScope was emitted.
unity::shell::scopes::ScopeInterface::gotoScope
void gotoScope(QString const &scopeId)
Signal requesting to change the currently focused scope.
unity::shell::scopes::ScopeInterface::primaryNavigationTag
QString primaryNavigationTag
Label for the currently active top level navigation (department or primary filter).
Definition ScopeInterface.h:159
unity::shell::scopes::ScopeInterface::activeFiltersCount
int activeFiltersCount
The number of currently selected filters.
Definition ScopeInterface.h:164
unity::shell::scopes::ScopeInterface::previewRequested
void previewRequested(QVariant const &result)
Signal requesting to preview a result.
unity::shell::scopes::ScopeInterface::customizations
QVariantMap customizations
VariantMap with customization properties.
Definition ScopeInterface.h:144
unity::shell::scopes::ScopeInterface::isActive
bool isActive
Boolean specifying whether the scope is currently active.
Definition ScopeInterface.h:129
unity::shell::scopes::ScopeInterface::activate
virtual Q_INVOKABLE void activate(QVariant const &result, QString const &categoryId)=0
Method used to activate a result.
unity::shell::scopes::ScopeInterface::setNavigationState
virtual Q_INVOKABLE void setNavigationState(QString const &navId)=0
Request change to the current navigation id.
unity::shell::scopes::ScopeInterface::description
QString description
Description of the scope.
Definition ScopeInterface.h:64
unity::shell::scopes::ScopeInterface::Status
Status
Status info code following the last operation.
Definition ScopeInterface.h:176
unity::shell::scopes::ScopeInterface::formFactor
QString formFactor
Form factor which is sent with search queries.
Definition ScopeInterface.h:124
unity::shell::scopes::ScopeInterface::currentNavigationId
QString currentNavigationId
String specifying currently selected department.
Definition ScopeInterface.h:134
unity::shell::scopes::ScopeInterface::name
QString name
Display name of the scope.
Definition ScopeInterface.h:54
unity::shell::scopes::ScopeInterface::favorite
bool favorite
Boolean specifying whether the scope is favourited.
Definition ScopeInterface.h:84
unity::shell::scopes::ScopeInterface::filters
unity::shell::scopes::FiltersInterface * filters
Filters model for the scope.
Definition ScopeInterface.h:154
unity::shell::scopes::ScopeInterface::refresh
virtual Q_INVOKABLE void refresh()=0
Force refresh of the scope contents.
unity::shell::scopes::ScopeInterface::resetPrimaryNavigationTag
virtual Q_INVOKABLE void resetPrimaryNavigationTag()=0
Reset primary navigation filter and its tag in the search bar.
unity::shell::scopes::SettingsModelInterface
Definition SettingsModelInterface.h:32
unity
Top-level namespace for all things Unity-related.
Definition Version.h:38