File indexing completed on 2024-05-19 05:54:09

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
0003     SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef FILE_FILTER
0009 #define FILE_FILTER
0010 
0011 #include <QPointer>
0012 #include <QString>
0013 
0014 #include "RegExpFilter.h"
0015 
0016 namespace Konsole
0017 {
0018 class Session;
0019 class HotSpot;
0020 
0021 /**
0022  * A filter which matches files according to POSIX Portable Filename Character Set
0023  * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_267
0024  */
0025 
0026 class KONSOLEPRIVATE_EXPORT FileFilter : public RegExpFilter
0027 {
0028 public:
0029     explicit FileFilter(Session *session, const QString &wordCharacters);
0030 
0031     void process() override;
0032 
0033     void updateRegex(const QString &wordCharacters);
0034 
0035 protected:
0036     QSharedPointer<HotSpot> newHotSpot(int, int, int, int, const QStringList &) override;
0037 
0038 private:
0039     QString concatRegexPattern(QString wordCharacters) const;
0040 
0041     QPointer<Session> _session;
0042     QString _dirPath;
0043     QList<QString> _currentDirContents;
0044     static QRegularExpression _regex;
0045 };
0046 
0047 }
0048 #endif