diff options
author | John Tapsell <john.tapsell.ext@basyskom.de> | 2010-10-08 14:10:20 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-13 11:32:19 (GMT) |
commit | fcda1b785bd7d86011f49bfe96cb22b04202933f (patch) | |
tree | 5adaeba24330f730e86550fac0d8f58de9a598fa /src | |
parent | 6d4d265e7e67dde58e45d7d89f4974d0bd8b70e4 (diff) | |
download | Qt-fcda1b785bd7d86011f49bfe96cb22b04202933f.zip Qt-fcda1b785bd7d86011f49bfe96cb22b04202933f.tar.gz Qt-fcda1b785bd7d86011f49bfe96cb22b04202933f.tar.bz2 |
QGraphicsLayoutItem - user set sizes should always override, even if there's a constraint
Notes:
* I have had to remove some of the old unit tests because the tested for
strange behaviour. Now that height for width items behave more like
normal items, it's no longer so easy to calculate what the geometries
should be in strangely-sized layouts.
* This also fixes alignment of height-for-width objects and adds a unit
test for this. This couldn't be done in a seperate commit since the two
fixes are related.
Merge-request: 847
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicslayoutitem.cpp | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgridlayoutengine.cpp | 17 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 634f68c..e43f7fa 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -140,11 +140,9 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) if (!sizeHintCacheDirty && cachedConstraint == constraint) return cachedSizeHints; - const bool hasConstraint = constraint.width() >= 0 || constraint.height() >= 0; - for (int i = 0; i < Qt::NSizeHints; ++i) { cachedSizeHints[i] = constraint; - if (userSizeHints && !hasConstraint) + if (userSizeHints) combineSize(cachedSizeHints[i], userSizeHints[i]); } diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index acac46f..e486b4d 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -631,14 +631,17 @@ QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal heig qreal cellWidth = width; qreal cellHeight = height; - QSize constraint; + + QSizeF size = effectiveMaxSize(QSizeF(-1,-1)); if (hasDynamicConstraint()) { - if (dynamicConstraintOrientation() == Qt::Vertical) - constraint.setWidth(cellWidth); - else - constraint.setHeight(cellHeight); + if (dynamicConstraintOrientation() == Qt::Vertical) { + if (size.width() > cellWidth) + size = effectiveMaxSize(QSizeF(cellWidth, -1)); + } else if(size.height() > cellHeight) { + size = effectiveMaxSize(QSizeF(-1, cellHeight)); + } } - QSizeF size = effectiveMaxSize(constraint).boundedTo(QSizeF(cellWidth, cellHeight)); + size = size.boundedTo(QSizeF(cellWidth, cellHeight)); width = size.width(); height = size.height(); @@ -714,7 +717,7 @@ QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const } if (!size.isValid()) { - QSizeF maxSize = layoutItem()->effectiveSizeHint(Qt::MaximumSize, constraint); + QSizeF maxSize = layoutItem()->effectiveSizeHint(Qt::MaximumSize, size); if (size.width() == -1) size.setWidth(maxSize.width()); if (size.height() == -1) |