From 81c648590e90bfea41162a3f2e1721ce68d873e1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 May 2020 15:50:33 +0200 Subject: [PATCH] QGraphicsAnchorLayout: rename AnchorData::{orientation -> isVertical} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That's basically what it is, and we don't want to extent the storage from one to two bits when porting QGraphicsAnchorLayoutPrivate::Orientation to Qt::Orientation later on. Change-Id: I965164141e8d08dbf190e2cd71d9bb7a272b1fda Reviewed-by: Jan Arve Sæther --- .../graphicsview/qgraphicsanchorlayout_p.cpp | 15 ++++++++------- .../graphicsview/qgraphicsanchorlayout_p.h | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 999561a497..78549e4c24 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -193,7 +193,7 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) maxPrefSize = maxSize; return; } else { - if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) { + if (!isVertical) { policy = item->sizePolicy().horizontalPolicy(); minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width(); prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width(); @@ -673,7 +673,7 @@ Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge) */ AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible) { - Orientation orientation = Orientation(newAnchor->orientation); + Orientation orientation = newAnchor->isVertical ? Vertical : Horizontal; Graph &g = graph[orientation]; *feasible = true; @@ -1184,6 +1184,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) { + const Orientation orientation = edge->isVertical ? Vertical : Horizontal; #if 0 static const char *anchortypes[] = {"Normal", "Sequential", @@ -1191,7 +1192,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) qDebug("Restoring %s edge.", anchortypes[int(edge->type)]); #endif - Graph &g = graph[edge->orientation]; + Graph &g = graph[orientation]; if (edge->type == AnchorData::Normal) { g.createEdge(edge->from, edge->to, edge); @@ -1211,7 +1212,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) // Skip parallel anchors that were created by vertex simplification, they will be processed // later, when restoring vertex simplification. // ### we could improve this check bit having a bit inside 'edge' - if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge)) + if (anchorsFromSimplifiedVertices[orientation].contains(edge)) return; ParallelAnchorData* parallel = static_cast(edge); @@ -1745,7 +1746,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt if (firstItem == secondItem) data->item = firstItem; - data->orientation = orientation; + data->isVertical = orientation == Vertical; // Create a bi-directional edge in the sense it can be transversed both // from v1 or v2. "data" however is shared between the two references @@ -2402,7 +2403,7 @@ QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin // Look for the layout edge. That can be either the first half in case the // layout is split in two, or the whole layout anchor. - Orientation orient = Orientation(anchors.first()->orientation); + Orientation orient = anchors.first()->isVertical ? Vertical : Horizontal; AnchorData *layoutEdge = nullptr; if (layoutCentralVertex[orient]) { layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]); @@ -2756,7 +2757,7 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation( */ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge) { - const Orientation orientation = Orientation(edge->orientation); + const Orientation orientation = edge->isVertical ? Vertical : Horizontal; const QPair factor(interpolationInterval[orientation], interpolationProgress[orientation]); diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index b5f14948ac..e3f1d139b9 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -129,7 +129,7 @@ struct AnchorData : public QSimplexVariable { sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0), item(nullptr), graphicsAnchor(nullptr), type(Normal), isLayoutAnchor(false), - isCenterAnchor(false), orientation(0), + isCenterAnchor(false), isVertical(false), dependency(Independent) {} virtual ~AnchorData(); @@ -176,7 +176,7 @@ struct AnchorData : public QSimplexVariable { uint type : 2; // either Normal, Sequential or Parallel uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor uint isCenterAnchor : 1; - uint orientation : 1; + uint isVertical : 1; uint dependency : 2; // either Independent, Master or Slave }; @@ -193,7 +193,7 @@ struct SequentialAnchorData : public AnchorData : AnchorData(), m_children(vertices), m_edges(edges) { type = AnchorData::Sequential; - orientation = m_edges.at(0)->orientation; + isVertical = m_edges.at(0)->isVertical; #ifdef QT_DEBUG name = QString::fromLatin1("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString()); #endif @@ -212,7 +212,7 @@ struct ParallelAnchorData : public AnchorData : AnchorData(), firstEdge(first), secondEdge(second) { type = AnchorData::Parallel; - orientation = first->orientation; + isVertical = first->isVertical; // This assert whether the child anchors share their vertices Q_ASSERT(((first->from == second->from) && (first->to == second->to)) ||