Revert a commit that did not work.
svn path=/trunk/KDE/kdelibs/; revision=1164609
This commit is contained in:
parent
bc6d40852b
commit
9dffd9dd77
@ -19,7 +19,6 @@
|
|||||||
#include "datacontainer.h"
|
#include "datacontainer.h"
|
||||||
#include "private/datacontainer_p.h"
|
#include "private/datacontainer_p.h"
|
||||||
#include "private/storage_p.h"
|
#include "private/storage_p.h"
|
||||||
#include "pluginloader.h"
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
@ -199,43 +198,36 @@ void DataContainer::store()
|
|||||||
|
|
||||||
setNeedsToBeStored(false);
|
setNeedsToBeStored(false);
|
||||||
|
|
||||||
if (!d->store) {
|
if (d->store == NULL) {
|
||||||
QVariantList args;
|
d->store = new Storage(de->name(), 0);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup op = d->store->operationDescription("save");
|
KConfigGroup op = d->store->operationDescription("save");
|
||||||
op.writeEntry("source", objectName());
|
op.writeEntry("source", objectName());
|
||||||
DataEngine::Data dataToStore = data();
|
DataEngine::Data dataToStore = data();
|
||||||
DataEngine::Data::const_iterator it = dataToStore.constBegin();
|
DataEngine::Data::const_iterator it = dataToStore.constBegin();
|
||||||
|
|
||||||
while (it != dataToStore.constEnd() && dataToStore.constEnd() == data().constEnd()) {
|
while (it != dataToStore.constEnd() && dataToStore.constEnd() == data().constEnd()) {
|
||||||
QVariant v = it.value();
|
QVariant v = it.value();
|
||||||
QByteArray b;
|
if ((it.value().type() == QVariant::String) || (it.value().type() == QVariant::Int)) {
|
||||||
QDataStream ds(&b, QIODevice::WriteOnly);
|
op.writeEntry("key", it.key());
|
||||||
ds << it.value();
|
op.writeEntry("data", it.value());
|
||||||
op.writeEntry("key", it.key());
|
} else {
|
||||||
op.writeEntry("data", b.toBase64());
|
QByteArray b;
|
||||||
}
|
QDataStream ds(&b, QIODevice::WriteOnly);
|
||||||
++it;
|
ds << it.value();
|
||||||
if (!d->store) {
|
op.writeEntry("key", "base64-" + it.key());
|
||||||
QVariantList args;
|
op.writeEntry("data", b.toBase64());
|
||||||
args.insert(0, de->name());
|
}
|
||||||
d->store = PluginLoader::pluginLoader()->loadService("plasma_storage_akonadi", args, 0);
|
++it;
|
||||||
if (!d->store) {
|
if (d->store == NULL) {
|
||||||
d->store = new Storage(de->name(), 0);
|
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* )
|
void DataContainerPrivate::storeJobFinished(KJob* )
|
||||||
{
|
{
|
||||||
--storeCount;
|
--storeCount;
|
||||||
@ -251,17 +243,10 @@ void DataContainer::retrieve()
|
|||||||
if (de == NULL) {
|
if (de == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!d->store) {
|
Storage* store = new Storage(de->name(), 0);
|
||||||
QVariantList args;
|
KConfigGroup retrieveGroup = store->operationDescription("retrieve");
|
||||||
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");
|
|
||||||
retrieveGroup.writeEntry("source", objectName());
|
retrieveGroup.writeEntry("source", objectName());
|
||||||
ServiceJob* retrieveJob = d->store->startOperationCall(retrieveGroup);
|
ServiceJob* retrieveJob = store->startOperationCall(retrieveGroup);
|
||||||
connect(retrieveJob, SIGNAL(result(KJob*)), this,
|
connect(retrieveJob, SIGNAL(result(KJob*)), this,
|
||||||
SLOT(populateFromStoredData(KJob*)));
|
SLOT(populateFromStoredData(KJob*)));
|
||||||
}
|
}
|
||||||
@ -276,22 +261,27 @@ void DataContainerPrivate::populateFromStoredData(KJob *job)
|
|||||||
ServiceJob* ret = dynamic_cast<ServiceJob*>(job);
|
ServiceJob* ret = dynamic_cast<ServiceJob*>(job);
|
||||||
QHash<QString, QVariant> h = ret->result().toHash();
|
QHash<QString, QVariant> h = ret->result().toHash();
|
||||||
foreach (QString key, h.keys()) {
|
foreach (QString key, h.keys()) {
|
||||||
QByteArray b = QByteArray::fromBase64(h[key].toString().toAscii());
|
if (key.startsWith("base64-")) {
|
||||||
QDataStream ds(&b, QIODevice::ReadOnly);
|
QByteArray b = QByteArray::fromBase64(h[key].toString().toAscii());
|
||||||
QVariant v(ds);
|
QDataStream ds(&b, QIODevice::ReadOnly);
|
||||||
key.remove(0, 7);
|
QVariant v(ds);
|
||||||
dataToInsert.insert(key, v);
|
key.remove(0, 7);
|
||||||
|
dataToInsert.insert(key, v);
|
||||||
|
} else {
|
||||||
|
dataToInsert.insert(key, h[key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Do not fill the source with old stored
|
if (!(data.isEmpty()))
|
||||||
//data if it is already populated with new data.
|
|
||||||
if (data.isEmpty())
|
|
||||||
{
|
{
|
||||||
data = dataToInsert;
|
//Do not fill the source with old stored
|
||||||
// dirty = true;
|
//data if it is already populated with new data.
|
||||||
// q->checkForUpdate();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data = dataToInsert;
|
||||||
|
dirty = true;
|
||||||
|
q->checkForUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataContainer::disconnectVisualization(QObject *visualization)
|
void DataContainer::disconnectVisualization(QObject *visualization)
|
||||||
|
@ -35,7 +35,7 @@ class DataContainerPrivate
|
|||||||
public:
|
public:
|
||||||
DataContainerPrivate(DataContainer *container)
|
DataContainerPrivate(DataContainer *container)
|
||||||
: q(container),
|
: q(container),
|
||||||
store(0),
|
store(NULL),
|
||||||
dirty(false),
|
dirty(false),
|
||||||
cached(false),
|
cached(false),
|
||||||
enableStorage(false),
|
enableStorage(false),
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
QMap<QObject *, SignalRelay *> relayObjects;
|
QMap<QObject *, SignalRelay *> relayObjects;
|
||||||
QMap<uint, SignalRelay *> relays;
|
QMap<uint, SignalRelay *> relays;
|
||||||
QTime updateTs;
|
QTime updateTs;
|
||||||
Service* store;
|
Storage* store;
|
||||||
bool dirty : 1;
|
bool dirty : 1;
|
||||||
bool cached : 1;
|
bool cached : 1;
|
||||||
bool enableStorage : 1;
|
bool enableStorage : 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user