diff options
author | Ahmad Samir <[email protected]> | 2023-08-13 01:05:06 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2023-10-08 17:17:33 +0000 |
commit | 26c3a2fd791683e11515d597c735fffd1ed0216a (patch) | |
tree | 78a6b5d887a8ccba70ba8df943ce65549231bd78 | |
parent | fcb2ba3d984d2aac7861d99b06d86d8c1ed66060 (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.5
Task-number: QTBUG-115803
Change-Id: I9cfc0c95865cbc7415dbecc82388c64c65ded4be
Reviewed-by: Christian Ehrlicher <[email protected]>
(cherry picked from commit 641bccce2a80b2a7268c3b8409bdc957b9a510b5)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r-- | src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 7b2e3fe734a..7b823b0cc18 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -459,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, @@ -496,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; @@ -532,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, ""); } @@ -1153,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; @@ -2554,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: |