diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-15 11:16:39 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-08 19:35:26 +0000 |
commit | 89034600939bbfe241ba3d6136abf7bb6961db52 (patch) | |
tree | 569ed773351a496ddac552fff66859967695351f /src/widgets/itemviews/qabstractitemview.cpp | |
parent | f931e5e72d4617023bbea46cba2c0d61bb1efa4f (diff) |
QtBase: use erase and std::remove_if with QList and QVector
... instead of using removeAt in a loop, with quadratic complexity.
Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 6c38c53a77..9bb4497811 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -68,6 +68,8 @@ # include <qscroller.h> #endif +#include <algorithm> + QT_BEGIN_NAMESPACE QAbstractItemViewPrivate::QAbstractItemViewPrivate() @@ -4459,10 +4461,12 @@ QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const { Q_Q(const QAbstractItemView); QModelIndexList indexes = q->selectedIndexes(); - for(int i = indexes.count() - 1 ; i >= 0; --i) { - if (!isIndexDragEnabled(indexes.at(i))) - indexes.removeAt(i); - } + auto isNotDragEnabled = [this](const QModelIndex &index) { + return !isIndexDragEnabled(index); + }; + indexes.erase(std::remove_if(indexes.begin(), indexes.end(), + isNotDragEnabled), + indexes.end()); return indexes; } |