summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qfileinfo.cpp19
-rw-r--r--src/corelib/io/qfileinfo.h4
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp16
3 files changed, 32 insertions, 7 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index fb5aeac189..062efcf40a 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1559,6 +1559,23 @@ void QFileInfo::setCaching(bool enable)
}
/*!
+ \internal
+
+ Reads all attributes from the file system.
+
+ This is useful when information about the file system is collected in a
+ worker thread, and then passed to the UI in the form of caching QFileInfo
+ instances.
+
+ \sa setCaching(), refresh()
+*/
+void QFileInfo::stat()
+{
+ Q_D(QFileInfo);
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::AllMetaDataFlags);
+}
+
+/*!
\typedef QFileInfoList
\relates QFileInfo
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 2bed64eb1a..d7cc51c7df 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -189,6 +189,8 @@ protected:
QSharedDataPointer<QFileInfoPrivate> d_ptr;
private:
+ friend class QFileInfoGatherer;
+ void stat();
QFileInfoPrivate* d_func();
inline const QFileInfoPrivate* d_func() const
{
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 750db9a2dc..11d963226f 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -40,6 +40,7 @@
#include "qfileinfogatherer_p.h"
#include <qdebug.h>
#include <qdiriterator.h>
+#include <private/qfileinfo_p.h>
#ifndef Q_OS_WIN
# include <unistd.h>
# include <sys/types.h>
@@ -378,12 +379,15 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
for (const auto &file : files)
infoList << QFileInfo(file);
}
+ QList<QPair<QString, QFileInfo>> updatedFiles;
+ updatedFiles.reserve(infoList.count());
for (int i = infoList.count() - 1; i >= 0; --i) {
- QString driveName = translateDriveName(infoList.at(i));
- QList<QPair<QString, QFileInfo>> updatedFiles;
- updatedFiles.append(QPair<QString,QFileInfo>(driveName, infoList.at(i)));
- emit updates(path, updatedFiles);
+ QFileInfo driveInfo = infoList.at(i);
+ driveInfo.stat();
+ QString driveName = translateDriveName(driveInfo);
+ updatedFiles.append(QPair<QString,QFileInfo>(driveName, driveInfo));
}
+ emit updates(path, updatedFiles);
return;
}
@@ -400,6 +404,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
while (!abort.loadRelaxed() && dirIt.hasNext()) {
dirIt.next();
fileInfo = dirIt.fileInfo();
+ fileInfo.stat();
allFiles.append(fileInfo.fileName());
fetch(fileInfo, base, firstTime, updatedFiles, path);
}
@@ -411,6 +416,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
while (!abort.loadRelaxed() && filesIt != filesToCheck.constEnd()) {
fileInfo.setFile(path + QDir::separator() + *filesIt);
++filesIt;
+ fileInfo.stat();
fetch(fileInfo, base, firstTime, updatedFiles, path);
}
if (!updatedFiles.isEmpty())