summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qitemselectionmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemviews/qitemselectionmodel.cpp')
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 9dad95f..0f35ac1 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -593,10 +593,30 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
// update selectionsx
QModelIndex tl = model->index(start, 0, parent);
QModelIndex br = model->index(end, model->columnCount(parent) - 1, parent);
- q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect);
+ recursiveDeselect(QItemSelectionRange(tl, br));
finalize();
}
+void QItemSelectionModelPrivate::recursiveDeselect(const QItemSelectionRange &range)
+{
+ Q_Q(QItemSelectionModel);
+
+ QItemSelection sel(range.topLeft(), range.bottomRight());
+ q->select(sel, QItemSelectionModel::Deselect);
+
+ QModelIndexList idxList = range.indexes();
+ QModelIndexList::const_iterator it = idxList.begin();
+ for (; it != idxList.end(); ++it)
+ {
+ if (!model->hasChildren(*it))
+ continue;
+
+ const QModelIndex &firstChild = it->child(0,0);
+ const QModelIndex &lastChild = it->child(model->rowCount(*it) - 1, model->columnCount(*it) - 1);
+ recursiveDeselect(QItemSelectionRange(firstChild, lastChild));
+ }
+}
+
/*!
\internal
*/