1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QFILESYSTEMWATCHER_P_H |
5 | #define QFILESYSTEMWATCHER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "qfilesystemwatcher.h" |
19 | |
20 | QT_REQUIRE_CONFIG(filesystemwatcher); |
21 | |
22 | #include <private/qobject_p.h> |
23 | |
24 | #include <QtCore/qstringlist.h> |
25 | #include <QtCore/qhash.h> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QFileSystemWatcherEngine : public QObject |
30 | { |
31 | Q_OBJECT |
32 | |
33 | protected: |
34 | inline QFileSystemWatcherEngine(QObject *parent) |
35 | : QObject(parent) |
36 | { |
37 | } |
38 | |
39 | public: |
40 | // fills \a files and \a directories with the \a paths it could |
41 | // watch, and returns a list of paths this engine could not watch |
42 | virtual QStringList addPaths(const QStringList &paths, |
43 | QStringList *files, |
44 | QStringList *directories) = 0; |
45 | // removes \a paths from \a files and \a directories, and returns |
46 | // a list of paths this engine does not know about (either addPath |
47 | // failed or wasn't called) |
48 | virtual QStringList removePaths(const QStringList &paths, |
49 | QStringList *files, |
50 | QStringList *directories) = 0; |
51 | |
52 | Q_SIGNALS: |
53 | void fileChanged(const QString &path, bool removed); |
54 | void directoryChanged(const QString &path, bool removed); |
55 | }; |
56 | |
57 | class QFileSystemWatcherPrivate : public QObjectPrivate |
58 | { |
59 | Q_DECLARE_PUBLIC(QFileSystemWatcher) |
60 | |
61 | static QFileSystemWatcherEngine *createNativeEngine(QObject *parent); |
62 | |
63 | public: |
64 | QFileSystemWatcherPrivate(); |
65 | void init(); |
66 | void initPollerEngine(); |
67 | |
68 | QFileSystemWatcherEngine *native, *poller; |
69 | QStringList files, directories; |
70 | |
71 | // private slots |
72 | void _q_fileChanged(const QString &path, bool removed); |
73 | void _q_directoryChanged(const QString &path, bool removed); |
74 | |
75 | #if defined(Q_OS_WIN) |
76 | void _q_winDriveLockForRemoval(const QString &); |
77 | void _q_winDriveLockForRemovalFailed(const QString &); |
78 | void _q_winDriveRemoved(const QString &); |
79 | |
80 | private: |
81 | QHash<QChar, QStringList> temporarilyRemovedPaths; |
82 | #endif // Q_OS_WIN |
83 | }; |
84 | |
85 | |
86 | QT_END_NAMESPACE |
87 | #endif // QFILESYSTEMWATCHER_P_H |
88 | |