use q QQmlPropertyMap, crash-- and more efficient
This commit is contained in:
parent
124139c2bf
commit
a721878fda
@ -30,6 +30,7 @@ DataSource::DataSource(QObject* parent)
|
||||
m_dataEngine(0),
|
||||
m_dataEngineConsumer(0)
|
||||
{
|
||||
m_models = new QQmlPropertyMap(this);
|
||||
setObjectName("DataSource");
|
||||
}
|
||||
|
||||
@ -150,12 +151,10 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine
|
||||
|
||||
void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *model)
|
||||
{
|
||||
m_models[sourceName] = QVariant::fromValue(model);
|
||||
m_models->insert(sourceName, QVariant::fromValue(model));
|
||||
connect(model, &QObject::destroyed, [=]() {
|
||||
m_models.remove(sourceName);
|
||||
emit modelsChanged();
|
||||
m_models->clear(sourceName);
|
||||
});
|
||||
emit modelsChanged();
|
||||
}
|
||||
|
||||
void DataSource::removeSource(const QString &source)
|
||||
|
@ -97,8 +97,8 @@ public:
|
||||
/**
|
||||
* All the models associated to this DataEngine, indexed by source
|
||||
*/
|
||||
Q_PROPERTY(QVariantMap models READ models NOTIFY modelsChanged);
|
||||
QVariantMap models() const {return m_models;}
|
||||
Q_PROPERTY(QQmlPropertyMap *models READ models CONSTANT);
|
||||
QQmlPropertyMap *models() const {return m_models;}
|
||||
|
||||
/**
|
||||
* @returns a Plasma::Service given a source name
|
||||
@ -131,7 +131,6 @@ Q_SIGNALS:
|
||||
void intervalChanged();
|
||||
void engineChanged();
|
||||
void dataChanged();
|
||||
void modelsChanged();
|
||||
void connectedSourcesChanged();
|
||||
void sourcesChanged();
|
||||
|
||||
@ -140,7 +139,7 @@ private:
|
||||
int m_interval;
|
||||
QString m_engine;
|
||||
QVariantMap m_data;
|
||||
QVariantMap m_models;
|
||||
QQmlPropertyMap *m_models;
|
||||
Plasma::DataEngine* m_dataEngine;
|
||||
Plasma::DataEngineConsumer* m_dataEngineConsumer;
|
||||
QStringList m_connectedSources;
|
||||
|
Loading…
Reference in New Issue
Block a user