From cce946b3aad812634f7a680f38b6a7bcd424252f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 11 Aug 2023 01:22:02 +0300 Subject: [PATCH] QGestureManager: port FOREACH to ranged-for, local const QSets [4/6] Those QSetS are local to the function, make them const, proving that the loop bodies didn't change them, and the copy Q_FOREACH took wasn't needed. Task-number: QTBUG-115803 Change-Id: Iec2fc31fc060c59760a84dc45baf8fa16f62eb6d Reviewed-by: Marc Mutz --- src/widgets/kernel/qgesturemanager.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index d1a013914f..dc7a4bcb52 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -282,18 +282,18 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap startedGestures = triggeredGestures - m_activeGestures; + const QSet startedGestures = triggeredGestures - m_activeGestures; triggeredGestures &= m_activeGestures; // check if a running gesture switched back to maybe state - QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; + const QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; // check if a maybe gesture switched to canceled - reset it but don't send an event QSet maybeToCanceledGestures = m_maybeGestures & notGestures; // check if a running gesture switched back to not gesture state, // i.e. were canceled - QSet canceledGestures = m_activeGestures & notGestures; + const QSet canceledGestures = m_activeGestures & notGestures; // new gestures in maybe state m_maybeGestures += newMaybeGestures; @@ -311,11 +311,11 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap notStarted = finishedGestures - m_activeGestures; + const QSet notStarted = finishedGestures - m_activeGestures; if (!notStarted.isEmpty()) { // there are some gestures that claim to be finished, but never started. // probably those are "singleshot" gestures so we'll fake the started state. - foreach (QGesture *gesture, notStarted) + for (QGesture *gesture : notStarted) gesture->d_func()->state = Qt::GestureStarted; QSet undeliveredGestures; deliverEvents(notStarted, &undeliveredGestures); @@ -330,15 +330,15 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMapd_func()->state = Qt::GestureStarted; foreach (QGesture *gesture, triggeredGestures) gesture->d_func()->state = Qt::GestureUpdated; foreach (QGesture *gesture, finishedGestures) gesture->d_func()->state = Qt::GestureFinished; - foreach (QGesture *gesture, canceledGestures) + for (QGesture *gesture : canceledGestures) gesture->d_func()->state = Qt::GestureCanceled; - foreach (QGesture *gesture, activeToMaybeGestures) + for (QGesture *gesture : activeToMaybeGestures) gesture->d_func()->state = Qt::GestureFinished; if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || @@ -358,7 +358,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMapgestureCancelPolicy() == QGesture::CancelAllInContext) { @@ -371,9 +371,9 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap endedGestures = + const QSet endedGestures = finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; - foreach (QGesture *gesture, endedGestures) { + for (QGesture *gesture : endedGestures) { recycle(gesture); m_gestureTargets.remove(gesture); }