File indexing completed on 2024-04-28 08:49:48
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIO_FILENAMESEARCH_H 0008 #define KIO_FILENAMESEARCH_H 0009 0010 #include <KIO/WorkerBase> 0011 0012 #include <QUrl> 0013 0014 #include <queue> 0015 #include <set> 0016 0017 /** 0018 * @brief Lists files that match a specific search pattern. 0019 * 0020 * For example, an application could create a url: 0021 * filenamesearch:?search=sometext&url=file:///home/foo/bar&title=Query Results from 'sometext' 0022 * 0023 * - The pattern to search for, @c sometext is the value of the "search" query 0024 * item of the URL 0025 * - The directory where the search is performed, @c file:///home/foo/bar, is the value 0026 * of the "url" query item. 0027 * 0028 * By default the files with names matching the search pattern are listed. 0029 * Alternatively if the query item "checkContent" is set to "yes", the contents 0030 * of files with a text MimeType will be searched for the given pattern and 0031 * the matching files will be listed. 0032 */ 0033 class FileNameSearchProtocol : public QObject, public KIO::WorkerBase 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 FileNameSearchProtocol(const QByteArray &pool, const QByteArray &app); 0039 ~FileNameSearchProtocol() override; 0040 0041 KIO::WorkerResult stat(const QUrl &url) override; 0042 KIO::WorkerResult listDir(const QUrl &url) override; 0043 0044 private: 0045 void listRootEntry(); 0046 void searchDir(const QUrl &dirUrl, const QRegularExpression ®ex, bool searchContents, std::set<QString> &iteratedDirs, std::queue<QUrl> &pendingDirs); 0047 }; 0048 0049 #endif