diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053f00) # Subdirectories add_definitions(-DTRANSLATION_DOMAIN=\"kxmlgui5\") +add_definitions(-DQT_NO_FOREACH) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() diff --git a/src/kaboutapplicationpersonlistdelegate_p.cpp b/src/kaboutapplicationpersonlistdelegate_p.cpp --- a/src/kaboutapplicationpersonlistdelegate_p.cpp +++ b/src/kaboutapplicationpersonlistdelegate_p.cpp @@ -154,7 +154,8 @@ socialLinks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); int currentSocialLinkAction = 0; - Q_FOREACH (KAboutApplicationPersonProfileOcsLink link, profile.ocsLinks()) { + const auto links = profile.ocsLinks(); + for (const KAboutApplicationPersonProfileOcsLink &link : links) { if (!profile.homepage().isEmpty() && profile.homepage() == link.url()) { continue; //We skip it if it's the same as the homepage from KAboutData } diff --git a/src/kkeysequencewidget.cpp b/src/kkeysequencewidget.cpp --- a/src/kkeysequencewidget.cpp +++ b/src/kkeysequencewidget.cpp @@ -591,7 +591,7 @@ stealActions = conflictingActions; // Announce that the user // agreed - Q_FOREACH (QAction *stealAction, stealActions) { + for (QAction *stealAction : qAsConst(stealActions)) { emit q->stealShortcut( keySequence, stealAction); diff --git a/src/kmainwindow.cpp b/src/kmainwindow.cpp --- a/src/kmainwindow.cpp +++ b/src/kmainwindow.cpp @@ -913,7 +913,8 @@ { QList ret; - foreach (QObject *child, children()) + const auto theChildren = children(); + for (QObject *child : theChildren) if (KToolBar *toolBar = qobject_cast(child)) { ret.append(toolBar); } diff --git a/src/ktoolbar.cpp b/src/ktoolbar.cpp --- a/src/ktoolbar.cpp +++ b/src/ktoolbar.cpp @@ -1188,7 +1188,7 @@ void KToolBar::dropEvent(QDropEvent *event) { if (toolBarsEditable()) { - Q_FOREACH (QAction *action, d->actionsBeingDragged) { + for (QAction *action : qAsConst(d->actionsBeingDragged)) { if (actions().contains(action)) { removeAction(action); } diff --git a/src/ktoolbarhandler.cpp b/src/ktoolbarhandler.cpp --- a/src/ktoolbarhandler.cpp +++ b/src/ktoolbarhandler.cpp @@ -86,7 +86,7 @@ return actions; } - Q_FOREACH (KToolBar *bar, m_toolBars) { + for (KToolBar *bar : qAsConst(m_toolBars)) { handleToolBar(bar); } diff --git a/src/kxmlguifactory.cpp b/src/kxmlguifactory.cpp --- a/src/kxmlguifactory.cpp +++ b/src/kxmlguifactory.cpp @@ -307,7 +307,7 @@ void KXMLGUIFactory::refreshActionProperties() { - Q_FOREACH (KXMLGUIClient *client, d->m_clients) { + for (KXMLGUIClient *client : qAsConst(d->m_clients)) { d->guiClient = client; QDomDocument doc = client->xmlguiBuildDocument(); if (doc.documentElement().isNull()) { diff --git a/src/kxmlguifactory_p.cpp b/src/kxmlguifactory_p.cpp --- a/src/kxmlguifactory_p.cpp +++ b/src/kxmlguifactory_p.cpp @@ -204,7 +204,7 @@ plugActionList(state, mIt); } - Q_FOREACH (ContainerNode *child, children) { + for (ContainerNode *child : qAsConst(children)) { child->plugActionList(state); } } @@ -244,7 +244,7 @@ unplugActionList(state, mIt); } - Q_FOREACH (ContainerNode *child, children) { + for (ContainerNode *child : qAsConst(children)) { child->unplugActionList(state); } }