1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

GM: port foreach -> range-based for

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-12-30 17:05:24 +01:00
parent c9a6a51285
commit 9bcfeb3cd7
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07
3 changed files with 8 additions and 5 deletions

View File

@ -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_Script*> 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);

View File

@ -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);
}
}

View File

@ -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());