add clearData() methods

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=685602
This commit is contained in:
Aaron J. Seigo 2007-07-09 09:33:15 +00:00
parent 44bf51c596
commit 606b1862a7
4 changed files with 32 additions and 0 deletions

View File

@ -225,6 +225,15 @@ void DataEngine::setData(const QString& source, const QString& key, const QVaria
d->queueUpdate();
}
void DataEngine::clearData(const QString& source)
{
DataSource* s = d->source(source, false);
if (s) {
s->clearData();
d->queueUpdate();
}
}
void DataEngine::removeData(const QString& source, const QString& key)
{
DataSource* s = d->source(source, false);

View File

@ -210,6 +210,13 @@ class PLASMA_EXPORT DataEngine : public QObject
**/
void setData(const QString& source, const QString& key, const QVariant& value);
/**
* Clears all the data associated with a data source.
*
* @param source the name of the data source
**/
void clearData(const QString& source);
/**
* Removes a data entry from a source
*

View File

@ -69,6 +69,17 @@ void DataSource::setData(const QString& key, const QVariant& value)
d->dirty = true;
}
void DataSource::clearData()
{
if (d->data.count() < 1) {
// avoid an update if we don't have any data anyways
return;
}
d->data.clear();
d->dirty = true;
}
void DataSource::checkForUpdate()
{
if (d->dirty) {

View File

@ -69,6 +69,11 @@ class PLASMA_EXPORT DataSource : public QObject
**/
void setData(const QString& key, const QVariant& value);
/**
* Clears all data currently associated with this source
**/
void clearData();
/**
* Checks for whether the data has changed and therefore an update
* signal needs to be emitted.