disabling treeitem suicide if the item is deleted due to a cleanup (internal stuff...
[quassel.git] / src / client / treemodel.cpp
index 5c23063..13b97f9 100644 (file)
  *****************************************/
 AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent)
   : QObject(parent),
-    _flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled)
+    _flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
+    _treeItemFlags(0)
 {
 }
 
-AbstractTreeItem::~AbstractTreeItem() {
-}
-
 bool AbstractTreeItem::newChild(AbstractTreeItem *item) {
   int newRow = childCount();
   emit beginAppendChilds(newRow, newRow);
@@ -68,6 +66,8 @@ bool AbstractTreeItem::removeChild(int row) {
   treeitem->deleteLater();
   emit endRemoveChilds();
 
+  checkForDeletion();
+  
   return true;
 }
 
@@ -84,6 +84,7 @@ void AbstractTreeItem::removeAllChilds() {
   childIter = _childItems.begin();
   while(childIter != _childItems.end()) {
     child = *childIter;
+    child->setTreeItemFlags(0); // disable self deletion, as this would only fuck up consitency and the child gets deleted anyways
     child->removeAllChilds();
     childIter++;
   }
@@ -96,6 +97,8 @@ void AbstractTreeItem::removeAllChilds() {
     child->deleteLater();
   }
   emit endRemoveChilds();
+
+  checkForDeletion();
 }
 
 bool AbstractTreeItem::reParent(AbstractTreeItem *newParent) {
@@ -114,6 +117,8 @@ bool AbstractTreeItem::reParent(AbstractTreeItem *newParent) {
   parent()->_childItems.removeAt(oldRow);
   emit parent()->endRemoveChilds();
 
+  parent()->checkForDeletion();
+
   setParent(newParent);
 
   bool success = newParent->newChild(this);