diff options
author | Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> | 2009-09-29 18:22:26 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-10-06 09:29:11 (GMT) |
commit | 6367a702b13a440557d4e0a405ae6d34ef0b778f (patch) | |
tree | afe40294d7fbcf4664fa7999a1a14b0d7e88b13c /src/gui | |
parent | 18da388497b5f3cbc77298a70bc83f037f06c013 (diff) | |
download | Qt-6367a702b13a440557d4e0a405ae6d34ef0b778f.zip Qt-6367a702b13a440557d4e0a405ae6d34ef0b778f.tar.gz Qt-6367a702b13a440557d4e0a405ae6d34ef0b778f.tar.bz2 |
QGraphicsAnchorLayoutPrivate: Fixing initial geometry values for new layout items
Now every item starts with its geometry on ((0,0), preferredSize()).
By doing this we guarantee that every item will have a known initial value, which
can be specially useful on float cases for instance.
Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index e760642..87f5aa0 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2068,22 +2068,35 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) right = geom.right() - right; foreach (QGraphicsLayoutItem *item, items) { - firstH = internalVertex(item, Qt::AnchorLeft); - secondH = internalVertex(item, Qt::AnchorRight); - firstV = internalVertex(item, Qt::AnchorTop); - secondV = internalVertex(item, Qt::AnchorBottom); - QRectF newGeom; - newGeom.setTop(top + firstV->distance); - newGeom.setBottom(top + secondV->distance); + QSizeF itemPreferredSize = item->effectiveSizeHint(Qt::PreferredSize); + if (m_nonFloatItems[Horizontal].contains(item)) { + firstH = internalVertex(item, Qt::AnchorLeft); + secondH = internalVertex(item, Qt::AnchorRight); + + if (visualDir == Qt::LeftToRight) { + newGeom.setLeft(left + firstH->distance); + newGeom.setRight(left + secondH->distance); + } else { + newGeom.setLeft(right - secondH->distance); + newGeom.setRight(right - firstH->distance); + } + } else { + newGeom.setLeft(0); + newGeom.setRight(itemPreferredSize.width()); + } + + if (m_nonFloatItems[Vertical].contains(item)) { + firstV = internalVertex(item, Qt::AnchorTop); + secondV = internalVertex(item, Qt::AnchorBottom); - if (visualDir == Qt::LeftToRight) { - newGeom.setLeft(left + firstH->distance); - newGeom.setRight(left + secondH->distance); + newGeom.setTop(top + firstV->distance); + newGeom.setBottom(top + secondV->distance); } else { - newGeom.setLeft(right - secondH->distance); - newGeom.setRight(right - firstH->distance); + newGeom.setTop(0); + newGeom.setBottom(itemPreferredSize.height()); } + item->setGeometry(newGeom); } } |