┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastian Trueg <[email protected]>2011-05-28 21:23:05 +0200
committerSebastian Trueg <[email protected]>2011-05-29 09:39:46 +0200
commit18d8150848811eddfa67b1756b4ecf01d9cf11c9 (patch)
tree275fe11f23f91ff9f34644f3164a7cb48b349fa9 /src
parent3ed09520ad6402586238da22878453d95b558ac8 (diff)
Improved query creation. There is absolutely no point in using a
regular expression in addition to the query created by the query parser. All it does is majorly slowing down the query execution. REVIEW: 101462
Diffstat (limited to 'src')
-rw-r--r--src/search/dolphinsearchbox.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index c4cc2cfc3..803f0056e 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -364,31 +364,29 @@ void DolphinSearchBox::init()
KUrl DolphinSearchBox::nepomukUrlForSearching() const
{
#ifdef HAVE_NEPOMUK
- Nepomuk::Query::OrTerm orTerm;
+ Nepomuk::Query::Term term;
const QString text = m_searchInput->text();
- // 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()) {
- orTerm.addSubTerm(customQuery.term());
- }
+ // Let Nepomuk parse the query
+ term = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern).term();
+ }
+ else {
+ // Search the text in the filename only
+ QString regex = QRegExp::escape(text);
+ regex.replace("\\*", QLatin1String(".*"));
+ regex.replace("\\?", QLatin1String("."));
+ regex.replace("\\", "\\\\");
+ term = Nepomuk::Query::ComparisonTerm(
+ Nepomuk::Vocabulary::NFO::fileName(),
+ Nepomuk::Query::LiteralTerm(regex),
+ Nepomuk::Query::ComparisonTerm::Regexp);
}
Nepomuk::Query::FileQuery fileQuery;
fileQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFilesAndFolders);
- fileQuery.setTerm(orTerm);
+ fileQuery.setTerm(term);
if (m_fromHereButton->isChecked()) {
const bool recursive = true;
fileQuery.addIncludeFolder(m_searchPath, recursive);