diff --git a/src/declarativeimports/core/datamodel.cpp b/src/declarativeimports/core/datamodel.cpp index ef68a6eca..64a5bf1dc 100644 --- a/src/declarativeimports/core/datamodel.cpp +++ b/src/declarativeimports/core/datamodel.cpp @@ -198,21 +198,17 @@ void DataModel::dataUpdated(const QString &sourceName, const QVariantMap &data) //an item is represented by a source: keys are roles m_roleLevel == FirstLevel QVariantList list; - if (!m_dataSource->data().isEmpty()) { - QVariantMap::const_iterator i = m_dataSource->data().constBegin(); - - while (i != m_dataSource->data().constEnd()) { - if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(i.key())) { - ++i; + if (!m_dataSource->data()->isEmpty()) { + foreach (const QString &key, m_dataSource->data()->keys()) { + if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(key)) { continue; } - QVariant value = i.value(); + QVariant value = m_dataSource->data()->value(key); if (value.isValid() && value.canConvert()) { Plasma::DataEngine::Data data = value.value(); - data["DataEngineSource"] = i.key(); + data["DataEngineSource"] = key; list.append(data); } - ++i; } } setItems(QString(), list); @@ -252,11 +248,8 @@ void DataModel::setDataSource(QObject *object) m_dataSource = source; - const QMap data = source->data(); - QMap::const_iterator i = data.constBegin(); - while (i != data.constEnd()) { - dataUpdated(i.key(), i.value().value()); - ++i; + foreach (const QString &key, m_dataSource->data()->keys()) { + dataUpdated(key, m_dataSource->data()->value(key).value()); } connect(m_dataSource, &DataSource::newData, diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp index 6b0336299..68e6b0b27 100644 --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -31,6 +31,7 @@ DataSource::DataSource(QObject* parent) m_dataEngineConsumer(0) { m_models = new QQmlPropertyMap(this); + m_data = new QQmlPropertyMap(this); setObjectName("DataSource"); } @@ -50,7 +51,7 @@ void DataSource::setConnectedSources(const QStringList &sources) foreach (const QString &source, m_connectedSources) { if (!sources.contains(source)) { - m_data.remove(source); + m_data->clear(source); sourcesChanged = true; if (m_dataEngine) { m_dataEngine->disconnectSource(source, this); @@ -141,7 +142,7 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine { //it can arrive also data we don't explicitly connected a source if (m_connectedSources.contains(sourceName)) { - m_data.insert(sourceName.toLatin1(), data); + m_data->insert(sourceName.toLatin1(), data); emit dataChanged(); emit newData(sourceName, data); } else if (m_dataEngine) { @@ -165,7 +166,7 @@ void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *mod void DataSource::removeSource(const QString &source) { - m_data.remove(source); + m_data->clear(source); m_models->clear(source); //TODO: emit those signals as last thing diff --git a/src/declarativeimports/core/datasource.h b/src/declarativeimports/core/datasource.h index 868ab63b6..66a3a5dad 100644 --- a/src/declarativeimports/core/datasource.h +++ b/src/declarativeimports/core/datasource.h @@ -91,8 +91,8 @@ public: * All the data fetched by this dataengine. * This is a map of maps. At the first level, there are the source names, at the second, they keys set by the DataEngine */ - Q_PROPERTY(QVariantMap data READ data NOTIFY dataChanged); - QVariantMap data() const {return m_data;} + Q_PROPERTY(QQmlPropertyMap *data READ data CONSTANT); + QQmlPropertyMap *data() const {return m_data;} /** * All the models associated to this DataEngine, indexed by source. @@ -140,7 +140,7 @@ private: QString m_id; int m_interval; QString m_engine; - QVariantMap m_data; + QQmlPropertyMap *m_data; QQmlPropertyMap *m_models; Plasma::DataEngine* m_dataEngine; Plasma::DataEngineConsumer* m_dataEngineConsumer;