diff options
| author | Elvis Angelaccio <[email protected]> | 2019-11-28 22:36:44 +0100 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2019-11-28 22:36:44 +0100 |
| commit | 26f0e55f84b4a745d3b5e47d8703406d13107d30 (patch) | |
| tree | e1aeb8e2142f88acede9c793d65bc3f16cf846de /src/search | |
| parent | fc4fd11c4dc7d5ca362a2241a69a18eaf8f65787 (diff) | |
| parent | 6776fbc94760188daeca0ab30e49f645f225f008 (diff) | |
Merge branch 'release/19.12'
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/dolphinquery.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp index 09a841859..8f8cb09ec 100644 --- a/src/search/dolphinquery.cpp +++ b/src/search/dolphinquery.cpp @@ -54,20 +54,38 @@ DolphinQuery DolphinQuery::fromBalooSearchUrl(const QUrl& searchUrl) model.m_includeFolder = query.includeFolder(); - model.m_searchText = query.searchString(); - const QStringList types = query.types(); model.m_fileType = types.isEmpty() ? QString() : types.first(); + QStringList textParts; + const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); foreach (const QString& subTerm, subTerms) { + QString value; if (subTerm.startsWith(QLatin1String("filename:"))) { - const QString value = subTerm.mid(9); - model.m_searchText = value; + value = subTerm.mid(9); } else if (isSearchTerm(subTerm)) { model.m_searchTerms << subTerm; + continue; + } else if (subTerm == QLatin1String("AND") && subTerm != subTerms.at(0) && subTerm != subTerms.back()) { + continue; + } else { + value = subTerm; + } + + if (!value.isEmpty() && value.at(0) == QLatin1Char('"')) { + value = value.mid(1); + } + if (!value.isEmpty() && value.back() == QLatin1Char('"')) { + value = value.mid(0, value.size() - 1); + } + if (!value.isEmpty()) { + textParts << value; } } + + model.m_searchText = textParts.join(QLatin1Char(' ')); + #endif return model; } |
