From 3984e607bb4437a38af16e007f1c23fbcff7dfb2 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 11 Nov 2019 09:42:43 +0100 Subject: [PATCH 1/6] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/dolphinpart.desktop | 4 ++++ src/org.kde.dolphin.desktop | 2 ++ src/settings/kcm/kcmdolphingeneral.desktop | 5 +++++ src/settings/kcm/kcmdolphinnavigation.desktop | 5 +++++ src/settings/kcm/kcmdolphinservices.desktop | 4 ++++ src/settings/kcm/kcmdolphinviewmodes.desktop | 5 +++++ .../versioncontrol/fileviewversioncontrolplugin.desktop | 1 + 7 files changed, 26 insertions(+) diff --git a/src/dolphinpart.desktop b/src/dolphinpart.desktop index 3d53ecbd63..ca3f48c48a 100644 --- a/src/dolphinpart.desktop +++ b/src/dolphinpart.desktop @@ -23,6 +23,7 @@ Name[it]=Vista di Dolphin Name[ja]=Dolphin ビュー Name[ko]=Dolphin 보기 Name[lt]=Dolphin rodinys +Name[lv]=Dolphin skats Name[ml]=ഡോള്‍ഫിന്‍ അവതരണരീതി Name[nb]=Dolphin visning Name[nl]=Dolphin-weergave @@ -83,6 +84,7 @@ Name[it]=Icone Name[ja]=アイコン Name[ko]=아이콘 Name[lt]=Piktogramos +Name[lv]=Ikonas Name[ml]=സൂചനാചിത്രങ്ങള്‍ Name[nb]=Ikoner Name[nl]=Pictogrammen @@ -134,6 +136,7 @@ Name[it]=Compatta Name[ja]=コンパクト Name[ko]=축소됨 Name[lt]=Kompaktiškas +Name[lv]=Kompakts Name[ml]=തിങ്ങിയതായി Name[nb]=Kompakt Name[nl]=Compact @@ -184,6 +187,7 @@ Name[it]=Dettagli Name[ja]=詳細 Name[ko]=자세히 Name[lt]=Išsamus +Name[lv]=Detaļas Name[ml]=വിശദമായി Name[nb]=Detaljer Name[nl]=Details diff --git a/src/org.kde.dolphin.desktop b/src/org.kde.dolphin.desktop index 3e71051efe..6404808eec 100755 --- a/src/org.kde.dolphin.desktop +++ b/src/org.kde.dolphin.desktop @@ -22,6 +22,7 @@ Name[it]=Dolphin Name[ja]=Dolphin Name[ko]=Dolphin Name[lt]=Dolphin +Name[lv]=Dolphin Name[ml]=ഡോള്‍ഫിന്‍ Name[nb]=Dolphin Name[nl]=Dolphin @@ -73,6 +74,7 @@ GenericName[it]=Gestore dei file GenericName[ja]=ファイルマネージャ GenericName[ko]=파일 관리자 GenericName[lt]=Failų tvarkytuvė +GenericName[lv]=Datņu pārvaldnieks GenericName[ml]=ഫയല്‍ മാനേജര്‍ GenericName[nb]=Filbehandler GenericName[nl]=Bestandsbeheerder diff --git a/src/settings/kcm/kcmdolphingeneral.desktop b/src/settings/kcm/kcmdolphingeneral.desktop index 6a5d70befd..d3f19539a4 100644 --- a/src/settings/kcm/kcmdolphingeneral.desktop +++ b/src/settings/kcm/kcmdolphingeneral.desktop @@ -21,6 +21,7 @@ Name[it]=Impostazioni generali di Dolphin Name[ja]=Dolphin 全般 Name[ko]=Dolphin 일반 Name[lt]=Dolphin bendrosios +Name[lv]=Dolphin vispārējs Name[ml]=പൊതു സജ്ജീകരണങ്ങള്‍ Name[nb]=Dolphin generelt Name[nl]=Dolphin algemeen @@ -66,6 +67,7 @@ Comment[it]=Questo servizio permette di configurare le impostazioni generali di Comment[ja]=Dolphin の全般的な設定を行います Comment[ko]=이 서비스를 통해 일반 Dolphin 설정을 구성할 수 있습니다. Comment[lt]=Ši paslauga leidžia bendrųjų Dolphin nuostatų konfigūravimą. +Comment[lv]=Šis serviss ļauj konfigurēt vispārējos Dolphin iestatījumus. Comment[ml]=പൊതുവായ ഡോള്‍ഫിന്‍ സജ്ജീകരണങ്ങള്‍ ക്രമീകരിയ്ക്കാന്‍ ഈ സേവനം അനുവദിക്കുന്നു. Comment[nb]=Med denne tjenesten kan du sette opp generelle innstillinger for Dolphin. Comment[nl]=Met deze dienst kunt u algemene Dolphin-instellingen configureren. @@ -123,6 +125,7 @@ Name[it]=Generale Name[ja]=全般 Name[ko]=일반 Name[lt]=Bendrosios +Name[lv]=Vispārējs Name[ml]=പൊതുവായതു് Name[nb]=Generelt Name[nl]=Algemeen @@ -167,6 +170,7 @@ Comment[it]=Configura le impostazioni generali del gestore dei file Comment[ja]=ファイルマネージャの全般的な設定を行います Comment[ko]=일반 파일 관리자 설정 구성 Comment[lt]=Konfigūruoti bendras failų tvarkytuvės nuostatas +Comment[lv]=Konfigurēt vispārējā datņu pārvaldnieka iestatījumus Comment[ml]=ഫയൽ മാനേജറിന്റെ പൊതുവായ സജ്ജീകരണങ്ങള്‍ ക്രമീകരിയ്ക്കുക Comment[nb]=Sett opp generelle innstillinger for filbehandleren Comment[nl]=Algemene bestandsbeheerderinstellingen configureren @@ -212,6 +216,7 @@ X-KDE-Keywords[it]=gestore dei file X-KDE-Keywords[ja]=ファイルマネージャ X-KDE-Keywords[ko]=파일 관리자 X-KDE-Keywords[lt]=failų tvarkytuvė +X-KDE-Keywords[lv]=datņu pārvaldnieks X-KDE-Keywords[ml]=ഫയൽ മാനേജർ X-KDE-Keywords[nb]=filbehandler X-KDE-Keywords[nl]=bestandsbeheerder diff --git a/src/settings/kcm/kcmdolphinnavigation.desktop b/src/settings/kcm/kcmdolphinnavigation.desktop index e0461db718..88c1252352 100644 --- a/src/settings/kcm/kcmdolphinnavigation.desktop +++ b/src/settings/kcm/kcmdolphinnavigation.desktop @@ -21,6 +21,7 @@ Name[it]=Navigazione di Dolphin Name[ja]=Dolphin ナビゲーション Name[ko]=Dolphin 탐색 Name[lt]=Dolphin naršymas +Name[lv]=Dolphin navigācija Name[ml]=ഡോള്‍ഫിന്‍ നാവിഗേഷന്‍ Name[nb]=Navigasjon i Dolphin Name[nl]=Dolphin-navigatie @@ -66,6 +67,7 @@ Comment[it]=Questo servizio permette di configurare la navigazione con Dolphin. Comment[ja]=Dolphin でのナビゲーションを設定します Comment[ko]=이 서비스를 통해 Dolphin 탐색을 설정할 수 있습니다. Comment[lt]=Ši paslauga leidžia Dolphin naršymo konfigūravimą. +Comment[lv]=Šis serviss ļauj konfigurēt Dolphin navigāciju. Comment[ml]=ഡോള്‍ഫിന്‍ നാവിഗേഷൻ ക്രമീകരിയ്ക്കാന്‍ ഈ സേവനം അനുവദിയ്ക്കുന്നു. Comment[nb]=Med denne tjenesten kan du sette opp navigasjon for Dolphin. Comment[nl]=Met deze dienst kunt u Dolphin-navigatie configureren. @@ -122,6 +124,7 @@ Name[it]=Navigazione Name[ja]=ナビゲーション Name[ko]=탐색 Name[lt]=Naršymas +Name[lv]=Navigācija Name[ml]=നാവിഗേഷന്‍ Name[nb]=Navigasjon Name[nl]=Navigatie @@ -167,6 +170,7 @@ Comment[it]=Configura la navigazione col gestore dei file Comment[ja]=ファイルマネージャでのナビゲーションを設定します Comment[ko]=파일 관리자 탐색 설정 Comment[lt]=Konfigūruoti failų tvarkytuvės naršymą +Comment[lv]=Konfigurēt datņu pārvaldnieka navigāciju Comment[ml]=ഫയല്‍ മാനേജർ നാവിഗേഷൻ ക്രമീകരിയ്ക്കുക Comment[nb]=Sett opp navigasjon i filbehandleren Comment[nl]=Bestandsbeheerdernavigatie configureren @@ -213,6 +217,7 @@ X-KDE-Keywords[it]=gestore dei file X-KDE-Keywords[ja]=ファイルマネージャ X-KDE-Keywords[ko]=파일 관리자 X-KDE-Keywords[lt]=failų tvarkytuvė +X-KDE-Keywords[lv]=datņu pārvaldnieks X-KDE-Keywords[ml]=ഫയൽ മാനേജർ X-KDE-Keywords[nb]=filbehandler X-KDE-Keywords[nl]=bestandsbeheerder diff --git a/src/settings/kcm/kcmdolphinservices.desktop b/src/settings/kcm/kcmdolphinservices.desktop index 9dccea5ed5..ea4dd15cf3 100644 --- a/src/settings/kcm/kcmdolphinservices.desktop +++ b/src/settings/kcm/kcmdolphinservices.desktop @@ -21,6 +21,7 @@ Name[it]=Servizi di Dolphin Name[ja]=Dolphin サービス Name[ko]=Dolphin 서비스 Name[lt]=Dolphin paslaugos +Name[lv]=Dolphin servisi Name[ml]=ഡോള്‍ഫിന്‍ സേവനങ്ങള്‍ Name[nb]=Dolphin-tjenester Name[nl]=Dolphin-services @@ -77,6 +78,7 @@ Name[it]=Servizi Name[ja]=サービス Name[ko]=서비스 Name[lt]=Paslaugos +Name[lv]=Servisi Name[ml]=സേവനങ്ങള്‍ Name[nb]=Tjenester Name[nl]=Services @@ -121,6 +123,7 @@ Comment[it]=Configura i servizi del gestore dei file Comment[ja]=ファイルマネージャのサービスを設定します Comment[ko]=파일 관리자 서비스 구성 Comment[lt]=Konfigūruoti failų tvarkytuvės paslaugas +Comment[lv]=Konfigurēt datņu pārvaldnieka servisus Comment[ml]=ഫയല്‍ മാനേജർ സേവനങ്ങള്‍ ക്രമീകരിയ്ക്കുക Comment[nb]=Sett opp tjenester i filbehandleren Comment[nl]=Bestandsbeheerderservices configureren @@ -166,6 +169,7 @@ X-KDE-Keywords[it]=gestore dei file X-KDE-Keywords[ja]=ファイルマネージャ X-KDE-Keywords[ko]=파일 관리자 X-KDE-Keywords[lt]=failų tvarkytuvė +X-KDE-Keywords[lv]=datņu pārvaldnieks X-KDE-Keywords[ml]=ഫയൽ മാനേജർ X-KDE-Keywords[nb]=filbehandler X-KDE-Keywords[nl]=bestandsbeheerder diff --git a/src/settings/kcm/kcmdolphinviewmodes.desktop b/src/settings/kcm/kcmdolphinviewmodes.desktop index 4207d49b03..996e841098 100644 --- a/src/settings/kcm/kcmdolphinviewmodes.desktop +++ b/src/settings/kcm/kcmdolphinviewmodes.desktop @@ -21,6 +21,7 @@ Name[it]=Viste di Dolphin Name[ja]=Dolphin 表示モード Name[ko]=Dolphin 보기 모드 Name[lt]=Dolphin rodinio veiksenos +Name[lv]=Dolphin skata režīmi Name[ml]=ഡോള്‍ഫിന്‍ അവതരണദശകള്‍ Name[nb]=Dolphin visningsmåter Name[nl]=Dolphin-weergavemodussen @@ -66,6 +67,7 @@ Comment[it]=Questo servizio permette di configurare le viste di Dolphin. Comment[ja]=Dolphin の表示モードを設定します Comment[ko]=이 서비스를 통해 Dolphin 보기 모드를 설정할 수 있습니다. Comment[lt]=Ši paslauga leidžia Dolphin rodinio veiksenų konfigūravimą. +Comment[lv]=Šis serviss ļauj konfigurēt Dolphin skata režīmus. Comment[ml]=ഡോള്‍ഫിന്‍ അവതരണദശകള്‍ ക്രമീകരിയ്ക്കാന്‍ ഈ സേവനം അനുവദിയ്ക്കുന്നു. Comment[nb]=Med denne tjenesten kan du sette opp Dolphins visningsmåter. Comment[nl]=Met deze dienst kunt u Dolphin-weergavemodussen configureren. @@ -121,6 +123,7 @@ Name[it]=Viste Name[ja]=表示モード Name[ko]=보기 모드 Name[lt]=Rodinio veiksenos +Name[lv]=Skata režīmi Name[ml]=അവതരണ ദശകള്‍ Name[nb]=Visningsmåter Name[nl]=Weergavemodi @@ -166,6 +169,7 @@ Comment[it]=Configura le viste del gestore dei file Comment[ja]=ファイルマネージャの表示モードを設定します Comment[ko]=파일 관리자 보기 모드 구성 Comment[lt]=Konfigūruoti failų tvarkytuvės rodinio veiksenas +Comment[lv]=Konfigurēt datņu pārvaldnieka skata režīmus Comment[ml]=ഫയല്‍ മാനേജറിന്റെ അവതരണ ദശകള്‍ ക്രമീകരിയ്ക്കുക Comment[nb]=Tilpass filbehandlerens visningsmåter Comment[nl]=Bestandsbeheerderweergavemodussen configureren @@ -212,6 +216,7 @@ X-KDE-Keywords[it]=gestore dei file X-KDE-Keywords[ja]=ファイルマネージャ X-KDE-Keywords[ko]=파일 관리자 X-KDE-Keywords[lt]=failų tvarkytuvė +X-KDE-Keywords[lv]=datņu pārvaldnieks X-KDE-Keywords[ml]=ഫയൽ മാനേജർ X-KDE-Keywords[nb]=filbehandler X-KDE-Keywords[nl]=bestandsbeheerder diff --git a/src/views/versioncontrol/fileviewversioncontrolplugin.desktop b/src/views/versioncontrol/fileviewversioncontrolplugin.desktop index efa6bb90cf..a04f1cc607 100644 --- a/src/views/versioncontrol/fileviewversioncontrolplugin.desktop +++ b/src/views/versioncontrol/fileviewversioncontrolplugin.desktop @@ -24,6 +24,7 @@ Comment[it]=Estensione di controllo delle versioni per le viste dei file Comment[ja]=ファイルビューのためのバージョン管理プラグイン Comment[ko]=파일 보기용 버전 제어 플러그인 Comment[lt]=Failo rodinių versijų tvarkymo papildinys +Comment[lv]=Versiju kontroles spraudnis priekš datņu skata Comment[ml]=ഫയല്‍ അവതരണദിശകൾക്കുള്ള പതിപ്പ് നിയന്ത്രണ സംയോജകം Comment[nb]=Versjonskontrollmodul for filvisninger Comment[nl]=Plugin voor versiecontrole op bestandoverzichten From 8d92c8be7f117dee18710ee1ba6b7cfa45d3f5f0 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Wed, 13 Nov 2019 22:16:35 +0100 Subject: [PATCH 2/6] refactor(search): De-couple baloo URL parsing logic from UI Summary: Extracts the logic that parses `baloosearch:` urls into a new model class. The parser logic itself is kept as is. The search box UI is later updated using the model fields. This refactor has been proposed by @bruns in the review of D24422, as it largely simplifies the unit tests and further expansion/improvements. Test Plan: No behavior changes. Test case is added in the follow-up revision: D25258 Reviewers: #dolphin, elvisangelaccio, bruns Reviewed By: #dolphin, elvisangelaccio, bruns Subscribers: ngraham, bruns, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D25257 --- src/CMakeLists.txt | 1 + src/search/dolphinquery.cpp | 98 +++++++++++++++++++++++++++++++++ src/search/dolphinquery.h | 60 ++++++++++++++++++++ src/search/dolphinsearchbox.cpp | 34 ++++-------- src/search/dolphinsearchbox.h | 6 +- 5 files changed, 172 insertions(+), 27 deletions(-) create mode 100644 src/search/dolphinquery.cpp create mode 100644 src/search/dolphinquery.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14701a1f41..617d594807 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -216,6 +216,7 @@ set(dolphinstatic_SRCS panels/folders/folderspanel.cpp panels/terminal/terminalpanel.cpp search/dolphinfacetswidget.cpp + search/dolphinquery.cpp search/dolphinsearchbox.cpp settings/general/behaviorsettingspage.cpp settings/general/configurepreviewplugindialog.cpp diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp new file mode 100644 index 0000000000..09a8418591 --- /dev/null +++ b/src/search/dolphinquery.cpp @@ -0,0 +1,98 @@ +/*************************************************************************** + * Copyright (C) 2019 by Ismael Asensio * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "dolphinquery.h" + +#include +#ifdef HAVE_BALOO +#include +#endif + +namespace { + /** Checks if a given term in the Baloo::Query::searchString() is a special search term. + * This is a copy of `DolphinFacetsWidget::isRatingTerm()` method. + */ + bool isSearchTerm(const QString& term) + { + static const QLatin1String searchTokens[] { + QLatin1String("modified>="), + QLatin1String("rating>=") + }; + + for (const auto &searchToken : searchTokens) { + if (term.startsWith(searchToken)) { + return true; + } + } + return false; + } +} + +DolphinQuery DolphinQuery::fromBalooSearchUrl(const QUrl& searchUrl) +{ + DolphinQuery model; + model.m_searchUrl = searchUrl; + +#ifdef HAVE_BALOO + const Baloo::Query query = Baloo::Query::fromSearchUrl(searchUrl); + + model.m_includeFolder = query.includeFolder(); + + model.m_searchText = query.searchString(); + + const QStringList types = query.types(); + model.m_fileType = types.isEmpty() ? QString() : types.first(); + + const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); + foreach (const QString& subTerm, subTerms) { + if (subTerm.startsWith(QLatin1String("filename:"))) { + const QString value = subTerm.mid(9); + model.m_searchText = value; + } else if (isSearchTerm(subTerm)) { + model.m_searchTerms << subTerm; + } + } +#endif + return model; +} + +QUrl DolphinQuery::searchUrl() const +{ + return m_searchUrl; +} + +QString DolphinQuery::text() const +{ + return m_searchText; +} + +QString DolphinQuery::type() const +{ + return m_fileType; +} + +QStringList DolphinQuery::searchTerms() const +{ + return m_searchTerms; +} + +QString DolphinQuery::includeFolder() const +{ + return m_includeFolder; +} diff --git a/src/search/dolphinquery.h b/src/search/dolphinquery.h new file mode 100644 index 0000000000..736abf66f5 --- /dev/null +++ b/src/search/dolphinquery.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (C) 2019 by Ismael Asensio * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef DOLPHINQUERY_H +#define DOLPHINQUERY_H + +#include "dolphin_export.h" + +#include +#include + +/** + * @brief Simple query model that parses a Baloo search Url and extracts its + * separate components to be displayed on dolphin search box. + */ +class DOLPHIN_EXPORT DolphinQuery +{ +public: + /** Calls Baloo::Query::fromSearchUrl() with the given @p searchUrl + * and parses the result to extract its separate components */ + static DolphinQuery fromBalooSearchUrl(const QUrl& searchUrl); + + /** @return the \a searchUrl passed to Baloo::Query::fromSearchUrl() */ + QUrl searchUrl() const; + /** @return the user text part of the query, to be shown in the searchbar */ + QString text() const; + /** @return the first of Baloo::Query::types(), or an empty string */ + QString type() const; + /** @return a list of the search terms of the Baloo::Query that act as a filter, + * such as \"rating>= value\" or \"modified>= date\"*/ + QStringList searchTerms() const; + /** @return Baloo::Query::includeFolder(), that is, the initial directory + * for the query or an empty string if its a global search" */ + QString includeFolder() const; + +private: + QUrl m_searchUrl; + QString m_searchText; + QString m_fileType; + QStringList m_searchTerms; + QString m_includeFolder; +}; + +#endif //DOLPHINQUERY_H diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 751b23942f..ee7cbe6283 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -22,6 +22,7 @@ #include "dolphin_searchsettings.h" #include "dolphinfacetswidget.h" +#include "dolphinquery.h" #include "panels/places/placesitemmodel.h" #include @@ -143,7 +144,8 @@ QUrl DolphinSearchBox::urlForSearching() const void DolphinSearchBox::fromSearchUrl(const QUrl& url) { if (url.scheme() == QLatin1String("baloosearch")) { - fromBalooSearchUrl(url); + const DolphinQuery query = DolphinQuery::fromBalooSearchUrl(url); + updateFromQuery(query); } else if (url.scheme() == QLatin1String("filenamesearch")) { const QUrlQuery query(url); setText(query.queryItemValue(QStringLiteral("search"))); @@ -498,11 +500,8 @@ QUrl DolphinSearchBox::balooUrlForSearching() const #endif } -void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url) +void DolphinSearchBox::updateFromQuery(const DolphinQuery& query) { -#ifdef HAVE_BALOO - const Baloo::Query query = Baloo::Query::fromSearchUrl(url); - // Block all signals to avoid unnecessary "searchRequest" signals // while we adjust the search text and the facet widget. blockSignals(true); @@ -514,30 +513,17 @@ void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url) setSearchPath(QUrl::fromLocalFile(QDir::homePath())); } + setText(query.text()); + m_facetsWidget->resetOptions(); - - setText(query.searchString()); - - QStringList types = query.types(); - if (!types.isEmpty()) { - m_facetsWidget->setFacetType(types.first()); - } - - const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); - foreach (const QString& subTerm, subTerms) { - if (subTerm.startsWith(QLatin1String("filename:"))) { - const QString value = subTerm.mid(9); - setText(value); - } else if (m_facetsWidget->isRatingTerm(subTerm)) { - m_facetsWidget->setRatingTerm(subTerm); - } + m_facetsWidget->setFacetType(query.type()); + const QStringList searchTerms = query.searchTerms(); + for (const QString& searchTerm : searchTerms) { + m_facetsWidget->setRatingTerm(searchTerm); } m_startSearchTimer->stop(); blockSignals(false); -#else - Q_UNUSED(url) -#endif } void DolphinSearchBox::updateFacetsVisible() diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index 241dc40c12..5fef4ec5a7 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -24,6 +24,7 @@ #include class DolphinFacetsWidget; +class DolphinQuery; class QLineEdit; class KSeparator; class QToolButton; @@ -152,10 +153,9 @@ private: QUrl balooUrlForSearching() const; /** - * Extracts information from the given Baloo search \a url to - * initialize the search box properly. + * Sets the searchbox UI with the parameters established by the \a query */ - void fromBalooSearchUrl(const QUrl& url); + void updateFromQuery(const DolphinQuery& query); void updateFacetsVisible(); From fc5546d03b08e89060ee6abf9d58c273ae1e705b Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Wed, 13 Nov 2019 22:40:41 +0100 Subject: [PATCH 3/6] DolphinQuery: drop DOLPHIN_EXPORT DOLPHIN_EXPORT is only used by classes in the `dolphinprivate` target, while DolphinQuery is part of `dolphinstatic`. This should fix the failing Windows build on the CI. --- src/search/dolphinquery.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/dolphinquery.h b/src/search/dolphinquery.h index 736abf66f5..e60008e3bf 100644 --- a/src/search/dolphinquery.h +++ b/src/search/dolphinquery.h @@ -29,7 +29,7 @@ * @brief Simple query model that parses a Baloo search Url and extracts its * separate components to be displayed on dolphin search box. */ -class DOLPHIN_EXPORT DolphinQuery +class DolphinQuery { public: /** Calls Baloo::Query::fromSearchUrl() with the given @p searchUrl From adfc098aa74723ec3f01cda513290864ef9ee0f9 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Wed, 13 Nov 2019 22:48:45 +0100 Subject: [PATCH 4/6] fix(search): Allow to set empty type Summary: This small patch allows to set and empty `type` to the extended options, which will set the `Any Type` option (index 0). It doesn't make any change in current code, since this case is not called, but it helps simplifying follow-up patches. Test Plan: No behavior changes with current code. Calling `setFacetsType(QString())` actually sets the first option (`Any Type`) Reviewers: elvisangelaccio, #dolphin Reviewed By: elvisangelaccio, #dolphin Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D25255 --- src/search/dolphinfacetswidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp index 1827192259..ae05509e77 100644 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -153,7 +153,7 @@ void DolphinFacetsWidget::setRatingTerm(const QString& term) void DolphinFacetsWidget::setFacetType(const QString& type) { - for (int index = 1; index <= m_typeSelector->count(); index++) { + for (int index = 0; index <= m_typeSelector->count(); index++) { if (type == m_typeSelector->itemData(index).toString()) { m_typeSelector->setCurrentIndex(index); break; From 0ba9e8bbc04225c6679ba5a30d359d55b3af7ed0 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Thu, 14 Nov 2019 22:48:26 +0100 Subject: [PATCH 5/6] test(search): Add test case for baloo parsing model Summary: Adds a new test unit for the model which parses baloo search URLs 14/19 tests are set to `XFAIL` on current implementation, as they will be fixed in a final revision. Supersedes D25135. Depends on: D25257 Test Plan: `bin/dolphinquerytest` Reviewers: elvisangelaccio, bruns, #dolphin Reviewed By: elvisangelaccio, bruns, #dolphin Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D25258 --- src/tests/CMakeLists.txt | 7 ++ src/tests/dolphinquerytest.cpp | 147 +++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 src/tests/dolphinquerytest.cpp diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6ecac1f1e8..8d44986758 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -49,6 +49,13 @@ if (KF5Baloo_FOUND) LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test) endif() +# DolphinQuery +if (KF5Baloo_FOUND) + ecm_add_test(dolphinquerytest.cpp + TEST_NAME dolphinquerytest + LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test) +endif() + # KStandardItemModelTest ecm_add_test(kstandarditemmodeltest.cpp TEST_NAME kstandarditemmodeltest diff --git a/src/tests/dolphinquerytest.cpp b/src/tests/dolphinquerytest.cpp new file mode 100644 index 0000000000..14eb03620c --- /dev/null +++ b/src/tests/dolphinquerytest.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** + * Copyright (C) 2019 by Ismael Asensio * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "search/dolphinquery.h" + +#include + +#include +#include +#include +#include +#include + +class DolphinSearchBoxTest : public QObject +{ + Q_OBJECT + +private slots: + void testBalooSearchParsing_data(); + void testBalooSearchParsing(); +}; + +/** + * Defines the parameters for the test cases in testBalooSearchParsing() + */ +void DolphinSearchBoxTest::testBalooSearchParsing_data() +{ + const QString text = QStringLiteral("xyz"); + const QString filename = QStringLiteral("filename:\"xyz\""); + const QString rating = QStringLiteral("rating>=2"); + const QString modified = QString("modified>=2019-08-07"); + + QTest::addColumn("searchString"); + QTest::addColumn("expectedText"); + QTest::addColumn("expectedTerms"); + + // Test for "Content" + QTest::newRow("content") << text << text << QStringList(); + QTest::newRow("content/empty") << "" << "" << QStringList(); + QTest::newRow("content/singleQuote") << "\"" << "" << QStringList(); + QTest::newRow("content/doubleQuote") << "\"\"" << "" << QStringList(); + // Test for empty `filename` + QTest::newRow("filename") << filename << text << QStringList(); + QTest::newRow("filename/empty") << "filename:" << "" << QStringList(); + QTest::newRow("filename/singleQuote") << "filename:\"" << "" << QStringList(); + QTest::newRow("filename/doubleQuote") << "filename:\"\"" << "" << QStringList(); + + // Test for rating + QTest::newRow("rating") << rating << "" << QStringList({rating}); + QTest::newRow("rating+content") << rating + " " + text << text << QStringList({rating}); + QTest::newRow("rating+filename") << rating + " " + filename << text << QStringList({rating}); + // Test for modified date + QTest::newRow("modified") << modified << "" << QStringList({modified}); + QTest::newRow("modified+content") << modified + " " + text << text << QStringList({modified}); + QTest::newRow("modified+filename") << modified + " " + filename << text << QStringList({modified}); + // Combined tests + QTest::newRow("rating+modified") << rating + " AND " + modified << "" << QStringList({modified, rating}); + QTest::newRow("rating+modified+content") << rating + " AND " + modified + " " + text << text << QStringList({modified, rating}); + QTest::newRow("rating+modified+filename") << rating + " AND " + modified + " " + filename << text << QStringList({modified, rating}); +} + +/** + * Helper function to compose the baloo query URL used for searching + */ +QUrl composeQueryUrl(const QString& searchString) +{ + const QJsonObject jsonObject { + {"searchString", searchString} + }; + + const QJsonDocument doc(jsonObject); + const QString queryString = QString::fromUtf8(doc.toJson(QJsonDocument::Compact)); + + QUrlQuery urlQuery; + urlQuery.addQueryItem(QStringLiteral("json"), queryString); + + QUrl searchUrl; + searchUrl.setScheme(QLatin1String("baloosearch")); + searchUrl.setQuery(urlQuery); + + return searchUrl; +} + +/** + * The test verifies whether the different terms of a Baloo search URL ("baloosearch:") are + * properly handled by the searchbox, and only "user" or filename terms are added to the + * text bar of the searchbox. + */ +void DolphinSearchBoxTest::testBalooSearchParsing() +{ + QFETCH(QString, searchString); + QFETCH(QString, expectedText); + QFETCH(QStringList, expectedTerms); + + const QUrl testUrl = composeQueryUrl(searchString); + const DolphinQuery query = DolphinQuery::fromBalooSearchUrl(testUrl); + + QStringList searchTerms = query.searchTerms(); + searchTerms.sort(); + + // FIXME: Current parsing bugs + QEXPECT_FAIL("content/singleQuote", "Quotes around text are shown", Continue); + QEXPECT_FAIL("content/doubleQuote", "Quotes around text are shown", Continue); + + QEXPECT_FAIL("filename", "Quotes around text are shown", Continue); + QEXPECT_FAIL("filename/singleQuote", "Quotes around text are shown", Continue); + QEXPECT_FAIL("filename/doubleQuote", "Quotes around text are shown", Continue); + + QEXPECT_FAIL("rating" , "Text includes also search terms", Continue); + QEXPECT_FAIL("rating+content" , "Text includes also search terms", Continue); + QEXPECT_FAIL("rating+filename" , "Text includes also search terms", Continue); + QEXPECT_FAIL("modified" , "Text includes also search terms", Continue); + QEXPECT_FAIL("modified+content" , "Text includes also search terms", Continue); + QEXPECT_FAIL("modified+filename" , "Text includes also search terms", Continue); + QEXPECT_FAIL("rating+modified" , "Text includes also search terms", Continue); + QEXPECT_FAIL("rating+modified+content" , "Text includes also search terms", Continue); + QEXPECT_FAIL("rating+modified+filename", "Text includes also search terms", Continue); + + // Check for parsed text (would be displayed on the input search bar) + QCOMPARE(query.text(), expectedText); + + // Check for parsed search terms (would be displayed by the facetsWidget) + QCOMPARE(searchTerms.count(), expectedTerms.count()); + for (int i = 0; i < expectedTerms.count(); i++) { + QCOMPARE(searchTerms.at(i), expectedTerms.at(i)); + } +} + +QTEST_MAIN(DolphinSearchBoxTest) + +#include "dolphinquerytest.moc" From 77e705ef3c9ed3253ce421413ed0d3755c95f12d Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 17 Nov 2019 18:53:44 +0100 Subject: [PATCH 6/6] Fix dolphin homepage in the appstream metadata --- src/org.kde.dolphin.appdata.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org.kde.dolphin.appdata.xml b/src/org.kde.dolphin.appdata.xml index 155be6c44a..9fcc1b5a5a 100644 --- a/src/org.kde.dolphin.appdata.xml +++ b/src/org.kde.dolphin.appdata.xml @@ -523,7 +523,7 @@
  • 復原支援
  • - https://dolphin.kde.org/ + https://kde.org/applications/system/dolphin https://bugs.kde.org/enter_bug.cgi?format=guided&product=dolphin https://docs.kde.org/?application=dolphin https://www.kde.org/community/donations/?app=dolphin&source=appdata