Lomiri
Loading...
Searching...
No Matches
indicatorsmodel.h
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 */
20
21#ifndef INDICATORSMODEL_H
22#define INDICATORSMODEL_H
23
24#include "indicator.h"
25#include "lomiriindicatorsglobal.h"
26
27#include <QAbstractListModel>
28#include <QQmlEngine>
29
30class IndicatorsManager;
31
32class LOMIRIINDICATORS_EXPORT IndicatorsModel : public QAbstractListModel
33{
34 Q_OBJECT
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
37
38 // Used for tests
39 Q_PROPERTY(bool light READ light WRITE setLight NOTIFY lightChanged)
40
41public:
42
43 IndicatorsModel(QObject *parent=nullptr);
44 ~IndicatorsModel();
45
46 Q_INVOKABLE void load();
47 Q_INVOKABLE void unload();
48
49 Q_INVOKABLE QVariant data(int row, int role) const;
50
51 QString profile() const;
52 void setProfile(const QString& profile);
53
54 bool light() const;
55 void setLight(const bool &light);
56
57 /* QAbstractItemModel */
58 QHash<int, QByteArray> roleNames() const override;
59 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
60 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
61 QModelIndex parent (const QModelIndex &index) const override;
62 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
63
64
65Q_SIGNALS:
66 void countChanged();
67 void profileChanged();
68 void indicatorDataChanged(const QVariant& data);
69 void lightChanged();
70
71private Q_SLOTS:
72 void onIdentifierChanged();
73 void onIndicatorPropertiesChanged();
74 void onIndicatorLoaded(const QString& indicator);
75 void onIndicatorAboutToBeUnloaded(const QString& indicator);
76
77private:
78 IndicatorsManager *m_manager;
79
80 QList<Indicator::Ptr> m_indicators;
81
82 void notifyDataChanged(QObject *sender, int role);
83 int count() const;
84
85 bool m_light;
86};
87
88#endif // INDICATORSMODEL_H