Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfilesystemwatcher_polling_p.h
Go to the documentation of this file.
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_POLLING_P_H
5#define QFILESYSTEMWATCHER_POLLING_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 <QtCore/qbasictimer.h>
19#include <QtCore/qfileinfo.h>
20#include <QtCore/qmutex.h>
21#include <QtCore/qdatetime.h>
22#include <QtCore/qdir.h>
23#include <QtCore/qhash.h>
24
26
27QT_REQUIRE_CONFIG(filesystemwatcher);
29
31{
33
34 class FileInfo
35 {
36 uint ownerId;
37 uint groupId;
38 QFile::Permissions permissions;
39 QDateTime lastModified;
40 QStringList entries;
41
42 public:
43 FileInfo(const QFileInfo &fileInfo)
44 : ownerId(fileInfo.ownerId()),
45 groupId(fileInfo.groupId()),
46 permissions(fileInfo.permissions()),
47 lastModified(fileInfo.lastModified(QTimeZone::UTC))
48 {
49 if (fileInfo.isDir()) {
50 entries = fileInfo.absoluteDir().entryList(QDir::AllEntries);
51 }
52 }
53 FileInfo &operator=(const QFileInfo &fileInfo)
54 {
55 *this = FileInfo(fileInfo);
56 return *this;
57 }
58
59 bool operator!=(const QFileInfo &fileInfo) const
60 {
61 if (fileInfo.isDir() && entries != fileInfo.absoluteDir().entryList(QDir::AllEntries))
62 return true;
63 return (ownerId != fileInfo.ownerId()
64 || groupId != fileInfo.groupId()
65 || permissions != fileInfo.permissions()
66 || lastModified != fileInfo.lastModified(QTimeZone::UTC));
67 }
68 };
69
70 QHash<QString, FileInfo> files, directories;
71
72public:
74
75 QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
76 QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
77
78private:
79 void timerEvent(QTimerEvent *) final;
80
81private:
82 QBasicTimer timer;
83};
84
86#endif // QFILESYSTEMWATCHER_POLLING_P_H
87
\inmodule QtCore
Definition qbasictimer.h:18
\inmodule QtCore\reentrant
Definition qdatetime.h:283
QStringList entryList(Filters filters=NoFilter, SortFlags sort=NoSort) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qdir.cpp:1365
@ AllEntries
Definition qdir.h:26
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition qfileinfo.h:160
uint groupId() const
Returns the id of the group the file belongs to.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
uint ownerId() const
Returns the id of the owner of the file.
QDir absoluteDir() const
Returns a QDir object representing the absolute path of the parent directory of the file system entry...
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
void timerEvent(QTimerEvent *) final
This event handler can be reimplemented in a subclass to receive timer events for the object.
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:366
Combined button and popup list for selecting options.
GLsizei const GLuint * paths
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
unsigned int uint
Definition qtypes.h:34
QStringList files
[8]