libquentier  0.4.0
The library for rich desktop clients of Evernote service
FileSystemWatcher.h
1 /*
2  * Copyright 2016 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/Macros.h>
23 #include <quentier/utility/Linkage.h>
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(const int removalTimeoutMSec = FILE_SYSTEM_WATCHER_DEFAULT_REMOVAL_TIMEOUT_MSEC,
38  QObject * parent = Q_NULLPTR);
39  explicit FileSystemWatcher(const QStringList & paths, const int removalTimeoutMSec = FILE_SYSTEM_WATCHER_DEFAULT_REMOVAL_TIMEOUT_MSEC,
40  QObject * parent = Q_NULLPTR);
41 
42  virtual ~FileSystemWatcher();
43 
44  void addPath(const QString & path);
45  void addPaths(const QStringList & paths);
46 
47  QStringList directories() const;
48  QStringList files() const;
49 
50  void removePath(const QString & path);
51  void removePaths(const QStringList & paths);
52 
53 Q_SIGNALS:
54  void directoryChanged(const QString & path);
55  void directoryRemoved(const QString & path);
56 
57  void fileChanged(const QString & path);
58  void fileRemoved(const QString & path);
59 
60 private:
61  Q_DISABLE_COPY(FileSystemWatcher)
62 
63 private:
64  FileSystemWatcherPrivate * d_ptr;
65  Q_DECLARE_PRIVATE(FileSystemWatcher)
66 };
67 
68 } // namespace quentier
69 
70 #endif // LIB_QUENTIER_UTILITY_FILE_SYSTEM_WATCHER_H
Definition: FileSystemWatcher.h:33