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 * Author: Nick Dedekind <nick.dedekind@canonical.com>
20#include "unitymenumodelpaths.h"
21#include <QDBusArgument>
23static QVariant parseVariantData(const QVariant& var);
25const QDBusArgument &operator>>(const QDBusArgument &arg, QVariantMap &map)
29 while (!arg.atEnd()) {
35 map.insertMulti(key, parseVariantData(value)); // re-parse for qdbusargument
43static QVariant parseVariantData(const QVariant& var) {
44 if ((int)var.type() == QMetaType::User && var.userType() == qMetaTypeId<QDBusArgument>()) {
45 QDBusArgument arg(var.value<QDBusArgument>());
46 if (arg.currentType() == QDBusArgument::MapType) {
51 return arg.asVariant();
57UnityMenuModelPaths::UnityMenuModelPaths(QObject *parent)
62QVariant UnityMenuModelPaths::source() const
67void UnityMenuModelPaths::setSource(const QVariant& data)
69 if (m_sourceData != data) {
71 Q_EMIT sourceChanged();
77void UnityMenuModelPaths::updateData()
79 QVariantMap dataMap = parseVariantData(m_sourceData).toMap();
81 if (!m_busNameHint.isEmpty() && dataMap.contains(m_busNameHint)) {
82 setBusName(dataMap[m_busNameHint].toByteArray());
87 if (!m_menuObjectPathHint.isEmpty() && dataMap.contains(m_menuObjectPathHint)) {
88 setMenuObjectPath(dataMap[m_menuObjectPathHint].toByteArray());
90 setMenuObjectPath("");
93 if (!m_actionsHint.isEmpty() && dataMap.contains(m_actionsHint)) {
94 setActions(dataMap[m_actionsHint].toMap());
96 setActions(QVariantMap());
100QByteArray UnityMenuModelPaths::busName() const
105void UnityMenuModelPaths::setBusName(const QByteArray &name)
107 if (m_busName != name) {
109 Q_EMIT busNameChanged();
113QVariantMap UnityMenuModelPaths::actions() const
118void UnityMenuModelPaths::setActions(const QVariantMap &actions)
120 if (m_actions != actions) {
122 Q_EMIT actionsChanged();
126QByteArray UnityMenuModelPaths::menuObjectPath() const
128 return m_menuObjectPath;
131void UnityMenuModelPaths::setMenuObjectPath(const QByteArray &path)
133 if (m_menuObjectPath != path) {
134 m_menuObjectPath = path;
135 Q_EMIT menuObjectPathChanged();
139QByteArray UnityMenuModelPaths::busNameHint() const
141 return m_busNameHint;
144void UnityMenuModelPaths::setBusNameHint(const QByteArray &nameHint)
146 if (m_busNameHint != nameHint) {
147 m_busNameHint = nameHint;
148 Q_EMIT busNameHintChanged();
154QByteArray UnityMenuModelPaths::actionsHint() const
156 return m_actionsHint;
159void UnityMenuModelPaths::setActionsHint(const QByteArray &actionsHint)
161 if (m_actionsHint != actionsHint) {
162 m_actionsHint = actionsHint;
163 Q_EMIT actionsHintChanged();
169QByteArray UnityMenuModelPaths::menuObjectPathHint() const
171 return m_menuObjectPathHint;
174void UnityMenuModelPaths::setMenuObjectPathHint(const QByteArray &pathHint)
176 if (m_menuObjectPathHint != pathHint) {
177 m_menuObjectPathHint = pathHint;
178 Q_EMIT menuObjectPathHintChanged();
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