QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCArchiveWatcher Class Reference

Watches directories for new archive files and optionally auto-decompresses them. More...

#include <QGCArchiveWatcher.h>

+ Inheritance diagram for QGCArchiveWatcher:
+ Collaboration diagram for QGCArchiveWatcher:

Public Types

enum class  FilterMode { Archives , Compressed , Both }
 Whether auto-decompression is enabled. More...
 

Signals

void archiveDetected (const QString &archivePath, QGCCompression::Format format)
 
void extractionComplete (const QString &archivePath, const QString &outputPath, bool success, const QString &errorString)
 
void autoDecompressChanged (bool autoDecompress)
 Property change signals.
 
void extractingChanged (bool extracting)
 
void progressChanged (qreal progress)
 
void outputDirectoryChanged (const QString &directory)
 

Public Member Functions

 QGCArchiveWatcher (QObject *parent=nullptr)
 
 ~QGCArchiveWatcher () override
 
void setFilterMode (FilterMode mode)
 
FilterMode filterMode () const
 
void setAutoDecompress (bool enable)
 
bool autoDecompress () const
 
void setOutputDirectory (const QString &directory)
 
QString outputDirectory () const
 
void setRemoveAfterExtraction (bool remove)
 
bool removeAfterExtraction () const
 
void setDebounceDelay (int milliseconds)
 
int debounceDelay () const
 
bool watchDirectory (const QString &directoryPath)
 
bool unwatchDirectory (const QString &directoryPath)
 
QStringList watchedDirectories () const
 
void clear ()
 Stop watching all directories.
 
bool isExtracting () const
 Check if extraction is in progress.
 
qreal progress () const
 Get current extraction progress.
 
QStringList scanDirectory (const QString &directoryPath) const
 
void cancelExtraction ()
 Cancel current extraction.
 

Detailed Description

Watches directories for new archive files and optionally auto-decompresses them.

Example usage:

watcher.setAutoDecompress(true);
watcher.setOutputDirectory("/extracted");
[](const QString &path) {
qDebug() << "Found archive:" << path;
});
[](const QString &archive, const QString &output, bool success) {
qDebug() << "Extracted" << archive << "to" << output
<< (success ? "OK" : "FAILED");
});
watcher.watchDirectory("/downloads");
Watches directories for new archive files and optionally auto-decompresses them.
void setOutputDirectory(const QString &directory)
bool watchDirectory(const QString &directoryPath)
void setAutoDecompress(bool enable)
void extractionComplete(const QString &archivePath, const QString &outputPath, bool success, const QString &errorString)
void archiveDetected(const QString &archivePath, QGCCompression::Format format)

Definition at line 34 of file QGCArchiveWatcher.h.

Member Enumeration Documentation

◆ FilterMode

enum class QGCArchiveWatcher::FilterMode
strong

Whether auto-decompression is enabled.

Whether an extraction is currently in progress Current extraction progress (0.0 to 1.0) Output directory for extractions (empty = same directory as archive) Filter mode for which files to watch

Enumerator
Archives 

Watch for archive files (.zip, .tar, .tar.gz, .7z)

Compressed 

Watch for single-file compressed (.gz, .xz, .zst, .bz2, .lz4)

Both 

Watch for both archives and compressed files.

Definition at line 54 of file QGCArchiveWatcher.h.

Constructor & Destructor Documentation

◆ QGCArchiveWatcher()

QGCArchiveWatcher::QGCArchiveWatcher ( QObject *  parent = nullptr)
explicit

Definition at line 14 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::directoryChanged(), and setDebounceDelay().

◆ ~QGCArchiveWatcher()

QGCArchiveWatcher::~QGCArchiveWatcher ( )
override

Member Function Documentation

◆ archiveDetected

void QGCArchiveWatcher::archiveDetected ( const QString &  archivePath,
QGCCompression::Format  format 
)
signal

Emitted when an archive file is detected in a watched directory

Parameters
archivePathFull path to the archive file
formatDetected format

◆ autoDecompress()

bool QGCArchiveWatcher::autoDecompress ( ) const
inline

Definition at line 76 of file QGCArchiveWatcher.h.

◆ autoDecompressChanged

void QGCArchiveWatcher::autoDecompressChanged ( bool  autoDecompress)
signal

Property change signals.

Referenced by setAutoDecompress().

◆ cancelExtraction()

void QGCArchiveWatcher::cancelExtraction ( )

Cancel current extraction.

Definition at line 163 of file QGCArchiveWatcher.cc.

References QGCCompressionJob::cancel(), and QGCCompressionJob::isRunning().

◆ clear()

void QGCArchiveWatcher::clear ( )

Stop watching all directories.

Definition at line 122 of file QGCArchiveWatcher.cc.

References QGCCompressionJob::cancel(), QGCFileWatcher::clear(), and QGCCompressionJob::isRunning().

◆ debounceDelay()

int QGCArchiveWatcher::debounceDelay ( ) const

Definition at line 67 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::debounceDelay().

◆ extractingChanged

void QGCArchiveWatcher::extractingChanged ( bool  extracting)
signal

◆ extractionComplete

void QGCArchiveWatcher::extractionComplete ( const QString &  archivePath,
const QString &  outputPath,
bool  success,
const QString &  errorString 
)
signal

Emitted when extraction completes (only if autoDecompress is enabled)

Parameters
archivePathPath to the source archive
outputPathPath to extracted files/directory
successtrue if extraction succeeded
errorStringError message if failed

◆ filterMode()

FilterMode QGCArchiveWatcher::filterMode ( ) const
inline

Definition at line 71 of file QGCArchiveWatcher.h.

◆ isExtracting()

bool QGCArchiveWatcher::isExtracting ( ) const
inline

Check if extraction is in progress.

Definition at line 119 of file QGCArchiveWatcher.h.

◆ outputDirectory()

QString QGCArchiveWatcher::outputDirectory ( ) const
inline

Definition at line 81 of file QGCArchiveWatcher.h.

◆ outputDirectoryChanged

void QGCArchiveWatcher::outputDirectoryChanged ( const QString &  directory)
signal

Referenced by setOutputDirectory().

◆ progress()

qreal QGCArchiveWatcher::progress ( ) const
inline

Get current extraction progress.

Definition at line 122 of file QGCArchiveWatcher.h.

◆ progressChanged

void QGCArchiveWatcher::progressChanged ( qreal  progress)
signal

◆ removeAfterExtraction()

bool QGCArchiveWatcher::removeAfterExtraction ( ) const
inline

Definition at line 86 of file QGCArchiveWatcher.h.

◆ scanDirectory()

QStringList QGCArchiveWatcher::scanDirectory ( const QString &  directoryPath) const

Scan a directory for existing archives (useful for initial scan)

Parameters
directoryPathDirectory to scan
Returns
List of archive files found

Definition at line 143 of file QGCArchiveWatcher.cc.

◆ setAutoDecompress()

void QGCArchiveWatcher::setAutoDecompress ( bool  enable)

Enable/disable automatic decompression of detected archives

Parameters
enabletrue to auto-decompress, false to just emit signals

Definition at line 41 of file QGCArchiveWatcher.cc.

References autoDecompressChanged().

◆ setDebounceDelay()

void QGCArchiveWatcher::setDebounceDelay ( int  milliseconds)

Set debounce delay (inherited from QGCFileWatcher)

Parameters
millisecondsDebounce delay (default 500ms for archives)

Definition at line 62 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::setDebounceDelay().

Referenced by QGCArchiveWatcher().

◆ setFilterMode()

void QGCArchiveWatcher::setFilterMode ( FilterMode  mode)

Set filter mode for which file types to watch

Parameters
modeFilter mode

Definition at line 36 of file QGCArchiveWatcher.cc.

◆ setOutputDirectory()

void QGCArchiveWatcher::setOutputDirectory ( const QString &  directory)

Set output directory for extracted files

Parameters
directoryOutput directory (empty = same directory as archive)

Definition at line 49 of file QGCArchiveWatcher.cc.

References outputDirectoryChanged().

◆ setRemoveAfterExtraction()

void QGCArchiveWatcher::setRemoveAfterExtraction ( bool  remove)

Set whether to remove archives after successful extraction

Parameters
removetrue to remove source archive after extraction

Definition at line 57 of file QGCArchiveWatcher.cc.

◆ unwatchDirectory()

bool QGCArchiveWatcher::unwatchDirectory ( const QString &  directoryPath)

Stop watching a directory

Parameters
directoryPathPath to directory
Returns
true if directory was being watched

Definition at line 110 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::unwatchDirectory().

◆ watchDirectory()

bool QGCArchiveWatcher::watchDirectory ( const QString &  directoryPath)

Watch a directory for archive files

Parameters
directoryPathPath to directory to watch
Returns
true if directory was added to watch list

Definition at line 76 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::watchDirectory().

◆ watchedDirectories()

QStringList QGCArchiveWatcher::watchedDirectories ( ) const

Get list of watched directories

Returns
List of directory paths being watched

Definition at line 117 of file QGCArchiveWatcher.cc.

References QGCFileWatcher::watchedDirectories().


The documentation for this class was generated from the following files: