~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to tests/mocks/Unity/Indicators/fakeindicatorsmodel.h

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
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_ENUMS(Roles)
 
29
    Q_PROPERTY(int count READ count NOTIFY countChanged)
 
30
public:
 
31
 
 
32
    FakeIndicatorsModel(QObject *parent=0);
 
33
    ~FakeIndicatorsModel();
 
34
 
 
35
    Q_INVOKABLE void load(const QString& profile);
 
36
    Q_INVOKABLE void unload();
 
37
 
 
38
    Q_INVOKABLE void append(const QVariantMap& row);
 
39
 
 
40
    Q_INVOKABLE QVariant data(int row, int role) const;
 
41
 
 
42
    /* QAbstractItemModel */
 
43
    QHash<int, QByteArray> roleNames() const;
 
44
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
45
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
46
    QModelIndex parent (const QModelIndex &index) const;
 
47
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
48
 
 
49
Q_SIGNALS:
 
50
    void countChanged();
 
51
 
 
52
private:
 
53
    int count() const;
 
54
 
 
55
    typedef QHash<int, QVariant> Indicator;
 
56
    QList<Indicator*> m_indicators;
 
57
};
 
58
 
 
59
#endif // FAKE_INDICATORSMODEL_H