FolderFilesList.h 1.15 KB
Newer Older
1
2
3
4
5
/*
    SPDX-FileCopyrightText: 2013 Kåre Särs <kare.sars@iki.fi>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/
Kåre Särs's avatar
Kåre Särs committed
6

7
8
#ifndef FolderFilesList_h
#define FolderFilesList_h
Kåre Särs's avatar
Kåre Särs committed
9

10
#include <QRegularExpression>
11
#include <QStringList>
12
13
#include <QThread>
#include <QVector>
Kåre Särs's avatar
Kåre Särs committed
14

15
class FolderFilesList : public QThread
Kåre Särs's avatar
Kåre Särs committed
16
17
18
19
{
    Q_OBJECT

public:
20
    FolderFilesList(QObject *parent = nullptr);
Kevin Funk's avatar
Kevin Funk committed
21
    ~FolderFilesList() override;
Kåre Särs's avatar
Kåre Särs committed
22

Kevin Funk's avatar
Kevin Funk committed
23
    void run() override;
Kåre Särs's avatar
Kåre Särs committed
24

25
    void generateList(const QString &folder, bool recursive, bool hidden, bool symlinks, const QString &types, const QString &excludes);
26

27
28
    void terminateSearch();

29
30
    QStringList fileList();

31
32
Q_SIGNALS:
    void searching(const QString &path);
33
    void fileListReady();
34

Kåre Särs's avatar
Kåre Särs committed
35
private:
36
37
38
39
40
41
42
    struct DirectoryWithResults {
        QString directory;
        QStringList newDirectories;
        QStringList newFiles;
    };

    void checkNextItem(DirectoryWithResults &handleOnFolder) const;
Kåre Särs's avatar
Kåre Särs committed
43
44

private:
45
46
    QString m_folder;
    QStringList m_files;
47
    bool m_cancelSearch = false;
48

49
50
51
    bool m_recursive = false;
    bool m_hidden = false;
    bool m_symlinks = false;
52
    QStringList m_types;
53
    QVector<QRegularExpression> m_excludes;
Kåre Särs's avatar
Kåre Särs committed
54
55
56
};

#endif