pre-populate the model if needed

since DataModel is a consumer of a consumer, in the case DataSource as already data, populate the model with it without waiting for the signal
This commit is contained in:
Marco Martin 2011-09-15 23:05:44 +02:00
parent ccc5bf7b90
commit 27c857db82

View File

@ -214,6 +214,13 @@ void DataModel::setDataSource(QObject *object)
disconnect(m_dataSource, 0, this, 0);
m_dataSource = source;
QMap<QString, QVariant>::const_iterator i = source->data().constBegin();
while (i != source->data().constEnd()) {
dataUpdated(i.key(), i.value().value<Plasma::DataEngine::Data>());
++i;
}
connect(m_dataSource, SIGNAL(newData(const QString &, const Plasma::DataEngine::Data &)),
this, SLOT(dataUpdated(const QString &, const Plasma::DataEngine::Data &)));
connect(m_dataSource, SIGNAL(sourceRemoved(const QString &)), this, SLOT(removeSource(const QString &)));