on a142f21 help sign in
unity8/tests/mocks/Unity/Indicators/fakeindicatorsmodel.h
71 lines 2.3 kB history 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 <nick.dedekind@canonical.com>
18 */
20#ifndef FAKE_INDICATORSMODEL_H
21#define FAKE_INDICATORSMODEL_H
23#include <QAbstractListModel>
25class FakeIndicatorsModel : public QAbstractListModel
27 Q_OBJECT
28 Q_ENUMS(Roles)
29 Q_PROPERTY(int count READ count NOTIFY countChanged)
30 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
31 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
33public:
35 FakeIndicatorsModel(QObject *parent=0);
36 ~FakeIndicatorsModel();
38 Q_INVOKABLE void load(const QString& profile);
39 Q_INVOKABLE void unload();
41 Q_INVOKABLE void append(const QVariantMap& row);
42 Q_INVOKABLE void insert(int row, const QVariantMap& data);
43 Q_INVOKABLE void remove(int row);
45 Q_INVOKABLE QVariant data(int row, int role) const;
47 QString profile() const;
48 void setProfile(const QString& profile);
49 void setModelData(const QVariant& data);
50 QVariant modelData() const { return m_modelData; }
52 /* QAbstractItemModel */
53 QHash<int, QByteArray> roleNames() const override;
54 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
55 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
56 QModelIndex parent (const QModelIndex &index) const override;
57 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
59Q_SIGNALS:
60 void countChanged();
61 void profileChanged();
62 void modelDataChanged();
64private:
65 int count() const;
67 QString m_profile;
68 QVariant m_modelData;
69};
71#endif // FAKE_INDICATORSMODEL_H