on 1aca428 help sign in
103 lines 2.7 kB history raw
1/*
2 * Copyright 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 Lesser 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 Lesser General Public License for more details.
12 *
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/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
20#include "indicator.h"
21#include "cachedunitymenumodel.h"
23#include <QStringList>
24#include <unitymenumodel.h>
26Indicator::Indicator(QObject *parent)
27 : QObject(parent),
28 m_position(0)
32Indicator::~Indicator()
36void Indicator::init(const QString& busName, const QSettings& settings)
38 setId(settings.value("Indicator Service/Name").toString());
39 setPosition(settings.value("Indicator Service/Position", QVariant::fromValue(0)).toInt());
41 QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
43 QVariantMap mapMenuObjectPaths;
44 Q_FOREACH(const QString& childGroup, settings.childGroups())
45 {
46 if (childGroup == "Indicator Service")
47 continue;
49 QString menuPath = childGroup+"/ObjectPath";
50 if (settings.contains(menuPath))
51 {
52 mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
53 }
54 }
56 QVariantMap properties;
57 properties.clear();
58 properties.insert("busType", 1);
59 properties.insert("busName", busName);
60 properties.insert("actionsObjectPath", actionObjectPath);
61 properties.insert("menuObjectPaths", mapMenuObjectPaths);
62 setIndicatorProperties(properties);
65QString Indicator::identifier() const
67 return m_identifier;
70void Indicator::setId(const QString &identifier)
72 if (identifier != m_identifier) {
73 m_identifier = identifier;
74 Q_EMIT identifierChanged(m_identifier);
75 }
78int Indicator::position() const
80 return m_position;
83void Indicator::setPosition(int position)
85 if (position != m_position) {
86 m_position = position;
87 Q_EMIT positionChanged(m_position);
88 }
91QVariant Indicator::indicatorProperties() const
93 return m_properties;
96void Indicator::setIndicatorProperties(const QVariant &properties)
98 if (m_properties != properties)
99 {
100 m_properties = properties;
101 Q_EMIT indicatorPropertiesChanged(m_properties);
102 }