From 90181a060630e5105288f0f4f773b606e0d353f0 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Sat, 24 Sep 2022 11:25:15 +0200 Subject: [PATCH] Update loops in getSiteSettings method Signed-off-by: Juraj Oravec --- src/lib/other/sitesettingsmanager.cpp | 15 +++++++-------- src/lib/other/sitesettingsmanager.h | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lib/other/sitesettingsmanager.cpp b/src/lib/other/sitesettingsmanager.cpp index d51ef3d8c..28c4bd8c0 100644 --- a/src/lib/other/sitesettingsmanager.cpp +++ b/src/lib/other/sitesettingsmanager.cpp @@ -529,7 +529,7 @@ QList SiteSettingsManager::getSupportedFeatures() const SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url, bool privateMode) { SiteSettings siteSettings; - int i; + int index = 0; QSqlQuery query(SqlDatabase::instance()->database()); query.prepare(everythingSql.arg(sqlTable(privateMode))); @@ -538,17 +538,16 @@ SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url if (query.next()) { Permission perm; - for (i = 0; i < supportedAttribute.size(); ++i) { - perm = intToPermission(query.value(i).toInt()); + for (int i = 0; i < supportedAttribute.size(); ++i, ++index) { + perm = intToPermission(query.value(index).toInt()); siteSettings.attributes[supportedAttribute[i]] = perm; } - for (i = 0; i < supportedFeatures.size(); ++i) { - perm = intToPermission(query.value(i + supportedAttribute.size()).toInt()); + for (int i = 0; i < supportedFeatures.size(); ++i, ++index) { + perm = intToPermission(query.value(index).toInt()); siteSettings.features[supportedFeatures[i]] = perm; } - perm = intToPermission(query.value(supportedAttribute.size() + supportedFeatures.size()).toInt()); - siteSettings.AllowCookies = perm; - siteSettings.ZoomLevel = query.value(supportedAttribute.size() + supportedFeatures.size() + 1).toInt(); + siteSettings.AllowCookies = intToPermission(query.value(index++).toInt()); + siteSettings.ZoomLevel = query.value(index++).toInt(); } return siteSettings; diff --git a/src/lib/other/sitesettingsmanager.h b/src/lib/other/sitesettingsmanager.h index 48fa3ee34..716fd18e5 100644 --- a/src/lib/other/sitesettingsmanager.h +++ b/src/lib/other/sitesettingsmanager.h @@ -47,8 +47,8 @@ public: struct SiteSettings { - Permission AllowCookies; - int ZoomLevel; + Permission AllowCookies = Default; + int ZoomLevel = -1; QMap attributes; /* Enable disable soem feature eg. Javascript, Images etc */ QMap features; /* HTML permissions */ QString server;