]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix enabled/disabled issue for the Search Panel
authorPeter Penz <peter.penz19@gmail.com>
Thu, 10 Mar 2011 22:48:43 +0000 (23:48 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 10 Mar 2011 22:49:39 +0000 (23:49 +0100)
src/panels/search/searchpanel.cpp
src/panels/search/searchpanel.h

index 21057f388398befa1d36896a24c29d52b354e785..4fb78c58105766f64b907366f539be4ab4d12939 100644 (file)
@@ -81,13 +81,9 @@ bool SearchPanel::urlChanged()
         // This is required to restore the directory in case that all facets
         // have been reset by the user (see slotQueryTermChanged()).
         m_startedFromDir = url();
-
-        const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
-        setEnabled(searchInfo.isIndexingEnabled() &&
-                   searchInfo.isPathIndexed(m_startedFromDir));
     }
 
-    if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) {
+    if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) {       
         const Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && m_facetWidget->queryTerm());
         if (query.toSearchUrl() == url()) {
             // The new URL has been triggered by the SearchPanel itself in
@@ -103,11 +99,14 @@ bool SearchPanel::urlChanged()
             m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
             connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)),
                     this, SLOT(slotSetUrlStatFinished(KJob*)));
-            setEnabled(false);
         } else {
             // Reset the search panel because a "normal" directory is shown.
             setQuery(Nepomuk::Query::Query());
         }
+
+        const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
+        setEnabled(searchInfo.isIndexingEnabled() &&
+                   searchInfo.isPathIndexed(m_startedFromDir));
     }
 
     return true;
@@ -168,16 +167,11 @@ void SearchPanel::showEvent(QShowEvent* event)
         m_initialized = true;
     }
 
-    Panel::showEvent(event);
-}
-
-void SearchPanel::hideEvent(QHideEvent* event)
-{
-    if (!event->spontaneous()) {
-        setEnabled(false);
-    }
+    const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
+    setEnabled(searchInfo.isIndexingEnabled() &&
+               searchInfo.isPathIndexed(url()));
 
-    Panel::hideEvent(event);
+    Panel::showEvent(event);
 }
 
 void SearchPanel::contextMenuEvent(QContextMenuEvent* event)
index 9404b4f8c417db80b624c27d3e3f8240134e85a9..700cfc84a7ad7e81241cbecc5d87db6e02a7d8c5 100644 (file)
@@ -69,9 +69,6 @@ protected:
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);
 
-    /** @see QWidget::hideEvent() */
-    virtual void hideEvent(QHideEvent* event);
-
     /** @see QWidget::contextMenuEvent() */
     virtual void contextMenuEvent(QContextMenuEvent* event);