forked from qt-creator/qt-creator
QmlDesigner: Optimize deleting nodes
- remove unnecessary call to directSubModelNodes() - replace foreach with for (avoid unnecessary copies) Change-Id: I42721a4c4e69f320664af8364f8baa0df0d11459 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -693,35 +693,33 @@ void ModelNode::removeProperty(const PropertyName &name) const
|
|||||||
model()->d->removeProperty(internalNode()->property(name));
|
model()->d->removeProperty(internalNode()->property(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief removes this node from the node tree
|
/*! \brief removes this node from the node tree
|
||||||
*/
|
*/
|
||||||
|
static QList<ModelNode> descendantNodes(const ModelNode &node)
|
||||||
static QList<ModelNode> descendantNodes(const ModelNode &parent)
|
|
||||||
{
|
{
|
||||||
QList<ModelNode> descendants(parent.directSubModelNodes());
|
const QList<ModelNode> children = node.directSubModelNodes();
|
||||||
foreach (const ModelNode &child, parent.directSubModelNodes()) {
|
QList<ModelNode> descendants = children;
|
||||||
|
for (const ModelNode &child : children)
|
||||||
descendants += descendantNodes(child);
|
descendants += descendantNodes(child);
|
||||||
}
|
|
||||||
return descendants;
|
return descendants;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeModelNodeFromSelection(const ModelNode &node)
|
static void removeModelNodeFromSelection(const ModelNode &node)
|
||||||
{
|
{
|
||||||
{ // remove nodes from the active selection:
|
// remove nodes from the active selection
|
||||||
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
|
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
|
||||||
|
|
||||||
foreach (const ModelNode &childModelNode, descendantNodes(node))
|
const QList<ModelNode> descendants = descendantNodes(node);
|
||||||
selectedList.removeAll(childModelNode);
|
for (const ModelNode &descendantNode : descendants)
|
||||||
selectedList.removeAll(node);
|
selectedList.removeAll(descendantNode);
|
||||||
|
|
||||||
node.view()->setSelectedModelNodes(selectedList);
|
selectedList.removeAll(node);
|
||||||
}
|
|
||||||
|
node.view()->setSelectedModelNodes(selectedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief complete removes this ModelNode from the Model
|
/*! \brief complete removes this ModelNode from the Model
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void ModelNode::destroy()
|
void ModelNode::destroy()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user