OpenMS  2.4.0
Signals | Public Member Functions | Protected Slots | Protected Attributes | List of all members
FileWatcher Class Reference

Watcher that monitors file changes. More...

#include <OpenMS/SYSTEM/FileWatcher.h>

Inheritance diagram for FileWatcher:
QFileSystemWatcher

Signals

void fileChanged (const String &)
 Delayed file change signal. More...
 

Public Member Functions

 FileWatcher (QObject *parent=nullptr)
 Constructor. More...
 
 ~FileWatcher () override
 Destructor. More...
 
void setDelayInSeconds (double delay)
 Sets the delay in seconds (default: 1s) More...
 
void addFile (const String &path)
 Adds a file to the watcher. More...
 
void removeFile (const String &path)
 removes a file from the watcher More...
 

Protected Slots

void monitorFileChanged_ (const QString &name)
 Slot that is connected to the fileChanged signal in order to track the changes. More...
 
void timerTriggered_ ()
 Slot that is called when the delay is over. More...
 

Protected Attributes

Map< QString, QString > timers_
 A map that links timer name and file. More...
 
double delay_in_seconds_
 Delay (seconds) More...
 

Detailed Description

Watcher that monitors file changes.

This class can be used similar to QFileSystemWatcher. Additionally it offers a delayed fileChanged signal.

This behaviour is required for the following reason: Normally QFileSystemWatcher emits a signal every time a file is changed. This causes several signals for large files (one for each flush of the buffer).

Constructor & Destructor Documentation

◆ FileWatcher()

FileWatcher ( QObject parent = nullptr)

Constructor.

◆ ~FileWatcher()

~FileWatcher ( )
override

Destructor.

Member Function Documentation

◆ addFile()

void addFile ( const String path)
inline

Adds a file to the watcher.

References String::toQString().

Referenced by TOPPViewBase::addDataFile(), and TOPPViewBase::fileChanged_().

◆ fileChanged

void fileChanged ( const String )
signal

Delayed file change signal.

◆ monitorFileChanged_

void monitorFileChanged_ ( const QString &  name)
protectedslot

Slot that is connected to the fileChanged signal in order to track the changes.

◆ removeFile()

void removeFile ( const String path)
inline

removes a file from the watcher

References String::toQString().

Referenced by TOPPViewBase::fileChanged_().

◆ setDelayInSeconds()

void setDelayInSeconds ( double  delay)
inline

Sets the delay in seconds (default: 1s)

References FileWatcher::delay_in_seconds_.

◆ timerTriggered_

void timerTriggered_ ( )
protectedslot

Slot that is called when the delay is over.

Member Data Documentation

◆ delay_in_seconds_

double delay_in_seconds_
protected

Delay (seconds)

Referenced by FileWatcher::setDelayInSeconds().

◆ timers_

Map<QString, QString> timers_
protected

A map that links timer name and file.