X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.cpp;h=1505a25ed11272a72f66d5e8fed3806f2f59fa71;hp=3f264498938b6167e07b8c55316bd1baa2250571;hb=e104b220388a276a4483a45567243a8473ca5fa6;hpb=13b2affbdccd1d52479e49affdb81a77258392a6;ds=sidebyside diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 3f264498..1505a25e 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -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(parent.internalPointer()); + for(int i = row; i < row + count; i++) { + item->removeChild(i); + } + endRemoveRows(); + return true; +} + +void TreeModel::clear() { + removeRows(0, rowCount(), QModelIndex()); +}