diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${KRunner_AUTOMOC_MACRO_NAMES}) endif() add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) +add_definitions(-DQT_NO_FOREACH) # Subdirectories add_subdirectory(src) diff --git a/src/declarative/runnermodel.cpp b/src/declarative/runnermodel.cpp --- a/src/declarative/runnermodel.cpp +++ b/src/declarative/runnermodel.cpp @@ -147,8 +147,8 @@ } else if (role == Actions) { QVariantList actions; Plasma::QueryMatch amatch = m_matches.at(index.row()); - QList theactions = m_manager->actionsForMatch(amatch); - foreach(QAction* action, theactions) { + const QList theactions = m_manager->actionsForMatch(amatch); + for (QAction* action : theactions) { actions += qVariantFromValue(action); } return actions; diff --git a/src/runnercontext.cpp b/src/runnercontext.cpp --- a/src/runnercontext.cpp +++ b/src/runnercontext.cpp @@ -395,7 +395,7 @@ } LOCK_FOR_WRITE(d) - foreach (QueryMatch match, matches) { + for (QueryMatch match : matches) { // Give previously launched matches a slight boost in relevance // The boost smoothly saturates to 0.5; if (int count = d->launchCounts.value(match.id())) { @@ -454,7 +454,7 @@ QList presentMatchList; LOCK_FOR_READ(d) - foreach(const QString &matchId, matchIdList) { + for (const QString &matchId : matchIdList) { const QueryMatch* match = d->matchesById.value(matchId, nullptr); if (match) { presentMatchList << match; @@ -468,10 +468,10 @@ } LOCK_FOR_WRITE(d) - foreach(const QueryMatch *match, presentMatchList) { + for (const QueryMatch *match : qAsConst(presentMatchList)) { d->matches.removeAll(*match); } - foreach(const QString &matchId, presentMatchIdList) { + for (const QString &matchId : qAsConst(presentMatchIdList)) { d->matchesById.remove(matchId); } UNLOCK(d) @@ -510,7 +510,7 @@ QList presentMatchList; LOCK_FOR_READ(d) - foreach(const QueryMatch &match, d->matches) { + for(const QueryMatch &match : qAsConst(d->matches)) { if (match.runner() == runner) { presentMatchList << match; } @@ -522,7 +522,7 @@ } LOCK_FOR_WRITE(d) - foreach (const QueryMatch &match, presentMatchList) { + for (const QueryMatch &match : qAsConst(presentMatchList)) { d->matchesById.remove(match.id()); d->matches.removeAll(match); } @@ -568,7 +568,7 @@ const QStringList cfgList = config.readEntry("LaunchCounts", QStringList()); const QRegExp r(QStringLiteral("(\\d*) (.*)")); - foreach (const QString& entry, cfgList) { + for (const QString& entry : cfgList) { r.indexIn(entry); int count = r.cap(1).toInt(); QString id = r.cap(2); diff --git a/src/runnermanager.cpp b/src/runnermanager.cpp --- a/src/runnermanager.cpp +++ b/src/runnermanager.cpp @@ -363,7 +363,7 @@ if (searchJobs.isEmpty() && oldSearchJobs.isEmpty()) { if (allRunnersPrepped) { - foreach (AbstractRunner *runner, runners) { + for (AbstractRunner *runner : qAsConst(runners)) { emit runner->teardown(); } @@ -717,7 +717,7 @@ d->singleRunnerPrepped = true; } } else { - foreach (AbstractRunner *runner, d->runners) { + for (AbstractRunner *runner : qAsConst(d->runners)) { #ifdef MEASURE_PREPTIME QTime t; t.start(); @@ -794,7 +794,7 @@ runable = d->runners; } - foreach (Plasma::AbstractRunner *r, runable) { + for (Plasma::AbstractRunner *r : qAsConst(runable)) { if (r->isMatchingSuspended()) { continue; } diff --git a/src/runnersyntax.cpp b/src/runnersyntax.cpp --- a/src/runnersyntax.cpp +++ b/src/runnersyntax.cpp @@ -73,7 +73,7 @@ { QStringList queries; const QString termDesc(QLatin1Char('<') + searchTermDescription() + QLatin1Char('>')); - foreach (QString query, d->exampleQueries) { + for (QString query : qAsConst(d->exampleQueries)) { queries << query.replace(QStringLiteral(":q:"), termDesc); }