summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-05 15:28:46 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-08 08:52:50 +0200
commita5094bc270bbffd4aeb8cdb30e86c2afecd8d1b8 (patch)
tree72fc6dc2e0a56754f3946c072c1d3eb219652033 /src/widgets
parent3144f90d93c2b6209e3b8a65bb9655cc7c6ada79 (diff)
QGraphicsAnchorLayout: port to QHVContainer [2/4]: edgeOrientation()
Port edgeOrientation() and all its callers from Orientation to Qt::Orientation. This function is singled out, since one caller is performing a conversion from Orientation to Qt::Orientation, which, if left unchanged, would cause an off-by-one bug. Change-Id: I37365195ea9552243822803b095a3926a28e7dd0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp18
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 9934255d25..53f753dbd9 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -227,7 +227,7 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
prefSizeHint = anchorPrivate->preferredSize;
} else {
// Fetch size information from style
- const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1);
+ const Qt::Orientation orient = QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge);
qreal s = styleInfo->defaultSpacing(orient);
if (s < 0) {
QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType();
@@ -1343,10 +1343,10 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation)
toRestore.clear();
}
-QGraphicsAnchorLayoutPrivate::Orientation
-QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge)
+Qt::Orientation
+QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge) noexcept
{
- return edge > Qt::AnchorRight ? Vertical : Horizontal;
+ return edge > Qt::AnchorRight ? Qt::Vertical : Qt::Horizontal;
}
/*!
@@ -1718,7 +1718,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt
{
Q_Q(QGraphicsAnchorLayout);
- const Orientation orientation = edgeOrientation(firstEdge);
+ const Qt::Orientation orientation = edgeOrientation(firstEdge);
// Create or increase the reference count for the related vertices.
AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge);
@@ -1733,7 +1733,7 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt
if (firstItem == secondItem)
data->item = firstItem;
- data->isVertical = orientation == Vertical;
+ data->isVertical = orientation == Qt::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
@@ -1759,7 +1759,7 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi
if (firstItem == secondItem)
return nullptr;
- const Orientation orientation = edgeOrientation(firstEdge);
+ const Qt::Orientation orientation = edgeOrientation(firstEdge);
AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
@@ -1864,7 +1864,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorV
Q_ASSERT(v1 && v2);
// Remove edge from graph
- const Orientation o = edgeOrientation(v1->m_edge);
+ const Qt::Orientation o = edgeOrientation(v1->m_edge);
graph[o].removeEdge(v1, v2);
// Decrease vertices reference count (may trigger a deletion)
@@ -1925,7 +1925,7 @@ void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::A
{
if (AnchorVertex *v = internalVertex(item, edge)) {
Graph<AnchorVertex, AnchorData> &g = graph[edgeOrientation(edge)];
- const QList<AnchorVertex *> allVertices = graph[edgeOrientation(edge)].adjacentVertices(v);
+ const auto allVertices = g.adjacentVertices(v);
for (auto *v2 : allVertices) {
g.removeEdge(v, v2);
removeInternalVertex(item, edge);
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index 35211c0182..e945c5d6b6 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
@@ -427,7 +427,7 @@ public:
static Qt::AnchorPoint oppositeEdge(
Qt::AnchorPoint edge);
- static Orientation edgeOrientation(Qt::AnchorPoint edge);
+ static Qt::Orientation edgeOrientation(Qt::AnchorPoint edge) noexcept;
static Qt::AnchorPoint pickEdge(Qt::AnchorPoint edge, Orientation orientation)
{