From 40c06eaaaed78624b2b15983d9fcb2f31bd939ce Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Mon, 30 Dec 2019 19:16:12 +0100 Subject: [PATCH] autofill: port foreach -> range-based for Signed-off-by: Juraj Oravec --- src/lib/autofill/autofill.cpp | 9 +++++---- .../databaseencryptedpasswordbackend.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index 9571d405e..470295dc1 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -188,7 +188,7 @@ void AutoFill::saveForm(WebPage *page, const QUrl &frameUrl, const PageFormData if (isStored(frameUrl)) { const QVector &list = getFormData(frameUrl); - foreach (const PasswordEntry &data, list) { + for (const PasswordEntry &data : list) { if (data.username == formData.username) { updateData = data; updateLastUsed(updateData); @@ -256,9 +256,9 @@ QByteArray AutoFill::exportPasswords() stream.writeStartElement(QStringLiteral("passwords")); stream.writeAttribute(QStringLiteral("version"), QStringLiteral("1.0")); - QVector entries = m_manager->getAllEntries(); + const QVector entries = m_manager->getAllEntries(); - foreach (const PasswordEntry &entry, entries) { + for (const PasswordEntry &entry : entries) { stream.writeStartElement(QStringLiteral("entry")); stream.writeTextElement(QStringLiteral("server"), entry.host); stream.writeTextElement(QStringLiteral("username"), entry.username); @@ -318,7 +318,8 @@ bool AutoFill::importPasswords(const QByteArray &data) if (entry.isValid()) { bool containsEntry = false; - foreach (const PasswordEntry &e, m_manager->getEntries(QUrl(entry.host))) { + const auto entries = m_manager->getEntries(QUrl(entry.host)); + for (const PasswordEntry &e : entries) { if (e.username == entry.username) { containsEntry = true; break; diff --git a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp index 68053a2a1..6b2719497 100644 --- a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp +++ b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp @@ -609,17 +609,17 @@ void MasterPasswordDialog::clearMasterPasswordAndConvert(bool forcedAskPass) } if (m_backend->hasPermission()) { - QVector list = m_backend->getAllEntries(); + const QVector list = m_backend->getAllEntries(); PasswordBackend* databaseBackend = mApp->autoFill()->passwordManager()->availableBackends().value(QSL("database")); if (!databaseBackend) { return; } - QVector databaseList = databaseBackend->getAllEntries(); + const QVector databaseList = databaseBackend->getAllEntries(); bool allDataMoved = true; - foreach (const PasswordEntry &entry, list) { + for (const PasswordEntry &entry : list) { bool sameEntry = false; - foreach (const PasswordEntry &dbEntry, databaseList) { + for (const PasswordEntry &dbEntry : databaseList) { sameEntry = samePasswordEntry(dbEntry, entry); if (sameEntry) { allDataMoved = false;