diff options
| author | Emmanuel Pescosta <[email protected]> | 2015-02-27 11:30:27 +0100 |
|---|---|---|
| committer | Emmanuel Pescosta <[email protected]> | 2015-02-27 11:30:27 +0100 |
| commit | 9aee5d22513f0367febab54b38b3a7dc58d120bb (patch) | |
| tree | 99cf391070ac5d4650a3f1b309c3ec2e814f1ac6 /src/search | |
| parent | f025aeb63aa2a38e91c43d99ba9955793d3adf1e (diff) | |
| parent | b701b7e4edefb628d6f8b14146b2e299bd0ce5fc (diff) | |
Merge branch 'frameworks'
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/dolphinfacetswidget.cpp | 5 | ||||
| -rw-r--r-- | src/search/dolphinfacetswidget.h | 3 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 107 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.h | 34 | ||||
| -rw-r--r-- | src/search/filenamesearch.protocol | 17 | ||||
| -rw-r--r-- | src/search/filenamesearchprotocol.cpp | 191 | ||||
| -rw-r--r-- | src/search/filenamesearchprotocol.h | 60 |
7 files changed, 76 insertions, 341 deletions
diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp index f20ae68d5..b183eb8a1 100644 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -19,7 +19,7 @@ #include "dolphinfacetswidget.h" -#include <KLocale> +#include <KLocalizedString> #include <QButtonGroup> #include <QCheckBox> #include <QDate> @@ -295,9 +295,8 @@ QRadioButton* DolphinFacetsWidget::createRadioButton(const QString& text, QButtonGroup* group) { QRadioButton* button = new QRadioButton(text); - connect(button, SIGNAL(clicked()), this, SIGNAL(facetChanged())); + connect(button, &QRadioButton::clicked, this, &DolphinFacetsWidget::facetChanged); group->addButton(button); return button; } -#include "dolphinfacetswidget.moc" diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h index 757dcd482..03fb1279d 100644 --- a/src/search/dolphinfacetswidget.h +++ b/src/search/dolphinfacetswidget.h @@ -24,11 +24,10 @@ #include <config-baloo.h> #ifdef HAVE_BALOO - #include <baloo/term.h> + #include <Baloo/Term> #endif class QButtonGroup; -class QCheckBox; class QDate; class QRadioButton; diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 46ca01a4c..524c4462f 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -22,15 +22,14 @@ #include "dolphin_searchsettings.h" #include "dolphinfacetswidget.h" -#include <KIcon> -#include <KLineEdit> -#include <KLocale> +#include <QIcon> +#include <QLineEdit> +#include <KLocalizedString> #include <KSeparator> #include <QButtonGroup> #include <QDir> #include <QEvent> -#include <QFormLayout> #include <QHBoxLayout> #include <QKeyEvent> #include <QLabel> @@ -38,13 +37,15 @@ #include <QTimer> #include <QToolButton> #include <QVBoxLayout> +#include <QUrlQuery> #include <config-baloo.h> #ifdef HAVE_BALOO - #include <baloo/query.h> - #include <baloo/term.h> - #include <baloo/indexerconfig.h> + #include <Baloo/Query> + #include <Baloo/Term> + #include <Baloo/IndexerConfig> #endif +#include <QFontDatabase> DolphinSearchBox::DolphinSearchBox(QWidget* parent) : QWidget(parent), @@ -81,7 +82,7 @@ QString DolphinSearchBox::text() const return m_searchInput->text(); } -void DolphinSearchBox::setSearchPath(const KUrl& url) +void DolphinSearchBox::setSearchPath(const QUrl& url) { m_searchPath = url; @@ -93,7 +94,7 @@ void DolphinSearchBox::setSearchPath(const KUrl& url) if (url.isLocalFile()) { location = QLatin1String("/"); } else { - location = url.protocol() + QLatin1String(" - ") + url.host(); + location = url.scheme() + QLatin1String(" - ") + url.host(); } } @@ -113,14 +114,14 @@ void DolphinSearchBox::setSearchPath(const KUrl& url) m_facetsWidget->setEnabled(hasFacetsSupport); } -KUrl DolphinSearchBox::searchPath() const +QUrl DolphinSearchBox::searchPath() const { return m_searchPath; } -KUrl DolphinSearchBox::urlForSearching() const +QUrl DolphinSearchBox::urlForSearching() const { - KUrl url; + QUrl url; bool useBalooSearch = false; #ifdef HAVE_BALOO const Baloo::IndexerConfig searchInfo; @@ -129,10 +130,12 @@ KUrl DolphinSearchBox::urlForSearching() const if (useBalooSearch) { url = balooUrlForSearching(); } else { - url.setProtocol("filenamesearch"); - url.addQueryItem("search", m_searchInput->text()); + url.setScheme("filenamesearch"); + + QUrlQuery query; + query.addQueryItem("search", m_searchInput->text()); if (m_contentButton->isChecked()) { - url.addQueryItem("checkContent", "yes"); + query.addQueryItem("checkContent", "yes"); } QString encodedUrl; @@ -144,21 +147,23 @@ KUrl DolphinSearchBox::urlForSearching() const } else { encodedUrl = m_searchPath.url(); } - url.addQueryItem("url", encodedUrl); + query.addQueryItem("url", encodedUrl); + + url.setQuery(query); } return url; } -void DolphinSearchBox::fromSearchUrl(const KUrl& url) +void DolphinSearchBox::fromSearchUrl(const QUrl& url) { - if (url.protocol() == "baloosearch") { + if (url.scheme() == "baloosearch") { fromBalooSearchUrl(url); - } else if (url.protocol() == "filenamesearch") { - const QMap<QString, QString>& queryItems = url.queryItems(); - setText(queryItems.value("search")); - setSearchPath(queryItems.value("url")); - m_contentButton->setChecked(queryItems.value("checkContent") == "yes"); + } else if (url.scheme() == "filenamesearch") { + const QUrlQuery query(url); + setText(query.queryItemValue("search")); + setSearchPath(QUrl::fromUserInput(query.queryItemValue("url"), QString(), QUrl::AssumeLocalFile)); + m_contentButton->setChecked(query.queryItemValue("checkContent") == "yes"); } else { setText(QString()); setSearchPath(url); @@ -253,6 +258,7 @@ void DolphinSearchBox::slotConfigurationChanged() void DolphinSearchBox::slotSearchTextChanged(const QString& text) { + if (text.isEmpty()) { m_startSearchTimer->stop(); } else { @@ -261,10 +267,10 @@ void DolphinSearchBox::slotSearchTextChanged(const QString& text) emit searchTextChanged(text); } -void DolphinSearchBox::slotReturnPressed(const QString& text) +void DolphinSearchBox::slotReturnPressed() { emitSearchRequest(); - emit returnPressed(text); + emit returnPressed(); } void DolphinSearchBox::slotFacetsButtonToggled() @@ -287,7 +293,7 @@ void DolphinSearchBox::initButton(QToolButton* button) button->setAutoExclusive(true); button->setAutoRaise(true); button->setCheckable(true); - connect(button, SIGNAL(clicked(bool)), this, SLOT(slotConfigurationChanged())); + connect(button, &QToolButton::clicked, this, &DolphinSearchBox::slotConfigurationChanged); } void DolphinSearchBox::loadSettings() @@ -312,7 +318,7 @@ void DolphinSearchBox::saveSettings() SearchSettings::setLocation(m_fromHereButton->isChecked() ? "FromHere" : "Everywhere"); SearchSettings::setWhat(m_fileNameButton->isChecked() ? "FileName" : "Content"); SearchSettings::setShowFacetsWidget(m_facetsToggleButton->isChecked()); - SearchSettings::self()->writeConfig(); + SearchSettings::self()->save(); } void DolphinSearchBox::init() @@ -320,23 +326,23 @@ void DolphinSearchBox::init() // Create close button QToolButton* closeButton = new QToolButton(this); closeButton->setAutoRaise(true); - closeButton->setIcon(KIcon("dialog-close")); + closeButton->setIcon(QIcon::fromTheme("dialog-close")); closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching")); - connect(closeButton, SIGNAL(clicked()), this, SLOT(emitCloseRequest())); + connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest); // Create search label m_searchLabel = new QLabel(this); // Create search box - m_searchInput = new KLineEdit(this); + m_searchInput = new QLineEdit(this); m_searchInput->installEventFilter(this); - m_searchInput->setClearButtonShown(true); - m_searchInput->setFont(KGlobalSettings::generalFont()); + m_searchInput->setClearButtonEnabled(true); + m_searchInput->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont)); + connect(m_searchInput, &QLineEdit::returnPressed, + this, &DolphinSearchBox::slotReturnPressed); + connect(m_searchInput, &QLineEdit::textChanged, + this, &DolphinSearchBox::slotSearchTextChanged); setFocusProxy(m_searchInput); - connect(m_searchInput, SIGNAL(returnPressed(QString)), - this, SLOT(slotReturnPressed(QString))); - connect(m_searchInput, SIGNAL(textChanged(QString)), - this, SLOT(slotSearchTextChanged(QString))); // Apply layout for the search input QHBoxLayout* searchInputLayout = new QHBoxLayout(); @@ -377,12 +383,12 @@ void DolphinSearchBox::init() m_facetsToggleButton = new QToolButton(this); m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); initButton(m_facetsToggleButton); - connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled())); + connect(m_facetsToggleButton, &QToolButton::clicked, this, &DolphinSearchBox::slotFacetsButtonToggled); m_facetsWidget = new DolphinFacetsWidget(this); m_facetsWidget->installEventFilter(this); m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - connect(m_facetsWidget, SIGNAL(facetChanged()), this, SLOT(slotFacetChanged())); + connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged); // Apply layout for the options QHBoxLayout* optionsLayout = new QHBoxLayout(); @@ -422,12 +428,12 @@ void DolphinSearchBox::init() m_startSearchTimer = new QTimer(this); m_startSearchTimer->setSingleShot(true); m_startSearchTimer->setInterval(1000); - connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest())); + connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest); updateFacetsToggleButton(); } -KUrl DolphinSearchBox::balooUrlForSearching() const +QUrl DolphinSearchBox::balooUrlForSearching() const { #ifdef HAVE_BALOO const QString text = m_searchInput->text(); @@ -450,7 +456,7 @@ KUrl DolphinSearchBox::balooUrlForSearching() const } if (m_fromHereButton->isChecked()) { - query.addCustomOption("includeFolder", m_searchPath.toLocalFile()); + query.setIncludeFolder(m_searchPath.toLocalFile()); } query.setTerm(term); @@ -458,11 +464,11 @@ KUrl DolphinSearchBox::balooUrlForSearching() const return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", "Query Results from '%1'", text)); #else - return KUrl(); + return QUrl(); #endif } -void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url) +void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url) { #ifdef HAVE_BALOO const Baloo::Query query = Baloo::Query::fromSearchUrl(url); @@ -472,16 +478,14 @@ void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url) // while we adjust the search text and the facet widget. blockSignals(true); - const QVariantHash customOptions = query.customOptions(); - if (customOptions.contains("includeFolder")) { - setSearchPath(customOptions.value("includeFolder").toString()); + const QString customDir = query.includeFolder(); + if (!customDir.isEmpty()) { + setSearchPath(QUrl::fromLocalFile(customDir)); } else { setSearchPath(QDir::homePath()); } - if (!query.searchString().isEmpty()) { - setText(query.searchString()); - } + setText(query.searchString()); QStringList types = query.types(); types.removeOne("File"); // We are only interested in facet widget types @@ -501,6 +505,8 @@ void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url) m_startSearchTimer->stop(); blockSignals(false); +#else + Q_UNUSED(url); #endif } @@ -508,8 +514,7 @@ void DolphinSearchBox::updateFacetsToggleButton() { const bool facetsIsVisible = SearchSettings::showFacetsWidget(); m_facetsToggleButton->setChecked(facetsIsVisible ? true : false); - m_facetsToggleButton->setIcon(KIcon(facetsIsVisible ? "arrow-up-double" : "arrow-down-double")); + m_facetsToggleButton->setIcon(QIcon::fromTheme(facetsIsVisible ? "arrow-up-double" : "arrow-down-double")); m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options")); } -#include "dolphinsearchbox.moc" diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index 53b12ffab..a80617476 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -20,12 +20,11 @@ #ifndef DOLPHINSEARCHBOX_H #define DOLPHINSEARCHBOX_H -#include <KUrl> -#include <QList> +#include <QUrl> #include <QWidget> class DolphinFacetsWidget; -class KLineEdit; +class QLineEdit; class KSeparator; class QToolButton; class QScrollArea; @@ -65,17 +64,17 @@ public: * Sets the current path that is used as root for * searching files, if "From Here" has been selected. */ - void setSearchPath(const KUrl& url); - KUrl searchPath() const; + void setSearchPath(const QUrl& url); + QUrl searchPath() const; /** @return URL that will start the searching of files. */ - KUrl urlForSearching() const; + QUrl urlForSearching() const; /** * Extracts information from the given search \a url to * initialize the search box properly. */ - void fromSearchUrl(const KUrl& url); + void fromSearchUrl(const QUrl& url); /** * Selects the whole text of the search box. @@ -99,10 +98,10 @@ public: bool isActive() const; protected: - virtual bool event(QEvent* event); - virtual void showEvent(QShowEvent* event); - virtual void keyReleaseEvent(QKeyEvent* event); - virtual bool eventFilter(QObject* obj, QEvent* event); + virtual bool event(QEvent* event) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE; + virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE; signals: /** @@ -116,7 +115,7 @@ signals: */ void searchTextChanged(const QString& text); - void returnPressed(const QString& text); + void returnPressed(); /** * Emitted as soon as the search box should get closed. @@ -135,7 +134,7 @@ private slots: void emitCloseRequest(); void slotConfigurationChanged(); void slotSearchTextChanged(const QString& text); - void slotReturnPressed(const QString& text); + void slotReturnPressed(); void slotFacetsButtonToggled(); void slotFacetChanged(); @@ -148,15 +147,16 @@ private: /** * @return URL that represents the Baloo query for starting the search. */ - KUrl balooUrlForSearching() const; + QUrl balooUrlForSearching() const; /** * Extracts information from the given Baloo search \a url to * initialize the search box properly. */ - void fromBalooSearchUrl(const KUrl& url); + void fromBalooSearchUrl(const QUrl& url); void updateFacetsToggleButton(); + private: bool m_startedSearching; bool m_active; @@ -164,7 +164,7 @@ private: QVBoxLayout* m_topLayout; QLabel* m_searchLabel; - KLineEdit* m_searchInput; + QLineEdit* m_searchInput; QScrollArea* m_optionsScrollArea; QToolButton* m_fileNameButton; QToolButton* m_contentButton; @@ -174,7 +174,7 @@ private: QToolButton* m_facetsToggleButton; DolphinFacetsWidget* m_facetsWidget; - KUrl m_searchPath; + QUrl m_searchPath; QTimer* m_startSearchTimer; }; diff --git a/src/search/filenamesearch.protocol b/src/search/filenamesearch.protocol deleted file mode 100644 index 06aec0e6b..000000000 --- a/src/search/filenamesearch.protocol +++ /dev/null @@ -1,17 +0,0 @@ -[Protocol] -exec=kio_filenamesearch -protocol=filenamesearch -input=none -output=filesystem -reading=true -writing=false -deleting=true -linking=false -makedir=false -moving=false -listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link -source=false -Icon=edit-find -Class=:local -determineMimetypeFromExtension=false -maxInstances=10 diff --git a/src/search/filenamesearchprotocol.cpp b/src/search/filenamesearchprotocol.cpp deleted file mode 100644 index 38dd26b23..000000000 --- a/src/search/filenamesearchprotocol.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Peter Penz <[email protected]> * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "filenamesearchprotocol.h" - -#include <KComponentData> -#include <KDirLister> -#include <KFileItem> -#include <KIO/NetAccess> -#include <KIO/Job> -#include <KUrl> -#include <ktemporaryfile.h> - -#include <QCoreApplication> -#include <QEventLoop> -#include <QRegExp> - -FileNameSearchProtocol::FileNameSearchProtocol( const QByteArray &pool, const QByteArray &app ) : - SlaveBase("search", pool, app), - m_checkContent(false), - m_regExp(0), - m_iteratedDirs() -{ -} - -FileNameSearchProtocol::~FileNameSearchProtocol() -{ - cleanup(); -} - -void FileNameSearchProtocol::listDir(const KUrl& url) -{ - cleanup(); - - const QString search = url.queryItem("search"); - if (!search.isEmpty()) { - m_regExp = new QRegExp(search, Qt::CaseInsensitive, QRegExp::Wildcard); - } - - m_checkContent = false; - const QString checkContent = url.queryItem("checkContent"); - if (checkContent == QLatin1String("yes")) { - m_checkContent = true; - } - - const QString urlString = url.queryItem("url"); - searchDirectory(KUrl(urlString)); - - cleanup(); - finished(); -} - -void FileNameSearchProtocol::searchDirectory(const KUrl& directory) -{ - if (directory.path() == QLatin1String("/proc")) { - // Don't try to iterate the /proc directory of Linux - return; - } - - // Get all items of the directory - KDirLister *dirLister = new KDirLister(); - dirLister->setDelayedMimeTypes(false); - dirLister->setAutoErrorHandlingEnabled(false, 0); - dirLister->openUrl(directory); - - QEventLoop eventLoop; - QObject::connect(dirLister, SIGNAL(canceled()), &eventLoop, SLOT(quit())); - QObject::connect(dirLister, SIGNAL(completed()), &eventLoop, SLOT(quit())); - eventLoop.exec(); - - // Visualize all items that match the search pattern - QList<KUrl> pendingDirs; - const KFileItemList items = dirLister->items(); - foreach (const KFileItem& item, items) { - bool addItem = false; - if (!m_regExp || item.name().contains(*m_regExp)) { - addItem = true; - } else if (m_checkContent && item.determineMimeType()->is(QLatin1String("text/plain"))) { - addItem = contentContainsPattern(item.url()); - } - - if (addItem) { - KIO::UDSEntry entry = item.entry(); - entry.insert(KIO::UDSEntry::UDS_URL, item.url().url() ); - listEntry(entry,false); - } - - if (item.isDir()) { - if (item.isLink()) { - // Assure that no endless searching is done in directories that - // have already been iterated. - const KUrl linkDest(item.url(), item.linkDest()); - if (!m_iteratedDirs.contains(linkDest.path())) { - pendingDirs.append(linkDest); - } - } else { - pendingDirs.append(item.url()); - } - } - } - listEntry(KIO::UDSEntry(), true); - - m_iteratedDirs.insert(directory.path()); - - delete dirLister; - dirLister = 0; - - // Recursively iterate all sub directories - foreach (const KUrl& pendingDir, pendingDirs) { - searchDirectory(pendingDir); - } -} - -bool FileNameSearchProtocol::contentContainsPattern(const KUrl& fileName) const -{ - Q_ASSERT(m_regExp); - - QString path; - KTemporaryFile tempFile; - - if (fileName.isLocalFile()) { - path = fileName.path(); - } else if (tempFile.open()) { - KIO::Job* getJob = KIO::file_copy(fileName, - tempFile.fileName(), - -1, - KIO::Overwrite | KIO::HideProgressInfo); - if (!KIO::NetAccess::synchronousRun(getJob, 0)) { - // The non-local file could not be downloaded - return false; - } - path = tempFile.fileName(); - } else { - // No temporary file could be created for downloading non-local files - return false; - } - - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - return false; - } - - QTextStream in(&file); - while (!in.atEnd()) { - const QString line = in.readLine(); - if (line.contains(*m_regExp)) { - return true; - } - } - - return false; -} - -void FileNameSearchProtocol::cleanup() -{ - delete m_regExp; - m_regExp = 0; - m_iteratedDirs.clear(); -} - -extern "C" int KDE_EXPORT kdemain( int argc, char **argv ) -{ - KComponentData instance("kio_search"); - QCoreApplication app(argc, argv); - - if (argc != 4) { - fprintf(stderr, "Usage: kio_filenamesearch protocol domain-socket1 domain-socket2\n"); - exit(-1); - } - - FileNameSearchProtocol slave(argv[2], argv[3]); - slave.dispatchLoop(); - - return 0; -} diff --git a/src/search/filenamesearchprotocol.h b/src/search/filenamesearchprotocol.h deleted file mode 100644 index 4a854d729..000000000 --- a/src/search/filenamesearchprotocol.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Peter Penz <[email protected]> * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef FILENAMESEARCHPROTOCOL_H -#define FILENAMESEARCHPROTOCOL_H - -#include <kio/slavebase.h> - -class KFileItem; -class KUrl; -class QRegExp; - -/** - * @brief Lists files where the filename matches do a given query. - * - * The query is defined as part of the "search" query item of the URL. - * The directory where the searching is started is defined in the "url" query - * item. If the query item "checkContent" is set to "yes", all files with - * a text MIME type will be checked for the content. - */ -class FileNameSearchProtocol : public KIO::SlaveBase { -public: - FileNameSearchProtocol(const QByteArray& pool, const QByteArray& app); - virtual ~FileNameSearchProtocol(); - - virtual void listDir(const KUrl& url); - -private: - void searchDirectory(const KUrl& directory); - - /** - * @return True, if the pattern m_searchPattern is part of - * the file \a fileName. - */ - bool contentContainsPattern(const KUrl& fileName) const; - - void cleanup(); - - bool m_checkContent; - QRegExp* m_regExp; - QSet<QString> m_iteratedDirs; -}; - -#endif |
