X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8ffc72e87f4cffa8dce32da06e9a1d51a595765e..e076d8668f673e09ddd01b3367e413a494d6d2bb:/src/search/dolphinsearchbox.cpp diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 16f17bbcd..cdc0718df 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -136,6 +136,7 @@ QUrl DolphinSearchBox::urlForSearching() const } query.addQueryItem(QStringLiteral("url"), searchPath().url()); + query.addQueryItem(QStringLiteral("title"), queryTitle(m_searchInput->text())); url.setQuery(query); } @@ -219,6 +220,9 @@ void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event) m_searchInput->clear(); } } + else if (event->key() == Qt::Key_Down) { + emit focusViewRequest(); + } } bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event) @@ -283,7 +287,7 @@ void DolphinSearchBox::slotSearchTextChanged(const QString& text) void DolphinSearchBox::slotReturnPressed() { emitSearchRequest(); - emit returnPressed(); + emit focusViewRequest(); } void DolphinSearchBox::slotFacetChanged() @@ -469,6 +473,12 @@ void DolphinSearchBox::init() connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest); } +QString DolphinSearchBox::queryTitle(const QString& text) const +{ + return i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", + "Query Results from '%1'", text); +} + QUrl DolphinSearchBox::balooUrlForSearching() const { #ifdef HAVE_BALOO @@ -477,11 +487,7 @@ QUrl DolphinSearchBox::balooUrlForSearching() const Baloo::Query query; query.addType(m_facetsWidget->facetType()); - QStringList queryStrings; - QString ratingQuery = m_facetsWidget->ratingTerm(); - if (!ratingQuery.isEmpty()) { - queryStrings << ratingQuery; - } + QStringList queryStrings = m_facetsWidget->searchTerms(); if (m_contentButton->isChecked()) { queryStrings << text; @@ -495,8 +501,7 @@ QUrl DolphinSearchBox::balooUrlForSearching() const query.setSearchString(queryStrings.join(QLatin1Char(' '))); - return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", - "Query Results from '%1'", text)); + return query.toSearchUrl(queryTitle(text)); #else return QUrl(); #endif @@ -517,11 +522,17 @@ void DolphinSearchBox::updateFromQuery(const DolphinQuery& query) setText(query.text()); - m_facetsWidget->resetOptions(); + if (query.hasContentSearch()) { + m_contentButton->setChecked(true); + } else if (query.hasFileName()) { + m_fileNameButton->setChecked(true); + } + + m_facetsWidget->resetSearchTerms(); m_facetsWidget->setFacetType(query.type()); const QStringList searchTerms = query.searchTerms(); for (const QString& searchTerm : searchTerms) { - m_facetsWidget->setRatingTerm(searchTerm); + m_facetsWidget->setSearchTerm(searchTerm); } m_startSearchTimer->stop(); @@ -539,7 +550,7 @@ bool DolphinSearchBox::isIndexingEnabled() const { #ifdef HAVE_BALOO const Baloo::IndexerConfig searchInfo; - return searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(searchPath().toLocalFile()); + return searchInfo.fileIndexingEnabled() && !searchPath().isEmpty() && searchInfo.shouldBeIndexed(searchPath().toLocalFile()); #else return false; #endif