2008-01-25 01:04:03 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dataenginescript.h"
|
|
|
|
|
|
|
|
#include "dataengine.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class DataEngineScript::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataEngine* dataEngine;
|
|
|
|
};
|
|
|
|
|
|
|
|
DataEngineScript::DataEngineScript(QObject *parent)
|
|
|
|
: ScriptEngine(parent),
|
2008-02-04 05:41:40 +01:00
|
|
|
d(new Private)
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DataEngineScript::~DataEngineScript()
|
|
|
|
{
|
|
|
|
// delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::setDataEngine(DataEngine *dataEngine)
|
|
|
|
{
|
|
|
|
d->dataEngine = dataEngine;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataEngine* DataEngineScript::dataEngine() const
|
|
|
|
{
|
|
|
|
return d->dataEngine;
|
|
|
|
}
|
|
|
|
|
2008-02-04 05:41:40 +01:00
|
|
|
bool DataEngineScript::sourceRequested(const QString &name)
|
|
|
|
{
|
|
|
|
Q_UNUSED(name)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataEngineScript::updateSource(const QString& source)
|
|
|
|
{
|
|
|
|
Q_UNUSED(source)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::setData(const QString& source, const QString& key,
|
|
|
|
const QVariant& value)
|
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
|
|
|
d->dataEngine->setData(source, key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::setData(const QString &source, const QVariant &value)
|
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
|
|
|
d->dataEngine->setData(source, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::clearData(const QString& source)
|
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 10:10:30 +02:00
|
|
|
d->dataEngine->removeAllData(source);
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::removeData(const QString& source, const QString& key)
|
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
|
|
|
d->dataEngine->removeData(source, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-25 18:17:33 +02:00
|
|
|
void DataEngineScript::setMaxSourceCount(uint limit)
|
2008-04-24 22:16:21 +02:00
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-25 18:17:33 +02:00
|
|
|
d->dataEngine->setMaxSourceCount(limit);
|
2008-04-24 22:16:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 04:21:22 +02:00
|
|
|
void DataEngineScript::setMinimumPollingInterval(int minimumMs)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 04:21:22 +02:00
|
|
|
d->dataEngine->setMinimumPollingInterval(minimumMs);
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 04:21:22 +02:00
|
|
|
int DataEngineScript::minimumPollingInterval() const
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 04:21:22 +02:00
|
|
|
return d->dataEngine->minimumPollingInterval();
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-24 04:21:22 +02:00
|
|
|
void DataEngineScript::setPollingInterval(uint frequency)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 04:21:22 +02:00
|
|
|
d->dataEngine->setPollingInterval(frequency);
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::clearSources()
|
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 08:38:14 +02:00
|
|
|
d->dataEngine->removeAllSources();
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:04:03 +01:00
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#include "dataenginescript.moc"
|