diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index d17f61077..69e019d6e 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -107,7 +107,7 @@ QString GM_Manager::requireScripts(const QStringList &urlList) const QString script; - foreach (const QString &url, urlList) { + for (const QString &url : urlList) { if (settings.contains(url)) { QString fileName = settings.value(url).toString(); if (!QFileInfo(fileName).isAbsolute()) { @@ -158,7 +158,7 @@ QList GM_Manager::allScripts() const bool GM_Manager::containsScript(const QString &fullName) const { - foreach (GM_Script* script, m_scripts) { + for (GM_Script* script : qAsConst(m_scripts)) { if (fullName == script->fullName()) { return true; } @@ -248,7 +248,8 @@ void GM_Manager::load() settings.beginGroup("GreaseMonkey"); m_disabledScripts = settings.value("disabledScripts", QStringList()).toStringList(); - foreach (const QString &fileName, gmDir.entryList(QStringList("*.js"), QDir::Files)) { + const auto fileNames = gmDir.entryList(QStringList("*.js"), QDir::Files); + for (const QString &fileName : fileNames) { const QString absolutePath = gmDir.absoluteFilePath(fileName); GM_Script* script = new GM_Script(this, absolutePath); diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 4ff73f473..a36180fd1 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -40,7 +40,8 @@ void GM_Plugin::init(InitState state, const QString &settingsPath) // Make sure userscripts works also with already created WebPages if (state == LateInitState) { - foreach (BrowserWindow *window, mApp->windows()) { + const auto windows = mApp->windows(); + for (BrowserWindow *window : windows) { m_manager->mainWindowCreated(window); } } diff --git a/src/plugins/GreaseMonkey/settings/gm_settings.cpp b/src/plugins/GreaseMonkey/settings/gm_settings.cpp index bf1162872..3d1685e6c 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settings.cpp +++ b/src/plugins/GreaseMonkey/settings/gm_settings.cpp @@ -152,7 +152,8 @@ void GM_Settings::loadScripts() ui->listWidget->clear(); - foreach (GM_Script* script, m_manager->allScripts()) { + const auto allScripts = m_manager->allScripts(); + for (GM_Script* script : allScripts) { QListWidgetItem* item = new QListWidgetItem(ui->listWidget); item->setText(script->name()); item->setIcon(script->icon());