summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2012-11-01 23:35:03 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-07 21:26:08 +0100
commita454ccb89ec2296234ee7328095f27ad7cb2361f (patch)
treecf141ec01b720ea0d0419d594d8da7d58f89706f
parent0d2997862bd46526d14bb5b8114215d8416bc751 (diff)
Remove qSort/qStableSort usages from itemmodels
Change-Id: I53c650f170fc8a6142373c1e7da0f4876188a39e Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp10
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp14
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp6
3 files changed, 18 insertions, 12 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index d1cbd7f461..e05b76f5da 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -43,6 +43,8 @@
#include <private/qitemselectionmodel_p.h>
#include <qdebug.h>
+#include <algorithm>
+
#ifndef QT_NO_ITEMVIEWS
QT_BEGIN_NAMESPACE
@@ -1007,8 +1009,8 @@ void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIn
if (hint != QAbstractItemModel::VerticalSortHint) {
// sort the "new" selection, as preparation for merging
- qStableSort(savedPersistentIndexes.begin(), savedPersistentIndexes.end());
- qStableSort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end());
+ std::stable_sort(savedPersistentIndexes.begin(), savedPersistentIndexes.end());
+ std::stable_sort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end());
// update the selection by merging the individual indexes
ranges = mergeIndexes(savedPersistentIndexes);
@@ -1019,8 +1021,8 @@ void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIn
savedPersistentCurrentIndexes.clear();
} else {
// sort the "new" selection, as preparation for merging
- qStableSort(savedPersistentRowLengths.begin(), savedPersistentRowLengths.end());
- qStableSort(savedPersistentCurrentRowLengths.begin(), savedPersistentCurrentRowLengths.end());
+ std::stable_sort(savedPersistentRowLengths.begin(), savedPersistentRowLengths.end());
+ std::stable_sort(savedPersistentCurrentRowLengths.begin(), savedPersistentCurrentRowLengths.end());
// update the selection by merging the individual indexes
ranges = mergeRowLengths(savedPersistentRowLengths);
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 80961e8eb3..6ab32a9366 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -52,6 +52,8 @@
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractproxymodel_p.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
typedef QList<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList;
@@ -475,13 +477,13 @@ void QSortFilterProxyModelPrivate::sort_source_rows(
if (source_sort_column >= 0) {
if (sort_order == Qt::AscendingOrder) {
QSortFilterProxyModelLessThan lt(source_sort_column, source_parent, model, q);
- qStableSort(source_rows.begin(), source_rows.end(), lt);
+ std::stable_sort(source_rows.begin(), source_rows.end(), lt);
} else {
QSortFilterProxyModelGreaterThan gt(source_sort_column, source_parent, model, q);
- qStableSort(source_rows.begin(), source_rows.end(), gt);
+ std::stable_sort(source_rows.begin(), source_rows.end(), gt);
}
} else { // restore the source model order
- qStableSort(source_rows.begin(), source_rows.end());
+ std::stable_sort(source_rows.begin(), source_rows.end());
}
}
@@ -518,7 +520,7 @@ QVector<QPair<int, int > > QSortFilterProxyModelPrivate::proxy_intervals_for_sou
// Add interval to result
proxy_intervals.append(QPair<int, int>(first_proxy_item, last_proxy_item));
}
- qStableSort(proxy_intervals.begin(), proxy_intervals.end());
+ std::stable_sort(proxy_intervals.begin(), proxy_intervals.end());
return proxy_intervals;
}
@@ -1255,7 +1257,7 @@ void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation or
}
}
- qSort(proxy_positions);
+ std::sort(proxy_positions.begin(), proxy_positions.end());
int last_index = 0;
const int numItems = proxy_positions.size();
@@ -2118,7 +2120,7 @@ bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &pa
QVector<int> rows;
for (int i = row; i < row + count; ++i)
rows.append(m->source_rows.at(i));
- qSort(rows.begin(), rows.end());
+ std::sort(rows.begin(), rows.end());
int pos = rows.count() - 1;
bool ok = true;
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
index 49345f155a..641dfb28f9 100644
--- a/src/corelib/itemmodels/qstringlistmodel.cpp
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -47,6 +47,8 @@
#include <QtCore/qvector.h>
+#include <algorithm>
+
#ifndef QT_NO_STRINGLISTMODEL
QT_BEGIN_NAMESPACE
@@ -267,9 +269,9 @@ void QStringListModel::sort(int, Qt::SortOrder order)
list.append(QPair<QString, int>(lst.at(i), i));
if (order == Qt::AscendingOrder)
- qSort(list.begin(), list.end(), ascendingLessThan);
+ std::sort(list.begin(), list.end(), ascendingLessThan);
else
- qSort(list.begin(), list.end(), decendingLessThan);
+ std::sort(list.begin(), list.end(), decendingLessThan);
lst.clear();
QVector<int> forwarding(list.count());