summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-18 09:24:44 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-18 10:35:47 (GMT)
commit9c62a7d9f0f8a02ad6c445b82a50eccb3c51a378 (patch)
treef74dac8ed97368dd7af703392fdf4e2c0157e8c0 /src/gui/graphicsview
parent5a201476f209ad0a39cf2240a996239f7074f86e (diff)
downloadQt-9c62a7d9f0f8a02ad6c445b82a50eccb3c51a378.zip
Qt-9c62a7d9f0f8a02ad6c445b82a50eccb3c51a378.tar.gz
Qt-9c62a7d9f0f8a02ad6c445b82a50eccb3c51a378.tar.bz2
Call effectiveSizeHint(Qt::MinimumSize).width instead of minimumWidth()
Small refactoring, since the two code blocks were almost the same. Reviewed-by: leo
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp88
1 files changed, 40 insertions, 48 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index f7266e2..4eeff82 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -95,58 +95,50 @@ qreal QGraphicsAnchorPrivate::spacing() const
void AnchorData::refreshSizeHints(qreal effectiveSpacing)
{
if (!isLayoutAnchor && from->m_item == to->m_item) {
- bool hasCenter = false;
QGraphicsLayoutItem *item = from->m_item;
- QSizePolicy policy = item->sizePolicy();
-
- if (QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge)
- == QGraphicsAnchorLayoutPrivate::Horizontal) {
-
- // minSize, prefSize and maxSize are initialized
- // with item's preferred Size: this is QSizePolicy::Fixed.
- //
- // Then we check each flag to find the resultant QSizePolicy,
- // according to the following table:
- //
- // constant value
- // QSizePolicy::Fixed 0
- // QSizePolicy::Minimum GrowFlag
- // QSizePolicy::Maximum ShrinkFlag
- // QSizePolicy::Preferred GrowFlag | ShrinkFlag
- // QSizePolicy::Ignored GrowFlag | ShrinkFlag | IgnoreFlag
- prefSize = item->preferredWidth();
- minSize = prefSize;
- maxSize = prefSize;
-
- if (policy.horizontalPolicy() & QSizePolicy::GrowFlag)
- maxSize = item->maximumWidth();
-
- if (policy.horizontalPolicy() & QSizePolicy::ShrinkFlag)
- minSize = item->minimumWidth();
-
- if (policy.horizontalPolicy() & QSizePolicy::IgnoreFlag)
- prefSize = minSize;
-
- hasCenter = (from->m_edge == Qt::AnchorHorizontalCenter
- || to->m_edge == Qt::AnchorHorizontalCenter);
- } else {
- prefSize = item->preferredHeight();
- minSize = prefSize;
- maxSize = prefSize;
-
- if (policy.verticalPolicy() & QSizePolicy::GrowFlag)
- maxSize = item->maximumHeight();
-
- if (policy.verticalPolicy() & QSizePolicy::ShrinkFlag)
- minSize = item->minimumHeight();
-
- if (policy.verticalPolicy() & QSizePolicy::IgnoreFlag)
- prefSize = minSize;
+ const QGraphicsAnchorLayoutPrivate::Orientation orient = QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge);
+ const Qt::AnchorPoint centerEdge = QGraphicsAnchorLayoutPrivate::pickEdge(Qt::AnchorHorizontalCenter, orient);
- hasCenter = (from->m_edge == Qt::AnchorVerticalCenter
- || to->m_edge == Qt::AnchorVerticalCenter);
+ QSizePolicy::Policy policy;
+ qreal minSizeHint, prefSizeHint, maxSizeHint;
+ if (orient == QGraphicsAnchorLayoutPrivate::Horizontal) {
+ policy = item->sizePolicy().horizontalPolicy();
+ minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();
+ prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width();
+ maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width();
+ } else {
+ policy = item->sizePolicy().verticalPolicy();
+ minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height();
+ prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height();
+ maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height();
}
+ // minSize, prefSize and maxSize are initialized
+ // with item's preferred Size: this is QSizePolicy::Fixed.
+ //
+ // Then we check each flag to find the resultant QSizePolicy,
+ // according to the following table:
+ //
+ // constant value
+ // QSizePolicy::Fixed 0
+ // QSizePolicy::Minimum GrowFlag
+ // QSizePolicy::Maximum ShrinkFlag
+ // QSizePolicy::Preferred GrowFlag | ShrinkFlag
+ // QSizePolicy::Ignored GrowFlag | ShrinkFlag | IgnoreFlag
+ prefSize = prefSizeHint;
+ minSize = prefSize;
+ maxSize = prefSize;
+
+ if (policy & QSizePolicy::GrowFlag)
+ maxSize = maxSizeHint;
+
+ if (policy & QSizePolicy::ShrinkFlag)
+ minSize = minSizeHint;
+
+ if (policy & QSizePolicy::IgnoreFlag)
+ prefSize = minSize;
+
+ bool hasCenter = (from->m_edge == centerEdge || to->m_edge == centerEdge);
if (hasCenter) {
minSize /= 2;