QGraphicsAnchorLayout: rename AnchorData::{orientation -> isVertical}

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 <jan-arve.saether@qt.io>
This commit is contained in:
Marc Mutz 2020-05-05 15:50:33 +02:00
parent 9a66dff369
commit 81c648590e
2 changed files with 12 additions and 11 deletions

View File

@ -193,7 +193,7 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
maxPrefSize = maxSize; maxPrefSize = maxSize;
return; return;
} else { } else {
if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) { if (!isVertical) {
policy = item->sizePolicy().horizontalPolicy(); policy = item->sizePolicy().horizontalPolicy();
minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width(); minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();
prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).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) AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)
{ {
Orientation orientation = Orientation(newAnchor->orientation); Orientation orientation = newAnchor->isVertical ? Vertical : Horizontal;
Graph<AnchorVertex, AnchorData> &g = graph[orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
*feasible = true; *feasible = true;
@ -1184,6 +1184,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
{ {
const Orientation orientation = edge->isVertical ? Vertical : Horizontal;
#if 0 #if 0
static const char *anchortypes[] = {"Normal", static const char *anchortypes[] = {"Normal",
"Sequential", "Sequential",
@ -1191,7 +1192,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
qDebug("Restoring %s edge.", anchortypes[int(edge->type)]); qDebug("Restoring %s edge.", anchortypes[int(edge->type)]);
#endif #endif
Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
if (edge->type == AnchorData::Normal) { if (edge->type == AnchorData::Normal) {
g.createEdge(edge->from, edge->to, edge); 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 // Skip parallel anchors that were created by vertex simplification, they will be processed
// later, when restoring vertex simplification. // later, when restoring vertex simplification.
// ### we could improve this check bit having a bit inside 'edge' // ### we could improve this check bit having a bit inside 'edge'
if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge)) if (anchorsFromSimplifiedVertices[orientation].contains(edge))
return; return;
ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge); ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge);
@ -1745,7 +1746,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt
if (firstItem == secondItem) if (firstItem == secondItem)
data->item = firstItem; data->item = firstItem;
data->orientation = orientation; data->isVertical = orientation == Vertical;
// Create a bi-directional edge in the sense it can be transversed both // 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 // from v1 or v2. "data" however is shared between the two references
@ -2402,7 +2403,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
// Look for the layout edge. That can be either the first half in case the // 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. // 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; AnchorData *layoutEdge = nullptr;
if (layoutCentralVertex[orient]) { if (layoutCentralVertex[orient]) {
layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]); layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);
@ -2756,7 +2757,7 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
*/ */
void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge) void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
{ {
const Orientation orientation = Orientation(edge->orientation); const Orientation orientation = edge->isVertical ? Vertical : Horizontal;
const QPair<Interval, qreal> factor(interpolationInterval[orientation], const QPair<Interval, qreal> factor(interpolationInterval[orientation],
interpolationProgress[orientation]); interpolationProgress[orientation]);

View File

@ -129,7 +129,7 @@ struct AnchorData : public QSimplexVariable {
sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMinimum(0), sizeAtPreferred(0),
sizeAtMaximum(0), item(nullptr), graphicsAnchor(nullptr), sizeAtMaximum(0), item(nullptr), graphicsAnchor(nullptr),
type(Normal), isLayoutAnchor(false), type(Normal), isLayoutAnchor(false),
isCenterAnchor(false), orientation(0), isCenterAnchor(false), isVertical(false),
dependency(Independent) {} dependency(Independent) {}
virtual ~AnchorData(); virtual ~AnchorData();
@ -176,7 +176,7 @@ struct AnchorData : public QSimplexVariable {
uint type : 2; // either Normal, Sequential or Parallel uint type : 2; // either Normal, Sequential or Parallel
uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor
uint isCenterAnchor : 1; uint isCenterAnchor : 1;
uint orientation : 1; uint isVertical : 1;
uint dependency : 2; // either Independent, Master or Slave uint dependency : 2; // either Independent, Master or Slave
}; };
@ -193,7 +193,7 @@ struct SequentialAnchorData : public AnchorData
: AnchorData(), m_children(vertices), m_edges(edges) : AnchorData(), m_children(vertices), m_edges(edges)
{ {
type = AnchorData::Sequential; type = AnchorData::Sequential;
orientation = m_edges.at(0)->orientation; isVertical = m_edges.at(0)->isVertical;
#ifdef QT_DEBUG #ifdef QT_DEBUG
name = QString::fromLatin1("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString()); name = QString::fromLatin1("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString());
#endif #endif
@ -212,7 +212,7 @@ struct ParallelAnchorData : public AnchorData
: AnchorData(), firstEdge(first), secondEdge(second) : AnchorData(), firstEdge(first), secondEdge(second)
{ {
type = AnchorData::Parallel; type = AnchorData::Parallel;
orientation = first->orientation; isVertical = first->isVertical;
// This assert whether the child anchors share their vertices // This assert whether the child anchors share their vertices
Q_ASSERT(((first->from == second->from) && (first->to == second->to)) || Q_ASSERT(((first->from == second->from) && (first->to == second->to)) ||