From 2e4e94a52824d2f85af739644461fdc184aed93d Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 30 Mar 2016 06:07:22 +0200 Subject: Save mappings from slide dialog Also fix a long standing bug in MappingTreeModel: also remove item from mCurrentData when the removed item is a parent of one of the items. --- mappingtreemodel.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mappingtreemodel.cpp') diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp index 78e4802..2cf4445 100644 --- a/mappingtreemodel.cpp +++ b/mappingtreemodel.cpp @@ -484,7 +484,20 @@ void MappingTreeResultModel::removeItem(const QModelIndex &idx){ int row = curItem->row(); SmTreeItem *parent = curItem->parent(); parent->removeChild(row); - mCurrentData.removeAll(rmData); + int count = mCurrentData.removeAll(rmData); + int toRemove = -1; + if(count == 0){ + for(int i = 0; i < mCurrentData.count(); ++i){ + MappingData cur = mCurrentData.at(i); + if(cur.parents.contains(rmData.mappingId)){ + toRemove = i; + break; + } + } + } + if(toRemove > -1 && toRemove < mCurrentData.count()){ + mCurrentData.removeAt(toRemove); + } endResetModel(); } -- cgit v1.2.3-70-g09d2