8#include <private/qabstractfileiconprovider_p.h>
9#include <private/qfileinfo_p.h>
12# include <sys/types.h>
14#if defined(Q_OS_VXWORKS)
15# include "qplatformdefs.h"
22#ifdef QT_BUILD_INTERNAL
26 fetchedRoot.storeRelaxed(
false);
31 return fetchedRoot.loadRelaxed();
39 if (driveName.startsWith(u
'/'))
41 if (driveName.endsWith(u
'/'))
52 , m_iconProvider(&defaultProvider)
102 m_resolveSymlinks =
enable;
106void QFileInfoGatherer::driveAdded()
111void QFileInfoGatherer::driveRemoved()
115 for (
const QFileInfo &fi : driveInfoList)
123 return m_resolveSymlinks;
131 m_iconProvider = provider;
136 return m_iconProvider;
150 if (this->files.at(loc) ==
files)
155 this->path.push(
path);
156 this->files.push(
files);
162#if QT_CONFIG(filesystemwatcher)
165 && !
path.startsWith(
"//"_L1) ) {
186#if QT_CONFIG(filesystemwatcher)
188 return m_watcher->files();
195#if QT_CONFIG(filesystemwatcher)
197 return m_watcher->directories();
202void QFileInfoGatherer::createWatcher()
204#if QT_CONFIG(filesystemwatcher)
208# if defined(Q_OS_WIN)
209 const QVariant listener = m_watcher->property(
"_q_driveListener");
222#if QT_CONFIG(filesystemwatcher)
224 if (m_watcher ==
nullptr)
226 m_watcher->addPaths(
paths);
235#if QT_CONFIG(filesystemwatcher)
236 if (m_watcher && !
paths.isEmpty())
237 m_watcher->removePaths(
paths);
246#if QT_CONFIG(filesystemwatcher)
264#if QT_CONFIG(filesystemwatcher)
266 if (
v != m_watching) {
269 delete std::exchange(m_watcher,
nullptr);
283#if QT_CONFIG(filesystemwatcher)
297#if QT_CONFIG(filesystemwatcher)
331 const QStringList thisList = std::as_const(files).front();
339 getFileInfos(thisPath, thisList);
346 if (m_iconProvider) {
347 info.icon = m_iconProvider->
icon(fileInfo);
348 info.displayType = m_iconProvider->
type(fileInfo);
352#if QT_CONFIG(filesystemwatcher)
370 if (m_resolveSymlinks &&
info.isSymLink(
true)) {
372 if (resolvedInfo.exists()) {
387 if (
path.isEmpty()) {
388#ifdef QT_BUILD_INTERNAL
389 fetchedRoot.storeRelaxed(
true);
391 QList<std::pair<QString, QFileInfo>> updatedFiles;
392 auto addToUpdatedFiles = [&updatedFiles](
QFileInfo &&fileInfo) {
397 if (
files.isEmpty()) {
401 updatedFiles.reserve(infoList.size());
402 for (
auto rit = infoList.rbegin(), rend = infoList.rend(); rit != rend; ++rit)
403 addToUpdatedFiles(std::move(*rit));
405 updatedFiles.reserve(
files.size());
406 for (
auto rit =
files.crbegin(), rend =
files.crend(); rit != rend; ++rit)
416 bool firstTime =
true;
417 QList<std::pair<QString, QFileInfo>> updatedFiles;
421 if (
files.isEmpty()) {
426 fileInfo = dirEntry.fileInfo();
428 allFiles.append(fileInfo.
fileName());
429 fetch(fileInfo,
base, firstTime, updatedFiles,
path);
432 if (!allFiles.isEmpty())
435 QStringList::const_iterator filesIt = filesToCheck.constBegin();
440 fetch(fileInfo,
base, firstTime, updatedFiles,
path);
442 if (!updatedFiles.isEmpty())
450 updatedFiles.emplace_back(std::pair(fileInfo.
fileName(), fileInfo));
453 if ((firstTime && updatedFiles.size() > 100) ||
base.msecsTo(current) > 1000) {
455 updatedFiles.clear();
463#include "moc_qfileinfogatherer_p.cpp"
static QString getFileType(const QFileInfo &info)
virtual QIcon icon(IconType) const
Returns an icon set for the given type, using the current icon theme.
virtual QString type(const QFileInfo &) const
Returns the type of the file described by info.
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
The QDirListing class provides an STL-style iterator for directory entries.
static QChar separator()
Returns the native directory separator: "/" under Unix and "\\" under Windows.
static QFileInfoList drives()
Returns a list of the root directories on this system.
void start() noexcept
\typealias QElapsedTimer::Duration Synonym for std::chrono::nanoseconds.
QAbstractFileIconProvider * iconProvider() const
QStringList watchedFiles() const
void list(const QString &directoryPath)
QFileInfoGatherer(QObject *parent=nullptr)
Creates thread.
QStringList watchedDirectories() const
void setIconProvider(QAbstractFileIconProvider *provider)
void newListOfFiles(const QString &directory, const QStringList &listOfFiles) const
void updates(const QString &directory, const QList< std::pair< QString, QFileInfo > > &updates)
void unwatchPaths(const QStringList &paths)
void fetchExtendedInformation(const QString &path, const QStringList &files)
Fetch extended information for all files in path.
void setResolveSymlinks(bool enable)
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
void nameResolved(const QString &fileName, const QString &resolvedName) const
void directoryLoaded(const QString &path)
void updateFile(const QString &path)
Fetch extended information for all filePath.
bool resolveSymlinks() const
void watchPaths(const QStringList &paths)
QExtendedInformation getInfo(const QFileInfo &info) const
~QFileInfoGatherer()
Destroys thread.
void removePath(const QString &path)
QString symLinkTarget() const
void stat()
Reads all attributes from the file system.
void setFile(const QString &file)
QString absoluteFilePath() const
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
QString filePath() const
Returns the path of the file system entry this QFileInfo refers to; the path may be absolute or relat...
bool exists() const
Returns true if the file system entry this QFileInfo refers to exists; otherwise returns false.
bool isReadable() const
Returns true if the user can read the file system entry this QFileInfo refers to; otherwise returns f...
void fileChanged(const QString &path, QPrivateSignal)
This signal is emitted when the file at the specified path is modified, renamed or removed from disk.
void directoryChanged(const QString &path, QPrivateSignal)
This signal is emitted when the directory at a specified path is modified (e.g., when a file is added...
void pop_front() noexcept
void unlock() noexcept
Unlocks this mutex locker.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
void chop(qsizetype n)
Removes n characters from the end of the string.
QString mid(qsizetype position, qsizetype n=-1) const &
qsizetype size() const noexcept
Returns the number of characters in this string.
bool isInterruptionRequested() const
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
static void setTerminationEnabled(bool enabled=true)
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
void finished(QPrivateSignal)
void requestInterruption()
bool canConvert(QMetaType targetType) const
list append(new Employee("Blackpool", "Stephen"))
Combined button and popup list for selecting options.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
static QString translateDriveName(const QFileInfo &drive)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLsizei const GLfloat * v
[13]
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
#define Q_AUTOTEST_EXPORT
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept