X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.cpp;h=d66cc3a9f838ac9d58c187dbd9f679eaa100e778;hp=9a01abf455c57446112474184a35a44f2240b676;hb=56607f81246f04db3a0e71c9a8757d7f75d6cfcf;hpb=ffa244c20cbaf74d50e27a9416d33ea8e08e2836 diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 9a01abf4..d66cc3a9 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -51,6 +51,35 @@ bool AbstractTreeItem::newChild(AbstractTreeItem *item) { return true; } +bool AbstractTreeItem::newChilds(const QList &items) { + if(items.isEmpty()) + return false; + + QList::const_iterator itemIter = items.constBegin(); + AbstractTreeItem *item; + while(itemIter != items.constEnd()) { + item = *itemIter; + if(childById(item->id()) != 0) { + qWarning() << "AbstractTreeItem::newChilds(): received child that is already attached" << item << item->id(); + return false; + } + itemIter++; + } + + int nextRow = childCount(); + int lastRow = nextRow + items.count() - 1; + + emit beginAppendChilds(nextRow, lastRow); + itemIter = items.constBegin(); + while(itemIter != items.constEnd()) { + _childItems.append(*itemIter); + itemIter++; + } + emit endAppendChilds(); + + return true; +} + bool AbstractTreeItem::removeChild(int row) { if(childCount() <= row) return false;