summaryrefslogtreecommitdiff
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-11-18 16:00:32 -0300
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-27 16:19:09 -0300
commitd622aef01e5c2624cd64c92ce77064718c6576af (patch)
tree92d62388947dcd323127849ea6543332bff529df /src/gui/graphicsview
parent12341a4e33a498037679e27edee829fa245a0148 (diff)
downloadqt4-tools-d622aef01e5c2624cd64c92ce77064718c6576af.tar.gz
QGAL: move second child direction check to a function
In a parallel anchor, the second child anchor may be forward or backwards in relation to the parallel itself. Moves the directionality check to a function. It'll be useful in the next commit. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview')
-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 a69d8f32d9..4ee58d10e3 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 925d7eff3b..8d2d6914d1 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;