summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-08-13 01:05:06 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-10-08 17:54:54 +0300
commit641bccce2a80b2a7268c3b8409bdc957b9a510b5 (patch)
treea9660433568d236ba507f91b96691ab36668641c /src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
parent4f1bb8ee40f2245375ee2afef0e45cc766fcd2d4 (diff)
QGraphicsAnchorLayout: compile with QT_NO_FOREACH
The m_edges container isn't changed after it's initialized in the constructor (in a later commit I'll make this container const, so as to keep this commit backport-able), and it isn't changed by the loop. Port all loops over m_edges to ranged-for. Remove "#undef QT_NO_FOREACH" from the source file, as that was the only usage of foreach in it. And remove that source file from NO_PCH_SOURCES. Pick-to: 6.6 6.5 Task-number: QTBUG-115803 Change-Id: I9cfc0c95865cbc7415dbecc82388c64c65ded4be Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index fdf98ab4cd..7b823b0cc1 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1,8 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
-
#include "qgraphicsanchorlayout_p.h"
#include <QtWidgets/qwidget.h>
@@ -461,9 +459,7 @@ void SequentialAnchorData::updateChildrenSizes()
// "from" or "to", that _contains_ one of them.
AnchorVertex *prev = from;
- for (int i = 0; i < m_edges.size(); ++i) {
- AnchorData *e = m_edges.at(i);
-
+ for (AnchorData *e : std::as_const(m_edges)) {
const bool edgeIsForward = (e->from == prev);
if (edgeIsForward) {
e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize,
@@ -498,9 +494,7 @@ void SequentialAnchorData::calculateSizeHints()
AnchorVertex *prev = from;
- for (int i = 0; i < m_edges.size(); ++i) {
- AnchorData *edge = m_edges.at(i);
-
+ for (AnchorData *edge : std::as_const(m_edges)) {
const bool edgeIsForward = (edge->from == prev);
if (edgeIsForward) {
minSize += edge->minSize;
@@ -534,12 +528,10 @@ void AnchorData::dump(int indent) {
p->firstEdge->dump(indent+2);
p->secondEdge->dump(indent+2);
} else if (type == Sequential) {
- SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this);
- int kids = s->m_edges.count();
- qDebug("%*s type: sequential(%d):", indent, "", kids);
- for (int i = 0; i < kids; ++i) {
- s->m_edges.at(i)->dump(indent+2);
- }
+ const auto *s = static_cast<SequentialAnchorData *>(this);
+ qDebug("%*s type: sequential(%lld):", indent, "", s->m_edges.size());
+ for (AnchorData *e : s->m_edges)
+ e->dump(indent + 2);
} else {
qDebug("%*s type: Normal:", indent, "");
}
@@ -1155,12 +1147,10 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
g.createEdge(edge->from, edge->to, edge);
} else if (edge->type == AnchorData::Sequential) {
- SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge);
+ const auto *sequence = static_cast<SequentialAnchorData *>(edge);
- for (int i = 0; i < sequence->m_edges.size(); ++i) {
- AnchorData *data = sequence->m_edges.at(i);
+ for (AnchorData *data : sequence->m_edges)
restoreSimplifiedAnchor(data);
- }
delete sequence;
@@ -2556,7 +2546,7 @@ void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData
nonFloatingItemsIdentifiedSoFar->insert(ad->item);
break;
case AnchorData::Sequential:
- foreach (const AnchorData *d, static_cast<const SequentialAnchorData *>(ad)->m_edges)
+ for (const AnchorData *d : static_cast<const SequentialAnchorData *>(ad)->m_edges)
identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar);
break;
case AnchorData::Parallel: