From 555a6b5d5d2dd91a0dcf9e3d5fbadd1b31bf80f3 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 26 Sep 2018 08:56:36 +0200 Subject: Modernize the "filesystemwatcher" feature Change-Id: If030b56ad97e047d89d442629262b4839df306d4 Reviewed-by: Edward Welbourne Reviewed-by: Ulf Hermann --- src/widgets/dialogs/qfileinfogatherer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/widgets/dialogs/qfileinfogatherer.cpp') diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index aef13a563f..1e03ad8b06 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -80,7 +80,7 @@ static QString translateDriveName(const QFileInfo &drive) */ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) : QThread(parent), abort(false), -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) watcher(0), #endif #ifdef Q_OS_WIN @@ -88,7 +88,7 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) #endif m_iconProvider(&defaultProvider) { -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString))); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); @@ -179,7 +179,7 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr this->files.push(files); condition.wakeAll(); -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) if (files.isEmpty() && !path.isEmpty() && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { @@ -208,7 +208,7 @@ void QFileInfoGatherer::updateFile(const QString &filePath) */ void QFileInfoGatherer::clear() { -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) QMutexLocker locker(&mutex); watcher->removePaths(watcher->files()); watcher->removePaths(watcher->directories()); @@ -222,7 +222,7 @@ void QFileInfoGatherer::clear() */ void QFileInfoGatherer::removePath(const QString &path) { -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) QMutexLocker locker(&mutex); watcher->removePath(path); #else @@ -266,7 +266,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const QExtendedInformation info(fileInfo); info.icon = m_iconProvider->icon(fileInfo); info.displayType = m_iconProvider->type(fileInfo); -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) // ### Not ready to listen all modifications by default static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES"); if (watchFiles) { @@ -280,7 +280,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const } } } -#endif +#endif // filesystemwatcher #ifdef Q_OS_WIN if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) { -- cgit v1.2.3