2
Copyright (c) 2007 Zack Rusin <zack@kde.org>
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
#include "plasmawebapplet.h"
25
#include <Plasma/DataEngine>
27
using namespace Plasma;
29
ConfigGroupWrapper::ConfigGroupWrapper(const KConfigGroup &config)
34
void ConfigGroupWrapper::setConfig(const KConfigGroup &config)
36
//kDebug() << config.config()->name() << config.name();
40
QVariant ConfigGroupWrapper::readEntry(const QString &key, const QVariant &aDefault) const
42
// Should KConfig do this?
43
// There is readEntry(key, QVariant) but it does not seem to work
44
// (if writeEntry was not QVariant??)
45
// kDebug() << aDefault.typeName();
46
if (aDefault.type() == QVariant::Int) {
47
return m_config.readEntry(key, aDefault.toInt());
48
} else if (aDefault.type() == QVariant::Double) {
49
return m_config.readEntry(key, aDefault.toDouble());
50
} else if (aDefault.type() == QVariant::Bool) {
51
return m_config.readEntry(key, aDefault.toBool());
53
return m_config.readEntry(key, aDefault.toString());
57
void ConfigGroupWrapper::writeEntry(const QString &key, const QVariant& value)
59
m_config.writeEntry(key, value);
62
DataEngineDataWrapper::DataEngineDataWrapper(const DataEngine::Data &data)
67
int DataEngineDataWrapper::length() const
69
return m_data.count();
72
void DataEngineDataWrapper::setData(const Plasma::DataEngine::Data &data)
77
QVariant DataEngineDataWrapper::value(const QString &key) const
82
bool DataEngineDataWrapper::contains(const QString &key) const
84
return m_data.keys().contains(key);
87
QStringList DataEngineDataWrapper::keys() const
92
QString DataEngineDataWrapper::key(int i) const
94
return m_data.keys().at(i);
97
DataEngineWrapper::DataEngineWrapper(Plasma::DataEngine *engine, QObject *applet)
98
: QObject(engine), m_engine(engine), m_applet(applet)
102
QStringList DataEngineWrapper::sources() const
104
return m_engine->sources();
107
QString DataEngineWrapper::engineName() const
109
return m_engine->name();
112
bool DataEngineWrapper::isValid() const
114
return m_engine->isValid();
117
QString DataEngineWrapper::icon() const
119
return m_engine->icon();
122
QObject * DataEngineWrapper::query(const QString &str) const
124
DataEngine::Data data = m_engine->query(str);
125
return new DataEngineDataWrapper(data);
128
DataEngineWrapper::~DataEngineWrapper()
132
void DataEngineWrapper::connectSource(const QString& source,
133
uint pollingInterval, uint intervalAlignment)
136
m_engine->connectSource(source, m_applet, pollingInterval,
137
(Plasma::IntervalAlignment)intervalAlignment);
141
#include "plasmajs.moc"