From 7045a25e3abaedab0d128f03702eaf48ffe6e0b7 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 2 Feb 2011 19:36:08 +0100 Subject: Fix visibility- and enabled-issues for the filter-panel The filter-panel should be disabled if the current folder is not indexed at all. Also when triggering a "Find" the filter-panel should stay invisible per default when the current folder is not indexed. CCBUG: 264969 --- src/panels/filter/filterpanel.cpp | 27 +++++++++++++++++++++------ src/panels/filter/filterpanel.h | 4 +++- 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'src/panels/filter') diff --git a/src/panels/filter/filterpanel.cpp b/src/panels/filter/filterpanel.cpp index 453c12729..97389e08f 100644 --- a/src/panels/filter/filterpanel.cpp +++ b/src/panels/filter/filterpanel.cpp @@ -36,6 +36,8 @@ #include #include +#include + #include #include #include @@ -49,12 +51,12 @@ FilterPanel::FilterPanel(QWidget* parent) : Panel(parent), m_initialized(false), - m_nepomukEnabled(false), m_lastSetUrlStatJob(0), m_startedFromDir(), m_facetWidget(0), m_unfacetedRestQuery() { + setEnabled(false); } FilterPanel::~FilterPanel() @@ -70,7 +72,7 @@ bool FilterPanel::urlChanged() m_startedFromDir = url(); } - if (isVisible() && m_nepomukEnabled) { + if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) { setQuery(Nepomuk::Query::Query()); delete m_lastSetUrlStatJob; @@ -140,15 +142,25 @@ void FilterPanel::showEvent(QShowEvent* event) connect(m_facetWidget, SIGNAL(queryTermChanged(Nepomuk::Query::Term)), this, SLOT(slotQueryTermChanged(Nepomuk::Query::Term))); - m_nepomukEnabled = (Nepomuk::ResourceManager::instance()->init() == 0); - m_facetWidget->setEnabled(m_nepomukEnabled); - m_initialized = true; } + const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); + setEnabled(searchInfo.isIndexingEnabled() && + searchInfo.isPathIndexed(m_startedFromDir)); + Panel::showEvent(event); } +void FilterPanel::hideEvent(QHideEvent* event) +{ + if (!event->spontaneous()) { + setEnabled(false); + } + + Panel::hideEvent(event); +} + void FilterPanel::contextMenuEvent(QContextMenuEvent* event) { Panel::contextMenuEvent(event); @@ -218,7 +230,10 @@ void FilterPanel::setQuery(const Nepomuk::Query::Query& query) m_unfacetedRestQuery = m_facetWidget->extractFacetsFromQuery(query); m_facetWidget->setClientQuery(query); - setEnabled(true); + + const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); + setEnabled(searchInfo.isIndexingEnabled() && + searchInfo.isPathIndexed(m_startedFromDir)); m_facetWidget->blockSignals(block); } else { diff --git a/src/panels/filter/filterpanel.h b/src/panels/filter/filterpanel.h index 20d4e9cbf..8ccc62d63 100644 --- a/src/panels/filter/filterpanel.h +++ b/src/panels/filter/filterpanel.h @@ -52,6 +52,9 @@ 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); @@ -64,7 +67,6 @@ private: private: bool m_initialized; - bool m_nepomukEnabled; KJob* m_lastSetUrlStatJob; KUrl m_startedFromDir; -- cgit v1.3