Loading...
Searching...
No Matches
ScopesInterface.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_SCOPESINTERFACE_H
#define UNITY_SHELL_SCOPES_SCOPESINTERFACE_H
#include <unity/SymbolExport.h>
#include <QAbstractListModel>
namespace unity
{
namespace shell
{
namespace scopes
{
class ScopeInterface;
class UNITY_API ScopesInterface : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(unity::shell::scopes::ScopeInterface* overviewScope READ overviewScope NOTIFY overviewScopeChanged)
protected:
explicit ScopesInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
public:
enum Roles {
RoleScope,
RoleId,
RoleTitle
};
Q_ENUM(Roles)
Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(int row) const = 0;
Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(QString const& scopeId) const = 0;
Q_INVOKABLE virtual void setFavorite(QString const& scopeId, bool favorite) = 0;
Q_INVOKABLE virtual void moveFavoriteTo(QString const& scopeId, int index) = 0;
// @cond
virtual bool loaded() const = 0;
virtual int count() const = 0;
virtual unity::shell::scopes::ScopeInterface* overviewScope() const = 0;
QHash<int, QByteArray> roleNames() const override
{
QHash<int, QByteArray> roles;
roles[RoleScope] = "scope";
roles[RoleId] = "id";
roles[RoleTitle] = "title";
return roles;
}
// @endcond
Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
Q_SIGNALS:
// @cond
void loadedChanged();
void countChanged();
void overviewScopeChanged();
// @endcond
};
}
}
}
Q_DECLARE_METATYPE(unity::shell::scopes::ScopesInterface*)
#endif
unity::shell::scopes::ScopeInterface
Object representing scope instance, which exposes model(s) with results.
Definition ScopeInterface.h:43
unity::shell::scopes::ScopesInterface
A list of scopes to display in the UI.
Definition ScopesInterface.h:39
unity::shell::scopes::ScopesInterface::loaded
bool loaded
Boolean indicating whether asynchronous populating of the model finished.
Definition ScopesInterface.h:45
unity::shell::scopes::ScopesInterface::overviewScope
unity::shell::scopes::ScopeInterface * overviewScope
Scope instance representing the overview scope.
Definition ScopesInterface.h:57
unity::shell::scopes::ScopesInterface::Roles
Roles
Roles supported by the model.
Definition ScopesInterface.h:68
unity::shell::scopes::ScopesInterface::moveFavoriteTo
virtual Q_INVOKABLE void moveFavoriteTo(QString const &scopeId, int index)=0
Move the given favorite scope to the given index.
unity::shell::scopes::ScopesInterface::setFavorite
virtual Q_INVOKABLE void setFavorite(QString const &scopeId, bool favorite)=0
Set the favorite bit of the given scope.
unity::shell::scopes::ScopesInterface::getScope
virtual Q_INVOKABLE unity::shell::scopes::ScopeInterface * getScope(int row) const =0
Get ScopeInterface instance associated with a row.
unity::shell::scopes::ScopesInterface::count
int count
Interger specifying how many items are in the model.
Definition ScopesInterface.h:50
unity
Top-level namespace for all things Unity-related.
Definition Version.h:38