From 8f056a022acd2a850630891011a469706ed8a70c Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 17 Jul 2007 18:08:57 +0000 Subject: [PATCH] convenience setData method for when one gets a DataEngine::Data to set. useful for chaining engines together svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=689132 --- dataengine.cpp | 12 ++++++++++++ dataengine.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/dataengine.cpp b/dataengine.cpp index 7405e2938..0684f81fe 100644 --- a/dataengine.cpp +++ b/dataengine.cpp @@ -225,6 +225,18 @@ void DataEngine::setData(const QString& source, const QString& key, const QVaria d->queueUpdate(); } +void DataEngine::setData(const QString &source, const Data &data) +{ + DataSource *s = d->source(source); + Data::const_iterator it = data.constBegin(); + while (it != data.constEnd()) { + s->setData(it.key(), it.value()); + ++it; + } + d->queueUpdate(); +} + + void DataEngine::clearData(const QString& source) { DataSource* s = d->source(source, false); diff --git a/dataengine.h b/dataengine.h index fefd3be87..8501d41bd 100644 --- a/dataengine.h +++ b/dataengine.h @@ -210,6 +210,15 @@ class PLASMA_EXPORT DataEngine : public QObject **/ void setData(const QString& source, const QString& key, const QVariant& value); + /** + * Adds a set of data to a data source. If the source + * doesn't exist then it is created. + * + * @param source the name of the data source + * @param data the data to add to the source + **/ + void setData(const QString &source, const Data &data); + /** * Clears all the data associated with a data source. *