From f02cb62b7b3cd47320347bfd8cba03145ac87fdb Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Mon, 30 Dec 2019 20:25:31 +0100 Subject: [PATCH] plugins: port foreach -> range-based for Signed-off-by: Juraj Oravec --- src/lib/plugins/pluginproxy.cpp | 20 ++++++++++---------- src/lib/plugins/plugins.cpp | 6 +++--- src/lib/plugins/speeddial.cpp | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/plugins/pluginproxy.cpp b/src/lib/plugins/pluginproxy.cpp index 6f6a5df05..3eb8f5121 100644 --- a/src/lib/plugins/pluginproxy.cpp +++ b/src/lib/plugins/pluginproxy.cpp @@ -96,7 +96,7 @@ void PluginProxy::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTe return; } - foreach (PluginInterface* iPlugin, m_loadedPlugins) { + for (PluginInterface* iPlugin : qAsConst(m_loadedPlugins)) { iPlugin->populateWebViewMenu(menu, view, r); } } @@ -107,7 +107,7 @@ void PluginProxy::populateExtensionsMenu(QMenu *menu) return; } - foreach (PluginInterface* iPlugin, m_loadedPlugins) { + for (PluginInterface* iPlugin : qAsConst(m_loadedPlugins)) { iPlugin->populateExtensionsMenu(menu); } } @@ -116,7 +116,7 @@ bool PluginProxy::processMouseDoubleClick(Qz::ObjectName type, QObject* obj, QMo { bool accepted = false; - foreach (PluginInterface* iPlugin, m_mouseDoubleClickHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_mouseDoubleClickHandlers)) { if (iPlugin->mouseDoubleClick(type, obj, event)) { accepted = true; } @@ -129,7 +129,7 @@ bool PluginProxy::processMousePress(Qz::ObjectName type, QObject* obj, QMouseEve { bool accepted = false; - foreach (PluginInterface* iPlugin, m_mousePressHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_mousePressHandlers)) { if (iPlugin->mousePress(type, obj, event)) { accepted = true; } @@ -142,7 +142,7 @@ bool PluginProxy::processMouseRelease(Qz::ObjectName type, QObject* obj, QMouseE { bool accepted = false; - foreach (PluginInterface* iPlugin, m_mouseReleaseHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_mouseReleaseHandlers)) { if (iPlugin->mouseRelease(type, obj, event)) { accepted = true; } @@ -155,7 +155,7 @@ bool PluginProxy::processMouseMove(Qz::ObjectName type, QObject* obj, QMouseEven { bool accepted = false; - foreach (PluginInterface* iPlugin, m_mouseMoveHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_mouseMoveHandlers)) { if (iPlugin->mouseMove(type, obj, event)) { accepted = true; } @@ -168,7 +168,7 @@ bool PluginProxy::processWheelEvent(Qz::ObjectName type, QObject* obj, QWheelEve { bool accepted = false; - foreach (PluginInterface* iPlugin, m_wheelEventHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_wheelEventHandlers)) { if (iPlugin->wheelEvent(type, obj, event)) { accepted = true; } @@ -181,7 +181,7 @@ bool PluginProxy::processKeyPress(Qz::ObjectName type, QObject* obj, QKeyEvent* { bool accepted = false; - foreach (PluginInterface* iPlugin, m_keyPressHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_keyPressHandlers)) { if (iPlugin->keyPress(type, obj, event)) { accepted = true; } @@ -194,7 +194,7 @@ bool PluginProxy::processKeyRelease(Qz::ObjectName type, QObject* obj, QKeyEvent { bool accepted = false; - foreach (PluginInterface* iPlugin, m_keyReleaseHandlers) { + for (PluginInterface* iPlugin : qAsConst(m_keyReleaseHandlers)) { if (iPlugin->keyRelease(type, obj, event)) { accepted = true; } @@ -207,7 +207,7 @@ bool PluginProxy::acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEn { bool accepted = true; - foreach (PluginInterface* iPlugin, m_loadedPlugins) { + for (PluginInterface* iPlugin : qAsConst(m_loadedPlugins)) { if (!iPlugin->acceptNavigationRequest(page, url, type, isMainFrame)) { accepted = false; } diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 6124eb16b..867745050 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -165,7 +165,7 @@ void Plugins::loadSettings() void Plugins::shutdown() { - foreach (PluginInterface* iPlugin, m_loadedPlugins) { + for (PluginInterface* iPlugin : qAsConst(m_loadedPlugins)) { iPlugin->unload(); } } @@ -227,7 +227,7 @@ void Plugins::loadPlugins() settingsDir.mkdir(settingsDir.absolutePath()); } - foreach (const QString &pluginId, m_allowedPlugins) { + for (const QString &pluginId : qAsConst(m_allowedPlugins)) { Plugin plugin = loadPlugin(pluginId); if (plugin.type == Plugin::Invalid) { continue; @@ -307,7 +307,7 @@ void Plugins::refreshLoadedPlugins() { m_loadedPlugins.clear(); - foreach (const Plugin &plugin, m_availablePlugins) { + for (const Plugin &plugin : qAsConst(m_availablePlugins)) { if (plugin.isLoaded()) { m_loadedPlugins.append(plugin.instance); } diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp index 5e7a4dc71..f1c3ed4f5 100644 --- a/src/lib/plugins/speeddial.cpp +++ b/src/lib/plugins/speeddial.cpp @@ -96,7 +96,7 @@ SpeedDial::Page SpeedDial::pageForUrl(const QUrl &url) if (urlString.endsWith(QL1C('/'))) urlString = urlString.left(urlString.size() - 1); - foreach (const Page &page, m_pages) { + for (const Page &page : qAsConst(m_pages)) { if (page.url == urlString) { return page; } @@ -202,7 +202,7 @@ QString SpeedDial::initialScript() QVariantList pages; - foreach (const Page &page, m_pages) { + for (const Page &page : qAsConst(m_pages)) { QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(page.url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png"; if (!QFile(imgSource).exists()) { @@ -232,7 +232,7 @@ void SpeedDial::changed(const QString &allPages) const QStringList entries = allPages.split(QLatin1String("\";"), QString::SkipEmptyParts); m_pages.clear(); - foreach (const QString &entry, entries) { + for (const QString &entry : entries) { if (entry.isEmpty()) { continue; } @@ -369,7 +369,7 @@ QString SpeedDial::generateAllPages() { QString allPages; - foreach (const Page &page, m_pages) { + for (const Page &page : qAsConst(m_pages)) { const QString string = QString("url:\"%1\"|title:\"%2\";").arg(page.url, page.title); allPages.append(string); }