tst_Gestures: compile with QT_NO_FOREACH [2/2]

The loops are iterating over local const containers, so use ranged-for.

Remove '#undef QT_NO_FOREACH'.

Task-number: QTBUG-115839
Change-Id: I252f048e3c469bf9bb34cb0756ccbd57571fd886
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Ahmad Samir 2023-10-08 18:19:23 +03:00
parent e48e2b3b4a
commit 042c38379f

View File

@ -1,8 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QTest>
#include <QtTest/qtesttouch.h>
@ -220,8 +218,8 @@ protected:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
QList<QGesture*> gestures = e->gestures();
foreach(QGesture *g, gestures) {
const QList<QGesture*> gestures = e->gestures();
for (QGesture *g : gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
case Qt::GestureStarted:
@ -746,7 +744,8 @@ public:
QGestureEvent *e = static_cast<QGestureEvent *>(event);
for (Qt::GestureType type : std::as_const(ignoredGestures))
e->ignore(e->gesture(type));
foreach(QGesture *g, e->gestures()) {
const auto gestures = e->gestures();
for (QGesture *g : gestures) {
switch (g->state()) {
case Qt::GestureStarted:
if (ignoredStartedGestures.contains(g->gestureType()))
@ -772,8 +771,8 @@ public:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
QList<QGesture*> gestures = e->gestures();
foreach(QGesture *g, gestures) {
const QList<QGesture*> gestures = e->gestures();
for (QGesture *g : gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
case Qt::GestureStarted: