X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Ftreemodel.cpp;h=0d6111fb5c3916f85ac6efd4717f1e54f08f8739;hb=2039f5e28eeb431e394f1c2468a26218bd926538;hp=d84f0e018e0090645090f47b421b8f56fc7b2c43;hpb=7f22197b5318ccbe7f0b6b644127a71c025ca917;p=quassel.git diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index d84f0e01..0d6111fb 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -165,8 +165,13 @@ bool TreeModel::removeRow(int row, const QModelIndex &parent) { if(row > rowCount(parent)) return false; + TreeItem *item; + if(!parent.isValid()) + item = rootItem; + else + item = static_cast(parent.internalPointer()); + beginRemoveRows(parent, row, row); - TreeItem *item = static_cast(parent.internalPointer()); item->removeChild(row); endRemoveRows(); return true; @@ -181,8 +186,15 @@ bool TreeModel::removeRows(int row, int count, const QModelIndex &parent) { if(row + count - 1 > rowCount(parent) || row < 0 || count < 0) return false; + TreeItem *item; + if(!parent.isValid()) + item = rootItem; + else + item = static_cast(parent.internalPointer()); + + beginRemoveRows(parent, row, row + count - 1); - TreeItem *item = static_cast(parent.internalPointer()); + for(int i = row + count - 1; i >= 0; i--) { item->removeChild(i); } @@ -191,5 +203,5 @@ bool TreeModel::removeRows(int row, int count, const QModelIndex &parent) { } void TreeModel::clear() { - removeRows(0, rowCount(), QModelIndex()); + removeRows(0, rowCount()); }