X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d1baf3398e53931735b724672d5ae48649b44a18..2fc117703f304ba053e2b58b692609f9632535d7:/src/search/dolphinquery.cpp diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp index 0581a02ec..4b5499378 100644 --- a/src/search/dolphinquery.cpp +++ b/src/search/dolphinquery.cpp @@ -59,7 +59,11 @@ namespace { QStringList splitOutsideQuotes(const QString& text) { - const QRegularExpression subTermsRegExp("(\\S*?\"[^\"]*?\"|(?<=\\s|^)\\S+(?=\\s|$))"); + // Match groups on 3 possible conditions: + // - Groups with two leading quotes must close both on them (filename:""abc xyz" tuv") + // - Groups enclosed in quotes + // - Words separated by spaces + const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))"); auto subTermsMatchIterator = subTermsRegExp.globalMatch(text); QStringList textParts; @@ -69,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); + } } @@ -79,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; @@ -88,6 +104,7 @@ bool DolphinQuery::supportsScheme(const QString& urlScheme) { static const QStringList supportedSchemes = { QStringLiteral("baloosearch"), + QStringLiteral("tags"), }; return supportedSchemes.contains(urlScheme);