From 9dffd9dd77904ce1287dce10daeb66a402ef6540 Mon Sep 17 00:00:00 2001 From: Brian David Pritchett Date: Tue, 17 Aug 2010 09:28:46 +0000 Subject: [PATCH] Revert a commit that did not work. svn path=/trunk/KDE/kdelibs/; revision=1164609 --- datacontainer.cpp | 82 +++++++++++++++++---------------------- private/datacontainer_p.h | 4 +- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/datacontainer.cpp b/datacontainer.cpp index 6ee42f8c1..225f06023 100644 --- a/datacontainer.cpp +++ b/datacontainer.cpp @@ -19,7 +19,6 @@ #include "datacontainer.h" #include "private/datacontainer_p.h" #include "private/storage_p.h" -#include "pluginloader.h" #include @@ -199,43 +198,36 @@ void DataContainer::store() setNeedsToBeStored(false); - if (!d->store) { - QVariantList args; - args.insert(0, de->name()); - d->store = PluginLoader::pluginLoader()->loadService("akonadi_storage_plugin", args, 0); - if (!d->store) { - d->store = new Storage(de->name(), 0); - } + if (d->store == NULL) { + d->store = new Storage(de->name(), 0); } KConfigGroup op = d->store->operationDescription("save"); op.writeEntry("source", objectName()); DataEngine::Data dataToStore = data(); DataEngine::Data::const_iterator it = dataToStore.constBegin(); - while (it != dataToStore.constEnd() && dataToStore.constEnd() == data().constEnd()) { QVariant v = it.value(); - QByteArray b; - QDataStream ds(&b, QIODevice::WriteOnly); - ds << it.value(); - op.writeEntry("key", it.key()); - op.writeEntry("data", b.toBase64()); - } - ++it; - if (!d->store) { - QVariantList args; - args.insert(0, de->name()); - d->store = PluginLoader::pluginLoader()->loadService("plasma_storage_akonadi", args, 0); - if (!d->store) { + if ((it.value().type() == QVariant::String) || (it.value().type() == QVariant::Int)) { + op.writeEntry("key", it.key()); + op.writeEntry("data", it.value()); + } else { + QByteArray b; + QDataStream ds(&b, QIODevice::WriteOnly); + ds << it.value(); + op.writeEntry("key", "base64-" + it.key()); + op.writeEntry("data", b.toBase64()); + } + ++it; + if (d->store == NULL) { d->store = new Storage(de->name(), 0); } + ServiceJob* job = d->store->startOperationCall(op); + d->storeCount++; + connect(job, SIGNAL(finished(KJob*)), this, SLOT(storeJobFinished(KJob*))); } - ServiceJob* job = d->store->startOperationCall(op); - d->storeCount++; - connect(job, SIGNAL(finished(KJob*)), this, SLOT(storeJobFinished(KJob*))); } - void DataContainerPrivate::storeJobFinished(KJob* ) { --storeCount; @@ -251,17 +243,10 @@ void DataContainer::retrieve() if (de == NULL) { return; } - if (!d->store) { - QVariantList args; - args.insert(0, de->name()); - d->store = PluginLoader::pluginLoader()->loadService("plasma_storage_akonadi", args, 0); - if (!d->store) { - d->store = new Storage(de->name(), 0); - } - } - KConfigGroup retrieveGroup = d->store->operationDescription("retrieve"); + Storage* store = new Storage(de->name(), 0); + KConfigGroup retrieveGroup = store->operationDescription("retrieve"); retrieveGroup.writeEntry("source", objectName()); - ServiceJob* retrieveJob = d->store->startOperationCall(retrieveGroup); + ServiceJob* retrieveJob = store->startOperationCall(retrieveGroup); connect(retrieveJob, SIGNAL(result(KJob*)), this, SLOT(populateFromStoredData(KJob*))); } @@ -276,22 +261,27 @@ void DataContainerPrivate::populateFromStoredData(KJob *job) ServiceJob* ret = dynamic_cast(job); QHash h = ret->result().toHash(); foreach (QString key, h.keys()) { - QByteArray b = QByteArray::fromBase64(h[key].toString().toAscii()); - QDataStream ds(&b, QIODevice::ReadOnly); - QVariant v(ds); - key.remove(0, 7); - dataToInsert.insert(key, v); + if (key.startsWith("base64-")) { + QByteArray b = QByteArray::fromBase64(h[key].toString().toAscii()); + QDataStream ds(&b, QIODevice::ReadOnly); + QVariant v(ds); + key.remove(0, 7); + dataToInsert.insert(key, v); + } else { + dataToInsert.insert(key, h[key]); + } } - //Do not fill the source with old stored - //data if it is already populated with new data. - if (data.isEmpty()) + if (!(data.isEmpty())) { - data = dataToInsert; - // dirty = true; - // q->checkForUpdate(); + //Do not fill the source with old stored + //data if it is already populated with new data. + return; } + data = dataToInsert; + dirty = true; + q->checkForUpdate(); } void DataContainer::disconnectVisualization(QObject *visualization) diff --git a/private/datacontainer_p.h b/private/datacontainer_p.h index 2243e123a..7ab62b837 100644 --- a/private/datacontainer_p.h +++ b/private/datacontainer_p.h @@ -35,7 +35,7 @@ class DataContainerPrivate public: DataContainerPrivate(DataContainer *container) : q(container), - store(0), + store(NULL), dirty(false), cached(false), enableStorage(false), @@ -66,7 +66,7 @@ public: QMap relayObjects; QMap relays; QTime updateTs; - Service* store; + Storage* store; bool dirty : 1; bool cached : 1; bool enableStorage : 1;