From c1e70db731cb00aee304d1d5cebb4df2abfa98e1 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 19 May 2013 10:34:54 +0200 Subject: [PATCH] [PasswordManager] Small code cleanup. Use iterators for QHash --- src/lib/preferences/autofillmanager.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lib/preferences/autofillmanager.cpp b/src/lib/preferences/autofillmanager.cpp index c64f93e25..36d9fd7dd 100644 --- a/src/lib/preferences/autofillmanager.cpp +++ b/src/lib/preferences/autofillmanager.cpp @@ -106,25 +106,30 @@ void AutoFillManager::changePasswordBackend() int current = 0; - foreach (const QString &key, backends.keys()) { - if (backends[key] == m_passwordManager->activeBackend()) { + QHashIterator i(backends); + while (i.hasNext()) { + i.next(); + if (i.value() == m_passwordManager->activeBackend()) { current = items.size(); } - - items << backends[key]->name(); + items << i.value()->name(); } QString item = QInputDialog::getItem(this, tr("Change backend..."), tr("Change backend:"), items, current, false); + // Switch backends if (!item.isEmpty()) { Settings settings; settings.beginGroup("PasswordManager"); PasswordBackend* backend = 0; - foreach (const QString &key, backends.keys()) { - if (backends[key]->name() == item) { - backend = backends[key]; - settings.setValue("Backend", key); + + QHashIterator i(backends); + while (i.hasNext()) { + i.next(); + if (i.value()->name() == item) { + backend = i.value(); + settings.setValue("Backend", i.key()); break; } } @@ -133,7 +138,8 @@ void AutoFillManager::changePasswordBackend() if (backend) { m_passwordManager->switchBackend(backend); - ui->backendOptions->setVisible(backend); + ui->backendOptions->setVisible(backend->hasSettings()); + ui->currentBackend->setText(QString("%1").arg(backend->name())); } }