summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorMaks Naumov <maksqwe1@ukr.net>2015-10-17 15:39:47 +0300
committerMaks Naumov <maksqwe1@ukr.net>2015-10-20 09:46:05 +0000
commit9b54f4c81c66917eb6d64f501007da5d3852b3f2 (patch)
treeaefaef8c3b06689cf3e4c503b04bba806dcad4f8 /src/widgets/dialogs
parent6df48eb668be4db85c48a4ae3ed22be2c70a9041 (diff)
QFileSystemModel: cleanup sortChildren()
Second value of QPair is not used. And add reserve for "indexNode->visibleChildren" list before pushing. Change-Id: Ia002130c929f71e0802f73f4c0694fd2887b4c91 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 70df7f305f..67af7f8107 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -1111,10 +1111,10 @@ public:
return false;
}
- bool operator()(const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &l,
- const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &r) const
+ bool operator()(const QFileSystemModelPrivate::QFileSystemNode *l,
+ const QFileSystemModelPrivate::QFileSystemNode *r) const
{
- return compareNodes(l.first, r.first);
+ return compareNodes(l, r);
}
@@ -1134,16 +1134,14 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
if (indexNode->children.count() == 0)
return;
- QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values;
+ QVector<QFileSystemModelPrivate::QFileSystemNode*> values;
QHash<QString, QFileSystemNode *>::const_iterator iterator;
- int i = 0;
for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) {
if (filtersAcceptsNode(iterator.value())) {
- values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i));
+ values.append(iterator.value());
} else {
iterator.value()->isVisible = false;
}
- i++;
}
QFileSystemModelSorter ms(column);
std::sort(values.begin(), values.end(), ms);
@@ -1151,9 +1149,11 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
indexNode->visibleChildren.clear();
//No more dirty item we reset our internal dirty index
indexNode->dirtyChildrenIndex = -1;
- for (int i = 0; i < values.count(); ++i) {
- indexNode->visibleChildren.append(values.at(i).first->fileName);
- values.at(i).first->isVisible = true;
+ const int numValues = values.count();
+ indexNode->visibleChildren.reserve(numValues);
+ for (int i = 0; i < numValues; ++i) {
+ indexNode->visibleChildren.append(values.at(i)->fileName);
+ values.at(i)->isVisible = true;
}
if (!disableRecursiveSort) {