forked from qt-creator/qt-creator
QmlDesigner: Fix Property Editor doesn't update binding properties
Now Property Editor correctly update a binding property when it is added, removed, or updated. Fixes: QDS-9465 Change-Id: I48eb101f7dcca04e123a84c6eebaf4ec6d098d6c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -365,6 +365,13 @@ void PropertyEditorQmlBackend::setValue(const QmlObjectNode & , const PropertyNa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyEditorQmlBackend::setExpression(const PropertyName &propName, const QString &exp)
|
||||||
|
{
|
||||||
|
PropertyEditorValue *propertyValue = propertyValueForName(QString::fromUtf8(propName));
|
||||||
|
if (propertyValue)
|
||||||
|
propertyValue->setExpression(exp);
|
||||||
|
}
|
||||||
|
|
||||||
QQmlContext *PropertyEditorQmlBackend::context() {
|
QQmlContext *PropertyEditorQmlBackend::context() {
|
||||||
return m_view->rootContext();
|
return m_view->rootContext();
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ public:
|
|||||||
void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
|
void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
|
||||||
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
|
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
|
||||||
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value);
|
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value);
|
||||||
|
void setExpression(const PropertyName &propName, const QString &exp);
|
||||||
|
|
||||||
QQmlContext *context();
|
QQmlContext *context();
|
||||||
PropertyEditorContextObject* contextObject();
|
PropertyEditorContextObject* contextObject();
|
||||||
|
@@ -328,7 +328,7 @@ PropertyEditorNodeWrapper *PropertyEditorValue::complexNode()
|
|||||||
|
|
||||||
void PropertyEditorValue::resetValue()
|
void PropertyEditorValue::resetValue()
|
||||||
{
|
{
|
||||||
if (m_value.isValid() || isBound()) {
|
if (m_value.isValid() || !m_expression.isEmpty() || isBound()) {
|
||||||
m_value = QVariant();
|
m_value = QVariant();
|
||||||
m_isBound = false;
|
m_isBound = false;
|
||||||
m_expression = QString();
|
m_expression = QString();
|
||||||
|
@@ -629,7 +629,7 @@ void PropertyEditorView::modelAboutToBeDetached(Model *model)
|
|||||||
resetView();
|
resetView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::propertiesRemoved(const QList<AbstractProperty>& propertyList)
|
void PropertyEditorView::propertiesRemoved(const QList<AbstractProperty> &propertyList)
|
||||||
{
|
{
|
||||||
if (noValidSelection())
|
if (noValidSelection())
|
||||||
return;
|
return;
|
||||||
@@ -641,7 +641,11 @@ void PropertyEditorView::propertiesRemoved(const QList<AbstractProperty>& proper
|
|||||||
m_qmlBackEndForCurrentType->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedNode).isAliasExported());
|
m_qmlBackEndForCurrentType->contextObject()->setHasAliasExport(QmlObjectNode(m_selectedNode).isAliasExported());
|
||||||
|
|
||||||
if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) {
|
if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) {
|
||||||
setValue(m_selectedNode, property.name(), QmlObjectNode(m_selectedNode).instanceValue(property.name()));
|
m_locked = true;
|
||||||
|
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(QString::fromUtf8(property.name()));
|
||||||
|
if (value)
|
||||||
|
value->resetValue();
|
||||||
|
m_locked = false;
|
||||||
|
|
||||||
if (propertyIsAttachedLayoutProperty(property.name())) {
|
if (propertyIsAttachedLayoutProperty(property.name())) {
|
||||||
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, property.name());
|
m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, property.name());
|
||||||
@@ -697,12 +701,9 @@ void PropertyEditorView::variantPropertiesChanged(const QList<VariantProperty>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags /*propertyChange*/)
|
void PropertyEditorView::bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags /*propertyChange*/)
|
||||||
{
|
{
|
||||||
if (locked())
|
if (locked() || noValidSelection())
|
||||||
return;
|
|
||||||
|
|
||||||
if (noValidSelection())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const BindingProperty &property : propertyList) {
|
for (const BindingProperty &property : propertyList) {
|
||||||
@@ -714,11 +715,11 @@ void PropertyEditorView::bindingPropertiesChanged(const QList<BindingProperty>&
|
|||||||
if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) {
|
if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) {
|
||||||
if (property.name().contains("anchor"))
|
if (property.name().contains("anchor"))
|
||||||
m_qmlBackEndForCurrentType->backendAnchorBinding().invalidate(m_selectedNode);
|
m_qmlBackEndForCurrentType->backendAnchorBinding().invalidate(m_selectedNode);
|
||||||
if ( QmlObjectNode(m_selectedNode).modelNode().property(property.name()).isBindingProperty())
|
|
||||||
setValue(m_selectedNode, property.name(), QmlObjectNode(m_selectedNode).instanceValue(property.name()));
|
|
||||||
else
|
|
||||||
setValue(m_selectedNode, property.name(), QmlObjectNode(m_selectedNode).modelValue(property.name()));
|
|
||||||
|
|
||||||
|
m_locked = true;
|
||||||
|
QString exp = QmlObjectNode(m_selectedNode).bindingProperty(property.name()).expression();
|
||||||
|
m_qmlBackEndForCurrentType->setExpression(property.name(), exp);
|
||||||
|
m_locked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user