From 2fc117703f304ba053e2b58b692609f9632535d7 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Sun, 14 Jun 2020 13:41:29 +0200 Subject: Add support to tags: scheme in DolphinQuery It allows to start a search from a `tags:/mytag/` view. The use case is to refine a search on additional terms (another tags, ratings, etc) --- src/search/dolphinquery.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/search/dolphinquery.cpp') diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp index 663ed9909..4b5499378 100644 --- a/src/search/dolphinquery.cpp +++ b/src/search/dolphinquery.cpp @@ -73,6 +73,14 @@ namespace { return textParts; } #endif + + QString trimChar(const QString& text, const QLatin1Char aChar) + { + const int start = text.startsWith(aChar) ? 1 : 0; + const int end = (text.length() > 1 && text.endsWith(aChar)) ? 1 : 0; + + return text.mid(start, text.length() - start - end); + } } @@ -83,6 +91,10 @@ DolphinQuery DolphinQuery::fromSearchUrl(const QUrl& searchUrl) if (searchUrl.scheme() == QLatin1String("baloosearch")) { model.parseBalooQuery(); + } else if (searchUrl.scheme() == QLatin1String("tags")) { + // tags can contain # symbols or slashes within the Url + QString tag = trimChar(searchUrl.toString(QUrl::RemoveScheme), QLatin1Char('/')); + model.m_searchTerms << QStringLiteral("tag:%1").arg(tag); } return model; @@ -92,6 +104,7 @@ bool DolphinQuery::supportsScheme(const QString& urlScheme) { static const QStringList supportedSchemes = { QStringLiteral("baloosearch"), + QStringLiteral("tags"), }; return supportedSchemes.contains(urlScheme); -- cgit v1.3