summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-10-23 14:01:35 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-10-23 14:45:03 +0200
commit790aef362fd195adf97d8c780a7cbbbade27d51f (patch)
tree8be464687ab21806cfe9f7ada27098b563aa41b2 /src/widgets/dialogs
parent9720efbd1035c2e939b0581163e6d804c713dd96 (diff)
parent07475c662eb73c833da2d461b8ef2702ca1e2cfb (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: .qmake.conf configure src/corelib/global/qglobal.h src/tools/qdoc/node.cpp src/tools/qdoc/qdocdatabase.cpp tests/auto/corelib/io/qsettings/tst_qsettings.cpp tools/configure/configureapp.cpp Change-Id: I66028ae5e441a06b73ee85ba72a03a3af3e8593f
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp53
1 files changed, 16 insertions, 37 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 00f466e227..6bbd464398 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -243,7 +243,7 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare
Q_ASSERT(parentNode);
// now get the internal pointer for the index
- QString childName = parentNode->visibleChildren[d->translateVisibleLocation(parentNode, row)];
+ const QString &childName = parentNode->visibleChildren.at(d->translateVisibleLocation(parentNode, row));
const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
Q_ASSERT(indexNode);
@@ -811,8 +811,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
#endif
!resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QString fullPath = QDir::fromNativeSeparators(filePath(index));
- if (resolvedSymLinks.contains(fullPath))
- return resolvedSymLinks[fullPath];
+ return resolvedSymLinks.value(fullPath, dirNode->fileName);
}
return dirNode->fileName;
}
@@ -1127,10 +1126,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);
}
@@ -1150,16 +1149,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);
@@ -1167,9 +1164,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) {
@@ -1783,26 +1782,6 @@ void QFileSystemModelPrivate::removeNode(QFileSystemModelPrivate::QFileSystemNod
q->endRemoveRows();
}
-/*
- \internal
- Helper functor used by addVisibleFiles()
-*/
-class QFileSystemModelVisibleFinder
-{
-public:
- inline QFileSystemModelVisibleFinder(QFileSystemModelPrivate::QFileSystemNode *node, QFileSystemModelSorter *sorter) : parentNode(node), sorter(sorter) {}
-
- bool operator()(const QString &, QString r) const
- {
- return sorter->compareNodes(parentNode->children.value(name), parentNode->children.value(r));
- }
-
- QString name;
-private:
- QFileSystemModelPrivate::QFileSystemNode *parentNode;
- QFileSystemModelSorter *sorter;
-};
-
/*!
\internal
@@ -1824,9 +1803,9 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const
parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
for (int i = 0; i < newFiles.count(); ++i) {
- parentNode->visibleChildren.append(newFiles.at(i));
- parentNode->children[newFiles.at(i)]->isVisible = true;
- }
+ parentNode->visibleChildren.append(newFiles.at(i));
+ parentNode->children.value(newFiles.at(i))->isVisible = true;
+ }
if (!indexHidden)
q->endInsertRows();
}
@@ -1848,7 +1827,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int
if (!indexHidden)
q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
translateVisibleLocation(parentNode, vLocation));
- parentNode->children[parentNode->visibleChildren.at(vLocation)]->isVisible = false;
+ parentNode->children.value(parentNode->visibleChildren.at(vLocation))->isVisible = false;
parentNode->visibleChildren.removeAt(vLocation);
if (!indexHidden)
q->endRemoveRows();