libquentier  0.5.0
The library for rich desktop clients of Evernote service
FileSystemWatcher.h
1 /*
2  * Copyright 2016-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_UTILITY_FILE_SYSTEM_WATCHER_H
20 #define LIB_QUENTIER_UTILITY_FILE_SYSTEM_WATCHER_H
21 
22 #include <quentier/utility/Linkage.h>
23 
24 #include <QObject>
25 #include <QStringList>
26 
27 #define FILE_SYSTEM_WATCHER_DEFAULT_REMOVAL_TIMEOUT_MSEC (500)
28 
29 namespace quentier {
30 
31 QT_FORWARD_DECLARE_CLASS(FileSystemWatcherPrivate)
32 
33 class QUENTIER_EXPORT FileSystemWatcher : public QObject
34 {
35  Q_OBJECT
36 public:
37  explicit FileSystemWatcher(
38  const int removalTimeoutMSec =
39  FILE_SYSTEM_WATCHER_DEFAULT_REMOVAL_TIMEOUT_MSEC,
40  QObject * parent = nullptr);
41 
42  explicit FileSystemWatcher(
43  const QStringList & paths,
44  const int removalTimeoutMSec =
45  FILE_SYSTEM_WATCHER_DEFAULT_REMOVAL_TIMEOUT_MSEC,
46  QObject * parent = nullptr);
47 
48  virtual ~FileSystemWatcher() override;
49 
50  void addPath(const QString & path);
51  void addPaths(const QStringList & paths);
52 
53  QStringList directories() const;
54  QStringList files() const;
55 
56  void removePath(const QString & path);
57  void removePaths(const QStringList & paths);
58 
59 Q_SIGNALS:
60  void directoryChanged(const QString & path);
61  void directoryRemoved(const QString & path);
62 
63  void fileChanged(const QString & path);
64  void fileRemoved(const QString & path);
65 
66 private:
67  Q_DISABLE_COPY(FileSystemWatcher)
68 
69 private:
70  FileSystemWatcherPrivate * d_ptr;
71  Q_DECLARE_PRIVATE(FileSystemWatcher)
72 };
73 
74 } // namespace quentier
75 
76 #endif // LIB_QUENTIER_UTILITY_FILE_SYSTEM_WATCHER_H
Definition: FileSystemWatcher.h:34