summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index d55cbe9d97..74bc0e6a9d 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -852,16 +852,26 @@ static QItemSelection mergeIndexes(const QVector<QPersistentModelIndex> &indexes
// merge columns
int i = 0;
while (i < indexes.count()) {
- QModelIndex tl = indexes.at(i);
- QModelIndex br = tl;
+ const QPersistentModelIndex &tl = indexes.at(i);
+ QPersistentModelIndex br = tl;
+ QModelIndex brParent = br.parent();
+ int brRow = br.row();
+ int brColumn = br.column();
while (++i < indexes.count()) {
- QModelIndex next = indexes.at(i);
- if ((next.parent() == br.parent())
- && (next.row() == br.row())
- && (next.column() == br.column() + 1))
+ const QPersistentModelIndex &next = indexes.at(i);
+ const QModelIndex nextParent = next.parent();
+ const int nextRow = next.row();
+ const int nextColumn = next.column();
+ if ((nextParent == brParent)
+ && (nextRow == brRow)
+ && (nextColumn == brColumn + 1)) {
br = next;
- else
+ brParent = nextParent;
+ brRow = nextRow;
+ brColumn = nextColumn;
+ } else {
break;
+ }
}
colSpans.append(QItemSelectionRange(tl, br));
}