1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[PasswordManager] Small code cleanup.

Use iterators for QHash
This commit is contained in:
nowrep 2013-05-19 10:34:54 +02:00
parent 19adf74dc5
commit c1e70db731

View File

@ -106,25 +106,30 @@ void AutoFillManager::changePasswordBackend()
int current = 0; int current = 0;
foreach (const QString &key, backends.keys()) { QHashIterator<QString, PasswordBackend*> i(backends);
if (backends[key] == m_passwordManager->activeBackend()) { while (i.hasNext()) {
i.next();
if (i.value() == m_passwordManager->activeBackend()) {
current = items.size(); current = items.size();
} }
items << i.value()->name();
items << backends[key]->name();
} }
QString item = QInputDialog::getItem(this, tr("Change backend..."), tr("Change backend:"), items, current, false); QString item = QInputDialog::getItem(this, tr("Change backend..."), tr("Change backend:"), items, current, false);
// Switch backends
if (!item.isEmpty()) { if (!item.isEmpty()) {
Settings settings; Settings settings;
settings.beginGroup("PasswordManager"); settings.beginGroup("PasswordManager");
PasswordBackend* backend = 0; PasswordBackend* backend = 0;
foreach (const QString &key, backends.keys()) {
if (backends[key]->name() == item) { QHashIterator<QString, PasswordBackend*> i(backends);
backend = backends[key]; while (i.hasNext()) {
settings.setValue("Backend", key); i.next();
if (i.value()->name() == item) {
backend = i.value();
settings.setValue("Backend", i.key());
break; break;
} }
} }
@ -133,7 +138,8 @@ void AutoFillManager::changePasswordBackend()
if (backend) { if (backend) {
m_passwordManager->switchBackend(backend); m_passwordManager->switchBackend(backend);
ui->backendOptions->setVisible(backend); ui->backendOptions->setVisible(backend->hasSettings());
ui->currentBackend->setText(QString("<b>%1</b>").arg(backend->name()));
} }
} }