Data is a QVariantmap again
this means that DataEngines and the Storage Service are directly usable from QML2 again
This commit is contained in:
parent
465c202b9b
commit
08ed91d7e0
@ -224,7 +224,7 @@ void DataModel::dataUpdated(const QString &sourceName, const Plasma::DataEngine:
|
|||||||
} else if (m_keyRoleFilterRE.isValid()) {
|
} else if (m_keyRoleFilterRE.isValid()) {
|
||||||
//try to match the key we want with a regular expression if set
|
//try to match the key we want with a regular expression if set
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
QHash<QString, QVariant>::const_iterator i;
|
QVariantMap::const_iterator i;
|
||||||
for (i = data.constBegin(); i != data.constEnd(); ++i) {
|
for (i = data.constBegin(); i != data.constEnd(); ++i) {
|
||||||
if (m_keyRoleFilterRE.exactMatch(i.key())) {
|
if (m_keyRoleFilterRE.exactMatch(i.key())) {
|
||||||
list.append(i.value());
|
list.append(i.value());
|
||||||
|
@ -63,8 +63,7 @@ void StorageTest::retrieve()
|
|||||||
if (storageJob) {
|
if (storageJob) {
|
||||||
QVERIFY(storageJob->exec());
|
QVERIFY(storageJob->exec());
|
||||||
QVERIFY(storageJob->result().type() != QVariant::Bool);
|
QVERIFY(storageJob->result().type() != QVariant::Bool);
|
||||||
QVariantHash h = storageJob->result().value<QVariantHash>();
|
QCOMPARE(storageJob->data(), m_data);
|
||||||
QCOMPARE(h, m_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariantHash m_data;
|
QVariantMap m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -180,7 +180,7 @@ void DataEngine::setData(const QString &source, const QString &key, const QVaria
|
|||||||
d->scheduleSourcesUpdated();
|
d->scheduleSourcesUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const QHash<QString, QVariant> &data)
|
void DataEngine::setData(const QString &source, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
DataContainer *s = d->source(source, false);
|
DataContainer *s = d->source(source, false);
|
||||||
bool isNew = !s;
|
bool isNew = !s;
|
||||||
|
@ -61,8 +61,8 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QHash<QString, DataEngine*> Dict;
|
typedef QHash<QString, DataEngine*> Dict;
|
||||||
typedef QHash<QString, QVariant> Data;
|
typedef QMap<QString, QVariant> Data;
|
||||||
typedef QHashIterator<QString, QVariant> DataIterator;
|
typedef QMapIterator<QString, QVariant> DataIterator;
|
||||||
typedef QHash<QString, DataContainer*> SourceDict;
|
typedef QHash<QString, DataContainer*> SourceDict;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,7 +287,7 @@ NoAlignment) const;
|
|||||||
* @param source the name of the data source
|
* @param source the name of the data source
|
||||||
* @param data the data to add to the source
|
* @param data the data to add to the source
|
||||||
**/
|
**/
|
||||||
void setData(const QString &source, const QHash<QString, QVariant> &data);
|
void setData(const QString &source, const QVariantMap &data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the data associated with a data source.
|
* Removes all the data associated with a data source.
|
||||||
|
@ -58,12 +58,12 @@ StorageJob::~StorageJob()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageJob::setData(const QVariantHash &data)
|
void StorageJob::setData(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantHash StorageJob::data() const
|
QVariantMap StorageJob::data() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
@ -102,8 +102,8 @@ void StorageJob::start()
|
|||||||
void StorageJob::resultSlot(StorageJob *job, const QVariant &result)
|
void StorageJob::resultSlot(StorageJob *job, const QVariant &result)
|
||||||
{
|
{
|
||||||
if (job == this) {
|
if (job == this) {
|
||||||
if (result.type() == QVariant::Hash) {
|
if (result.type() == QVariant::Map) {
|
||||||
m_data = result.toHash();
|
m_data = result.toMap();
|
||||||
}
|
}
|
||||||
setResult(result);
|
setResult(result);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
class StorageJob : public Plasma::ServiceJob
|
class StorageJob : public Plasma::ServiceJob
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QVariantHash data READ data WRITE setData)
|
Q_PROPERTY(QVariantMap data READ data WRITE setData)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StorageJob(const QString& destination,
|
StorageJob(const QString& destination,
|
||||||
@ -40,8 +40,8 @@ public:
|
|||||||
const QVariantMap& parameters,
|
const QVariantMap& parameters,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
~StorageJob();
|
~StorageJob();
|
||||||
void setData(const QVariantHash &data);
|
void setData(const QVariantMap &data);
|
||||||
QVariantHash data() const;
|
QVariantMap data() const;
|
||||||
void start();
|
void start();
|
||||||
QString clientName() const;
|
QString clientName() const;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ protected Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_clientName;
|
QString m_clientName;
|
||||||
QVariantHash m_data;
|
QVariantMap m_data;
|
||||||
};
|
};
|
||||||
//End StorageJob
|
//End StorageJob
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantMap &pa
|
|||||||
caller->data().insert(params.value("key").toString(), params.value("data"));
|
caller->data().insert(params.value("key").toString(), params.value("data"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QHashIterator<QString, QVariant> it(caller->data());
|
QMapIterator<QString, QVariant> it(caller->data());
|
||||||
|
|
||||||
QString ids;
|
QString ids;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -247,7 +247,7 @@ void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantMap
|
|||||||
const int floatColumn = rec.indexOf("float");
|
const int floatColumn = rec.indexOf("float");
|
||||||
const int binaryColumn = rec.indexOf("binary");
|
const int binaryColumn = rec.indexOf("binary");
|
||||||
|
|
||||||
QVariantHash data;
|
QVariantMap data;
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
const QString key = query.value(keyColumn).toString();
|
const QString key = query.value(keyColumn).toString();
|
||||||
if (!query.value(textColumn).isNull()) {
|
if (!query.value(textColumn).isNull()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user