2
* Copyright (C) 2011 Canonical, Ltd.
5
* Florian Boucault <florian.boucault@canonical.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 3.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include <QAbstractListModel>
28
#include <UnityCore/Scope.h>
29
#include <UnityCore/GSettingsScopes.h>
42
class Scopes : public QAbstractListModel
48
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
51
explicit Scopes(QObject *parent = 0);
60
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
61
Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
63
Q_INVOKABLE QVariant get(int row) const;
64
Q_INVOKABLE QVariant get(const QString& scope_id) const;
66
QHash<int, QByteArray> roleNames() const;
71
void activateScopeRequested(const QString& scope_id);
72
void loadedChanged(bool loaded);
73
void scopeRemoved(const QString& scope_id, int index);
76
void onScopesLoaded();
77
void onScopeAdded(const unity::dash::Scope::Ptr& scope, int position);
78
void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
79
void onScopesReordered(const unity::dash::Scopes::ScopeList& scopes);
80
void onScopePropertyChanged();
83
unity::dash::GSettingsScopesReader::Ptr m_scopesReader;
84
unity::dash::Scopes::Ptr m_unityScopes;
85
QList<Scope*> m_scopes;
86
QHash<int, QByteArray> m_roles;
89
void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
90
void removeUnityScope(int index);
91
int findScopeById(const QString& scope_id);