From 47353584f92fe9952e27b7ebb58d684b67ace5ef Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 11 Nov 2022 13:40:17 +0100 Subject: [PATCH] Squish: Fix adding object by copy and paste Pasting an object should directly add the object at the right branch of the tree if necessary. So, in case of having a container or widget property the new item has to be added as a child of this. Change-Id: I0d7398eec8ae7b5bf6414a525e695d52b13b1113 Reviewed-by: David Schulz --- src/plugins/squish/objectsmaptreeitem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/squish/objectsmaptreeitem.cpp b/src/plugins/squish/objectsmaptreeitem.cpp index 79c0c27eaea..00eaa041e56 100644 --- a/src/plugins/squish/objectsmaptreeitem.cpp +++ b/src/plugins/squish/objectsmaptreeitem.cpp @@ -284,7 +284,14 @@ void ObjectsMapModel::addNewObject(ObjectsMapTreeItem *item) QTC_ASSERT(item, return ); QTC_ASSERT(rootItem(), return ); - rootItem()->appendChild(item); + auto parentItem = rootItem(); + const QString parentName = item->parentName(); + if (!parentName.isEmpty()) { + if (auto found = findItem(parentName)) + parentItem = found; + } + + parentItem->appendChild(item); emit modelChanged(); }