Autocomplete usernames based on most frequent in database

* Fixes #3126
* Limit autocompletion to the top ten used usernames
- Load common usernames when database is opened
- Transition from QLineEdit to QComboBox for usernames
- Dropdown menu of the combobox lets user choose a common username
- Common usernames are autocompleted via inline completion
- Common usernames are sorted by frequency (first) and name (second)
This commit is contained in:
Matthias Drexler 2019-06-22 15:38:02 +02:00 committed by Jonathan White
parent a22e8a1f40
commit f85642741d
13 changed files with 134 additions and 10 deletions

View file

@ -54,6 +54,7 @@ Database::Database()
connect(m_metadata, SIGNAL(metadataModified()), this, SLOT(markAsModified()));
connect(m_timer, SIGNAL(timeout()), SIGNAL(databaseModified()));
connect(this, SIGNAL(databaseSaved()), SLOT(updateCommonUsernames()));
m_modified = false;
m_emitModified = true;
@ -149,6 +150,8 @@ bool Database::open(const QString& filePath, QSharedPointer<const CompositeKey>
setFilePath(filePath);
dbFile.close();
updateCommonUsernames();
setInitialized(ok);
markAsClean();
@ -525,6 +528,17 @@ void Database::addDeletedObject(const QUuid& uuid)
addDeletedObject(delObj);
}
QList<QString> Database::commonUsernames()
{
return m_commonUsernames;
}
void Database::updateCommonUsernames(int topN)
{
m_commonUsernames.clear();
m_commonUsernames.append(rootGroup()->usernamesRecursive(topN));
}
const QUuid& Database::cipher() const
{
return m_data.cipher;