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>
This commit is contained in:
parent
6df48eb668
commit
9b54f4c81c
@ -1111,10 +1111,10 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &l,
|
bool operator()(const QFileSystemModelPrivate::QFileSystemNode *l,
|
||||||
const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &r) const
|
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)
|
if (indexNode->children.count() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values;
|
QVector<QFileSystemModelPrivate::QFileSystemNode*> values;
|
||||||
QHash<QString, QFileSystemNode *>::const_iterator iterator;
|
QHash<QString, QFileSystemNode *>::const_iterator iterator;
|
||||||
int i = 0;
|
|
||||||
for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) {
|
for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) {
|
||||||
if (filtersAcceptsNode(iterator.value())) {
|
if (filtersAcceptsNode(iterator.value())) {
|
||||||
values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i));
|
values.append(iterator.value());
|
||||||
} else {
|
} else {
|
||||||
iterator.value()->isVisible = false;
|
iterator.value()->isVisible = false;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
QFileSystemModelSorter ms(column);
|
QFileSystemModelSorter ms(column);
|
||||||
std::sort(values.begin(), values.end(), ms);
|
std::sort(values.begin(), values.end(), ms);
|
||||||
@ -1151,9 +1149,11 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
|
|||||||
indexNode->visibleChildren.clear();
|
indexNode->visibleChildren.clear();
|
||||||
//No more dirty item we reset our internal dirty index
|
//No more dirty item we reset our internal dirty index
|
||||||
indexNode->dirtyChildrenIndex = -1;
|
indexNode->dirtyChildrenIndex = -1;
|
||||||
for (int i = 0; i < values.count(); ++i) {
|
const int numValues = values.count();
|
||||||
indexNode->visibleChildren.append(values.at(i).first->fileName);
|
indexNode->visibleChildren.reserve(numValues);
|
||||||
values.at(i).first->isVisible = true;
|
for (int i = 0; i < numValues; ++i) {
|
||||||
|
indexNode->visibleChildren.append(values.at(i)->fileName);
|
||||||
|
values.at(i)->isVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disableRecursiveSort) {
|
if (!disableRecursiveSort) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user