]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Implemented search restriction to filenames.
authorSebastian Trueg <sebastian@trueg.de>
Wed, 17 Feb 2010 21:01:29 +0000 (21:01 +0000)
committerSebastian Trueg <sebastian@trueg.de>
Wed, 17 Feb 2010 21:01:29 +0000 (21:01 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1091902

src/search/dolphinsearchoptionsconfigurator.cpp

index 93b7a589c7ddc3b1d27d42836b303ef7a3b2f9a2..29df5f49d690c63865b8e5e1c85275576856474a 100644 (file)
@@ -28,7 +28,7 @@
 #include <nepomuk/orterm.h>
 #include <nepomuk/queryparser.h>
 #include <nepomuk/resourcetypeterm.h>
 #include <nepomuk/orterm.h>
 #include <nepomuk/queryparser.h>
 #include <nepomuk/resourcetypeterm.h>
-#include <nepomuk/term.h>
+#include <nepomuk/literalterm.h>
 
 #include "nfo.h"
 
 
 #include "nfo.h"
 
@@ -318,11 +318,7 @@ Nepomuk::Query::Query DolphinSearchOptionsConfigurator::nepomukQuery() const
         andTerm.addSubTerm(term);
     }
 
         andTerm.addSubTerm(term);
     }
 
-    // add custom query term from the searchbar
-    const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(m_customSearchQuery);
-    if (customQuery.isValid()) {
-        andTerm.addSubTerm(customQuery.term());
-    }
+    bool addCustomQuery = true;
 
     // filter result by the "What" filter
     switch (m_whatBox->currentIndex()) {
 
     // filter result by the "What" filter
     switch (m_whatBox->currentIndex()) {
@@ -338,9 +334,27 @@ Nepomuk::Query::Query DolphinSearchOptionsConfigurator::nepomukQuery() const
         andTerm.addSubTerm(textDocument);
         break;
     }
         andTerm.addSubTerm(textDocument);
         break;
     }
+    case 3: {
+        // Filenames
+        // trueg: Restriction to filename differs a bit from restriction to a type of file since it does not add a condition
+        // on the query but influences the text edited in the search bar directly.
+        // This is a bit tricky as we need to use the search bar text as plain text value for filename searches
+        // We do it the ugly way assuming the user only entered a literal value.
+        Nepomuk::Query::ComparisonTerm filenameTerm(Nepomuk::Vocabulary::NFO::fileName(), Nepomuk::Query::LiteralTerm(m_customSearchQuery));
+        andTerm.addSubTerm(filenameTerm);
+        addCustomQuery = false;
+    }
     default: break;
     }
 
     default: break;
     }
 
+    if (addCustomQuery) {
+        // add custom query term from the searchbar
+        const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(m_customSearchQuery);
+        if (customQuery.isValid()) {
+            andTerm.addSubTerm(customQuery.term());
+        }
+    }
+
     Nepomuk::Query::FileQuery fileQuery;
     if ((m_locationBox->currentIndex() == 1) && m_directory.isValid()) {
         // "From Here" is selected as location filter
     Nepomuk::Query::FileQuery fileQuery;
     if ((m_locationBox->currentIndex() == 1) && m_directory.isValid()) {
         // "From Here" is selected as location filter