on ac4b821 help sign in
unity8/tests/mocks/QMenuModel/unitymenumodel.h
96 lines 3.5 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 * Authors: Nick Dedekind <nick.dedekind@canonical.com>
17 */
19#ifndef MOCK_UNITYMENUMODEL_H
20#define MOCK_UNITYMENUMODEL_H
22#include <QAbstractListModel>
23class QQmlComponent;
24class UnityMenuAction;
25class ActionStateParser;
27class Q_DECL_EXPORT UnityMenuModel : public QAbstractListModel
29 Q_OBJECT
30 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
31 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
32 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
33 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
34 Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)
36public:
37 UnityMenuModel(QObject *parent = NULL);
38 virtual ~UnityMenuModel();
40 Q_INVOKABLE void insertRow(int row, const QVariant& data);
41 Q_INVOKABLE void appendRow(const QVariant& data);
42 Q_INVOKABLE void removeRow(int row);
44 QVariant modelData() const;
45 void setModelData(const QVariant& data);
47 QByteArray busName() const;
48 void setBusName(const QByteArray &busName);
50 QVariantMap actions() const;
51 void setActions(const QVariantMap &actions);
53 QByteArray menuObjectPath() const;
54 void setMenuObjectPath(const QByteArray &path);
56 ActionStateParser* actionStateParser() const;
57 void setActionStateParser(ActionStateParser* actionStateParser);
59 int rowCount(const QModelIndex &parent = QModelIndex()) const;
60 int columnCount(const QModelIndex &parent = QModelIndex()) const;
61 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
62 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
63 QModelIndex parent(const QModelIndex &index) const;
64 QHash<int, QByteArray> roleNames() const;
66 Q_INVOKABLE QObject * submenu(int position, QQmlComponent* actionStateParser = NULL);
67 Q_INVOKABLE bool loadExtendedAttributes(int position, const QVariantMap &schema);
68 Q_INVOKABLE QVariant get(int row, const QByteArray &role);
70 Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant());
71 Q_INVOKABLE void changeState(int index, const QVariant& parameter);
73 void registerAction(UnityMenuAction* action);
74 void unregisterAction(UnityMenuAction* action);
76Q_SIGNALS:
77 void busNameChanged();
78 void actionsChanged();
79 void menuObjectPathChanged();
80 void actionStateParserChanged();
81 void modelDataChanged();
83private:
84 QVariantMap rowData(int row) const;
85 QVariant subMenuData(int row) const;
87 class Row;
88 QVariantList m_modelData;
89 QList<UnityMenuModel*> submenus;
91 QByteArray m_busName;
92 QVariantMap m_actions;
93 QByteArray m_menuObjectPath;
94};
96#endif // MOCK_UNITYMENUMODEL_H