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
20QT_REQUIRE_CONFIG(filesystemwatcher);
21
22#include <private/qobject_p.h>
23
24#include <QtCore/qstringlist.h>
25#include <QtCore/qhash.h>
26
27QT_BEGIN_NAMESPACE
28
29class QFileSystemWatcherEngine : public QObject
30{
31 Q_OBJECT
32
33protected:
34 inline QFileSystemWatcherEngine(QObject *parent)
35 : QObject(parent)
36 {
37 }
38
39public:
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
52Q_SIGNALS:
53 void fileChanged(const QString &path, bool removed);
54 void directoryChanged(const QString &path, bool removed);
55};
56
57class QFileSystemWatcherPrivate : public QObjectPrivate
58{
59 Q_DECLARE_PUBLIC(QFileSystemWatcher)
60
61 static QFileSystemWatcherEngine *createNativeEngine(QObject *parent);
62
63public:
64 QFileSystemWatcherPrivate();
65 void init();
66 void initPollerEngine();
67
68 QFileSystemWatcherEngine *native, *poller;
69 QStringList files, directories;
70
71 // private slots
72 void fileChanged(const QString &path, bool removed);
73 void directoryChanged(const QString &path, bool removed);
74
75 void connectEngine(QFileSystemWatcherEngine *e);
76
77#if defined(Q_OS_WIN)
78 void winDriveLockForRemoval(const QString &);
79 void winDriveLockForRemovalFailed(const QString &);
80 void winDriveRemoved(const QString &);
81
82private:
83 QHash<QChar, QStringList> temporarilyRemovedPaths;
84#endif // Q_OS_WIN
85};
86
87
88QT_END_NAMESPACE
89#endif // QFILESYSTEMWATCHER_P_H
90

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/corelib/io/qfilesystemwatcher_p.h