|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <QGCFileWatcher.h>
Inheritance diagram for QGCFileWatcher:
Collaboration diagram for QGCFileWatcher:Public Types | |
| using | ChangeCallback = std::function< void(const QString &path)> |
Signals | |
| void | fileChanged (const QString &path) |
| void | directoryChanged (const QString &path) |
Public Member Functions | |
| QGCFileWatcher (QObject *parent=nullptr) | |
| ~QGCFileWatcher () override | |
| void | setDebounceDelay (int milliseconds) |
| int | debounceDelay () const |
| bool | watchFile (const QString &filePath, ChangeCallback callback) |
| bool | unwatchFile (const QString &filePath) |
| bool | isWatchingFile (const QString &filePath) const |
| QStringList | watchedFiles () const |
| bool | watchDirectory (const QString &directoryPath, ChangeCallback callback) |
| bool | unwatchDirectory (const QString &directoryPath) |
| bool | isWatchingDirectory (const QString &directoryPath) const |
| QStringList | watchedDirectories () const |
| int | watchFiles (const QStringList &filePaths, ChangeCallback callback) |
| int | watchDirectories (const QStringList &directoryPaths, ChangeCallback callback) |
| void | clear () |
| Stop watching all files and directories. | |
| bool | watchFilePersistent (const QString &filePath, ChangeCallback callback) |
Callback-based file/directory watcher with debouncing support Provides a simpler API than QFileSystemWatcher for common use cases
Example usage:
Definition at line 24 of file QGCFileWatcher.h.
| using QGCFileWatcher::ChangeCallback = std::function<void(const QString &path)> |
Callback for file/directory changes
| path | Path to the changed file or directory |
Definition at line 31 of file QGCFileWatcher.h.
|
explicit |
Construct a file watcher
| parent | QObject parent |
Definition at line 13 of file QGCFileWatcher.cc.
|
override |
Definition at line 28 of file QGCFileWatcher.cc.
References clear().
| void QGCFileWatcher::clear | ( | ) |
Stop watching all files and directories.
Definition at line 197 of file QGCFileWatcher.cc.
Referenced by ~QGCFileWatcher().
|
inline |
Get current debounce delay
Definition at line 46 of file QGCFileWatcher.h.
|
signal |
Emitted when a watched directory changes
| path | Path to the changed directory |
|
signal |
Emitted when a watched file changes
| path | Path to the changed file |
| bool QGCFileWatcher::isWatchingDirectory | ( | const QString & | directoryPath | ) | const |
Check if a directory is being watched
| directoryPath | Path to check |
Definition at line 160 of file QGCFileWatcher.cc.
| bool QGCFileWatcher::isWatchingFile | ( | const QString & | filePath | ) | const |
Check if a file is being watched
| filePath | Path to check |
Definition at line 96 of file QGCFileWatcher.cc.
| void QGCFileWatcher::setDebounceDelay | ( | int | milliseconds | ) |
Set debounce delay for change notifications Multiple rapid changes are coalesced into a single callback
| milliseconds | Debounce delay (default 100ms, 0 = no debounce) |
Definition at line 37 of file QGCFileWatcher.cc.
| bool QGCFileWatcher::unwatchDirectory | ( | const QString & | directoryPath | ) |
Stop watching a specific directory
| directoryPath | Path to directory to stop watching |
Definition at line 145 of file QGCFileWatcher.cc.
| bool QGCFileWatcher::unwatchFile | ( | const QString & | filePath | ) |
Stop watching a specific file
| filePath | Path to file to stop watching |
Definition at line 80 of file QGCFileWatcher.cc.
| int QGCFileWatcher::watchDirectories | ( | const QStringList & | directoryPaths, |
| ChangeCallback | callback | ||
| ) |
Watch multiple directories
| directoryPaths | List of directory paths to watch |
| callback | Function to call when any directory changes |
Definition at line 186 of file QGCFileWatcher.cc.
References watchDirectory().
| bool QGCFileWatcher::watchDirectory | ( | const QString & | directoryPath, |
| ChangeCallback | callback | ||
| ) |
Watch a directory for changes
| directoryPath | Path to directory to watch |
| callback | Function to call when directory changes |
Definition at line 111 of file QGCFileWatcher.cc.
Referenced by watchDirectories().
| QStringList QGCFileWatcher::watchedDirectories | ( | ) | const |
Get list of watched directories
Definition at line 166 of file QGCFileWatcher.cc.
| QStringList QGCFileWatcher::watchedFiles | ( | ) | const |
Get list of watched files
Definition at line 102 of file QGCFileWatcher.cc.
| bool QGCFileWatcher::watchFile | ( | const QString & | filePath, |
| ChangeCallback | callback | ||
| ) |
Watch a file for changes
| filePath | Path to file to watch |
| callback | Function to call when file changes |
Definition at line 46 of file QGCFileWatcher.cc.
Referenced by watchFilePersistent(), and watchFiles().
| bool QGCFileWatcher::watchFilePersistent | ( | const QString & | filePath, |
| ChangeCallback | callback | ||
| ) |
Watch a file and automatically re-watch if it's recreated Useful for config files that may be replaced atomically
| filePath | Path to file to watch |
| callback | Function to call when file changes |
Definition at line 223 of file QGCFileWatcher.cc.
References watchFile().
| int QGCFileWatcher::watchFiles | ( | const QStringList & | filePaths, |
| ChangeCallback | callback | ||
| ) |
Watch multiple files
| filePaths | List of file paths to watch |
| callback | Function to call when any file changes |
Definition at line 175 of file QGCFileWatcher.cc.
References watchFile().