diff options
author | Joni Poikelin <joni.poikelin@theqtcompany.com> | 2015-09-23 13:42:11 +0300 |
---|---|---|
committer | Joni Poikelin <joni.poikelin@theqtcompany.com> | 2015-09-24 08:13:07 +0000 |
commit | 61f2e9a9a72ba4daa96960bf3cb7a605c0b4634c (patch) | |
tree | 0233735440ded55a35313f910813bdf06c6335b0 /src/corelib/itemmodels/qitemselectionmodel.cpp | |
parent | 7183d08095f4598fc0f7702608bd726986bf1307 (diff) |
Fix QItemSelectionModel deselection range
Left and right were swapped which caused invalid selection ranges to be
emitted through selectionChanged.
Task-number: QTBUG-48402
Change-Id: I18692c2b50c49ab39065f9b360b37b7615227ee9
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/corelib/itemmodels/qitemselectionmodel.cpp')
-rw-r--r-- | src/corelib/itemmodels/qitemselectionmodel.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index ba97543c44..51c670f79e 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -729,11 +729,11 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare deselected.append(*it); it = ranges.erase(it); } else if (start <= it->top() && it->top() <= end) { // Top intersection - deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent()))); + deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->right(), it->parent()))); *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight()); ++it; } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection - deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); + deselected.append(QItemSelectionRange(model->index(start, it->left(), it->parent()), it->bottomRight())); *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); ++it; } else if (it->top() < start && end < it->bottom()) { // Middle intersection @@ -741,8 +741,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6]. // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection // in ranges. - const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()), - model->index(end, it->left(), it->parent())); + const QItemSelectionRange removedRange(model->index(start, it->left(), it->parent()), + model->index(end, it->right(), it->parent())); deselected.append(removedRange); QItemSelection::split(*it, removedRange, &newParts); it = ranges.erase(it); |