OpenMS
Loading...
Searching...
No Matches
FileWatcher.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm $
7// --------------------------------------------------------------------------
8
9
10#pragma once
11
12// OpenMS_GUI config
13#include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
14
15//OpenMS
18#include <map>
19
20//Qt
21#include <QtCore/QFileSystemWatcher>
22
23//STL
24#include <map>
25
26namespace OpenMS
27{
28 class String;
29
41 class OPENMS_GUI_DLLAPI FileWatcher :
42 public QFileSystemWatcher //find out why ICC requires public instead of protected
43 {
44 Q_OBJECT
45
46public:
48 FileWatcher(QObject * parent = nullptr);
49
51 ~FileWatcher() override;
52
54 inline void setDelayInSeconds(double delay)
55 {
56 delay_in_seconds_ = delay;
57 }
58
60 inline void addFile(const String & path)
61 {
62 QFileSystemWatcher::addPath(path.toQString());
63 }
64
66 inline void removeFile(const String & path)
67 {
68 QFileSystemWatcher::removePath(path.toQString());
69 }
70
71signals:
73 void fileChanged(const String &);
74
75protected slots:
77 void monitorFileChanged_(const QString & name);
80
81protected:
83 std::map<QString, QString> timers_;
86 };
87
88 // OPENMS_DLLAPI extern FileWatcher myFileWatcher_instance;
89}
90
Watcher that monitors file changes.
Definition FileWatcher.h:43
std::map< QString, QString > timers_
A map that links timer name and file.
Definition FileWatcher.h:83
void fileChanged(const String &)
Delayed file change signal.
void removeFile(const String &path)
removes a file from the watcher
Definition FileWatcher.h:66
void timerTriggered_()
Slot that is called when the delay is over.
void setDelayInSeconds(double delay)
Sets the delay in seconds (default: 1s)
Definition FileWatcher.h:54
~FileWatcher() override
Destructor.
void monitorFileChanged_(const QString &name)
Slot that is connected to the fileChanged signal in order to track the changes.
double delay_in_seconds_
Delay (seconds)
Definition FileWatcher.h:85
void addFile(const String &path)
Adds a file to the watcher.
Definition FileWatcher.h:60
FileWatcher(QObject *parent=nullptr)
Constructor.
A more convenient string class.
Definition String.h:34
QString toQString() const
Conversion to Qt QString.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19