diff options
Diffstat (limited to 'src/widgets/itemviews/qlistwidget.cpp')
-rw-r--r-- | src/widgets/itemviews/qlistwidget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 39d03124ce..27abfb8eb4 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -304,7 +304,7 @@ void QListModel::sort(int column, Qt::SortOrder order) } LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); - qSort(sorting.begin(), sorting.end(), compare); + std::sort(sorting.begin(), sorting.end(), compare); QModelIndexList fromIndexes; QModelIndexList toIndexes; for (int r = 0; r < sorting.count(); ++r) { @@ -338,7 +338,7 @@ void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int en } LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); - qSort(sorting.begin(), sorting.end(), compare); + std::sort(sorting.begin(), sorting.end(), compare); QModelIndexList oldPersistentIndexes = persistentIndexList(); QModelIndexList newPersistentIndexes = oldPersistentIndexes; @@ -347,7 +347,11 @@ void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int en bool changed = false; for (int i = 0; i < count; ++i) { int oldRow = sorting.at(i).second; + int tmpitepos = lit - tmp.begin(); QListWidgetItem *item = tmp.takeAt(oldRow); + if (tmpitepos > tmp.size()) + --tmpitepos; + lit = tmp.begin() + tmpitepos; lit = sortedInsertionIterator(lit, tmp.end(), order, item); int newRow = qMax(lit - tmp.begin(), 0); lit = tmp.insert(lit, item); @@ -1828,7 +1832,7 @@ void QListWidget::dropEvent(QDropEvent *event) { if (persIndexes.contains(topIndex)) return; - qSort(persIndexes); // The dropped items will remain in the same visual order. + std::sort(persIndexes.begin(), persIndexes.end()); // The dropped items will remain in the same visual order. QPersistentModelIndex dropRow = model()->index(row, col, topIndex); |