Commit cb61b50a authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: enables caching for WidgetLoader

parent 1b9c1f8b
...@@ -839,7 +839,7 @@ private: ...@@ -839,7 +839,7 @@ private:
QWidget *m_widget; QWidget *m_widget;
QmlComponent *m_component; QmlComponent *m_component;
QVBoxLayout *m_layout; QVBoxLayout *m_layout;
QHash<QString, QWidget*> m_cachedWidgets;
}; };
QUrl WidgetLoader::source() const QUrl WidgetLoader::source() const
...@@ -872,6 +872,10 @@ void WidgetLoader::setSource(const QUrl &source) ...@@ -872,6 +872,10 @@ void WidgetLoader::setSource(const QUrl &source)
return; return;
} }
if (m_cachedWidgets.contains(source.toString())) {
m_widget = m_cachedWidgets.value(source.toString());
m_widget->show();
} else {
m_component = new QmlComponent(qmlEngine(this), m_source, this); m_component = new QmlComponent(qmlEngine(this), m_source, this);
if (m_component) { if (m_component) {
...@@ -895,13 +899,14 @@ void WidgetLoader::setSource(const QUrl &source) ...@@ -895,13 +899,14 @@ void WidgetLoader::setSource(const QUrl &source)
if (obj) { if (obj) {
QWidget *widget = qobject_cast<QWidget *>(obj); QWidget *widget = qobject_cast<QWidget *>(obj);
if (widget) { if (widget) {
m_cachedWidgets.insert(source.toString(), widget);
m_widget = widget; m_widget = widget;
m_layout->addWidget(m_widget); m_layout->addWidget(m_widget);
m_widget->show(); m_widget->show();
} }
} }
} }
}
} }
QWidget *WidgetLoader::widget() const QWidget *WidgetLoader::widget() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment