┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search/dolphinsearchbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/dolphinsearchbox.cpp')
-rw-r--r--src/search/dolphinsearchbox.cpp86
1 files changed, 30 insertions, 56 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index cf1f0c8e5..e6377639b 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -21,7 +21,6 @@
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
-#include "dolphinsearchinformation.h"
#include <KIcon>
#include <KLineEdit>
@@ -40,18 +39,11 @@
#include <QToolButton>
#include <QVBoxLayout>
-#include <config-nepomuk.h>
-#ifdef HAVE_NEPOMUK
- #include <Nepomuk2/Query/AndTerm>
- #include <Nepomuk2/Query/FileQuery>
- #include <Nepomuk2/Query/LiteralTerm>
- #include <Nepomuk2/Query/OrTerm>
- #include <Nepomuk2/Query/Query>
- #include <Nepomuk2/Query/QueryParser>
- #include <Nepomuk2/Query/ResourceTypeTerm>
- #include <Nepomuk2/Query/ComparisonTerm>
- #include <Nepomuk2/ResourceManager>
- #include <Nepomuk2/Vocabulary/NFO>
+#include <config-baloo.h>
+#ifdef HAVE_BALOO
+ #include <baloo/query.h>
+ #include <baloo/term.h>
+ #include <baloo/indexerconfig.h>
#endif
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
@@ -115,8 +107,8 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
m_fromHereButton->setVisible(showSearchFromButtons);
m_everywhereButton->setVisible(showSearchFromButtons);
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- const bool hasFacetsSupport = searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath);
+ const Baloo::IndexerConfig searchInfo;
+ const bool hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
m_facetsWidget->setEnabled(hasFacetsSupport);
}
@@ -128,9 +120,9 @@ KUrl DolphinSearchBox::searchPath() const
KUrl DolphinSearchBox::urlForSearching() const
{
KUrl url;
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath)) {
- url = nepomukUrlForSearching();
+ const Baloo::IndexerConfig searchInfo;
+ if (searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile())) {
+ url = balooUrlForSearching();
} else {
url.setProtocol("filenamesearch");
url.addQueryItem("search", m_searchInput->text());
@@ -430,52 +422,34 @@ void DolphinSearchBox::init()
applyReadOnlyState();
}
-KUrl DolphinSearchBox::nepomukUrlForSearching() const
+KUrl DolphinSearchBox::balooUrlForSearching() const
{
-#ifdef HAVE_NEPOMUK
- // Create the term for the text from the input-field
- // dependent on whether a searching for content or
- // filename is done
+#ifdef HAVE_BALOO
const QString text = m_searchInput->text();
- Nepomuk2::Query::Term searchLabelTerm;
- if (m_contentButton->isChecked()) {
- // Let Nepomuk parse the query
- searchLabelTerm = Nepomuk2::Query::QueryParser::parseQuery(text, Nepomuk2::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("\\", "\\\\");
- searchLabelTerm = Nepomuk2::Query::ComparisonTerm(
- Nepomuk2::Vocabulary::NFO::fileName(),
- Nepomuk2::Query::LiteralTerm(regex),
- Nepomuk2::Query::ComparisonTerm::Regexp);
- }
- // Get the term from the facets and merge it with the
- // created term from the input-field.
- Nepomuk2::Query::Term facetsTerm = m_facetsWidget->facetsTerm();
+ Baloo::Query query;
+ query.addType("File");
+ query.addTypes(m_facetsWidget->facetTypes());
+
+ Baloo::Term term(Baloo::Term::And);
- Nepomuk2::Query::FileQuery fileQuery;
- fileQuery.setFileMode(Nepomuk2::Query::FileQuery::QueryFilesAndFolders);
- if (facetsTerm.isValid()) {
- Nepomuk2::Query::AndTerm andTerm;
- andTerm.addSubTerm(searchLabelTerm);
- andTerm.addSubTerm(facetsTerm);
- fileQuery.setTerm(andTerm);
+ Baloo::Term ratingTerm = m_facetsWidget->ratingTerm();
+ if (ratingTerm.isValid()) {
+ term.addSubTerm(ratingTerm);
+ }
+
+ if (m_contentButton->isChecked()) {
+ query.setSearchString(text);
} else {
- fileQuery.setTerm(searchLabelTerm);
+ term.addSubTerm(Baloo::Term("filename", text));
}
if (m_fromHereButton->isChecked()) {
- const bool recursive = true;
- fileQuery.addIncludeFolder(m_searchPath, recursive);
+ query.addCustomOption("includeFolder", m_searchPath.toLocalFile());
}
- return fileQuery.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
- "Query Results from '%1'",
- text));
+ 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();
#endif
@@ -483,9 +457,9 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
void DolphinSearchBox::applyReadOnlyState()
{
-#ifdef HAVE_NEPOMUK
+#ifdef HAVE_BALOO
if (m_readOnly) {
- m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
+ m_searchLabel->setText(Baloo::Query::titleFromQueryUrl(m_readOnlyQuery));
} else {
#else
{