2 * Copyright 2014 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Nick Dedekind <nick.dedekind@canonical.com>
20#include "fakeindicatorsmodel.h"
21#include "indicators.h"
23FakeIndicatorsModel::FakeIndicatorsModel(QObject *parent)
24 : QAbstractListModel(parent)
26 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
27 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
28 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
32FakeIndicatorsModel::~FakeIndicatorsModel()
34 qDeleteAll(m_indicators);
37int FakeIndicatorsModel::count() const
42void FakeIndicatorsModel::load(const QString&)
46void FakeIndicatorsModel::unload()
50 qDeleteAll(m_indicators);
57void FakeIndicatorsModel::append(const QVariantMap& row)
59 Indicator* new_row = new QHash<int, QVariant>();
60 for (auto iter = row.begin(); iter != row.end(); ++iter )
62 int key = roleNames().key(iter.key().toUtf8(), -1);
64 new_row->insert(key, iter.value());
68 beginInsertRows(QModelIndex(), m_indicators.count(), m_indicators.count());
70 m_indicators.append(new_row);
75QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const
77 static QHash<int, QByteArray> roles;
80 roles[IndicatorsModelRole::Identifier] = "identifier";
81 roles[IndicatorsModelRole::Position] = "position";
82 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
83 roles[IndicatorsModelRole::PageSource] = "pageSource";
84 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
89int FakeIndicatorsModel::columnCount(const QModelIndex &) const
94Q_INVOKABLE QVariant FakeIndicatorsModel::data(int row, int role) const
96 return data(index(row, 0), role);
99QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const
101 if (!index.isValid() || index.row() >= m_indicators.size())
104 Indicator* indicator = m_indicators[index.row()];
105 return indicator->value(role, QVariant());
108QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const
110 return QModelIndex();
113int FakeIndicatorsModel::rowCount(const QModelIndex&) const
115 return m_indicators.count();
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