diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-10-16 11:07:35 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-10-16 20:20:20 +0000 |
| commit | fb9b208ae9b22e8ced331f4d4e20392c9bc1357b (patch) | |
| tree | 455599e9e03ca2c9f61dc0842cf5680e184f4fc6 /src/xml/node.h | |
| parent | Extensions: only check existence for interpreted scripts. (diff) | |
| download | inkscape-fb9b208ae9b22e8ced331f4d4e20392c9bc1357b.tar.gz inkscape-fb9b208ae9b22e8ced331f4d4e20392c9bc1357b.zip | |
Inkscape::XML::Node::addChildAtPos
Diffstat (limited to 'src/xml/node.h')
| -rw-r--r-- | src/xml/node.h | 16 |
1 files changed, 15 insertions, 1 deletions
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 |
