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 55 56 57 58 59 60 61 62 63 64
|
/*
* SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KIO_FILENAMESEARCH_H
#define KIO_FILENAMESEARCH_H
#include <KIO/WorkerBase>
#include <QUrl>
#include <queue>
#include <set>
/**
* @brief Lists files that match a specific search pattern.
*
* For example, an application could create a url:
* filenamesearch:?search=sometext&url=file:///home/foo/bar&title=Query Results from 'sometext'
*
* - The pattern to search for, @c sometext is the value of the "search" query
* item of the URL
* - The directory where the search is performed, @c file:///home/foo/bar, is the value
* of the "url" query item.
*
* By default the files with names matching the search pattern are listed.
* Alternatively if the query item "checkContent" is set to "yes", the contents
* of files with a text MimeType will be searched for the given pattern and
* the matching files will be listed.
*/
class FileNameSearchProtocol : public QObject, public KIO::WorkerBase
{
Q_OBJECT
public:
FileNameSearchProtocol(const QByteArray &pool, const QByteArray &app);
~FileNameSearchProtocol() override;
KIO::WorkerResult stat(const QUrl &url) override;
KIO::WorkerResult listDir(const QUrl &url) override;
private:
void listRootEntry();
void searchDir(const QUrl &dirUrl,
const QRegularExpression ®ex,
bool searchContents,
bool includeHidden,
std::set<QString> &iteratedDirs,
std::queue<QUrl> &pendingDirs);
#if !defined(Q_OS_WIN32)
/**
* @brief Searches the directory using external tools if available.
* @return ERR_UNSUPPORTED_ACTION if the external tool is not available. Otherwise, the result of the search.
*/
KIO::WorkerResult searchDirWithExternalTool(const QUrl &dirUrl, const QRegularExpression ®ex);
#endif // !defined(Q_OS_WIN32)
};
#endif
|