]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix enabled/disabled issue of Search Panel
authorPeter Penz <peter.penz19@gmail.com>
Wed, 20 Apr 2011 20:10:18 +0000 (22:10 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 20 Apr 2011 20:11:22 +0000 (22:11 +0200)
src/dolphinmainwindow.cpp
src/panels/search/searchpanel.cpp
src/panels/search/searchpanel.h

index ed6d0f19626084d95d7a5fb98eafd912ce3b7855..f5ac94f407b25088eb0b83c411453f4e0ef3fb86 100644 (file)
@@ -831,9 +831,9 @@ void DolphinMainWindow::slotSearchLocationChanged()
 
     SearchPanel* searchPanel = qobject_cast<SearchPanel*>(searchDock->widget());
     if (searchPanel) {
-        searchPanel->setSearchMode(SearchSettings::location() == QLatin1String("FromHere")
-                                   ? SearchPanel::FromCurrentDir
-                                   : SearchPanel::Everywhere);
+        searchPanel->setSearchLocation(SearchSettings::location() == QLatin1String("FromHere")
+                                       ? SearchPanel::FromCurrentDir
+                                       : SearchPanel::Everywhere);
     }
 }
 
@@ -1346,17 +1346,20 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled)
     }
 
     SearchPanel* searchPanel = qobject_cast<SearchPanel*>(searchDock->widget());
-    if (searchPanel) {
-        // Per default any search-operation triggered by the Search Panel is done
-        // "Everywhere".
-        SearchPanel::SearchMode searchMode = SearchPanel::Everywhere;
-
-        if (enabled && (SearchSettings::location() == QLatin1String("FromHere"))) {
-            // Only if the search-mode is enabled it is visible for the user whether
-            // a searching is done "Everywhere" or "From Here" (= current directory).
-            searchMode = SearchPanel::FromCurrentDir;
+    if (!searchPanel) {
+        return;
+    }
+
+    if (enabled) {
+        SearchPanel::SearchLocation searchLocation = SearchPanel::Everywhere;
+        const KUrl url = m_activeViewContainer->url();
+        const bool isSearchUrl = (url.protocol() == QLatin1String("nepomuksearch"));
+        if ((SearchSettings::location() == QLatin1String("FromHere") && !isSearchUrl)) {
+            searchLocation = SearchPanel::FromCurrentDir;
         }
-        searchPanel->setSearchMode(searchMode);
+        searchPanel->setSearchLocation(searchLocation);
+    } else {
+        searchPanel->setSearchLocation(SearchPanel::Everywhere);
     }
 #else
     Q_UNUSED(enabled);
index a7226154b033768850ab86a3a41eb1cc3e05d6bc..dd0ad9be42b158d71e65ed085657ae8a8c1dfafe 100644 (file)
@@ -50,7 +50,7 @@
 SearchPanel::SearchPanel(QWidget* parent) :
     Panel(parent),
     m_initialized(false),
-    m_searchMode(Everywhere),
+    m_searchLocation(Everywhere),
     m_lastSetUrlStatJob(0),
     m_startedFromDir(),
     m_facetWidget(0),
@@ -63,17 +63,17 @@ SearchPanel::~SearchPanel()
 {
 }
 
-void SearchPanel::setSearchMode(SearchMode mode)
+void SearchPanel::setSearchLocation(SearchLocation location)
 {
-    m_searchMode = mode;
+    m_searchLocation = location;
     if (isVisible()) {
         setEnabled(isFilteringPossible());
     }
 }
 
-SearchPanel::SearchMode SearchPanel::searchMode() const
+SearchPanel::SearchLocation SearchPanel::searchLocation() const
 {
-    return m_searchMode;
+    return m_searchLocation;
 }
 
 bool SearchPanel::urlChanged()
@@ -213,7 +213,7 @@ void SearchPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
 {
     if (term.isValid()) {
         // Default case: A facet has been changed by the user to restrict the query.
-        if ((m_searchMode == FromCurrentDir) && !m_unfacetedRestQuery.isValid()) {
+        if ((m_searchLocation == FromCurrentDir) && !m_unfacetedRestQuery.isValid()) {
             // Adjust the query to respect the FromCurrentDir setting
             Nepomuk::Query::ComparisonTerm compTerm(
                                     Nepomuk::Vocabulary::NFO::fileName(),
@@ -262,5 +262,5 @@ bool SearchPanel::isFilteringPossible() const
 {
     const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
     return searchInfo.isIndexingEnabled()
-           && ((m_searchMode == Everywhere) || searchInfo.isPathIndexed(m_startedFromDir));
+           && ((m_searchLocation == Everywhere) || searchInfo.isPathIndexed(m_startedFromDir));
 }
index b92b692aaecc3d7cf45c32c012afaaed387d5814..ae34b20c69b9951ed43ba4db118b1fad1c8927f0 100644 (file)
@@ -42,7 +42,7 @@ class SearchPanel : public Panel
     Q_OBJECT
 
 public:
-    enum SearchMode
+    enum SearchLocation
     {
         Everywhere,
         FromCurrentDir
@@ -56,8 +56,8 @@ public:
      * or from the current directory (= FromCurrentDir). The current directory
      * is automatically determined when setUrl() has been called.
      */
-    void setSearchMode(SearchMode mode);
-    SearchMode searchMode() const;
+    void setSearchLocation(SearchLocation location);
+    SearchLocation searchLocation() const;
 
 signals:
     void urlActivated(const KUrl& url);
@@ -83,7 +83,7 @@ private:
      * @return True if the facets can be applied to the given URL
      *         and hence a filtering of the content is possible.
      *         False is returned if the search-mode is set to
-     *         SearchMode::FromCurrentDir and this directory is
+     *         SearchLocation::FromCurrentDir and this directory is
      *         not indexed at all. Also if indexing is disabled
      *         false will be returned.
      */
@@ -91,7 +91,7 @@ private:
 
 private:
     bool m_initialized;
-    SearchMode m_searchMode;
+    SearchLocation m_searchLocation;
     KJob* m_lastSetUrlStatJob;
 
     KUrl m_startedFromDir;