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_lenses.h"
22// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
27Lenses::Lenses(QObject *parent)
28: QAbstractListModel(parent)
32 m_roles[Lenses::RoleLens] = "lens";
33 m_roles[Lenses::RoleId] = "id";
34 m_roles[Lenses::RoleVisible] = "visible";
36 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
37 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
38 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
40 timer.setSingleShot(true);
41 timer.setInterval(100);
42 QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateLenses()));
50void Lenses::updateLenses()
53 addLens(new Lens("MockLens1", "People", true, this));
54 addLens(new Lens("MockLens2", "Music", false, this));
55 addLens(new Lens("MockLens3", "Home", true, this));
56 addLens(new Lens("MockLens4", "Applications", true, this));
57 addLens(new Lens("MockLens5", "Videos", true, this));
61 Q_EMIT loadedChanged(m_loaded);
68 if (m_lenses.size() > 0) {
69 beginRemoveRows(QModelIndex(), 0, m_lenses.count()-1);
77 Q_EMIT loadedChanged(m_loaded);
86QHash<int, QByteArray> Lenses::roleNames() const
91int Lenses::rowCount(const QModelIndex&) const
93 return m_lenses.count();
96QVariant Lenses::data(const QModelIndex& index, int role) const
98 if (!index.isValid() || index.row() >= m_lenses.size()) {
102 Lens* lens = m_lenses.at(index.row());
104 if (role == Lenses::RoleLens) {
105 return QVariant::fromValue(lens);
106 } else if (role == Lenses::RoleId) {
107 return QVariant::fromValue(lens->id());
108 } else if (role == Lenses::RoleVisible) {
109 return QVariant::fromValue(lens->visible());
115QVariant Lenses::get(int row) const
117 return data(QAbstractListModel::index(row), 0);
120QVariant Lenses::get(QString const&) const
125QModelIndex Lenses::parent(const QModelIndex&) const
127 return QModelIndex();
130bool Lenses::loaded() const
135int Lenses::count() const
140void Lenses::addLens(Lens* lens)
142 int index = rowCount();
143 beginInsertRows(QModelIndex(), index, index);
144 m_lenses.append(lens);
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