6#include <QtCore/QFileSystemWatcher>
7#include <QtCore/QObject>
9#include <QtCore/QString>
10#include <QtCore/QTimer>
138 void _onFileChanged(
const QString &path);
139 void _onDirectoryChanged(
const QString &path);
140 void _processPendingChanges();
143 void _scheduleCallback(
const QString &path,
bool isDirectory);
145 QFileSystemWatcher *_watcher =
nullptr;
148 QHash<QString, ChangeCallback> _fileCallbacks;
149 QHash<QString, ChangeCallback> _directoryCallbacks;
152 QSet<QString> _persistentFiles;
155 int _debounceDelay = 100;
156 QTimer *_debounceTimer =
nullptr;
157 QSet<QString> _pendingFileChanges;
158 QSet<QString> _pendingDirectoryChanges;
159 bool _processingPendingChanges =
false;
Callback-based file/directory watcher with debouncing support.
bool unwatchDirectory(const QString &directoryPath)
bool isWatchingDirectory(const QString &directoryPath) const
void clear()
Stop watching all files and directories.
int watchFiles(const QStringList &filePaths, ChangeCallback callback)
int watchDirectories(const QStringList &directoryPaths, ChangeCallback callback)
~QGCFileWatcher() override
QStringList watchedFiles() const
void setDebounceDelay(int milliseconds)
bool isWatchingFile(const QString &filePath) const
bool watchFilePersistent(const QString &filePath, ChangeCallback callback)
void directoryChanged(const QString &path)
void fileChanged(const QString &path)
int debounceDelay() const
std::function< void(const QString &path)> ChangeCallback
QStringList watchedDirectories() const
bool unwatchFile(const QString &filePath)
bool watchFile(const QString &filePath, ChangeCallback callback)
bool watchDirectory(const QString &directoryPath, ChangeCallback callback)