summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-03 14:44:51 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-03 14:45:15 (GMT)
commit108f549a446e13a3be7ee6753be9eb74260547d7 (patch)
tree26e66b829fbc4afe831e5cb05cc2b75b5d2216be
parent208bba0abd8a417cf8fdfd61295682738df3bc67 (diff)
downloadQt-108f549a446e13a3be7ee6753be9eb74260547d7.zip
Qt-108f549a446e13a3be7ee6753be9eb74260547d7.tar.gz
Qt-108f549a446e13a3be7ee6753be9eb74260547d7.tar.bz2
QHeaderView: code cleanup in sizehint calculation
-rw-r--r--src/gui/itemviews/qheaderview.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index a73f85a..57e44c7 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -522,12 +522,9 @@ int QHeaderView::length() const
QSize QHeaderView::sizeHint() const
{
Q_D(const QHeaderView);
- if (count() < 1)
- return QSize(0, 0);
if (d->cachedSizeHint.isValid())
return d->cachedSizeHint;
- int width = 0;
- int height = 0;
+ d->cachedSizeHint = QSize(0, 0);
d->executePostedLayout();
// get size hint for the first n sections
@@ -537,8 +534,7 @@ QSize QHeaderView::sizeHint() const
continue;
checked++;
QSize hint = sectionSizeFromContents(i);
- width = qMax(hint.width(), width);
- height = qMax(hint.height(), height);
+ d->cachedSizeHint = d->cachedSizeHint.expandedTo(hint);
}
// get size hint for the last n sections
i = qMax(i, d->sectionCount - 100 );
@@ -547,10 +543,8 @@ QSize QHeaderView::sizeHint() const
continue;
checked++;
QSize hint = sectionSizeFromContents(j);
- width = qMax(hint.width(), width);
- height = qMax(hint.height(), height);
+ d->cachedSizeHint = d->cachedSizeHint.expandedTo(hint);
}
- d->cachedSizeHint = QSize(width, height);
return d->cachedSizeHint;
}