summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfileinfogatherer_p.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-07-09 13:22:26 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-08-13 17:26:22 +0200
commit9cae146c42376868432040bf7427c0b995f2bb64 (patch)
tree62e52e28b69768721c199ff1ff157d4afd8f72e7 /src/widgets/dialogs/qfileinfogatherer_p.h
parente8c7124768b0e3e556a8ae53629478284bbdca8e (diff)
QFileInfoGatherer: Make it possible to turn off file watching
Add a boolean watch property and delay-create the file system watcher in watchPaths(). De-inline the watchedFiles(), watchedDirectories(), watchPaths(), unwatchPaths() helpers and a check for the watcher. Task-number: QTBUG-76493 Change-Id: Ie02ac496c8c0246be62bc67ff7e0fcdb990b5ca6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qfileinfogatherer_p.h')
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 829c620c1e..3d30a98d04 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -169,12 +169,13 @@ public:
explicit QFileInfoGatherer(QObject *parent = nullptr);
~QFileInfoGatherer();
-#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
- QStringList watchedFiles() const { return watcher->files(); }
- QStringList watchedDirectories() const { return watcher->directories(); }
- void watchPaths(const QStringList &paths) { watcher->addPaths(paths); }
- void unwatchPaths(const QStringList &paths) { watcher->removePaths(paths); }
-#endif // filesystemwatcher && Q_OS_WIN
+ QStringList watchedFiles() const;
+ QStringList watchedDirectories() const;
+ void watchPaths(const QStringList &paths);
+ void unwatchPaths(const QStringList &paths);
+
+ bool isWatching() const;
+ void setWatching(bool v);
// only callable from this->thread():
void clear();
@@ -201,6 +202,8 @@ private:
void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
private:
+ void createWatcher();
+
mutable QMutex mutex;
// begin protected by mutex
QWaitCondition condition;
@@ -210,13 +213,16 @@ private:
QAtomicInt abort;
#if QT_CONFIG(filesystemwatcher)
- QFileSystemWatcher *watcher = nullptr;
+ QFileSystemWatcher *m_watcher = nullptr;
#endif
QFileIconProvider *m_iconProvider; // not accessed by run()
QFileIconProvider defaultProvider;
#ifdef Q_OS_WIN
bool m_resolveSymlinks = true; // not accessed by run()
#endif
+#if QT_CONFIG(filesystemwatcher)
+ bool m_watching = true;
+#endif
};
QT_END_NAMESPACE