From 08ed91d7e0caa9b59707d04dd0469e4dd9841a4a Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 2 May 2013 18:02:38 +0200 Subject: [PATCH] Data is a QVariantmap again this means that DataEngines and the Storage Service are directly usable from QML2 again --- src/declarativeimports/core/datamodel.cpp | 2 +- src/plasma/autotests/storagetest.cpp | 3 +-- src/plasma/autotests/storagetest.h | 2 +- src/plasma/dataengine.cpp | 2 +- src/plasma/dataengine.h | 6 +++--- src/plasma/private/storage.cpp | 8 ++++---- src/plasma/private/storage_p.h | 8 ++++---- src/plasma/private/storagethread.cpp | 4 ++-- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/declarativeimports/core/datamodel.cpp b/src/declarativeimports/core/datamodel.cpp index 5f06a8190..86cac4068 100644 --- a/src/declarativeimports/core/datamodel.cpp +++ b/src/declarativeimports/core/datamodel.cpp @@ -224,7 +224,7 @@ void DataModel::dataUpdated(const QString &sourceName, const Plasma::DataEngine: } else if (m_keyRoleFilterRE.isValid()) { //try to match the key we want with a regular expression if set QVariantList list; - QHash::const_iterator i; + QVariantMap::const_iterator i; for (i = data.constBegin(); i != data.constEnd(); ++i) { if (m_keyRoleFilterRE.exactMatch(i.key())) { list.append(i.value()); diff --git a/src/plasma/autotests/storagetest.cpp b/src/plasma/autotests/storagetest.cpp index 4d1bba4b3..b80b28925 100644 --- a/src/plasma/autotests/storagetest.cpp +++ b/src/plasma/autotests/storagetest.cpp @@ -63,8 +63,7 @@ void StorageTest::retrieve() if (storageJob) { QVERIFY(storageJob->exec()); QVERIFY(storageJob->result().type() != QVariant::Bool); - QVariantHash h = storageJob->result().value(); - QCOMPARE(h, m_data); + QCOMPARE(storageJob->data(), m_data); } } diff --git a/src/plasma/autotests/storagetest.h b/src/plasma/autotests/storagetest.h index 282d2fc31..da1f1c493 100644 --- a/src/plasma/autotests/storagetest.h +++ b/src/plasma/autotests/storagetest.h @@ -36,7 +36,7 @@ private Q_SLOTS: private: - QVariantHash m_data; + QVariantMap m_data; }; #endif diff --git a/src/plasma/dataengine.cpp b/src/plasma/dataengine.cpp index 422e3c09a..8f2a4cdfd 100644 --- a/src/plasma/dataengine.cpp +++ b/src/plasma/dataengine.cpp @@ -180,7 +180,7 @@ void DataEngine::setData(const QString &source, const QString &key, const QVaria d->scheduleSourcesUpdated(); } -void DataEngine::setData(const QString &source, const QHash &data) +void DataEngine::setData(const QString &source, const QVariantMap &data) { DataContainer *s = d->source(source, false); bool isNew = !s; diff --git a/src/plasma/dataengine.h b/src/plasma/dataengine.h index d6cbb6402..13559a2e9 100644 --- a/src/plasma/dataengine.h +++ b/src/plasma/dataengine.h @@ -61,8 +61,8 @@ class PLASMA_EXPORT DataEngine : public QObject public: typedef QHash Dict; - typedef QHash Data; - typedef QHashIterator DataIterator; + typedef QMap Data; + typedef QMapIterator DataIterator; typedef QHash SourceDict; /** @@ -287,7 +287,7 @@ NoAlignment) const; * @param source the name of the data source * @param data the data to add to the source **/ - void setData(const QString &source, const QHash &data); + void setData(const QString &source, const QVariantMap &data); /** * Removes all the data associated with a data source. diff --git a/src/plasma/private/storage.cpp b/src/plasma/private/storage.cpp index 6f1da4d0c..8e9977a26 100644 --- a/src/plasma/private/storage.cpp +++ b/src/plasma/private/storage.cpp @@ -58,12 +58,12 @@ StorageJob::~StorageJob() { } -void StorageJob::setData(const QVariantHash &data) +void StorageJob::setData(const QVariantMap &data) { m_data = data; } -QVariantHash StorageJob::data() const +QVariantMap StorageJob::data() const { return m_data; } @@ -102,8 +102,8 @@ void StorageJob::start() void StorageJob::resultSlot(StorageJob *job, const QVariant &result) { if (job == this) { - if (result.type() == QVariant::Hash) { - m_data = result.toHash(); + if (result.type() == QVariant::Map) { + m_data = result.toMap(); } setResult(result); } diff --git a/src/plasma/private/storage_p.h b/src/plasma/private/storage_p.h index 21fd3aad0..6ec80c4d8 100644 --- a/src/plasma/private/storage_p.h +++ b/src/plasma/private/storage_p.h @@ -32,7 +32,7 @@ class StorageJob : public Plasma::ServiceJob { Q_OBJECT - Q_PROPERTY(QVariantHash data READ data WRITE setData) + Q_PROPERTY(QVariantMap data READ data WRITE setData) public: StorageJob(const QString& destination, @@ -40,8 +40,8 @@ public: const QVariantMap& parameters, QObject *parent = 0); ~StorageJob(); - void setData(const QVariantHash &data); - QVariantHash data() const; + void setData(const QVariantMap &data); + QVariantMap data() const; void start(); QString clientName() const; @@ -50,7 +50,7 @@ protected Q_SLOTS: private: QString m_clientName; - QVariantHash m_data; + QVariantMap m_data; }; //End StorageJob diff --git a/src/plasma/private/storagethread.cpp b/src/plasma/private/storagethread.cpp index e895be4eb..747692378 100644 --- a/src/plasma/private/storagethread.cpp +++ b/src/plasma/private/storagethread.cpp @@ -113,7 +113,7 @@ void StorageThread::save(QWeakPointer wcaller, const QVariantMap &pa caller->data().insert(params.value("key").toString(), params.value("data")); } - QHashIterator it(caller->data()); + QMapIterator it(caller->data()); QString ids; while (it.hasNext()) { @@ -247,7 +247,7 @@ void StorageThread::retrieve(QWeakPointer wcaller, const QVariantMap const int floatColumn = rec.indexOf("float"); const int binaryColumn = rec.indexOf("binary"); - QVariantHash data; + QVariantMap data; while (query.next()) { const QString key = query.value(keyColumn).toString(); if (!query.value(textColumn).isNull()) {