From 616d4e6bdd707ac819707263255809df576a8c2b Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Sat, 21 Dec 2019 19:14:17 +0100 Subject: fix(search): Correctly parse filename and/or content search Summary: Currently, the search url parsing does not detect if the search is based on Content or Filename, and it just keeps the last selection which can be inconsistent with the actual search. This patch add such detection, and since an advanced user can combine filename and content search (using the keyword `filename:`), now the parsing detects both items and handles the four possible cases: | Content | Filename | Search text | Search type | |---|---|------------------------|------------------| | T | T | abc filename:"xyz" | Content | | T | F | abc | Content | | F | T | xyz | Filename | | F | F | | do not set | Depends on: D25260 Test Plan: `bin/dolphinquerytest`: Added new test cases for searches with content text and/or filename Reviewers: elvisangelaccio, bruns, #dolphin Reviewed By: elvisangelaccio, #dolphin Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D25416 --- src/search/dolphinsearchbox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/search/dolphinsearchbox.cpp') diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 16f17bbcd..302081d7d 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -517,6 +517,12 @@ void DolphinSearchBox::updateFromQuery(const DolphinQuery& query) setText(query.text()); + if (query.hasContentSearch()) { + m_contentButton->setChecked(true); + } else if (query.hasFileName()) { + m_fileNameButton->setChecked(true); + } + m_facetsWidget->resetOptions(); m_facetsWidget->setFacetType(query.type()); const QStringList searchTerms = query.searchTerms(); -- cgit v1.3