From ae488b13186a4cb5d0bc5d7f23b07467d6638979 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 20 Apr 2011 20:03:51 +0200 Subject: Improve usability of Search Panel If the Search Panel is shown outside the context of the "Find" mode it will be always enabled and does a global search. Only if the user is in the "Find" mode and the searching is restricted to the current directory the Search Panel might get disabled if the current directory is not indexed. This solves the major usability issue that it was not clear for the users whether a global or restricted search is done. --- src/panels/search/searchpanel.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/panels/search/searchpanel.cpp') diff --git a/src/panels/search/searchpanel.cpp b/src/panels/search/searchpanel.cpp index 38c78aacb..a7226154b 100644 --- a/src/panels/search/searchpanel.cpp +++ b/src/panels/search/searchpanel.cpp @@ -66,6 +66,9 @@ SearchPanel::~SearchPanel() void SearchPanel::setSearchMode(SearchMode mode) { m_searchMode = mode; + if (isVisible()) { + setEnabled(isFilteringPossible()); + } } SearchPanel::SearchMode SearchPanel::searchMode() const @@ -104,9 +107,7 @@ bool SearchPanel::urlChanged() setQuery(Nepomuk::Query::Query()); } - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - setEnabled(searchInfo.isIndexingEnabled() && - searchInfo.isPathIndexed(m_startedFromDir)); + setEnabled(isFilteringPossible()); } return true; @@ -167,9 +168,7 @@ void SearchPanel::showEvent(QShowEvent* event) m_initialized = true; } - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - setEnabled(searchInfo.isIndexingEnabled() && - searchInfo.isPathIndexed(url())); + setEnabled(isFilteringPossible()); Panel::showEvent(event); } @@ -190,9 +189,7 @@ void SearchPanel::slotSetUrlStatFinished(KJob* job) { m_lastSetUrlStatJob = 0; - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - setEnabled(searchInfo.isIndexingEnabled() && - searchInfo.isPathIndexed(m_startedFromDir)); + setEnabled(isFilteringPossible()); const KIO::UDSEntry uds = static_cast(job)->statResult(); const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY); @@ -260,3 +257,10 @@ void SearchPanel::setQuery(const Nepomuk::Query::Query& query) m_facetWidget->setClientQuery(query); m_facetWidget->blockSignals(block); } + +bool SearchPanel::isFilteringPossible() const +{ + const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); + return searchInfo.isIndexingEnabled() + && ((m_searchMode == Everywhere) || searchInfo.isPathIndexed(m_startedFromDir)); +} -- cgit v1.3