X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.cpp;h=929622d6af3eb92ec81e5b6dfcce91027c217037;hp=05b2635764d84a15d472fbfbac96ef8dad6dd891;hb=7df7429c009d2bea4c516e87f1ec4c956c722e09;hpb=7f9a9f7627d590ae99d489c343b75d76c9db33ae diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 05b26357..929622d6 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -86,6 +86,20 @@ void AbstractTreeItem::removeChild(int row) { removeChild(defaultColumn(), row); } +void AbstractTreeItem::removeChildById(int column, const quint64 &id) { + if(!_childHash[column].contains(id)) + return; + + AbstractTreeItem *treeItem = _childHash[column][id]; + int row = _childItems[column].indexOf(treeItem); + Q_ASSERT(row >= 0); + removeChild(column, row); +} + +void AbstractTreeItem::removeChildById(const quint64 &id) { + removeChildById(defaultColumn(), id); +} + void AbstractTreeItem::removeAllChilds() { if(childCount() == 0) return; @@ -93,11 +107,12 @@ void AbstractTreeItem::removeAllChilds() { emit beginRemoveChilds(0, childCount() - 1); AbstractTreeItem *child; - foreach(int key, _childItems.keys()) { - QList::iterator iter = _childItems[key].begin(); - while(iter != _childItems[key].end()) { + foreach(int column, _childItems.keys()) { + QList::iterator iter = _childItems[column].begin(); + while(iter != _childItems[column].end()) { child = *iter; - iter = _childItems[key].erase(iter); + _childHash[column].remove(_childHash[column].key(child)); + iter = _childItems[column].erase(iter); disconnect(child, 0, this, 0); child->removeAllChilds(); child->deleteLater(); @@ -430,9 +445,6 @@ void TreeModel::appendChild(AbstractTreeItem *parent, AbstractTreeItem *child) { connect(child, SIGNAL(newChild(AbstractTreeItem *)), this, SLOT(newChild(AbstractTreeItem *))); -// connect(child, SIGNAL(childRemoved(int)), -// this, SLOT(childRemoved(int))); - connect(child, SIGNAL(beginRemoveChilds(int, int)), this, SLOT(beginRemoveChilds(int, int))); @@ -453,19 +465,6 @@ void TreeModel::endRemoveChilds() { endRemoveRows(); } -void TreeModel::childRemoved(int row) { - QModelIndex parent = indexByItem(static_cast(sender())); - beginRemoveRows(parent, row, row); - endRemoveRows(); -} - -void TreeModel::childsRemoved(int firstRow, int lastRow) { - QModelIndex parent = indexByItem(static_cast(sender())); - beginRemoveRows(parent, firstRow, lastRow); - endRemoveRows(); - -} - bool TreeModel::removeRow(int row, const QModelIndex &parent) { if(row > rowCount(parent)) return false;