Increment node numberOfChildren when adding child

This commit is contained in:
Léa Saviot
2018-06-27 17:22:14 +02:00
parent 170ce95041
commit c208da2f90
4 changed files with 3 additions and 10 deletions

View File

@@ -17,7 +17,7 @@ public:
}
int numberOfChildren() const override { return m_numberOfChildren; }
void incrementNumberOfChildren() { m_numberOfChildren++; }
void incrementNumberOfChildren() override { m_numberOfChildren++; }
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override {
if (this == cursor->layoutReference().node()) {
@@ -85,11 +85,6 @@ public:
addChild(l2);
addChild(l1);
}
virtual void addChild(LayoutRef l) override {
LayoutReference<HorizontalLayoutNode>::addChild(l);
node()->incrementNumberOfChildren();
}
};
#endif

View File

@@ -20,10 +20,6 @@ public:
LayoutCursor cursor() const;
virtual void addChild(LayoutReference<LayoutNode> l) {
TreeReference<T>::addChild(l);
}
LayoutReference<LayoutNode> childAtIndex(int i) {
TreeReference<T> treeRefChild = TreeReference<T>::treeChildAtIndex(i);
return LayoutReference<LayoutNode>(treeRefChild.node());

View File

@@ -38,6 +38,7 @@ public:
TreeNode * parentTree() const;
TreeNode * editableRootTree();
virtual int numberOfChildren() const = 0;
virtual void incrementNumberOfChildren() {} //TODO Put an assert false
int numberOfDescendants(bool includeSelf) const;
TreeNode * childTreeAtIndex(int i) const;
int indexOfChildByIdentifier(int childID) const;

View File

@@ -81,6 +81,7 @@ public:
void addChild(TreeReference<TreeNode> t) {
t.node()->retain();
TreePool::sharedPool()->move(t.node(), node()->next());
node()->incrementNumberOfChildren();
}
void removeChild(TreeReference<TreeNode> t) {