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
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class DataEngineScriptPrivate
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
public:
|
2008-10-12 03:39:10 +02:00
|
|
|
DataEngine *dataEngine;
|
2008-01-25 01:04:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DataEngineScript::DataEngineScript(QObject *parent)
|
|
|
|
: ScriptEngine(parent),
|
2008-07-01 20:56:43 +02:00
|
|
|
d(new DataEngineScriptPrivate)
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DataEngineScript::~DataEngineScript()
|
|
|
|
{
|
|
|
|
// delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataEngineScript::setDataEngine(DataEngine *dataEngine)
|
|
|
|
{
|
|
|
|
d->dataEngine = dataEngine;
|
|
|
|
}
|
|
|
|
|
2008-10-12 03:39:10 +02:00
|
|
|
DataEngine *DataEngineScript::dataEngine() const
|
2008-01-25 01:04:03 +01:00
|
|
|
{
|
|
|
|
return d->dataEngine;
|
|
|
|
}
|
|
|
|
|
2008-11-03 21:23:31 +01:00
|
|
|
QStringList DataEngineScript::sources() const
|
|
|
|
{
|
|
|
|
return d->dataEngine->sources();
|
|
|
|
}
|
|
|
|
|
2008-04-26 14:59:44 +02:00
|
|
|
bool DataEngineScript::sourceRequestEvent(const QString &name)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
2008-10-12 03:39:10 +02:00
|
|
|
Q_UNUSED(name);
|
2008-02-04 05:41:40 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-12 03:39:10 +02:00
|
|
|
bool DataEngineScript::updateSourceEvent(const QString &source)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
2008-10-12 03:39:10 +02:00
|
|
|
Q_UNUSED(source);
|
2008-02-04 05:41:40 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-11-03 21:23:31 +01:00
|
|
|
Service *DataEngineScript::serviceForSource(const QString &source)
|
|
|
|
{
|
|
|
|
return d->dataEngine->serviceForSource(source);
|
|
|
|
}
|
|
|
|
|
2008-10-12 03:39:10 +02:00
|
|
|
void DataEngineScript::setData(const QString &source, const QString &key,
|
|
|
|
const QVariant &value)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 03:39:10 +02:00
|
|
|
void DataEngineScript::removeAllData(const QString &source)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
if (d->dataEngine) {
|
2008-04-24 10:10:30 +02:00
|
|
|
d->dataEngine->removeAllData(source);
|
2008-02-04 05:41:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 03:39:10 +02:00
|
|
|
void DataEngineScript::removeData(const QString &source, const QString &key)
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-26 14:30:42 +02:00
|
|
|
void DataEngineScript::removeAllSources()
|
2008-02-04 05:41:40 +01:00
|
|
|
{
|
|
|
|
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"
|