on e82caeb help sign in
101 lines 2.6 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"
22#include <QStringList>
24Indicator::Indicator(QObject *parent)
25 : QObject(parent),
26 m_position(0)
30Indicator::~Indicator()
34void Indicator::init(const QString& busName, const QSettings& settings)
36 setId(settings.value("Indicator Service/Name").toString());
37 setPosition(settings.value("Indicator Service/Position", QVariant::fromValue(0)).toInt());
39 QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
41 QVariantMap mapMenuObjectPaths;
42 Q_FOREACH(const QString& childGroup, settings.childGroups())
43 {
44 if (childGroup == "Indicator Service")
45 continue;
47 QString menuPath = childGroup+"/ObjectPath";
48 if (settings.contains(menuPath))
49 {
50 mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
51 }
52 }
54 QVariantMap properties;
55 properties.clear();
56 properties.insert("busType", 1);
57 properties.insert("busName", busName);
58 properties.insert("actionsObjectPath", actionObjectPath);
59 properties.insert("menuObjectPaths", mapMenuObjectPaths);
60 setIndicatorProperties(properties);
63QString Indicator::identifier() const
65 return m_identifier;
68void Indicator::setId(const QString &identifier)
70 if (identifier != m_identifier) {
71 m_identifier = identifier;
72 Q_EMIT identifierChanged(m_identifier);
73 }
76int Indicator::position() const
78 return m_position;
81void Indicator::setPosition(int position)
83 if (position != m_position) {
84 m_position = position;
85 Q_EMIT positionChanged(m_position);
86 }
89QVariant Indicator::indicatorProperties() const
91 return m_properties;
94void Indicator::setIndicatorProperties(const QVariant &properties)
96 if (m_properties != properties)
97 {
98 m_properties = properties;
99 Q_EMIT indicatorPropertiesChanged(m_properties);
100 }