-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkfilefilter.h
54 lines (40 loc) · 1.35 KB
/
kfilefilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef KFILEFILTER_H
#define KFILEFILTER_H
#include <QObject>
/**
* @brief 自定义的过滤器,可以选择是否支持正则表达式
*/
class KFileFilter : public QObject
{
Q_OBJECT
public:
enum FilterType { None, Dir, File };
explicit KFileFilter(QObject *parent = nullptr);
explicit KFileFilter(const QString &pattern, FilterType filterType = None,
bool isRegExpEnabled = false, QObject *parent = nullptr);
explicit KFileFilter(const KFileFilter &filter);
KFileFilter &operator=(const KFileFilter &filter);
/**
* @brief 返回匹配模式字符串(可以是正则表达式)
* @return
*/
const QString &pattern() const;
/**
* @brief 返回是否支持正则表达式,如果不支持则采用LCS算法匹配字符串,支持则用QRegularExpression匹配
* @return
*/
bool isRegExpEnabled() const;
/**
* @brief 返回过滤类型,可以是文件夹或者是文件
* @return
*/
FilterType filterType() const;
void setFilterType(FilterType newFilterType);
void setPattern(const QString &newPattern);
void setIsRegExpEnabled(bool newIsRegExpEnabled);
private:
QString m_pattern;
FilterType m_filterType;
bool m_isRegExpEnabled;
};
#endif // KFILEFILTER_H