diff options
| author | Peter Penz <[email protected]> | 2011-03-10 23:17:55 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-03-10 23:21:42 +0100 |
| commit | 984c20161bc71684325a1394cfbb292683c94d53 (patch) | |
| tree | 8be45dd133b78acb2acbfa65a9d1bb49d8cf60be /src/search | |
| parent | 6e0583f9888fcf46bb89735423b02b5ca53f1459 (diff) | |
Add search modes for the Search Panel
The search panel must get a hint whether clicking on the facets should result in searching everywhere or from the current folder. It is not sufficient to check the search-settings of the "Find:"-box, as when the "Find:"-box is invisible there is no hint for the user what kind of searching is done and the setting must be ignored.
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 8119e821f..17a691e44 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -42,9 +42,9 @@ #include <config-nepomuk.h> #ifdef HAVE_NEPOMUK - #include <Nepomuk/Query/AndTerm> #include <Nepomuk/Query/FileQuery> #include <Nepomuk/Query/LiteralTerm> + #include <Nepomuk/Query/OrTerm> #include <Nepomuk/Query/Query> #include <Nepomuk/Query/QueryParser> #include <Nepomuk/Query/ResourceTypeTerm> @@ -349,28 +349,31 @@ void DolphinSearchBox::init() KUrl DolphinSearchBox::nepomukUrlForSearching() const { #ifdef HAVE_NEPOMUK - Nepomuk::Query::AndTerm andTerm; + Nepomuk::Query::OrTerm orTerm; const QString text = m_searchInput->text(); - if (m_fileNameButton->isChecked()) { - QString regex = QRegExp::escape(text); - regex.replace("\\*", QLatin1String(".*")); - regex.replace("\\?", QLatin1String(".")); - regex.replace("\\", "\\\\"); - andTerm.addSubTerm(Nepomuk::Query::ComparisonTerm( - Nepomuk::Vocabulary::NFO::fileName(), - Nepomuk::Query::LiteralTerm(regex), - Nepomuk::Query::ComparisonTerm::Regexp)); - } else { + + // Search the text in the filename in any case + QString regex = QRegExp::escape(text); + regex.replace("\\*", QLatin1String(".*")); + regex.replace("\\?", QLatin1String(".")); + regex.replace("\\", "\\\\"); + orTerm.addSubTerm(Nepomuk::Query::ComparisonTerm( + Nepomuk::Vocabulary::NFO::fileName(), + Nepomuk::Query::LiteralTerm(regex), + Nepomuk::Query::ComparisonTerm::Regexp)); + + if (m_contentButton->isChecked()) { + // Search the text also in the content of the files const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern); if (customQuery.isValid()) { - andTerm.addSubTerm(customQuery.term()); + orTerm.addSubTerm(customQuery.term()); } } Nepomuk::Query::FileQuery fileQuery; fileQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFilesAndFolders); - fileQuery.setTerm(andTerm); + fileQuery.setTerm(orTerm); if (m_fromHereButton->isChecked()) { const bool recursive = true; fileQuery.addIncludeFolder(m_searchPath, recursive); |
