forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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)
|
void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode)
|
||||||
{
|
{
|
||||||
|
QList<FormEditorItem*> removedItemList;
|
||||||
|
|
||||||
if (qmlItemNode.isValid()) {
|
if (qmlItemNode.isValid()) {
|
||||||
QList<QmlItemNode> nodeList;
|
QList<QmlItemNode> nodeList;
|
||||||
nodeList.append(qmlItemNode.allSubModelNodes());
|
nodeList.append(qmlItemNode.allSubModelNodes());
|
||||||
nodeList.append(qmlItemNode);
|
nodeList.append(qmlItemNode);
|
||||||
|
|
||||||
QList<FormEditorItem*> removedItemList;
|
|
||||||
|
|
||||||
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
|
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
|
||||||
m_currentTool->itemsAboutToRemoved(removedItemList);
|
|
||||||
|
|
||||||
//The destructor of QGraphicsItem does delete all its children.
|
//The destructor of QGraphicsItem does delete all its children.
|
||||||
//We have to keep the children if they are not children in the model anymore.
|
//We have to keep the children if they are not children in the model anymore.
|
||||||
//Otherwise we delete the children explicitly anyway.
|
//Otherwise we delete the children explicitly anyway.
|
||||||
deleteWithoutChildren(removedItemList);
|
deleteWithoutChildren(removedItemList);
|
||||||
} else if (qmlItemNode.isFlowTransition()) {
|
} else if (isFlowNonItem(qmlItemNode)) {
|
||||||
deleteWithoutChildren(scene()->itemsForQmlItemNodes({qmlItemNode}));
|
removedItemList.append(scene()->itemsForQmlItemNodes({qmlItemNode}));
|
||||||
|
deleteWithoutChildren(removedItemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!removedItemList.isEmpty())
|
||||||
|
m_currentTool->itemsAboutToRemoved(removedItemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
|
void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
|
||||||
@@ -308,6 +318,11 @@ void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& p
|
|||||||
removedItems.append(item);
|
removedItems.append(item);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
} else if (isFlowNonItem(qmlItemNode)) {
|
||||||
|
if (FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode)) {
|
||||||
|
removedItems.append(item);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user