@@ -1,90 +0,0 @@
2− * Copyright (C) 2012, 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/>.
18−#include "visibleindicatorsmodel.h"
19−#include "indicators.h"
21−VisibleIndicatorsModel::VisibleIndicatorsModel(QObject *parent)
22− : QIdentityProxyModel(parent),
25− QObject::connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(onBeginRowInserted(QModelIndex, int, int)));
26− QObject::connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(onRowInserted(QModelIndex, int, int)));
29−QHash<int, QByteArray> VisibleIndicatorsModel::roleNames() const
31− static QHash<int, QByteArray> roles;
34− roles[IndicatorsModelRole::Identifier] = "identifier";
35− roles[IndicatorsModelRole::Position] = "position";
36− roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
37− roles[IndicatorsModelRole::IsVisible] = "isVisible";
42−void VisibleIndicatorsModel::setSourceModel(QAbstractItemModel *model)
44− if (sourceModel() != model) {
45− QIdentityProxyModel::setSourceModel(model);
46− Q_EMIT modelChanged();
50−QVariantMap VisibleIndicatorsModel::visible() const
55−void VisibleIndicatorsModel::onBeginRowInserted(const QModelIndex&, int, int)
60−void VisibleIndicatorsModel::onRowInserted(const QModelIndex&, int, int)
65−void VisibleIndicatorsModel::setVisible(const QVariantMap& visible)
67− if (m_visible != visible) {
69− Q_EMIT visibleChanged();
71− // need to tell the view that the visible data has changed.
72− if (!m_inserting && rowCount() > 0) {
73− Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << IndicatorsModelRole::IsVisible);
78−QVariant VisibleIndicatorsModel::data(const QModelIndex &index, int role) const
80− if (role != IndicatorsModelRole::IsVisible) {
81− return QIdentityProxyModel::data(index, role);
84− if (!index.isValid()) {
88− QString ident = QIdentityProxyModel::data(index, IndicatorsModelRole::Identifier).toString();
89− return m_visible.value(ident, false).toBool();