diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp index f396e840267..ab809806241 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp @@ -49,7 +49,8 @@ namespace QtWaylandClient { bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) { - Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { + const auto globals = display->globals(); + for (QWaylandDisplay::RegistryGlobal global : globals) { if (global.interface == QLatin1String("wl_shell")) { m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1); break; diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp index 410f2700129..4e25949fa30 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp @@ -51,7 +51,8 @@ namespace QtWaylandClient { bool QWaylandXdgShellV5Integration::initialize(QWaylandDisplay *display) { - Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { + const auto globals = display->globals(); + for (QWaylandDisplay::RegistryGlobal global : globals) { if (global.interface == QLatin1String("xdg_shell")) { m_xdgShell.reset(new QWaylandXdgShellV5(display->wl_registry(), global.id)); break; diff --git a/src/plugins/platforms/wayland/qwaylanddatasource.cpp b/src/plugins/platforms/wayland/qwaylanddatasource.cpp index 0c6ad50e4b7..ea76943a734 100644 --- a/src/plugins/platforms/wayland/qwaylanddatasource.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatasource.cpp @@ -60,7 +60,8 @@ QWaylandDataSource::QWaylandDataSource(QWaylandDataDeviceManager *dataDeviceMana { if (!mimeData) return; - Q_FOREACH (const QString &format, mimeData->formats()) { + const auto formats = mimeData->formats(); + for (const QString &format : formats) { offer(format); } } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index d0f98170201..41bdf6b056b 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -366,7 +366,7 @@ void QWaylandDisplay::registry_global_remove(uint32_t id) } } - foreach (QWaylandScreen *screen, mScreens) { + for (QWaylandScreen *screen : qAsConst(mScreens)) { if (screen->outputId() == id) { mScreens.removeOne(screen); QWindowSystemInterface::handleScreenRemoved(screen); diff --git a/src/plugins/platforms/wayland/qwaylandinputcontext.cpp b/src/plugins/platforms/wayland/qwaylandinputcontext.cpp index 1d34f06cc45..068c058e7a0 100644 --- a/src/plugins/platforms/wayland/qwaylandinputcontext.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputcontext.cpp @@ -221,11 +221,11 @@ void QWaylandTextInput::zwp_text_input_v2_leave(uint32_t serial, ::wl_surface *s void QWaylandTextInput::zwp_text_input_v2_modifiers_map(wl_array *map) { - QList modifiersMap = QByteArray::fromRawData(static_cast(map->data), map->size).split('\0'); + const QList modifiersMap = QByteArray::fromRawData(static_cast(map->data), map->size).split('\0'); m_modifiersMap.clear(); - Q_FOREACH (const QByteArray &modifier, modifiersMap) { + for (const QByteArray &modifier : modifiersMap) { if (modifier == "Shift") m_modifiersMap.append(Qt::ShiftModifier); else if (modifier == "Control") diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 8a580898d81..6ebc3bed748 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -1349,7 +1349,7 @@ bool QWaylandInputDevice::Touch::allTouchPointsReleased() void QWaylandInputDevice::Touch::releasePoints() { - Q_FOREACH (const QWindowSystemInterface::TouchPoint &previousPoint, mPrevTouchPoints) { + for (const QWindowSystemInterface::TouchPoint &previousPoint : qAsConst(mPrevTouchPoints)) { QWindowSystemInterface::TouchPoint tp = previousPoint; tp.state = Qt::TouchPointReleased; mTouchPoints.append(tp); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index ea2b50b4aea..e75aebd9e9a 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -421,7 +421,7 @@ void QWaylandIntegration::initializeShellIntegration() preferredShells << QLatin1String("wl-shell") << QLatin1String("ivi-shell"); } - Q_FOREACH (QString preferredShell, preferredShells) { + for (const QString &preferredShell : qAsConst(preferredShells)) { mShellIntegration.reset(createShellIntegration(preferredShell)); if (mShellIntegration) { qCDebug(lcQpaWayland, "Using the '%s' shell integration", qPrintable(preferredShell)); diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index d116a807bb9..e707968322d 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -175,7 +175,8 @@ QList QWaylandScreen::virtualSiblings() const void QWaylandScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) { - foreach (QWindow *window, QGuiApplication::allWindows()) { + const auto allWindows = QGuiApplication::allWindows(); + for (QWindow *window : allWindows) { QWaylandWindow *w = static_cast(window->handle()); if (w && w->waylandScreen() == this) w->setOrientationMask(mask); diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index c16d346eb3f..d768e7fc236 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -243,7 +243,8 @@ void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &) QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size) { - foreach (QWaylandShmBuffer *b, mBuffers) { + const auto copy = mBuffers; // remove when ported to vector + remove_if + for (QWaylandShmBuffer *b : copy) { if (!b->busy()) { if (b->size() == size) { return b; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 9bc400f8af8..c3bfdeaff5f 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -94,7 +94,8 @@ QWaylandWindow::~QWaylandWindow() reset(false); const QWindow *parent = window(); - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + const auto tlw = QGuiApplication::topLevelWindows(); + for (QWindow *w : tlw) { if (w->transientParent() == parent) QWindowSystemInterface::handleCloseEvent(w); } @@ -786,7 +787,7 @@ bool QWaylandWindow::createDecoration() } if (hadDecoration != (bool)mWindowDecoration) { - foreach (QWaylandSubSurface *subsurf, mChildren) { + for (QWaylandSubSurface *subsurf : qAsConst(mChildren)) { QPoint pos = subsurf->window()->geometry().topLeft(); QMargins m = frameMargins(); subsurf->set_position(pos.x() + m.left(), pos.y() + m.top()); diff --git a/src/plugins/platforms/wayland/shared/qwaylandinputmethodeventbuilder.cpp b/src/plugins/platforms/wayland/shared/qwaylandinputmethodeventbuilder.cpp index 88056637df9..526d0ef465e 100644 --- a/src/plugins/platforms/wayland/shared/qwaylandinputmethodeventbuilder.cpp +++ b/src/plugins/platforms/wayland/shared/qwaylandinputmethodeventbuilder.cpp @@ -157,7 +157,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant())); } - Q_FOREACH (const QInputMethodEvent::Attribute &attr, m_preeditStyles) { + for (const QInputMethodEvent::Attribute &attr : qAsConst(m_preeditStyles)) { int start = indexFromWayland(text, attr.start); int length = indexFromWayland(text, attr.start + attr.length) - start; attributes.append(QInputMethodEvent::Attribute(attr.type, start, length, attr.value)); diff --git a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp index 7f3dc5ad6bb..02bb5701cda 100644 --- a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp @@ -542,7 +542,7 @@ bool Scanner::process() if (hasEvents) { printf("\n"); - foreach (const WaylandEvent &e, interface.events) { + for (const WaylandEvent &e : interface.events) { printf(" void send_"); printEvent(e); printf(";\n"); @@ -563,7 +563,7 @@ bool Scanner::process() if (hasRequests) { printf("\n"); - foreach (const WaylandEvent &e, interface.requests) { + for (const WaylandEvent &e : interface.requests) { printf(" virtual void %s_", interfaceNameStripped); printEvent(e); printf(";\n"); @@ -826,7 +826,7 @@ bool Scanner::process() printf("\n"); printf(" };\n"); - foreach (const WaylandEvent &e, interface.requests) { + for (const WaylandEvent &e : interface.requests) { printf("\n"); printf(" void %s::%s_", interfaceName, interfaceNameStripped); printEvent(e, true); @@ -996,7 +996,7 @@ bool Scanner::process() if (!interface.requests.isEmpty()) { printf("\n"); - foreach (const WaylandEvent &e, interface.requests) { + for (const WaylandEvent &e : interface.requests) { const WaylandArgument *new_id = newIdArgument(e.arguments); QByteArray new_id_str = "void "; if (new_id) { @@ -1016,7 +1016,7 @@ bool Scanner::process() if (hasEvents) { printf("\n"); printf(" protected:\n"); - foreach (const WaylandEvent &e, interface.events) { + for (const WaylandEvent &e : interface.events) { printf(" virtual void %s_", interfaceNameStripped); printEvent(e); printf(";\n"); diff --git a/tests/auto/wayland/shared_old/mockcompositor.cpp b/tests/auto/wayland/shared_old/mockcompositor.cpp index 0dfaef5eaa6..f71a78102e9 100644 --- a/tests/auto/wayland/shared_old/mockcompositor.cpp +++ b/tests/auto/wayland/shared_old/mockcompositor.cpp @@ -221,8 +221,8 @@ QSharedPointer MockCompositor::surface() QSharedPointer result; lock(); { - QVector surfaces = m_compositor->surfaces(); - foreach (Impl::Surface *surface, surfaces) { + const QVector surfaces = m_compositor->surfaces(); + for (Impl::Surface *surface : surfaces) { // we don't want to mistake the cursor surface for a window surface if (surface->isMapped()) { result = surface->mockSurface();