2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
20#include "fake_scopes.h"
21#include "fake_scopesoverview.h"
23// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
28Scopes::Scopes(QObject *parent)
29 : unity::shell::scopes::ScopesInterface(parent)
30 , m_scopesOverview(nullptr)
34 timer.setSingleShot(true);
35 timer.setInterval(100);
36 QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateScopes()));
44void Scopes::updateScopes()
47 addScope(new Scope("MockScope1", "People", true, this));
48 addScope(new Scope("MockScope2", "Music", false, this));
49 addScope(new Scope("clickscope", "Apps", true, this));
50 addScope(new Scope("MockScope5", "Videos", true, this));
51 addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
52 addScope(new Scope("MockScope4", "MS4", true, this));
53 addScope(new Scope("MockScope6", "MS6", true, this));
54 addScope(new Scope("MockScope7", "MS7", false, this));
55 addScope(new Scope("MockScope8", "MS8", false, this));
56 addScope(new Scope("MockScope9", "MS9", false, this));
57 m_scopesOverview = new ScopesOverview(this);
61 Q_EMIT loadedChanged();
62 Q_EMIT overviewScopeChanged();
69 if (m_scopes.size() > 0) {
70 beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
75 delete m_scopesOverview;
76 m_scopesOverview = nullptr;
80 Q_EMIT loadedChanged();
89int Scopes::rowCount(const QModelIndex&) const
91 return m_scopes.count();
94QVariant Scopes::data(const QModelIndex& index, int role) const
96 if (!index.isValid() || index.row() >= m_scopes.size()) {
100 Scope* scope = m_scopes.at(index.row());
102 if (role == Scopes::RoleScope) {
103 return QVariant::fromValue(scope);
104 } else if (role == Scopes::RoleId) {
105 return QVariant::fromValue(scope->id());
106 } else if (role == Scopes::RoleVisible) {
107 return QVariant::fromValue(scope->visible());
108 } else if (role == Scopes::RoleTitle) {
109 return QVariant::fromValue(scope->name());
115unity::shell::scopes::ScopeInterface* Scopes::getScope(int row) const
117 if (row < 0 || row >= m_scopes.size()) {
121 return m_scopes[row];
124unity::shell::scopes::ScopeInterface* Scopes::getScope(QString const &scope_id) const
126 for (Scope *scope : m_scopes) {
127 // According to mh3 Scopes::getScope should only return non null for visible scopes
128 if (scope->id() == scope_id && scope->visible())
134unity::shell::scopes::ScopeInterface* Scopes::getScopeFromAll(const QString& scope_id) const
136 for (Scope *scope : m_scopes) {
137 if (scope->id() == scope_id)
143QModelIndex Scopes::parent(const QModelIndex&) const
145 return QModelIndex();
148bool Scopes::loaded() const
153unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
155 return m_scopesOverview;
158QList<unity::shell::scopes::ScopeInterface *> Scopes::scopes(bool onlyVisible) const
160 QList<unity::shell::scopes::ScopeInterface *> res;
161 for (Scope *scope : m_scopes) {
162 if (!onlyVisible || scope->visible()) {
169void Scopes::addScope(Scope* scope)
171 int index = rowCount();
172 beginInsertRows(QModelIndex(), index, index);
173 m_scopes.append(scope);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list