Whitespace separated search terms are AND concatenated.

This commit is contained in:
Florian Geyer 2012-10-21 20:45:01 +02:00
parent 4d263a09db
commit 92bf7c94d0
4 changed files with 48 additions and 4 deletions

View file

@ -536,10 +536,21 @@ const Database* Entry::database() const
bool Entry::match(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity)
{
return title().contains(searchTerm, caseSensitivity) ||
username().contains(searchTerm, caseSensitivity) ||
url().contains(searchTerm, caseSensitivity) ||
notes().contains(searchTerm, caseSensitivity);
QStringList wordList = searchTerm.split(QRegExp("\\s"), QString::SkipEmptyParts);
Q_FOREACH (const QString& word, wordList) {
if (!wordMatch(word, caseSensitivity)) {
return false;
}
}
return true;
}
bool Entry::wordMatch(const QString& word, Qt::CaseSensitivity caseSensitivity)
{
return title().contains(word, caseSensitivity) ||
username().contains(word, caseSensitivity) ||
url().contains(word, caseSensitivity) ||
notes().contains(word, caseSensitivity);
}
QString Entry::resolvePlaceholders(const QString& str) const