From 5b648e5a23d53a1c0b4865def8ca960a23db6eea Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 2 May 2013 15:33:57 +0200 Subject: [PATCH] complete migration, storage test passes results still have to be converted in qmaps --- src/plasma/autotests/storagetest.cpp | 3 ++- src/plasma/private/storagethread.cpp | 9 ++++----- src/plasma/private/storagethread_p.h | 8 ++++---- src/plasma/service.cpp | 29 +++++----------------------- 4 files changed, 15 insertions(+), 34 deletions(-) diff --git a/src/plasma/autotests/storagetest.cpp b/src/plasma/autotests/storagetest.cpp index b80b28925..4d1bba4b3 100644 --- a/src/plasma/autotests/storagetest.cpp +++ b/src/plasma/autotests/storagetest.cpp @@ -63,7 +63,8 @@ void StorageTest::retrieve() if (storageJob) { QVERIFY(storageJob->exec()); QVERIFY(storageJob->result().type() != QVariant::Bool); - QCOMPARE(storageJob->data(), m_data); + QVariantHash h = storageJob->result().value(); + QCOMPARE(h, m_data); } } diff --git a/src/plasma/private/storagethread.cpp b/src/plasma/private/storagethread.cpp index 671cae50d..e895be4eb 100644 --- a/src/plasma/private/storagethread.cpp +++ b/src/plasma/private/storagethread.cpp @@ -96,7 +96,7 @@ void StorageThread::initializeDb(StorageJob *caller) m_db.transaction(); } -void StorageThread::save(QWeakPointer wcaller, const QVariantHash ¶ms) +void StorageThread::save(QWeakPointer wcaller, const QVariantMap ¶ms) { StorageJob *caller = wcaller.data(); if (!caller) { @@ -198,7 +198,7 @@ void StorageThread::save(QWeakPointer wcaller, const QVariantHash &p emit newResult(caller, true); } -void StorageThread::retrieve(QWeakPointer wcaller, const QVariantHash ¶ms) +void StorageThread::retrieve(QWeakPointer wcaller, const QVariantMap ¶ms) { StorageJob *caller = wcaller.data(); if (!caller) { @@ -263,7 +263,6 @@ void StorageThread::retrieve(QWeakPointer wcaller, const QVariantHas data.insert(key, v); } } - result = data; } else { result = false; @@ -272,7 +271,7 @@ void StorageThread::retrieve(QWeakPointer wcaller, const QVariantHas emit newResult(caller, result); } -void StorageThread::deleteEntry(QWeakPointer wcaller, const QVariantHash ¶ms) +void StorageThread::deleteEntry(QWeakPointer wcaller, const QVariantMap ¶ms) { StorageJob *caller = wcaller.data(); if (!caller) { @@ -302,7 +301,7 @@ void StorageThread::deleteEntry(QWeakPointer wcaller, const QVariant emit newResult(caller, success); } -void StorageThread::expire(QWeakPointer wcaller, const QVariantHash ¶ms) +void StorageThread::expire(QWeakPointer wcaller, const QVariantMap ¶ms) { StorageJob *caller = wcaller.data(); if (!caller) { diff --git a/src/plasma/private/storagethread_p.h b/src/plasma/private/storagethread_p.h index 9ca2bd5fd..1afbb1b29 100644 --- a/src/plasma/private/storagethread_p.h +++ b/src/plasma/private/storagethread_p.h @@ -44,10 +44,10 @@ public: void closeDb(); public Q_SLOTS: - void save(QWeakPointer caller, const QVariantHash ¶meters); - void retrieve(QWeakPointer caller, const QVariantHash ¶meters); - void deleteEntry(QWeakPointer caller, const QVariantHash ¶meters); - void expire(QWeakPointer caller, const QVariantHash ¶meters); + void save(QWeakPointer caller, const QVariantMap ¶meters); + void retrieve(QWeakPointer caller, const QVariantMap ¶meters); + void deleteEntry(QWeakPointer caller, const QVariantMap ¶meters); + void expire(QWeakPointer caller, const QVariantMap ¶meters); Q_SIGNALS: void newResult(StorageJob* caller, const QVariant &result); diff --git a/src/plasma/service.cpp b/src/plasma/service.cpp index 2d62cbd16..a7b2e2806 100644 --- a/src/plasma/service.cpp +++ b/src/plasma/service.cpp @@ -76,9 +76,9 @@ void ConfigLoaderHandlerMap::addItem() if (!m_groupsMap.contains(currentGroup())) { m_groupsMap[currentGroup()] = QVariantMap(); + m_groupsMap[currentGroup()]["_name"] = currentGroup(); } - if (type() == "bool") { bool defaultVal = defaultValue().toLower() == "true"; m_groupsMap[currentGroup()][key()] = defaultVal; @@ -201,7 +201,7 @@ QString Service::destination() const QStringList Service::operationNames() const { - if (!d->operationsMap.keys().isEmpty()) { + if (d->operationsMap.keys().isEmpty()) { #ifndef NDEBUG kDebug() << "No valid operations scheme has been registered"; #endif @@ -213,7 +213,7 @@ QStringList Service::operationNames() const QVariantMap Service::operationDescription(const QString &operationName) { - if (!d->operationsMap.keys().isEmpty()) { + if (d->operationsMap.keys().isEmpty()) { #ifndef NDEBUG kDebug() << "No valid operations scheme has been registered"; #endif @@ -225,32 +225,13 @@ QVariantMap Service::operationDescription(const QString &operationName) return d->operationsMap.value(operationName); } -/*QHash Service::parametersFromDescription(const KConfigGroup &description) -{ - QHash params; - - if (!d->operationsMap.keys().isEmpty() || !description.isValid()) { - return params; - } - - const QString op = description.name(); - foreach (const QString &key, description.keyList()) { - KConfigSkeletonItem *item = d->config->findItem(op, key); - if (item) { - params.insert(key, description.readEntry(key, item->property())); - } - } - - return params; -}*/ - ServiceJob *Service::startOperationCall(const QVariantMap &description, QObject *parent) { // TODO: nested groups? ServiceJob *job = 0; const QString op = !description.isEmpty() ? description.value("_name").toString() : QString(); - if (!d->operationsMap.keys().isEmpty()) { + if (d->operationsMap.keys().isEmpty()) { #ifndef NDEBUG kDebug() << "No valid operations scheme has been registered"; #endif @@ -325,7 +306,7 @@ void Service::setName(const QString &name) void Service::setOperationEnabled(const QString &operation, bool enable) { - if (!d->operationsMap.keys().isEmpty() || !d->operationsMap.contains(operation)) { + if (d->operationsMap.keys().isEmpty() || !d->operationsMap.contains(operation)) { return; }