QmlDesigner: Fix pasting 3D nodes

Pasting multiple 3D nodes are now pasted in correct scope instead of
always pasting under scene root.

Fixes: QDS-4534
Change-Id: I233bf360e2bd335c952b1e727a9ee775d2cdd23a
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2021-06-15 14:50:15 +03:00
parent 089802cabd
commit 200723cf13

View File

@@ -517,13 +517,13 @@ void DesignDocument::paste()
// in case we copy and paste a selection we paste in the parent item // in case we copy and paste a selection we paste in the parent item
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty()) { if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty()) {
targetNode = targetNode.parentProperty().parentModelNode(); targetNode = targetNode.parentProperty().parentModelNode();
} else { } else if (view.selectedModelNodes().isEmpty()) {
// if selection is empty and copied nodes are all 3D nodes, paste them under the active scene // if selection is empty and copied nodes are all 3D nodes, paste them under the active scene
bool all3DNodes = std::find_if(selectedNodes.cbegin(), selectedNodes.cend(), bool all3DNodes = std::find_if(selectedNodes.cbegin(), selectedNodes.cend(),
[](const ModelNode &node) { return !node.isSubclassOf("QtQuick3D.Node"); }) [](const ModelNode &node) { return !node.isSubclassOf("QtQuick3D.Node"); })
== selectedNodes.cend(); == selectedNodes.cend();
if (all3DNodes) { if (all3DNodes) {
int activeSceneId = rootModelNode().auxiliaryData("active3dScene").toInt(); int activeSceneId = rootModelNode().auxiliaryData("active3dScene@Internal").toInt();
if (activeSceneId != -1) { if (activeSceneId != -1) {
NodeListProperty sceneNodeProperty NodeListProperty sceneNodeProperty
= QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId); = QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId);
@@ -570,7 +570,7 @@ void DesignDocument::paste()
} else { } else {
// if selection is empty and this is a 3D Node, paste it under the active scene // if selection is empty and this is a 3D Node, paste it under the active scene
if (pastedNode.isSubclassOf("QtQuick3D.Node")) { if (pastedNode.isSubclassOf("QtQuick3D.Node")) {
int activeSceneId = rootModelNode().auxiliaryData("active3dScene").toInt(); int activeSceneId = rootModelNode().auxiliaryData("active3dScene@Internal").toInt();
if (activeSceneId != -1) { if (activeSceneId != -1) {
NodeListProperty sceneNodeProperty NodeListProperty sceneNodeProperty
= QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId); = QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId);