]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[dolphin/search] Add method isIndexEnabled()
authorIsmael Asensio <isma.af@mgmail.com>
Tue, 8 Oct 2019 19:42:11 +0000 (21:42 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Tue, 8 Oct 2019 19:42:11 +0000 (21:42 +0200)
Summary: Extracts the logic for checking if the current path is indexed to its own method.

Test Plan: No behavior changes

Reviewers: elvisangelaccio, ngraham, meven

Reviewed By: ngraham, meven

Subscribers: meven, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D24478

src/search/dolphinsearchbox.cpp
src/search/dolphinsearchbox.h

index 6a87edc9e05b43c7c1bc27839c7bbb22e2b5f0c3..1c1accd26961f00b7876a4e2d25933024635ae1d 100644 (file)
@@ -107,12 +107,7 @@ void DolphinSearchBox::setSearchPath(const QUrl& url)
     m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation));
     m_fromHereButton->setToolTip(i18nc("action:button", "Limit search to '%1' and its subfolders", cleanedUrl.toString(QUrl::PreferLocalFile)));
 
-    bool hasFacetsSupport = false;
-#ifdef HAVE_BALOO
-    const Baloo::IndexerConfig searchInfo;
-    hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
-#endif
-    m_facetsWidget->setEnabled(hasFacetsSupport);
+    m_facetsWidget->setEnabled(isIndexingEnabled());
 }
 
 QUrl DolphinSearchBox::searchPath() const
@@ -123,12 +118,8 @@ QUrl DolphinSearchBox::searchPath() const
 QUrl DolphinSearchBox::urlForSearching() const
 {
     QUrl url;
-    bool useBalooSearch = false;
-#ifdef HAVE_BALOO
-    const Baloo::IndexerConfig searchInfo;
-    useBalooSearch = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
-#endif
-    if (useBalooSearch) {
+
+    if (isIndexingEnabled()) {
         url = balooUrlForSearching();
     } else {
         url.setScheme(QStringLiteral("filenamesearch"));
@@ -566,3 +557,12 @@ void DolphinSearchBox::updateFacetsToggleButton()
     m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options"));
 }
 
+bool DolphinSearchBox::isIndexingEnabled() const
+{
+#ifdef HAVE_BALOO
+    const Baloo::IndexerConfig searchInfo;
+    return searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
+#else
+    return false;
+#endif
+}
index bb71049c746a6999aa92e10a56ea386a6943f057..9ccd50b834538412f854ae6e961f6bd4a07b287f 100644 (file)
@@ -160,6 +160,8 @@ private:
 
     void updateFacetsToggleButton();
 
+    bool isIndexingEnabled() const;
+
 private:
     bool m_startedSearching;
     bool m_active;