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
fileinfothread_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 FILEINFOTHREAD_P_H
5#define FILEINFOTHREAD_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 <QThread>
19#include <QMutex>
20#include <QWaitCondition>
21#if QT_CONFIG(filesystemwatcher)
22#include <QFileSystemWatcher>
23#endif
24#include <QFileInfo>
25#include <QDir>
26
27#include "fileproperty_p.h"
29
31
32class FileInfoThread : public QThread
33{
35
37 void directoryChanged(const QString &directory, const QList<FileProperty> &list) const;
38 void directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex) const;
39 void sortFinished(const QList<FileProperty> &list) const;
41
42public:
43 FileInfoThread(QObject *parent = nullptr);
45
46 void clear();
47 void removePath(const QString &path);
48 void setPath(const QString &path);
49 void setRootPath(const QString &path);
50 void setSortFlags(QDir::SortFlags flags);
51 void setNameFilters(const QStringList & nameFilters);
52 void setShowFiles(bool show);
53 void setShowDirs(bool showFolders);
54 void setShowDirsFirst(bool show);
55 void setShowDotAndDotDot(bool on);
56 void setShowHidden(bool on);
57 void setShowOnlyReadable(bool on);
58 void setCaseSensitive(bool on);
59
60public Q_SLOTS:
61#if QT_CONFIG(filesystemwatcher)
62 void dirChanged(const QString &directoryPath);
63 void updateFile(const QString &path);
64#endif
65
66protected:
67 void run() override;
68 void runOnce();
69 void initiateScan();
70 void getFileInfos(const QString &path);
71 void findChangeRange(const QList<FileProperty> &list, int &fromIndex, int &toIndex);
72
73private:
74 enum class UpdateType {
75 None = 1 << 0,
76 // The order of the files in the current folder changed.
77 Sort = 1 << 1,
78 // A subset of files in the current folder changed.
79 Contents = 1 << 2
80 };
81 Q_DECLARE_FLAGS(UpdateTypes, UpdateType)
82
83 // Declare these ourselves, as Q_DECLARE_OPERATORS_FOR_FLAGS needs the enum to be public.
84 friend constexpr UpdateTypes operator|(UpdateType f1, UpdateTypes f2) noexcept;
85 friend constexpr UpdateTypes operator&(UpdateType f1, UpdateTypes f2) noexcept;
86
87 QMutex mutex;
89 volatile bool abort;
90 bool scanPending;
91
92#if QT_CONFIG(filesystemwatcher)
94#endif
95 QList<FileProperty> currentFileList;
96 QDir::SortFlags sortFlags;
97 QString currentPath;
98 QString rootPath;
99 QStringList nameFilters;
100 bool needUpdate;
101 UpdateTypes updateTypes;
102 bool showFiles;
103 bool showDirs;
104 bool showDirsFirst;
105 bool showDotAndDotDot;
106 bool showHidden;
107 bool showOnlyReadable;
108 bool caseSensitive;
109};
110
112
113#endif // FILEINFOTHREAD_P_H
void removePath(const QString &path)
void setRootPath(const QString &path)
void setShowFiles(bool show)
void directoryUpdated(const QString &directory, const QList< FileProperty > &list, int fromIndex, int toIndex) const
void setShowDotAndDotDot(bool on)
void statusChanged(QQuickFolderListModel::Status status) const
void directoryChanged(const QString &directory, const QList< FileProperty > &list) const
void setNameFilters(const QStringList &nameFilters)
FileInfoThread(QObject *parent=nullptr)
void setShowDirsFirst(bool show)
void setCaseSensitive(bool on)
void setShowDirs(bool showFolders)
void sortFinished(const QList< FileProperty > &list) const
void findChangeRange(const QList< FileProperty > &list, int &fromIndex, int &toIndex)
void setShowHidden(bool on)
void getFileInfos(const QString &path)
void setShowOnlyReadable(bool on)
void setPath(const QString &path)
void run() override
void setSortFlags(QDir::SortFlags flags)
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
GLenum condition
GLbitfield flags
GLsizei const GLchar *const * path
bool updateFile(const QString &fileName, const QHash< QString, QString > &replacements)
Definition main.cpp:1620
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
static uint toIndex(ExecutionEngine *e, const Value &v)
view show()
[18] //! [19]
QList< int > list
[14]
QFutureWatcher< int > watcher