diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-04-15 19:33:33 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-04-21 05:43:59 +0000 |
commit | ad944631340841f7f12d7669bbc4e7c136cbdef9 (patch) | |
tree | 9981900a244f722dfadf44963937b4063fcd83b1 | |
parent | e75a1ea601b413749084320c103548e804abe06f (diff) |
QmlDesigner: Take care of deleted items in FormEditor
The FormEditor did not take care of deleted transition items
in all cases.
Change-Id: Ic5a700b98ae8c400ffd398c5c6972587e2863971
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/formeditorview.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 6149b248ce..781bbab1ef 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -169,25 +169,35 @@ static void deleteWithoutChildren(const QList<FormEditorItem*> &items) } } +static bool isFlowNonItem(const QmlItemNode &itemNode) +{ + return itemNode.isFlowTransition() + || itemNode.isFlowWildcard() + || itemNode.isFlowWildcard(); +} + void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode) { + QList<FormEditorItem*> removedItemList; + if (qmlItemNode.isValid()) { QList<QmlItemNode> nodeList; nodeList.append(qmlItemNode.allSubModelNodes()); nodeList.append(qmlItemNode); - QList<FormEditorItem*> removedItemList; - removedItemList.append(scene()->itemsForQmlItemNodes(nodeList)); - m_currentTool->itemsAboutToRemoved(removedItemList); //The destructor of QGraphicsItem does delete all its children. //We have to keep the children if they are not children in the model anymore. //Otherwise we delete the children explicitly anyway. deleteWithoutChildren(removedItemList); - } else if (qmlItemNode.isFlowTransition()) { - deleteWithoutChildren(scene()->itemsForQmlItemNodes({qmlItemNode})); + } else if (isFlowNonItem(qmlItemNode)) { + removedItemList.append(scene()->itemsForQmlItemNodes({qmlItemNode})); + deleteWithoutChildren(removedItemList); } + + if (!removedItemList.isEmpty()) + m_currentTool->itemsAboutToRemoved(removedItemList); } void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode) @@ -308,6 +318,11 @@ void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& p removedItems.append(item); delete item; } + } else if (isFlowNonItem(qmlItemNode)) { + if (FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode)) { + removedItems.append(item); + delete item; + } } } } |