diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-07-22 08:37:13 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-07-22 18:04:49 (GMT) |
commit | 4a5b176b5bd302903a7baf1517e7cb9dced70d3f (patch) | |
tree | 36a72582e400c19578b1ccc23bdebdcc0b6fe3a6 /src | |
parent | 8bb931a6bff959279189662299ad6f8516de1789 (diff) | |
download | Qt-4a5b176b5bd302903a7baf1517e7cb9dced70d3f.zip Qt-4a5b176b5bd302903a7baf1517e7cb9dced70d3f.tar.gz Qt-4a5b176b5bd302903a7baf1517e7cb9dced70d3f.tar.bz2 |
Anchors to center edges should also have a default spacing of 0.
Since the spacing will be 0 in most cases, we therefore "invert" the
if (..) to only check for the cases where the spacing will *not* be zero.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 9023344..e969e40 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -603,12 +603,22 @@ void QGraphicsAnchorLayoutPrivate::anchor(QGraphicsLayoutItem *firstItem, AnchorData *data; if (!spacing) { - // If we anchor to the layout edges or if we anchor - // Right->Right or Left->Left, our default spacing will be 0 - if (firstItem == q || secondItem == q || firstEdge == secondEdge) - data = new AnchorData(0); - else - data = new AnchorData; // otherwise, ask the style later + // If firstItem or secondItem is the layout itself, the spacing will default to 0. + // Otherwise, the following matrix is used (questionmark means that the spacing + // is queried from the style): + // from + // to Left HCenter Right + // Left 0 0 ? + // HCenter 0 0 0 + // Right ? 0 0 + if (firstItem != q + && secondItem != q + && pickEdge(firstEdge, Horizontal) != QGraphicsAnchorLayout::HCenter + && oppositeEdge(firstEdge) == secondEdge) { + data = new AnchorData; // ask the style later + } else { + data = new AnchorData(0); // spacing should be 0 + } addAnchor(firstItem, firstEdge, secondItem, secondEdge, data); } else if (*spacing >= 0) { data = new AnchorData(*spacing); |