Debian Codegraph @

tests/mocks/Lomiri/Indicators/fakeindicatorsmodel.h

raw
1 /*
2 * Copyright 2014 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 * Nick Dedekind <[email protected]>
18 */
19
20 #ifndef FAKE_INDICATORSMODEL_H
21 #define FAKE_INDICATORSMODEL_H
22
23 #include <QAbstractListModel>
24
25 class FakeIndicatorsModel : public QAbstractListModel
26 {
27 Q_OBJECT
28 Q_PROPERTY(int count READ count NOTIFY countChanged)
29 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
30 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
31
32 public:
33
34 FakeIndicatorsModel(QObject *parent=0);
35 ~FakeIndicatorsModel();
36
37 Q_INVOKABLE void load(const QString& profile);
38 Q_INVOKABLE void unload();
39
40 Q_INVOKABLE void append(const QVariantMap& row);
41 Q_INVOKABLE void insert(int row, const QVariantMap& data);
42 Q_INVOKABLE void remove(int row);
43
44 Q_INVOKABLE QVariant data(int row, int role) const;
45
46 QString profile() const;
47 void setProfile(const QString& profile);
48 void setModelData(const QVariant& data);
49 QVariant modelData() const { return m_modelData; }
50
51 /* QAbstractItemModel */
52 QHash<int, QByteArray> roleNames() const override;
53 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
54 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
55 QModelIndex parent (const QModelIndex &index) const override;
56 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
57
58 Q_SIGNALS:
59 void countChanged();
60 void profileChanged();
61 void modelDataChanged();
62
63 private:
64 int count() const;
65
66 QString m_profile;
67 QVariant m_modelData;
68 };
69
70 #endif // FAKE_INDICATORSMODEL_H