forked from qt-creator/qt-creator
QmlDesigner: Fix cloning of extended states
* When cloning an extended state add the new state after the extended group * When cloning a state that extends another one also copy the extends property * Fix two "call to a temporary is a no-op" clang warnings Task-number: QDS-8412 Change-Id: I1e8595ddc69f210a27c04fc91869df3beb4ba980 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
committed by
Henning Gründl
parent
fd1864d678
commit
dd2c4cc6ea
@@ -229,6 +229,16 @@ void StatesEditorView::cloneState(int nodeId)
|
|||||||
int from = newNode.parentProperty().indexOf(newNode);
|
int from = newNode.parentProperty().indexOf(newNode);
|
||||||
int to = stateNode.parentProperty().indexOf(stateNode) + 1;
|
int to = stateNode.parentProperty().indexOf(stateNode) + 1;
|
||||||
|
|
||||||
|
// When duplicating an extended state the new state needs to be added after the extend group.
|
||||||
|
if (!modelState.hasExtend()) {
|
||||||
|
auto modelNodeList = activeStatesGroupNode().nodeListProperty("states").toModelNodeList();
|
||||||
|
for (; to != modelNodeList.count(); ++to) {
|
||||||
|
QmlModelState currentState(modelNodeList.at(to));
|
||||||
|
if (!currentState.isValid() || currentState.isBaseState() || !currentState.hasExtend())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
executeInTransaction("moveState", [this, &newState, from, to]() {
|
executeInTransaction("moveState", [this, &newState, from, to]() {
|
||||||
activeStatesGroupNode().nodeListProperty("states").slide(from, to);
|
activeStatesGroupNode().nodeListProperty("states").slide(from, to);
|
||||||
setCurrentState(newState);
|
setCurrentState(newState);
|
||||||
|
|||||||
@@ -254,17 +254,31 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
|
|||||||
if (!isValid())
|
if (!isValid())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// QmlModelState newState(stateGroup().addState(name));
|
|
||||||
QmlModelState newState(createQmlState(view(), {{PropertyName("name"), QVariant(name)}}));
|
QmlModelState newState(createQmlState(view(), {{PropertyName("name"), QVariant(name)}}));
|
||||||
|
|
||||||
|
if (hasExtend())
|
||||||
|
newState.setExtend(extend());
|
||||||
|
|
||||||
const QList<ModelNode> nodes = modelNode().nodeListProperty("changes").toModelNodeList();
|
const QList<ModelNode> nodes = modelNode().nodeListProperty("changes").toModelNodeList();
|
||||||
for (const ModelNode &childNode : nodes) {
|
for (const ModelNode &childNode : nodes) {
|
||||||
ModelNode newModelNode(view()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
|
ModelNode newModelNode(view()->createModelNode(childNode.type(),
|
||||||
|
childNode.majorVersion(),
|
||||||
|
childNode.minorVersion()));
|
||||||
|
|
||||||
|
for (const BindingProperty &bindingProperty : childNode.bindingProperties()) {
|
||||||
|
auto property = newModelNode.bindingProperty(bindingProperty.name());
|
||||||
|
property.setExpression(bindingProperty.expression());
|
||||||
|
}
|
||||||
|
|
||||||
const QList<BindingProperty> bindingProperties = childNode.bindingProperties();
|
const QList<BindingProperty> bindingProperties = childNode.bindingProperties();
|
||||||
for (const BindingProperty &bindingProperty : bindingProperties)
|
for (const BindingProperty &bindingProperty : bindingProperties)
|
||||||
newModelNode.bindingProperty(bindingProperty.name()).setExpression(bindingProperty.expression());
|
newModelNode.bindingProperty(bindingProperty.name())
|
||||||
const QList<VariantProperty> variantProperties = childNode.variantProperties();
|
.setExpression(bindingProperty.expression());
|
||||||
for (const VariantProperty &variantProperty : variantProperties)
|
|
||||||
newModelNode.variantProperty(variantProperty.name()).setValue(variantProperty.value());
|
for (const VariantProperty &variantProperty : childNode.variantProperties()) {
|
||||||
|
auto property = newModelNode.variantProperty(variantProperty.name());
|
||||||
|
property.setValue(variantProperty.value());
|
||||||
|
}
|
||||||
newState.modelNode().nodeListProperty("changes").reparentHere(newModelNode);
|
newState.modelNode().nodeListProperty("changes").reparentHere(newModelNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user