+void TreeModel::beginAppendChilds(int firstRow, int lastRow) {
+ AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ if(!parentItem) {
+ qWarning() << "TreeModel::beginAppendChilds(): cannot append Childs to unknown parent";
+ return;
+ }
+
+ QModelIndex parent = indexByItem(parentItem);
+ Q_ASSERT(!_aboutToRemoveOrInsert);
+
+ _aboutToRemoveOrInsert = true;
+ _childStatus = ChildStatus(parent, rowCount(parent), firstRow, lastRow);
+ beginInsertRows(parent, firstRow, lastRow);
+}
+
+void TreeModel::endAppendChilds() {
+ AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ if(!parentItem) {
+ qWarning() << "TreeModel::endAppendChilds(): cannot append Childs to unknown parent";
+ return;
+ }
+ Q_ASSERT(_aboutToRemoveOrInsert);
+ ChildStatus cs = _childStatus;
+ QModelIndex parent = indexByItem(parentItem);
+ Q_ASSERT(cs.parent == parent);
+ Q_ASSERT(rowCount(parent) == cs.childCount + cs.end - cs.start + 1);
+
+ _aboutToRemoveOrInsert = false;
+ for(int i = cs.start; i <= cs.end; i++) {
+ connectItem(parentItem->child(i));
+ }
+ endInsertRows();