on ac4b821 help sign in
unity8/tests/mocks/Unity/fake_scopes.h
80 lines 2.0 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
19#ifndef FAKE_SCOPES_H
20#define FAKE_SCOPES_H
22// Local
23#include "fake_scope.h"
25// Qt
26#include <QAbstractListModel>
27#include <QList>
28#include <QTimer>
30class Scopes : public QAbstractListModel
32 Q_OBJECT
33 Q_ENUMS(Roles)
34 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
37public:
38 explicit Scopes(QObject *parent = 0);
39 ~Scopes();
41 enum Roles {
42 RoleScope,
43 RoleId,
44 RoleVisible,
45 RoleTitle
46 };
48 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
50 Q_INVOKABLE QVariant get(int row) const;
51 Q_INVOKABLE QVariant get(const QString& scope_id) const;
53 Q_INVOKABLE void addScope(Scope* scope);
55 Q_INVOKABLE void clear();
56 Q_INVOKABLE void load();
58 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
59 QHash<int, QByteArray> roleNames() const;
60 QModelIndex parent ( const QModelIndex & index ) const;
62 bool loaded() const;
63 int count() const;
65Q_SIGNALS:
66 void activateScopeRequested(const QString& scope_id);
67 void loadedChanged(bool);
68 void countChanged();
70private Q_SLOTS:
71 void updateScopes();
73private:
74 QList<Scope*> m_scopes;
75 QHash<int, QByteArray> m_roles;
76 bool m_loaded;
77 QTimer timer;
78};
80#endif // SCOPES_H