use the new and improve retrieval

This commit is contained in:
Aaron Seigo 2011-04-28 17:23:17 +02:00 committed by Marco Martin
parent 7cd768fd6f
commit f5ad63632e

View File

@ -244,39 +244,26 @@ void DataContainerPrivate::populateFromStoredData(KJob *job)
return; return;
} }
DataEngine::Data dataToInsert; StorageJob *ret = dynamic_cast<StorageJob*>(job);
ServiceJob* ret = dynamic_cast<ServiceJob*>(job); if (!ret) {
const QHash<QString, QVariant> h = ret->result().toHash(); return;
QHash<QString, QVariant>::const_iterator it = h.begin();
QHash<QString, QVariant>::const_iterator itEnd = h.end();
for ( ; it != itEnd; ++it) {
QString key = it.key();
if (key.startsWith("base64-")) {
QByteArray b = QByteArray::fromBase64(it.value().toString().toAscii());
QDataStream ds(&b, QIODevice::ReadOnly);
QVariant v(ds);
key.remove(0, 7);
dataToInsert.insert(key, v);
} else {
dataToInsert.insert(key, it.value());
}
} }
DataEngine::Data dataToInsert = ret->data();
KConfigGroup expireGroup = storage->operationDescription("expire"); KConfigGroup expireGroup = storage->operationDescription("expire");
//expire things older than 4 days //expire things older than 4 days
expireGroup.writeEntry("age", 345600); expireGroup.writeEntry("age", 345600);
storage->startOperationCall(expireGroup); storage->startOperationCall(expireGroup);
if (!(data.isEmpty())) { // Only fill the source with old stored
//Do not fill the source with old stored
// data if it is already populated with new data. // data if it is already populated with new data.
return; if (data.isEmpty()) {
}
data = dataToInsert; data = dataToInsert;
dirty = true; dirty = true;
q->checkForUpdate(); q->checkForUpdate();
} }
}
void DataContainer::disconnectVisualization(QObject *visualization) void DataContainer::disconnectVisualization(QObject *visualization)
{ {