treemodels can now be cleared
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 25 Jul 2007 17:55:00 +0000 (17:55 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 25 Jul 2007 17:55:00 +0000 (17:55 +0000)
src/client/treemodel.cpp
src/client/treemodel.h

index 3f26449..1505a25 100644 (file)
@@ -169,3 +169,16 @@ bool TreeModel::removeRow(int row, const QModelIndex &parent) {
   return true;
 }
 
+bool TreeModel::removeRows(int row, int count, const QModelIndex &parent) {
+  beginRemoveRows(parent, row, row + count - 1);
+  TreeItem *item = static_cast<TreeItem*>(parent.internalPointer());
+  for(int i = row; i < row + count; i++) {
+    item->removeChild(i);
+  }
+  endRemoveRows();
+  return true;
+}
+
+void TreeModel::clear() {
+  removeRows(0, rowCount(), QModelIndex());
+}
index 1941602..f979d11 100644 (file)
@@ -73,6 +73,8 @@ public:
 
 protected:
   bool removeRow(int row, const QModelIndex &parent = QModelIndex());
+  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+  void clear();
   
   TreeItem *rootItem;
 };