+void TreeModel::itemDataChanged(int column) {
+ AbstractTreeItem *item = qobject_cast<AbstractTreeItem *>(sender());
+ QModelIndex leftIndex, rightIndex;
+
+ if(item == rootItem)
+ return;
+
+ if(column == -1) {
+ leftIndex = createIndex(item->row(), 0, item);
+ rightIndex = createIndex(item->row(), item->columnCount() - 1, item);
+ } else {
+ leftIndex = createIndex(item->row(), column, item);
+ rightIndex = leftIndex;
+ }
+
+ emit dataChanged(leftIndex, rightIndex);
+}
+
+void TreeModel::connectItem(AbstractTreeItem *item) {
+ connect(item, SIGNAL(dataChanged(int)),
+ this, SLOT(itemDataChanged(int)));
+
+ connect(item, SIGNAL(beginAppendChilds(int, int)),
+ this, SLOT(beginAppendChilds(int, int)));
+ connect(item, SIGNAL(endAppendChilds()),
+ this, SLOT(endAppendChilds()));
+
+ connect(item, SIGNAL(beginRemoveChilds(int, int)),
+ this, SLOT(beginRemoveChilds(int, int)));
+ connect(item, SIGNAL(endRemoveChilds()),
+ this, SLOT(endRemoveChilds()));
+}
+
+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);