#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"
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::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;
}
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)));
/** 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.
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();
const DolphinView* view() const;
DolphinView* view();
+ const DolphinSearchBox* searchBox() const;
+ DolphinSearchBox* searchBox();
+
/**
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
*/
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
void SearchPanel::setSearchMode(SearchMode mode)
{
m_searchMode = mode;
+ if (isVisible()) {
+ setEnabled(isFilteringPossible());
+ }
}
SearchPanel::SearchMode SearchPanel::searchMode() const
setQuery(Nepomuk::Query::Query());
}
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- setEnabled(searchInfo.isIndexingEnabled() &&
- searchInfo.isPathIndexed(m_startedFromDir));
+ setEnabled(isFilteringPossible());
}
return true;
m_initialized = true;
}
- const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
- setEnabled(searchInfo.isIndexingEnabled() &&
- searchInfo.isPathIndexed(url()));
+ setEnabled(isFilteringPossible());
Panel::showEvent(event);
}
{
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);
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);
+ /**
+ * @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;
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()
{
+ saveSettings();
if (m_startedSearching) {
emitSearchSignal();
}
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()
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);
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();
Q_OBJECT
public:
+ enum SearchContext {
+ SearchFileName,
+ SearchContent
+ };
+
+ enum SearchLocation {
+ SearchFromHere,
+ SearchEverywhere
+ };
+
explicit DolphinSearchBox(QWidget* parent = 0);
virtual ~DolphinSearchBox();
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.
*/
private slots:
void emitSearchSignal();
+ void slotSearchLocationChanged();
+ void slotSearchContextChanged();
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
void slotReturnPressed(const QString& text);