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"
23#include "fake_applications_scope.h"
25// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
30Scopes::Scopes(QObject *parent)
31: QAbstractListModel(parent)
35 m_roles[Scopes::RoleScope] = "scope";
36 m_roles[Scopes::RoleId] = "id";
37 m_roles[Scopes::RoleVisible] = "visible";
39 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
40 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
41 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
43 timer.setSingleShot(true);
44 timer.setInterval(100);
45 QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateScopes()));
53void Scopes::updateScopes()
56 addScope(new Scope("MockScope1", "People", true, this));
57 addScope(new Scope("MockScope2", "Music", false, this));
58 addScope(new Scope("home.scope", "Home", true, this));
59 addScope(new ApplicationsScope(true, this));
60 addScope(new Scope("MockScope5", "Videos", true, this));
64 Q_EMIT loadedChanged(m_loaded);
71 if (m_scopes.size() > 0) {
72 beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
80 Q_EMIT loadedChanged(m_loaded);
89QHash<int, QByteArray> Scopes::roleNames() const
94int Scopes::rowCount(const QModelIndex&) const
96 return m_scopes.count();
99QVariant Scopes::data(const QModelIndex& index, int role) const
101 if (!index.isValid() || index.row() >= m_scopes.size()) {
105 Scope* scope = m_scopes.at(index.row());
107 if (role == Scopes::RoleScope) {
108 return QVariant::fromValue(scope);
109 } else if (role == Scopes::RoleId) {
110 return QVariant::fromValue(scope->id());
111 } else if (role == Scopes::RoleVisible) {
112 return QVariant::fromValue(scope->visible());
118QVariant Scopes::get(int row) const
120 return data(QAbstractListModel::index(row), 0);
123QVariant Scopes::get(QString const&) const
128QModelIndex Scopes::parent(const QModelIndex&) const
130 return QModelIndex();
133bool Scopes::loaded() const
138int Scopes::count() const
143void Scopes::addScope(Scope* scope)
145 int index = rowCount();
146 beginInsertRows(QModelIndex(), index, index);
147 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