Ruled out duplicates when searching.

This commit is contained in:
tastytea 2019-05-19 12:47:38 +02:00
parent 33b84e3100
commit da5ff47396
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 18 additions and 0 deletions

View File

@ -102,6 +102,12 @@ search_all(const vector<Database::entry> &entries, string expression)
bool matched_description = true;
bool matched_fulltext = true;
const auto it = find(result.begin(), result.end(), entry);
if (it != result.end())
{ // Skip if already in result list.
continue;
}
for (const string &term : terms_or)
{
if (entry.title.find(term) == std::string::npos)

View File

@ -63,6 +63,16 @@ Database::operator bool() const
return _connected;
}
bool operator ==(const Database::entry &a, const Database::entry &b)
{
if (a.datetime == b.datetime)
{
return true;
}
return false;
}
const string Database::entry::fulltext_oneline() const
{
return regex_replace(fulltext, regex("\n"), "\\n");

View File

@ -44,6 +44,8 @@ public:
string description;
string fulltext;
friend bool operator ==(const Database::entry &a,
const Database::entry &b);
//! The full text in one line.
const string fulltext_oneline() const;
} entry;