diff --git a/src/kactioncollection.cpp b/src/kactioncollection.cpp --- a/src/kactioncollection.cpp +++ b/src/kactioncollection.cpp @@ -224,20 +224,22 @@ const QList< QAction * > KActionCollection::actionsWithoutGroup() const { QList ret; - Q_FOREACH (QAction *action, d->actions) + for (QAction *action : qAsConst(d->actions)) { if (!action->actionGroup()) { ret.append(action); } + } return ret; } const QList< QActionGroup * > KActionCollection::actionGroups() const { QSet set; - Q_FOREACH (QAction *action, d->actions) + for (QAction *action : qAsConst(d->actions)) { if (action->actionGroup()) { set.insert(action->actionGroup()); } + } return set.toList(); } @@ -321,7 +323,7 @@ d->actionByName.insert(indexName, action); d->actions.append(action); - Q_FOREACH (QWidget *widget, d->associatedWidgets) { + for (QWidget *widget : qAsConst(d->associatedWidgets)) { widget->addAction(action); } @@ -362,7 +364,7 @@ } // Remove the action from all widgets - Q_FOREACH (QWidget *widget, d->associatedWidgets) { + for (QWidget *widget : qAsConst(d->associatedWidgets)) { widget->removeAction(action); } @@ -859,10 +861,12 @@ void KActionCollection::clearAssociatedWidgets() { - Q_FOREACH (QWidget *widget, d->associatedWidgets) - Q_FOREACH (QAction *action, actions()) { + for (QWidget *widget : qAsConst(d->associatedWidgets)) { + const auto actions = this->actions(); + for (QAction *action : actions) { widget->removeAction(action); } + } d->associatedWidgets.clear(); } diff --git a/src/kgesture.cpp b/src/kgesture.cpp --- a/src/kgesture.cpp +++ b/src/kgesture.cpp @@ -377,7 +377,7 @@ { uint hash = 0; - foreach (const QPoint &point, d->m_shape) { + for (const QPoint point : qAsConst(d->m_shape)) { hash += qHash(point.x()) + qHash(point.y()); } diff --git a/src/kkeysequencewidget.cpp b/src/kkeysequencewidget.cpp --- a/src/kkeysequencewidget.cpp +++ b/src/kkeysequencewidget.cpp @@ -389,15 +389,15 @@ { QSet changedCollections; - Q_FOREACH (QAction *stealAction, d->stealActions) { + for (QAction *stealAction : qAsConst(d->stealActions)) { // Stealing a shortcut means setting it to an empty one. stealAction->setShortcuts(QList()); // The following code will find the action we are about to // steal from and save it's actioncollection. KActionCollection *parentCollection = nullptr; - foreach (KActionCollection *collection, d->checkActionCollections) { + for (KActionCollection *collection : qAsConst(d->checkActionCollections)) { if (collection->actions().contains(stealAction)) { parentCollection = collection; break; @@ -544,7 +544,7 @@ // removed from the collection again. QList allActions; allActions += checkList; - foreach (KActionCollection *collection, checkActionCollections) { + for (KActionCollection *collection : qAsConst(checkActionCollections)) { allActions += collection->actions(); } diff --git a/src/kshortcutsdialog.cpp b/src/kshortcutsdialog.cpp --- a/src/kshortcutsdialog.cpp +++ b/src/kshortcutsdialog.cpp @@ -91,7 +91,7 @@ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_keyChooser->clearCollections(); - foreach (KActionCollection *collection, m_collections) { + for (KActionCollection *collection : qAsConst(m_collections)) { // passing an empty stream forces the clients to reread the XML KXMLGUIClient *client = const_cast(collection->parentGUIClient()); if (client) { @@ -110,7 +110,7 @@ } } - foreach (KActionCollection *collection, m_collections) { + for (KActionCollection *collection : qAsConst(m_collections)) { m_keyChooser->addCollection(collection); } diff --git a/src/kshortcutseditor.cpp b/src/kshortcutseditor.cpp --- a/src/kshortcutseditor.cpp +++ b/src/kshortcutseditor.cpp @@ -195,22 +195,22 @@ if (d->actionTypes & KShortcutsEditor::GlobalAction) { QString groupName(QStringLiteral("Global Shortcuts")); KConfigGroup group(config, groupName); - foreach (KActionCollection *collection, d->actionCollections) { + for (KActionCollection *collection : qAsConst(d->actionCollections)) { collection->exportGlobalShortcuts(&group, true); } } if (d->actionTypes & ~KShortcutsEditor::GlobalAction) { QString groupName(QStringLiteral("Shortcuts")); KConfigGroup group(config, groupName); - foreach (KActionCollection *collection, d->actionCollections) { + for (KActionCollection *collection : qAsConst(d->actionCollections)) { collection->writeSettings(&group, true); } } } void KShortcutsEditor::writeConfiguration(KConfigGroup *config) const { - foreach (KActionCollection *collection, d->actionCollections) { + for (KActionCollection *collection : qAsConst(d->actionCollections)) { collection->writeSettings(config); } } diff --git a/src/ktoolbar.cpp b/src/ktoolbar.cpp --- a/src/ktoolbar.cpp +++ b/src/ktoolbar.cpp @@ -577,7 +577,7 @@ QAction *KToolBar::Private::findAction(const QString &actionName, KXMLGUIClient **clientOut) const { - Q_FOREACH (KXMLGUIClient *client, xmlguiClients) { + for (KXMLGUIClient *client : xmlguiClients) { QAction *action = client->actionCollection()->action(actionName); if (action) { if (clientOut) { diff --git a/src/ktoolbarhandler.cpp b/src/ktoolbarhandler.cpp --- a/src/ktoolbarhandler.cpp +++ b/src/ktoolbarhandler.cpp @@ -103,7 +103,7 @@ KActionMenu *menuAction = new KActionMenu(i18n("Toolbars Shown"), m_actionCollection); m_actionCollection->addAction(QStringLiteral("toolbars_submenu_action"), menuAction); - Q_FOREACH (QAction *action, m_toolBarActions) { + for (QAction *action : qAsConst(m_toolBarActions)) { menuAction->menu()->addAction(action); } @@ -185,7 +185,7 @@ void ToolBarHandler::Private::connectToActionContainers() { - Q_FOREACH (QAction *action, actions) { + for (QAction *action : qAsConst(actions)) { connectToActionContainer(action); } } diff --git a/src/kxmlguiclient.cpp b/src/kxmlguiclient.cpp --- a/src/kxmlguiclient.cpp +++ b/src/kxmlguiclient.cpp @@ -101,7 +101,7 @@ d->m_factory->forgetClient(this); } - Q_FOREACH (KXMLGUIClient *client, d->m_children) { + for (KXMLGUIClient *client : qAsConst(d->m_children)) { if (d->m_factory) { d->m_factory->forgetClient(client); } @@ -117,7 +117,7 @@ { QAction *act = actionCollection()->action(QLatin1String(name)); if (!act) { - Q_FOREACH (KXMLGUIClient *client, d->m_children) { + for (KXMLGUIClient *client : qAsConst(d->m_children)) { act = client->actionCollection()->action(QLatin1String(name)); if (act) { break; @@ -786,7 +786,7 @@ void KXMLGUIClient::beginXMLPlug(QWidget *w) { actionCollection()->addAssociatedWidget(w); - foreach (KXMLGUIClient *client, d->m_children) { + for (KXMLGUIClient *client : qAsConst(d->m_children)) { client->beginXMLPlug(w); } } @@ -798,7 +798,7 @@ void KXMLGUIClient::prepareXMLUnplug(QWidget *w) { actionCollection()->removeAssociatedWidget(w); - foreach (KXMLGUIClient *client, d->m_children) { + for (KXMLGUIClient *client : qAsConst(d->m_children)) { client->prepareXMLUnplug(w); } } diff --git a/src/kxmlguifactory.cpp b/src/kxmlguifactory.cpp --- a/src/kxmlguifactory.cpp +++ b/src/kxmlguifactory.cpp @@ -195,7 +195,7 @@ KXMLGUIFactory::~KXMLGUIFactory() { - Q_FOREACH (KXMLGUIClient *client, d->m_clients) { + for (KXMLGUIClient *client : qAsConst(d->m_clients)) { client->setFactory(nullptr); } delete d; @@ -526,7 +526,7 @@ return node->container; } - Q_FOREACH (ContainerNode *child, node->children) { + for (ContainerNode *child : qAsConst(node->children)) { QWidget *cont = findRecursive(child, tag); if (cont) { return cont; @@ -555,7 +555,7 @@ res.append(node->container); } - Q_FOREACH (KXMLGUI::ContainerNode *child, node->children) { + for (KXMLGUI::ContainerNode *child : qAsConst(node->children)) { res << findRecursive(child, tagName); } @@ -726,7 +726,7 @@ KShortcutsDialog dlg(KShortcutsEditor::AllActions, letterCutsOk ? KShortcutsEditor::LetterShortcutsAllowed : KShortcutsEditor::LetterShortcutsDisallowed, qobject_cast(parent())); - Q_FOREACH (KXMLGUIClient *client, d->m_clients) { + for (KXMLGUIClient *client : qAsConst(d->m_clients)) { if (client) { qCDebug(DEBUG_KXMLGUI) << "Adding collection from client" << client->componentName() << "with" << client->actionCollection()->count() << "actions"; dlg.addCollection(client->actionCollection()); diff --git a/src/kxmlguifactory_p.cpp b/src/kxmlguifactory_p.cpp --- a/src/kxmlguifactory_p.cpp +++ b/src/kxmlguifactory_p.cpp @@ -41,7 +41,7 @@ before = container->actions().at(index); // Insert before indexed action. } - Q_FOREACH (QAction *action, *this) { + for (QAction *action : *this) { container->insertAction(before, action); // before = action; // BUG FIX: do not insert actions in reverse order. } @@ -104,7 +104,7 @@ return this; } - Q_FOREACH (ContainerNode *child, children) { + for (ContainerNode *child : qAsConst(children)) { ContainerNode *res = child->findContainer(_name, tag); if (res) { return res; @@ -170,7 +170,7 @@ const MergingIndexList::iterator &mergingIdx) { if (!clients.isEmpty()) { - Q_FOREACH (ContainerClient *client, clients) + for (ContainerClient *client : qAsConst(clients)) { if (client->client == currentGUIClient) { if (groupName.isEmpty()) { return client; @@ -180,6 +180,7 @@ return client; } } + } } ContainerClient *client = new ContainerClient; @@ -426,7 +427,7 @@ void ContainerNode::reset() { - Q_FOREACH (ContainerNode *child, children) { + for (ContainerNode *child : qAsConst(children)) { child->reset(); } @@ -461,7 +462,7 @@ { QString indent; indent.fill(QLatin1Char(' '), offset); qCDebug(DEBUG_KXMLGUI) << qPrintable(indent) << name << tagName << groupName << mergingName << mergingIndices; - Q_FOREACH (ContainerNode *child, children) { + for (ContainerNode *child : qAsConst(children)) { child->dump(offset + 2); } }