Tweak the replacement of colons.

Make sure that there are no trailing whitspaces on tokens before appending "* ".
This commit is contained in:
Mattias Andersson 2014-01-13 22:15:07 +01:00
parent 3f4e8e5b88
commit bd880dcafe
1 changed files with 6 additions and 2 deletions

View File

@ -39,9 +39,11 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
// expected with sqlite's FTS3:
// 1) Append * to all tokens.
// 2) Prefix "fts" to column names.
// 3) Remove colons which don't correspond to column names.
// Split on whitespace
QStringList tokens(options.filter().split(QRegExp("\\s+")));
QStringList tokens(options.filter().split(
QRegExp("\\s+"), QString::SkipEmptyParts));
QString query;
foreach (QString token, tokens) {
token.remove('(');
@ -57,9 +59,11 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
':', 0, 0, QString::SectionIncludeTrailingSep);
QString subtoken = token.section(':', 1, -1);
subtoken.replace(":", " ");
subtoken = subtoken.trimmed();
query += "fts" + columntoken + subtoken + "* ";
} else {
token.replace(':', 1, ' ');
token.replace(":", " ");
token = token.trimmed();
query += token + "* ";
}
} else {