diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-10-08 19:55:42 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-10-15 14:37:51 (GMT) |
commit | e7e67b26fcd6c53dd822b1ae36074d418d432b4a (patch) | |
tree | f3ada89096e6367ad8f1a30eaf6143d5a2d3fcc4 | |
parent | eb2717ccbb20334b52aea269303258fe6236c117 (diff) | |
download | Qt-e7e67b26fcd6c53dd822b1ae36074d418d432b4a.zip Qt-e7e67b26fcd6c53dd822b1ae36074d418d432b4a.tar.gz Qt-e7e67b26fcd6c53dd822b1ae36074d418d432b4a.tar.bz2 |
QGAL: update the sizes of all anchors instead of doing it separatedly
After calculations, update the size of all anchors in the simplified
graph. Those updates were happening locally after each calculation
(trunk and semifloats), however some anchors that were not involved in
simplex calculation were missing.
One concrete consequence of the previous behaviour is that semifloat
parts that were simplified into just one anchor, didn't have the chance
to set their sizeAt* values. One consequence of the new behaviour is
one more test passing.
Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 28 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.h | 1 | ||||
-rw-r--r-- | tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 2 |
3 files changed, 20 insertions, 11 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 485743e..260e8dc 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1709,11 +1709,6 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( // they have a different logic for solveExpanding(). solveExpanding(trunkConstraints, trunkVariables); - // Propagate the new sizes down the simplified graph, ie. tell the - // group anchors to set their children anchors sizes. - for (int i = 0; i < trunkVariables.count(); ++i) - trunkVariables.at(i)->updateChildrenSizes(); - // Calculate and set the preferred and expanding sizes for the layout, // from the edge sizes that were calculated above. qreal pref(0.0); @@ -1756,9 +1751,6 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( ad->sizeAtExpanding = ad->expSize; ad->sizeAtMaximum = ad->maxSize; - // Propagate - ad->updateChildrenSizes(); - sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum; sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred; sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum; @@ -1790,13 +1782,17 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( ad->sizeAtMinimum = ad->sizeAtPreferred; ad->sizeAtExpanding = ad->sizeAtPreferred; ad->sizeAtMaximum = ad->sizeAtPreferred; - ad->updateChildrenSizes(); } // Delete the constraints, we won't use them anymore. qDeleteAll(sizeHintConstraints); } } + + // Propagate the new sizes down the simplified graph, ie. tell the + // group anchors to set their children anchors sizes. + updateAnchorSizes(orientation); + graphHasConflicts[orientation] = !feasible; // Clean up our data structures. They are not needed anymore since @@ -1907,6 +1903,20 @@ void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation) /*! \internal +*/ +void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation) +{ + Graph<AnchorVertex, AnchorData> &g = graph[orientation]; + const QList<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections(); + + for (int i = 0; i < vertices.count(); ++i) { + AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second); + ad->updateChildrenSizes(); + } +} + +/*! + \internal Create LP constraints for each anchor based on its minimum and maximum sizes, as specified in its size hints diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 1d7b758..e045fbd 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -441,6 +441,7 @@ public: void setAnchorSizeHintsFromItems(Orientation orientation); void findPaths(Orientation orientation); void constraintsFromPaths(Orientation orientation); + void updateAnchorSizes(Orientation orientation); QList<QSimplexConstraint *> constraintsFromSizeHints(const QList<AnchorData *> &anchors); QList<QList<QSimplexConstraint *> > getGraphParts(Orientation orientation); void identifyFloatItems(const QSet<AnchorData *> &visited, Orientation orientation); diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 148b2c8..755d866 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1711,8 +1711,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Validate for (int i = 0; i < result.count(); ++i) { - if (i == 1) - QEXPECT_FAIL("Two, mixed", "Works with simplification disabled.", Continue); const BasicLayoutTestResult item = result[i]; QCOMPARE(widgets[item.index]->geometry(), item.rect); } |