Properly fix issue in qtablewidget.cpp
The original fix done in 4b2f5371d9
actually introduced another subtle issue which should in theory cause
additional overhead. Fixed the behavior to be in fact compatible to the
old one
Task-number: QTBUG-84320
Change-Id: I22b130076f9eedbcf7c5eeae78362adfd0eee9af
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
parent
92a32e050f
commit
90a053d203
@ -584,12 +584,15 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
|
||||
QList<QTableWidgetItem *> newVertical = verticalHeaderItems;
|
||||
QList<QTableWidgetItem *> colItems = columnItems(column);
|
||||
QList<QTableWidgetItem *>::iterator vit = colItems.begin();
|
||||
qsizetype distanceFromBegin = 0;
|
||||
bool changed = false;
|
||||
for (int i = 0; i < sorting.count(); ++i) {
|
||||
distanceFromBegin = std::distance(colItems.begin(), vit);
|
||||
int oldRow = sorting.at(i).second;
|
||||
QTableWidgetItem *item = colItems.at(oldRow);
|
||||
colItems.remove(oldRow);
|
||||
vit = sortedInsertionIterator(colItems.begin(), colItems.end(), order, item);
|
||||
vit = sortedInsertionIterator(colItems.begin() + distanceFromBegin, colItems.end(), order,
|
||||
item);
|
||||
int newRow = qMax((int)(vit - colItems.begin()), 0);
|
||||
if ((newRow < oldRow) && !(*item < *colItems.at(oldRow - 1)) && !(*colItems.at(oldRow - 1) < *item))
|
||||
newRow = oldRow;
|
||||
|
Loading…
Reference in New Issue
Block a user