2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
16 * Authors: Nick Dedekind <nick.dedekind@canonical.com>
19#ifndef MOCK_UNITYMENUMODEL_H
20#define MOCK_UNITYMENUMODEL_H
22#include <QAbstractListModel>
25class ActionStateParser;
27class Q_DECL_EXPORT UnityMenuModel : public QAbstractListModel
30 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
31 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
32 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
33 Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)
34 Q_PROPERTY(QString nameOwner READ nameOwner NOTIFY nameOwnerChanged)
36 // internal mock properties
37 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
40 UnityMenuModel(QObject *parent = nullptr);
41 virtual ~UnityMenuModel();
43 Q_INVOKABLE void insertRow(int row, const QVariant& data);
44 Q_INVOKABLE void appendRow(const QVariant& data);
45 Q_INVOKABLE void removeRow(int row);
47 QVariant modelData() const;
48 void setModelData(const QVariant& data);
50 QByteArray busName() const;
51 void setBusName(const QByteArray &busName);
53 QVariantMap actions() const;
54 void setActions(const QVariantMap &actions);
56 QByteArray menuObjectPath() const;
57 void setMenuObjectPath(const QByteArray &path);
59 ActionStateParser* actionStateParser() const;
60 void setActionStateParser(ActionStateParser* actionStateParser);
62 QString nameOwner() const;
64 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
65 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
66 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
67 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
68 QModelIndex parent(const QModelIndex &index) const override;
69 QHash<int, QByteArray> roleNames() const override;
71 Q_INVOKABLE QObject * submenu(int position, QQmlComponent* actionStateParser = nullptr);
72 Q_INVOKABLE bool loadExtendedAttributes(int position, const QVariantMap &schema);
73 Q_INVOKABLE QVariant get(int row, const QByteArray &role);
75 Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant());
76 Q_INVOKABLE void changeState(int index, const QVariant& parameter);
78 void registerAction(UnityMenuAction* action);
79 void unregisterAction(UnityMenuAction* action);
82 void busNameChanged();
83 void actionsChanged();
84 void menuObjectPathChanged();
85 void actionStateParserChanged();
86 void nameOwnerChanged();
88 // Internal mock usage
89 void modelDataChanged();
92 QVariantMap rowData(int row) const;
93 QVariant subMenuData(int row) const;
96 QVariantList m_modelData;
97 QList<UnityMenuModel*> submenus;
100 QVariantMap m_actions;
101 QByteArray m_menuObjectPath;
104#endif // MOCK_UNITYMENUMODEL_H
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list