QFileSystemModel: avoid detaching
Change-Id: If7e9f11e5514b2f8975e7f83c56b606e67f5952f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
85226dfed3
commit
bfb6a8cd44
@ -243,7 +243,7 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare
|
|||||||
Q_ASSERT(parentNode);
|
Q_ASSERT(parentNode);
|
||||||
|
|
||||||
// now get the internal pointer for the index
|
// 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);
|
const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
|
||||||
Q_ASSERT(indexNode);
|
Q_ASSERT(indexNode);
|
||||||
|
|
||||||
@ -797,7 +797,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
|
|||||||
!resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
|
!resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
|
||||||
QString fullPath = QDir::fromNativeSeparators(filePath(index));
|
QString fullPath = QDir::fromNativeSeparators(filePath(index));
|
||||||
if (resolvedSymLinks.contains(fullPath))
|
if (resolvedSymLinks.contains(fullPath))
|
||||||
return resolvedSymLinks[fullPath];
|
return resolvedSymLinks.value(fullPath);
|
||||||
}
|
}
|
||||||
return dirNode->fileName;
|
return dirNode->fileName;
|
||||||
}
|
}
|
||||||
@ -1790,7 +1790,7 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const
|
|||||||
|
|
||||||
for (int i = 0; i < newFiles.count(); ++i) {
|
for (int i = 0; i < newFiles.count(); ++i) {
|
||||||
parentNode->visibleChildren.append(newFiles.at(i));
|
parentNode->visibleChildren.append(newFiles.at(i));
|
||||||
parentNode->children[newFiles.at(i)]->isVisible = true;
|
parentNode->children.value(newFiles.at(i))->isVisible = true;
|
||||||
}
|
}
|
||||||
if (!indexHidden)
|
if (!indexHidden)
|
||||||
q->endInsertRows();
|
q->endInsertRows();
|
||||||
@ -1813,7 +1813,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int
|
|||||||
if (!indexHidden)
|
if (!indexHidden)
|
||||||
q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
|
q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
|
||||||
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);
|
parentNode->visibleChildren.removeAt(vLocation);
|
||||||
if (!indexHidden)
|
if (!indexHidden)
|
||||||
q->endRemoveRows();
|
q->endRemoveRows();
|
||||||
|
Loading…
Reference in New Issue
Block a user