on fbbd0a0 help sign in
unity8/plugins/Unity/Indicators/indicatorsmodel.h
82 lines 2.6 kB history raw
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
19 */
21#ifndef INDICATORSMODEL_H
22#define INDICATORSMODEL_H
24#include "indicator.h"
25#include "unityindicatorsglobal.h"
27#include <QAbstractListModel>
28#include <QQmlEngine>
30class IndicatorsManager;
32class UNITYINDICATORS_EXPORT IndicatorsModel : public QAbstractListModel
34 Q_OBJECT
35 Q_ENUMS(Roles)
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
37 Q_PROPERTY(QVariant indicatorData READ indicatorData WRITE setIndicatorData NOTIFY indicatorDataChanged)
39public:
41 IndicatorsModel(QObject *parent=0);
42 ~IndicatorsModel();
44 Q_INVOKABLE void load();
45 Q_INVOKABLE void unload();
47 Q_INVOKABLE QVariant data(int row, int role = Qt::DisplayRole) const;
49 /* QAbstractItemModel */
50 QHash<int, QByteArray> roleNames() const;
51 int columnCount(const QModelIndex &parent = QModelIndex()) const;
52 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
53 QModelIndex parent (const QModelIndex &index) const;
54 int rowCount(const QModelIndex &parent = QModelIndex()) const;
56 void setIndicatorData(const QVariant& data);
57 QVariant indicatorData() const;
59Q_SIGNALS:
60 void countChanged();
61 void indicatorDataChanged(const QVariant& data);
63private Q_SLOTS:
64 void onIdentifierChanged();
65 void onIndicatorPropertiesChanged();
66 void onIndicatorLoaded(const QString& indicator);
67 void onIndicatorAboutToBeUnloaded(const QString& indicator);
69private:
70 IndicatorsManager *m_manager;
72 QList<Indicator::Ptr> m_indicators;
73 QVariant m_indicator_data;
74 QMap<QString, QVariantMap> m_parsed_indicator_data;
76 void notifyDataChanged(QObject *sender, int role);
77 int count() const;
78 QVariant indicatorData(const Indicator::Ptr& indicator, int role) const;
79 static QVariant defaultData(Indicator::Ptr indicator, int role);
80};
82#endif // INDICATORSMODEL_H