2
* Copyright 2014 Canonical Ltd.
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.
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.
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/>.
18
#include "sharedunitymenumodel.h"
19
#include "unitymenumodelcache.h"
21
#include <unitymenumodel.h>
23
SharedUnityMenuModel::SharedUnityMenuModel(QObject* parent)
28
QByteArray SharedUnityMenuModel::busName() const
33
void SharedUnityMenuModel::setBusName(const QByteArray& busName)
35
if (m_busName != busName) {
37
Q_EMIT busNameChanged();
42
QByteArray SharedUnityMenuModel::menuObjectPath() const
44
return m_menuObjectPath;
47
void SharedUnityMenuModel::setMenuObjectPath(const QByteArray& menuObjectPath)
49
if (m_menuObjectPath != menuObjectPath) {
50
m_menuObjectPath = menuObjectPath;
51
Q_EMIT menuObjectPathChanged();
56
QVariantMap SharedUnityMenuModel::actions() const
61
void SharedUnityMenuModel::setActions(const QVariantMap& actions)
63
if (m_actions != actions) {
65
Q_EMIT actionsChanged();
70
UnityMenuModel* SharedUnityMenuModel::model() const
72
return m_model ? m_model.data() : nullptr;
75
void SharedUnityMenuModel::initialize()
77
if (m_busName.isEmpty() || m_menuObjectPath.isEmpty() || m_actions.isEmpty()) {
78
if (!m_model.isNull()) {
80
Q_EMIT modelChanged();
83
QSharedPointer<UnityMenuModel> model = UnityMenuModelCache::singleton()->model(m_menuObjectPath);
84
if (model != m_model) {
85
if (model->busName() != m_busName) model->setBusName(m_busName);
86
if (model->actions() != m_actions) model->setActions(m_actions);
89
Q_EMIT modelChanged();