QmlDesigner: Fix QML for bindings/properties

* Ensure a "node" is added to the model if missing, for e.g. Singletons
* Expose targetNode of property

Change-Id: Ifbb131c1d6efaaceb15a6e630ce56023ace63311
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Thomas Hartmann
2023-09-01 17:29:07 +02:00
parent a2d801ac0e
commit 5907e480a0
7 changed files with 178 additions and 117 deletions

View File

@@ -1022,6 +1022,10 @@ void DynamicPropertiesModelBackendDelegate::setCurrentRow(int i)
m_value.setText(property.toVariantProperty().value().toString());
else if (property.isBindingProperty())
m_value.setText(property.toBindingProperty().expression());
m_targetNode = property.parentModelNode().id();
emit targetNodeChanged();
}
void DynamicPropertiesModelBackendDelegate::handleTypeChanged()
@@ -1077,9 +1081,10 @@ void DynamicPropertiesModelBackendDelegate::handleNameChanged()
const QString expression = bindingProperty.expression();
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
targetNode.removeProperty(bindingProperty.name());
targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType,
expression);
targetNode.removeProperty(bindingProperty.name());
});
return;
@@ -1093,9 +1098,10 @@ void DynamicPropertiesModelBackendDelegate::handleNameChanged()
ModelNode targetNode = variantProperty.parentModelNode();
model->view()->executeInTransaction(__FUNCTION__, [=]() {
targetNode.removeProperty(variantProperty.name());
targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType,
value);
targetNode.removeProperty(variantProperty.name());
});
}
@@ -1167,6 +1173,11 @@ QVariant DynamicPropertiesModelBackendDelegate::variantValue() const
return m_value.text();
}
QString DynamicPropertiesModelBackendDelegate::targetNode() const
{
return m_targetNode;
}
StudioQmlComboBoxBackend *DynamicPropertiesModelBackendDelegate::type()
{
return &m_type;