┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/search')
-rw-r--r--src/search/dolphinfacetswidget.cpp210
-rw-r--r--src/search/dolphinfacetswidget.h34
-rw-r--r--src/search/dolphinsearchbox.cpp171
-rw-r--r--src/search/dolphinsearchbox.h31
-rw-r--r--src/search/dolphinsearchinformation.cpp124
-rw-r--r--src/search/dolphinsearchinformation.h57
6 files changed, 269 insertions, 358 deletions
diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp
index d786117c9..f20ae68d5 100644
--- a/src/search/dolphinfacetswidget.cpp
+++ b/src/search/dolphinfacetswidget.cpp
@@ -27,18 +27,6 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
-#ifdef HAVE_NEPOMUK
- #include <Nepomuk2/Query/AndTerm>
- #include <Nepomuk2/Query/ComparisonTerm>
- #include <Nepomuk2/Query/LiteralTerm>
- #include <Nepomuk2/Query/OrTerm>
- #include <Nepomuk2/Query/Query>
- #include <Nepomuk2/Query/ResourceTypeTerm>
- #include <Nepomuk2/Vocabulary/NFO>
- #include <Nepomuk2/Vocabulary/NIE>
- #include <Soprano/Vocabulary/NAO>
-#endif
-
DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
QWidget(parent),
m_documents(0),
@@ -58,13 +46,16 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
m_fourOrMore(0),
m_maxRating(0)
{
- m_documents = createCheckBox(i18nc("@option:check", "Documents"));
- m_images = createCheckBox(i18nc("@option:check", "Images"));
- m_audio = createCheckBox(i18nc("@option:check", "Audio Files"));
- m_videos = createCheckBox(i18nc("@option:check", "Videos"));
+ QButtonGroup* filetypeGroup = new QButtonGroup(this);
+ m_anyType = createRadioButton(i18nc("@option:check", "Any"), filetypeGroup);
+ m_documents = createRadioButton(i18nc("@option:check", "Documents"), filetypeGroup);
+ m_images = createRadioButton(i18nc("@option:check", "Images"), filetypeGroup);
+ m_audio = createRadioButton(i18nc("@option:check", "Audio Files"), filetypeGroup);
+ m_videos = createRadioButton(i18nc("@option:check", "Videos"), filetypeGroup);
QVBoxLayout* typeLayout = new QVBoxLayout();
typeLayout->setSpacing(0);
+ typeLayout->addWidget(m_anyType);
typeLayout->addWidget(m_documents);
typeLayout->addWidget(m_images);
typeLayout->addWidget(m_audio);
@@ -112,6 +103,7 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
topLayout->addLayout(ratingLayout);
topLayout->addStretch();
+ m_anyType->setChecked(true);
m_anytime->setChecked(true);
m_anyRating->setChecked(true);
}
@@ -120,38 +112,11 @@ DolphinFacetsWidget::~DolphinFacetsWidget()
{
}
-#ifdef HAVE_NEPOMUK
-Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
+#ifdef HAVE_BALOO
+Baloo::Term DolphinFacetsWidget::ratingTerm() const
{
- Nepomuk2::Query::AndTerm andTerm;
-
- const bool hasTypeFilter = m_documents->isChecked() ||
- m_images->isChecked() ||
- m_audio->isChecked() ||
- m_videos->isChecked();
- if (hasTypeFilter) {
- Nepomuk2::Query::OrTerm orTerm;
-
- if (m_documents->isChecked()) {
- orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document()));
- }
-
- if (m_images->isChecked()) {
- orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image()));
- }
-
- if (m_audio->isChecked()) {
- orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
- Nepomuk2::Query::LiteralTerm("audio")));
- }
-
- if (m_videos->isChecked()) {
- orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
- Nepomuk2::Query::LiteralTerm("video")));
- }
-
- andTerm.addSubTerm(orTerm);
- }
+ Baloo::Term ratingTerm;
+ Baloo::Term modifiedTerm;
if (!m_anyRating->isChecked()) {
int stars = 1; // represents m_oneOrMore
@@ -166,10 +131,7 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
}
const int rating = stars * 2;
- Nepomuk2::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(),
- Nepomuk2::Query::LiteralTerm(rating),
- Nepomuk2::Query::ComparisonTerm::GreaterOrEqual);
- andTerm.addSubTerm(term);
+ ratingTerm = Baloo::Term("rating", rating, Baloo::Term::GreaterEqual);
}
if (!m_anytime->isChecked()) {
@@ -184,21 +146,149 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
date = date.addDays(1 - date.dayOfYear());
}
- Nepomuk2::Query::ComparisonTerm term(Nepomuk2::Vocabulary::NIE::lastModified(),
- Nepomuk2::Query::LiteralTerm(QDateTime(date)),
- Nepomuk2::Query::ComparisonTerm::GreaterOrEqual);
- andTerm.addSubTerm(term);
+ modifiedTerm = Baloo::Term("modified", date, Baloo::Term::GreaterEqual);
+ }
+
+ if (ratingTerm.isValid() && modifiedTerm.isValid()) {
+ Baloo::Term term(Baloo::Term::And);
+ term.addSubTerm(ratingTerm);
+ term.addSubTerm(modifiedTerm);
+
+ return term;
+ } else if (modifiedTerm.isValid()) {
+ return modifiedTerm;
+ } else if (ratingTerm.isValid()) {
+ return ratingTerm;
+ }
+
+ return Baloo::Term();
+}
+
+QString DolphinFacetsWidget::facetType() const
+{
+ if (m_documents->isChecked()) {
+ return QLatin1String("Document");
+ } else if (m_images->isChecked()) {
+ return QLatin1String("Image");
+ } else if (m_audio->isChecked()) {
+ return QLatin1String("Audio");
+ } else if (m_videos->isChecked()) {
+ return QLatin1String("Video");
+ }
+
+ return QString();
+}
+
+bool DolphinFacetsWidget::isRatingTerm(const Baloo::Term& term) const
+{
+ const QList<Baloo::Term> subTerms = term.subTerms();
+ if (subTerms.isEmpty()) {
+ // If term has no sub terms, then the term itself is either a "rating" term
+ // or a "modified" term.
+ return term.property() == QLatin1String("modified") ||
+ term.property() == QLatin1String("rating");
+
+ } else if (subTerms.size() == 2) {
+ // If term has sub terms, then the sub terms are always "rating" and "modified" terms.
+
+ QStringList properties;
+ foreach (const Baloo::Term& subTerm, subTerms) {
+ properties << subTerm.property();
+ }
+
+ return properties.contains(QLatin1String("modified")) &&
+ properties.contains(QLatin1String("rating"));
+ }
+
+ return false;
+}
+
+void DolphinFacetsWidget::setRatingTerm(const Baloo::Term& term)
+{
+ // If term has sub terms, then the sub terms are always "rating" and "modified" terms.
+ // If term has no sub terms, then the term itself is either a "rating" term or a "modified"
+ // term. To avoid code duplication we add term to subTerms list, if the list is empty.
+ QList<Baloo::Term> subTerms = term.subTerms();
+ if (subTerms.isEmpty()) {
+ subTerms << term;
}
- return andTerm;
+ foreach (const Baloo::Term& subTerm, subTerms) {
+ const QString property = subTerm.property();
+
+ if (property == QLatin1String("modified")) {
+ const QDate date = subTerm.value().toDate();
+ setTimespan(date);
+ } else if (property == QLatin1String("rating")) {
+ const int stars = subTerm.value().toInt() / 2;
+ setRating(stars);
+ }
+ }
}
+
#endif
-QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text)
+void DolphinFacetsWidget::setFacetType(const QString& type)
{
- QCheckBox* checkBox = new QCheckBox(text);
- connect(checkBox, SIGNAL(clicked()), this, SIGNAL(facetChanged()));
- return checkBox;
+ if (type == QLatin1String("Document")) {
+ m_documents->setChecked(true);
+ } else if (type == QLatin1String("Image")) {
+ m_images->setChecked(true);
+ } else if (type == QLatin1String("Audio")) {
+ m_audio->setChecked(true);
+ } else if (type == QLatin1String("Video")) {
+ m_videos->setChecked(true);
+ } else {
+ m_anyType->setChecked(true);
+ }
+}
+
+void DolphinFacetsWidget::setRating(const int stars)
+{
+ switch (stars) {
+ case 5:
+ m_maxRating->setChecked(true);
+ break;
+
+ case 4:
+ m_fourOrMore->setChecked(true);
+ break;
+
+ case 3:
+ m_threeOrMore->setChecked(true);
+ break;
+
+ case 2:
+ m_twoOrMore->setChecked(true);
+ break;
+
+ case 1:
+ m_oneOrMore->setChecked(true);
+ break;
+
+ default:
+ m_anyRating->setChecked(true);
+ }
+}
+
+void DolphinFacetsWidget::setTimespan(const QDate& date)
+{
+ const QDate currentDate = QDate::currentDate();
+ const int days = date.daysTo(currentDate);
+
+ if (days <= 0) {
+ m_today->setChecked(true);
+ } else if (days <= 1) {
+ m_yesterday->setChecked(true);
+ } else if (days <= currentDate.dayOfWeek()) {
+ m_thisWeek->setChecked(true);
+ } else if (days <= currentDate.day()) {
+ m_thisMonth->setChecked(true);
+ } else if (days <= currentDate.dayOfYear()) {
+ m_thisYear->setChecked(true);
+ } else {
+ m_anytime->setChecked(true);
+ }
}
QRadioButton* DolphinFacetsWidget::createRadioButton(const QString& text,
diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h
index 57bed9e68..757dcd482 100644
--- a/src/search/dolphinfacetswidget.h
+++ b/src/search/dolphinfacetswidget.h
@@ -22,13 +22,14 @@
#include <QWidget>
-#include <config-nepomuk.h>
-#ifdef HAVE_NEPOMUK
- #include <Nepomuk2/Query/Term>
+#include <config-baloo.h>
+#ifdef HAVE_BALOO
+ #include <baloo/term.h>
#endif
class QButtonGroup;
class QCheckBox;
+class QDate;
class QRadioButton;
/**
@@ -55,20 +56,22 @@ public:
explicit DolphinFacetsWidget(QWidget* parent = 0);
virtual ~DolphinFacetsWidget();
-#ifdef HAVE_NEPOMUK
- Nepomuk2::Query::Term facetsTerm() const;
+#ifdef HAVE_BALOO
+ Baloo::Term ratingTerm() const;
+ QString facetType() const;
+
+ bool isRatingTerm(const Baloo::Term& term) const;
+ void setRatingTerm(const Baloo::Term& term);
#endif
+ void setFacetType(const QString& type);
+
signals:
void facetChanged();
private:
- /**
- * @return New checkbox which is connected to the
- * slotFacedChanged() slot whenever it has
- * been toggled.
- */
- QCheckBox* createCheckBox(const QString& text);
+ void setRating(const int stars);
+ void setTimespan(const QDate& date);
/**
* @return New radiobutton which is connected to the
@@ -79,10 +82,11 @@ private:
QButtonGroup* group);
private:
- QCheckBox* m_documents;
- QCheckBox* m_images;
- QCheckBox* m_audio;
- QCheckBox* m_videos;
+ QRadioButton* m_anyType;
+ QRadioButton* m_documents;
+ QRadioButton* m_images;
+ QRadioButton* m_audio;
+ QRadioButton* m_videos;
QRadioButton* m_anytime;
QRadioButton* m_today;
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index cf1f0c8e5..46ca01a4c 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,24 +39,16 @@
#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) :
QWidget(parent),
m_startedSearching(false),
- m_readOnly(false),
m_active(true),
m_topLayout(0),
m_searchLabel(0),
@@ -71,7 +62,6 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
m_facetsToggleButton(0),
m_facetsWidget(0),
m_searchPath(),
- m_readOnlyQuery(),
m_startSearchTimer(0)
{
}
@@ -110,13 +100,16 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth);
m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation));
- const bool showSearchFromButtons = url.isLocalFile() && !m_readOnly;
+ const bool showSearchFromButtons = url.isLocalFile();
m_separator->setVisible(showSearchFromButtons);
m_fromHereButton->setVisible(showSearchFromButtons);
m_everywhereButton->setVisible(showSearchFromButtons);
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- const bool hasFacetsSupport = searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath);
+ bool hasFacetsSupport = false;
+#ifdef HAVE_BALOO
+ const Baloo::IndexerConfig searchInfo;
+ hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
+#endif
m_facetsWidget->setEnabled(hasFacetsSupport);
}
@@ -128,9 +121,13 @@ KUrl DolphinSearchBox::searchPath() const
KUrl DolphinSearchBox::urlForSearching() const
{
KUrl url;
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath)) {
- url = nepomukUrlForSearching();
+ bool useBalooSearch = false;
+#ifdef HAVE_BALOO
+ const Baloo::IndexerConfig searchInfo;
+ useBalooSearch = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
+#endif
+ if (useBalooSearch) {
+ url = balooUrlForSearching();
} else {
url.setProtocol("filenamesearch");
url.addQueryItem("search", m_searchInput->text());
@@ -153,23 +150,24 @@ KUrl DolphinSearchBox::urlForSearching() const
return url;
}
-void DolphinSearchBox::selectAll()
-{
- m_searchInput->selectAll();
-}
-
-void DolphinSearchBox::setReadOnly(bool readOnly, const KUrl& query)
+void DolphinSearchBox::fromSearchUrl(const KUrl& url)
{
- if (m_readOnly != readOnly || m_readOnlyQuery != query) {
- m_readOnly = readOnly;
- m_readOnlyQuery = query;
- applyReadOnlyState();
+ if (url.protocol() == "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 {
+ setText(QString());
+ setSearchPath(url);
}
}
-bool DolphinSearchBox::isReadOnly() const
+void DolphinSearchBox::selectAll()
{
- return m_readOnly;
+ m_searchInput->selectAll();
}
void DolphinSearchBox::setActive(bool active)
@@ -427,80 +425,83 @@ void DolphinSearchBox::init()
connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest()));
updateFacetsToggleButton();
- 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.addType(m_facetsWidget->facetType());
- 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);
- } else {
- fileQuery.setTerm(searchLabelTerm);
+ Baloo::Term term(Baloo::Term::And);
+
+ Baloo::Term ratingTerm = m_facetsWidget->ratingTerm();
+ if (ratingTerm.isValid()) {
+ term.addSubTerm(ratingTerm);
+ }
+
+ if (m_contentButton->isChecked()) {
+ query.setSearchString(text);
+ } else if (!text.isEmpty()) {
+ term.addSubTerm(Baloo::Term(QLatin1String("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));
+ query.setTerm(term);
+
+ 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
}
-void DolphinSearchBox::applyReadOnlyState()
+void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url)
{
-#ifdef HAVE_NEPOMUK
- if (m_readOnly) {
- m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
+#ifdef HAVE_BALOO
+ const Baloo::Query query = Baloo::Query::fromSearchUrl(url);
+ const Baloo::Term term = query.term();
+
+ // Block all signals to avoid unnecessary "searchRequest" signals
+ // 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());
} else {
-#else
- {
-#endif
- m_searchLabel->setText(i18nc("@label:textbox", "Find:"));
+ setSearchPath(QDir::homePath());
+ }
+
+ if (!query.searchString().isEmpty()) {
+ setText(query.searchString());
+ }
+
+ QStringList types = query.types();
+ types.removeOne("File"); // We are only interested in facet widget types
+ if (!types.isEmpty()) {
+ m_facetsWidget->setFacetType(types.first());
}
- m_searchInput->setVisible(!m_readOnly);
- m_optionsScrollArea->setVisible(!m_readOnly);
+ foreach (const Baloo::Term& subTerm, term.subTerms()) {
+ const QString property = subTerm.property();
- if (m_readOnly) {
- m_facetsWidget->hide();
- } else {
- m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
+ if (property == QLatin1String("filename")) {
+ setText(subTerm.value().toString());
+ } else if (m_facetsWidget->isRatingTerm(subTerm)) {
+ m_facetsWidget->setRatingTerm(subTerm);
+ }
}
+
+ m_startSearchTimer->stop();
+ blockSignals(false);
+#endif
}
void DolphinSearchBox::updateFacetsToggleButton()
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index e4c14b7cb..53b12ffab 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -33,13 +33,13 @@ class QLabel;
class QVBoxLayout;
/**
- * @brief Input box for searching files with or without Nepomuk.
+ * @brief Input box for searching files with or without Baloo.
*
* The widget allows to specify:
* - Where to search: Everywhere or below the current directory
* - What to search: Filenames or content
*
- * If Nepomuk is available and the current folder is indexed, further
+ * If Baloo is available and the current folder is indexed, further
* options are offered.
*/
class DolphinSearchBox : public QWidget {
@@ -72,20 +72,15 @@ public:
KUrl urlForSearching() const;
/**
- * Selects the whole text of the search box.
+ * Extracts information from the given search \a url to
+ * initialize the search box properly.
*/
- void selectAll();
+ void fromSearchUrl(const KUrl& url);
/**
- * @param readOnly If set to true the searchbox cannot be modified
- * by the user and acts as visual indicator for
- * an externally triggered search query.
- * @param query If readOnly is true this URL will be used
- * to show a human readable information about the
- * query.
+ * Selects the whole text of the search box.
*/
- void setReadOnly(bool readOnly, const KUrl& query = KUrl());
- bool isReadOnly() const;
+ void selectAll();
/**
* Set the search box to the active mode, if \a active
@@ -151,16 +146,19 @@ private:
void init();
/**
- * @return URL that represents the Nepomuk query for starting the search.
+ * @return URL that represents the Baloo query for starting the search.
*/
- KUrl nepomukUrlForSearching() const;
+ KUrl balooUrlForSearching() const;
- void applyReadOnlyState();
+ /**
+ * Extracts information from the given Baloo search \a url to
+ * initialize the search box properly.
+ */
+ void fromBalooSearchUrl(const KUrl& url);
void updateFacetsToggleButton();
private:
bool m_startedSearching;
- bool m_readOnly;
bool m_active;
QVBoxLayout* m_topLayout;
@@ -177,7 +175,6 @@ private:
DolphinFacetsWidget* m_facetsWidget;
KUrl m_searchPath;
- KUrl m_readOnlyQuery;
QTimer* m_startSearchTimer;
};
diff --git a/src/search/dolphinsearchinformation.cpp b/src/search/dolphinsearchinformation.cpp
deleted file mode 100644
index b723f1ec0..000000000
--- a/src/search/dolphinsearchinformation.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2011 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 "dolphinsearchinformation.h"
-
-#include <config-nepomuk.h>
-#ifdef HAVE_NEPOMUK
- #include <KConfig>
- #include <KConfigGroup>
- #include <Nepomuk2/ResourceManager>
-#endif
-
-#include <KGlobal>
-#include <KUrl>
-#include <QFileInfo>
-#include <QDir>
-
-struct DolphinSearchInformationSingleton
-{
- DolphinSearchInformation instance;
-};
-K_GLOBAL_STATIC(DolphinSearchInformationSingleton, s_dolphinSearchInformation)
-
-
-DolphinSearchInformation& DolphinSearchInformation::instance()
-{
- return s_dolphinSearchInformation->instance;
-}
-
-DolphinSearchInformation::~DolphinSearchInformation()
-{
-}
-
-bool DolphinSearchInformation::isIndexingEnabled() const
-{
- return m_indexingEnabled;
-}
-
-namespace {
- /// recursively check if a folder is hidden
- bool isDirHidden( QDir& dir ) {
- if (QFileInfo(dir.path()).isHidden()) {
- return true;
- } else if (dir.cdUp()) {
- return isDirHidden(dir);
- } else {
- return false;
- }
- }
-
- bool isDirHidden(const QString& path) {
- QDir dir(path);
- return isDirHidden(dir);
- }
-}
-
-bool DolphinSearchInformation::isPathIndexed(const KUrl& url) const
-{
-#ifdef HAVE_NEPOMUK
- const KConfig strigiConfig("nepomukstrigirc");
- const QStringList indexedFolders = strigiConfig.group("General").readPathEntry("folders", QStringList());
-
- // Nepomuk does not index hidden folders
- if (isDirHidden(url.toLocalFile())) {
- return false;
- }
-
- // Check whether the path is part of an indexed folder
- bool isIndexed = false;
- foreach (const QString& indexedFolder, indexedFolders) {
- const KUrl indexedPath(indexedFolder);
- if (indexedPath.isParentOf(url)) {
- isIndexed = true;
- break;
- }
- }
-
- if (isIndexed) {
- // The path is part of an indexed folder. Check whether no
- // excluded folder is part of the path.
- const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList());
- foreach (const QString& excludedFolder, excludedFolders) {
- const KUrl excludedPath(excludedFolder);
- if (excludedPath.isParentOf(url)) {
- isIndexed = false;
- break;
- }
- }
- }
-
- return isIndexed;
-#else
- Q_UNUSED(url);
- return false;
-#endif
-}
-
-DolphinSearchInformation::DolphinSearchInformation() :
- m_indexingEnabled(false)
-{
-#ifdef HAVE_NEPOMUK
- if (Nepomuk2::ResourceManager::instance()->initialized()) {
- KConfig config("nepomukserverrc");
- m_indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
- }
-#endif
-}
-
diff --git a/src/search/dolphinsearchinformation.h b/src/search/dolphinsearchinformation.h
deleted file mode 100644
index 6fb1947ca..000000000
--- a/src/search/dolphinsearchinformation.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2011 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 DOLPHINSEARCHINFORMATION_H
-#define DOLPHINSEARCHINFORMATION_H
-
-class KUrl;
-
-/**
- * @brief Allows to access search-engine related information.
- */
-class DolphinSearchInformation
-{
-public:
- static DolphinSearchInformation& instance();
- virtual ~DolphinSearchInformation();
-
- /**
- * @return True if the Nepomuk indexer is enabled. If Nepomuk is
- * disabled, always false is returned.
- */
- bool isIndexingEnabled() const;
-
- /**
- * @return True if the complete directory tree specified by path
- * is indexed by the Nepomuk indexer. If Nepomuk is disabled,
- * always false is returned.
- */
- bool isPathIndexed(const KUrl& url) const;
-
-protected:
- DolphinSearchInformation();
-
-private:
- bool m_indexingEnabled;
-
- friend class DolphinSearchInformationSingleton;
-};
-
-#endif
-