summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp26
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h10
2 files changed, 24 insertions, 12 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index a69d8f3..4ee58d1 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -265,13 +265,7 @@ void ParallelAnchorData::updateChildrenSizes()
firstEdge->sizeAtPreferred = sizeAtPreferred;
firstEdge->sizeAtMaximum = sizeAtMaximum;
- // We have the convention that the first children will define the direction of the
- // pararell group. So we can check whether the second edge is "forward" in relation
- // to the group if it have the same direction as the first edge. Note that we don't
- // use 'this->from' because it might be changed by vertex simplification.
- const bool secondForward = (firstEdge->from == secondEdge->from);
-
- if (secondForward) {
+ if (secondForward()) {
secondEdge->sizeAtMinimum = sizeAtMinimum;
secondEdge->sizeAtPreferred = sizeAtPreferred;
secondEdge->sizeAtMaximum = sizeAtMaximum;
@@ -296,10 +290,20 @@ bool ParallelAnchorData::calculateSizeHints()
// to a backwards anchor of size (-max, -pref, -min)
// Also see comments in updateChildrenSizes().
- const bool secondForward = (firstEdge->from == secondEdge->from);
- const qreal secondMin = secondForward ? secondEdge->minSize : -secondEdge->maxSize;
- const qreal secondPref = secondForward ? secondEdge->prefSize : -secondEdge->prefSize;
- const qreal secondMax = secondForward ? secondEdge->maxSize : -secondEdge->minSize;
+
+ qreal secondMin;
+ qreal secondPref;
+ qreal secondMax;
+
+ if (secondForward()) {
+ secondMin = secondEdge->minSize;
+ secondPref = secondEdge->prefSize;
+ secondMax = secondEdge->maxSize;
+ } else {
+ secondMin = -secondEdge->maxSize;
+ secondPref = -secondEdge->prefSize;
+ secondMax = -secondEdge->minSize;
+ }
minSize = qMax(firstEdge->minSize, secondMin);
maxSize = qMin(firstEdge->maxSize, secondMax);
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 925d7ef..8d2d691 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -212,7 +212,8 @@ struct ParallelAnchorData : public AnchorData
Q_ASSERT(((first->from == second->from) && (first->to == second->to)) ||
((first->from == second->to) && (first->to == second->from)));
- // We arbitrarily choose the direction of the first child as "our" direction
+ // Our convention will be that the parallel group anchor will have the same
+ // direction as the first anchor.
from = first->from;
to = first->to;
#ifdef QT_DEBUG
@@ -223,6 +224,13 @@ struct ParallelAnchorData : public AnchorData
virtual void updateChildrenSizes();
bool calculateSizeHints();
+ bool secondForward() const {
+ // We have the convention that the first children will define the direction of the
+ // pararell group. Note that we can't rely on 'this->from' or 'this->to' because they
+ // might be changed by vertex simplification.
+ return firstEdge->from == secondEdge->from;
+ }
+
AnchorData* firstEdge;
AnchorData* secondEdge;