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.
#include "panels/folders/folderspanel.h"
#include "panels/places/placespanel.h"
#include "panels/information/informationpanel.h"
#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"
#include "search/dolphinsearchinformation.h"
#include "settings/dolphinsettings.h"
#include "settings/dolphinsettingsdialog.h"
m_activeViewContainer->setSearchModeEnabled(true);
}
m_activeViewContainer->setSearchModeEnabled(true);
}
+void DolphinMainWindow::slotSearchLocationChanged()
+{
+ QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
+ if (!searchDock) {
+ return;
+ }
+
+ SearchPanel* searchPanel = qobject_cast<SearchPanel*>(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));
void DolphinMainWindow::updatePasteAction()
{
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
void DolphinMainWindow::slotSearchModeChanged(bool enabled)
{
#ifdef HAVE_NEPOMUK
void DolphinMainWindow::slotSearchModeChanged(bool enabled)
{
#ifdef HAVE_NEPOMUK
- const KUrl url = m_activeViewContainer->url();
const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- if (!searchInfo.isIndexingEnabled() || !searchInfo.isPathIndexed(url)) {
+ if (!searchInfo.isIndexingEnabled()) {
connect(container, SIGNAL(searchModeChanged(bool)),
this, SLOT(slotSearchModeChanged(bool)));
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)));
DolphinView* view = container->view();
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
/** Replaces the URL navigator by a search box to find files. */
void find();
/** Replaces the URL navigator by a search box to find files. */
void find();
+ /**
+ * Is invoked when the "Find" is active and the search location
+ * (From Here/Everywhere) has been changed. Updates the
+ * enabled state of the Search Panel.
+ */
+ void slotSearchLocationChanged();
+
/**
* Updates the text of the paste action dependent on
* the number of items which are in the clipboard.
/**
* Updates the text of the paste action dependent on
* the number of items which are in the clipboard.
return m_view->isActive();
}
return m_view->isActive();
}
+const DolphinStatusBar* DolphinViewContainer::statusBar() const
+{
+ return m_statusBar;
+}
+
+DolphinStatusBar* DolphinViewContainer::statusBar()
+{
+ return m_statusBar;
+}
+
+const KUrlNavigator* DolphinViewContainer::urlNavigator() const
+{
+ return m_urlNavigator;
+}
+
+KUrlNavigator* DolphinViewContainer::urlNavigator()
+{
+ return m_urlNavigator;
+}
+
+const DolphinView* DolphinViewContainer::view() const
+{
+ return m_view;
+}
+
+DolphinView* DolphinViewContainer::view()
+{
+ return m_view;
+}
+
+const DolphinSearchBox* DolphinViewContainer::searchBox() const
+{
+ return m_searchBox;
+}
+
+DolphinSearchBox* DolphinViewContainer::searchBox()
+{
+ return m_searchBox;
+}
+
void DolphinViewContainer::refresh()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
void DolphinViewContainer::refresh()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
const DolphinView* view() const;
DolphinView* view();
const DolphinView* view() const;
DolphinView* view();
+ const DolphinSearchBox* searchBox() const;
+ DolphinSearchBox* searchBox();
+
/**
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
*/
/**
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
*/
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
};
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
};
-inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
-{
- return m_statusBar;
-}
-
-inline DolphinStatusBar* DolphinViewContainer::statusBar()
-{
- return m_statusBar;
-}
-
-inline const KUrlNavigator* DolphinViewContainer::urlNavigator() const
-{
- return m_urlNavigator;
-}
-
-inline KUrlNavigator* DolphinViewContainer::urlNavigator()
-{
- return m_urlNavigator;
-}
-
-inline const DolphinView* DolphinViewContainer::view() const
-{
- return m_view;
-}
-
-inline DolphinView* DolphinViewContainer::view()
-{
- return m_view;
-}
-
#endif // DOLPHINVIEWCONTAINER_H
#endif // DOLPHINVIEWCONTAINER_H
void SearchPanel::setSearchMode(SearchMode mode)
{
m_searchMode = mode;
void SearchPanel::setSearchMode(SearchMode mode)
{
m_searchMode = mode;
+ if (isVisible()) {
+ setEnabled(isFilteringPossible());
+ }
}
SearchPanel::SearchMode SearchPanel::searchMode() const
}
SearchPanel::SearchMode SearchPanel::searchMode() const
setQuery(Nepomuk::Query::Query());
}
setQuery(Nepomuk::Query::Query());
}
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- setEnabled(searchInfo.isIndexingEnabled() &&
- searchInfo.isPathIndexed(m_startedFromDir));
+ setEnabled(isFilteringPossible());
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- setEnabled(searchInfo.isIndexingEnabled() &&
- searchInfo.isPathIndexed(url()));
+ setEnabled(isFilteringPossible());
Panel::showEvent(event);
}
Panel::showEvent(event);
}
{
m_lastSetUrlStatJob = 0;
{
m_lastSetUrlStatJob = 0;
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- setEnabled(searchInfo.isIndexingEnabled() &&
- searchInfo.isPathIndexed(m_startedFromDir));
+ setEnabled(isFilteringPossible());
const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY);
const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY);
m_facetWidget->setClientQuery(query);
m_facetWidget->blockSignals(block);
}
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));
+}
private:
void setQuery(const Nepomuk::Query::Query& query);
private:
void setQuery(const Nepomuk::Query::Query& query);
+ /**
+ * @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
+ * not indexed at all. Also if indexing is disabled
+ * false will be returned.
+ */
+ bool isFilteringPossible() const;
+
private:
bool m_initialized;
SearchMode m_searchMode;
private:
bool m_initialized;
SearchMode m_searchMode;
emit search(m_searchInput->text());
}
emit search(m_searchInput->text());
}
+void DolphinSearchBox::slotSearchLocationChanged()
+{
+ emit searchLocationChanged(m_fromHereButton->isChecked() ? SearchFromHere : SearchEverywhere);
+}
+
+void DolphinSearchBox::slotSearchContextChanged()
+{
+ emit searchContextChanged(m_fileNameButton->isChecked() ? SearchFileName : SearchContent);
+}
+
void DolphinSearchBox::slotConfigurationChanged()
{
void DolphinSearchBox::slotConfigurationChanged()
{
if (m_startedSearching) {
emitSearchSignal();
}
if (m_startedSearching) {
emitSearchSignal();
}
button->setAutoExclusive(true);
button->setFlat(true);
button->setCheckable(true);
button->setAutoExclusive(true);
button->setFlat(true);
button->setCheckable(true);
- connect(button, SIGNAL(toggled(bool)), this, SLOT(slotConfigurationChanged()));
+ connect(button, SIGNAL(clicked(bool)), this, SLOT(slotConfigurationChanged()));
}
void DolphinSearchBox::loadSettings()
}
void DolphinSearchBox::loadSettings()
QButtonGroup* searchWhatGroup = new QButtonGroup(this);
searchWhatGroup->addButton(m_fileNameButton);
searchWhatGroup->addButton(m_contentButton);
QButtonGroup* searchWhatGroup = new QButtonGroup(this);
searchWhatGroup->addButton(m_fileNameButton);
searchWhatGroup->addButton(m_contentButton);
+ connect(m_fileNameButton, SIGNAL(clicked()), this, SLOT(slotSearchContextChanged()));
+ connect(m_contentButton, SIGNAL(clicked()), this, SLOT(slotSearchContextChanged()));
m_separator = new KSeparator(Qt::Vertical, this);
m_separator = new KSeparator(Qt::Vertical, this);
QButtonGroup* searchLocationGroup = new QButtonGroup(this);
searchLocationGroup->addButton(m_fromHereButton);
searchLocationGroup->addButton(m_everywhereButton);
QButtonGroup* searchLocationGroup = new QButtonGroup(this);
searchLocationGroup->addButton(m_fromHereButton);
searchLocationGroup->addButton(m_everywhereButton);
+ connect(m_fromHereButton, SIGNAL(clicked()), this, SLOT(slotSearchLocationChanged()));
+ connect(m_everywhereButton, SIGNAL(clicked()), this, SLOT(slotSearchLocationChanged()));
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
+ enum SearchContext {
+ SearchFileName,
+ SearchContent
+ };
+
+ enum SearchLocation {
+ SearchFromHere,
+ SearchEverywhere
+ };
+
explicit DolphinSearchBox(QWidget* parent = 0);
virtual ~DolphinSearchBox();
explicit DolphinSearchBox(QWidget* parent = 0);
virtual ~DolphinSearchBox();
void returnPressed(const QString& text);
void returnPressed(const QString& text);
+ /**
+ * Is emitted if the search location has been changed by the user.
+ */
+ void searchLocationChanged(SearchLocation location);
+
+ /**
+ * Is emitted if the search context has been changed by the user.
+ */
+ void searchContextChanged(SearchContext context);
+
/**
* Emitted as soon as the search box should get closed.
*/
/**
* Emitted as soon as the search box should get closed.
*/
private slots:
void emitSearchSignal();
private slots:
void emitSearchSignal();
+ void slotSearchLocationChanged();
+ void slotSearchContextChanged();
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
void slotReturnPressed(const QString& text);
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
void slotReturnPressed(const QString& text);