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/dolphinmainwindow.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 07a3bc153..ed6d0f196 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -35,6 +35,7 @@ #include "panels/folders/folderspanel.h" #include "panels/places/placespanel.h" #include "panels/information/informationpanel.h" +#include "search/dolphinsearchbox.h" #include "search/dolphinsearchinformation.h" #include "settings/dolphinsettings.h" #include "settings/dolphinsettingsdialog.h" @@ -821,6 +822,21 @@ void DolphinMainWindow::find() m_activeViewContainer->setSearchModeEnabled(true); } +void DolphinMainWindow::slotSearchLocationChanged() +{ + QDockWidget* searchDock = findChild("searchDock"); + if (!searchDock) { + return; + } + + SearchPanel* searchPanel = qobject_cast(searchDock->widget()); + if (searchPanel) { + searchPanel->setSearchMode(SearchSettings::location() == QLatin1String("FromHere") + ? SearchPanel::FromCurrentDir + : SearchPanel::Everywhere); + } +} + void DolphinMainWindow::updatePasteAction() { QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); @@ -1307,9 +1323,8 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) void DolphinMainWindow::slotSearchModeChanged(bool enabled) { #ifdef HAVE_NEPOMUK - const KUrl url = m_activeViewContainer->url(); const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - if (!searchInfo.isIndexingEnabled() || !searchInfo.isPathIndexed(url)) { + if (!searchInfo.isIndexingEnabled()) { return; } @@ -2066,6 +2081,10 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) connect(container, SIGNAL(searchModeChanged(bool)), this, SLOT(slotSearchModeChanged(bool))); + const DolphinSearchBox* searchBox = container->searchBox(); + connect(searchBox, SIGNAL(searchLocationChanged(SearchLocation)), + this, SLOT(slotSearchLocationChanged())); + DolphinView* view = container->view(); connect(view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(slotSelectionChanged(KFileItemList))); -- cgit v1.3