on 262fb79 help sign in
unity8/plugins/Unity/scopes.h.THIS
95 lines 2.4 kB history raw
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>
6 *
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.
10 *
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.
15 *
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/>.
18 */
20#ifndef SCOPES_H
21#define SCOPES_H
23// Qt
24#include <QAbstractListModel>
25#include <QList>
27// libunity-core
28#include <UnityCore/Scope.h>
29#include <UnityCore/GSettingsScopes.h>
31namespace unity
33namespace dash
35class Scopes;
39class Hotkey;
40class Scope;
42class Scopes : public QAbstractListModel
44 Q_OBJECT
46 Q_ENUMS(Roles)
48 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
50public:
51 explicit Scopes(QObject *parent = 0);
52 ~Scopes() = default;
54 enum Roles {
55 RoleScope,
56 RoleId,
57 RoleVisible,
58 RoleTitle
59 };
61 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
62 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
64 Q_INVOKABLE QVariant get(int row) const;
65 Q_INVOKABLE QVariant get(const QString& scope_id) const;
67 QHash<int, QByteArray> roleNames() const;
69 bool loaded() const;
71Q_SIGNALS:
72 void activateScopeRequested(const QString& scope_id);
73 void loadedChanged(bool loaded);
74 void scopeRemoved(const QString& scope_id, int index);
76private Q_SLOTS:
77 void onScopesLoaded();
78 void onScopeAdded(const unity::dash::Scope::Ptr& scope, int position);
79 void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
80 void onScopesReordered(const unity::dash::Scopes::ScopeList& scopes);
81 void onScopePropertyChanged();
83private:
84 unity::dash::GSettingsScopesReader::Ptr m_scopesReader;
85 unity::dash::Scopes::Ptr m_unityScopes;
86 QList<Scope*> m_scopes;
87 QHash<int, QByteArray> m_roles;
88 bool m_loaded;
90 void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
91 void removeUnityScope(int index);
92 int findScopeById(const QString& scope_id);
93};
95#endif // SCOPES_H