From fb9b208ae9b22e8ced331f4d4e20392c9bc1357b Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 16 Oct 2019 13:07:35 +0200 Subject: Inkscape::XML::Node::addChildAtPos --- src/xml/node.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/xml/node.h') diff --git a/src/xml/node.h b/src/xml/node.h index c32508eec..17e09b5fa 100644 --- a/src/xml/node.h +++ b/src/xml/node.h @@ -351,7 +351,21 @@ public: * @param after The node after which the inserted node should be placed, or NULL */ virtual void addChild(Node *child, Node *after)=0; - + + /** + * @brief Insert another node as a child of this node + * + * This is more efficient than appendChild() + setPosition(). + * + * @param child The node to insert + * @param pos The position in parent's child order + */ + void addChildAtPos(Node *child, unsigned pos) + { + Node *after = (pos == 0) ? nullptr : nthChild(pos - 1); + addChild(child, after); + } + /** * @brief Append a node as the last child of this node * @param child The node to append -- cgit v1.2.3