QHeaderView::ResizeToContents slow hide fix

I have been a bit confused about what QHeaderView::ResizeToContents
does good. It only sizes depending of the visible part.

However in hide it goes crazy and checks calculates size hints
for every row. At first I considered to solve it in QTableView.
It could be made to calculate the maximum height of the maximum
screen - however I decided not to touch it since I was not
certain that it wouldn't have any unexpected side effects.

Therefore I instead made this patch which is more simple and seems
to be safer. The logic is that when a QHeaderView is hidden we actually
only want to recalculate sizes if the headerview has a visible parent.

Task-number: QTBUG-14234

Change-Id: I186ab6afa95aed43022f2bb7c36e3fd008355d9b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Thorbjørn Lund Martsum 2011-12-11 20:28:01 +01:00 committed by Qt by Nokia
parent eeade8bf9c
commit f86007175d

View File

@ -2405,7 +2405,13 @@ bool QHeaderView::viewportEvent(QEvent *e)
} }
return true; } return true; }
#endif // QT_NO_STATUSTIP #endif // QT_NO_STATUSTIP
case QEvent::Hide: case QEvent::Hide: {
d->invalidateCachedSizeHint();
QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget());
if (parent && parent->isVisible()) // Only resize if we have a visible parent
resizeSections();
emit geometriesChanged();
break;}
case QEvent::Show: case QEvent::Show:
case QEvent::FontChange: case QEvent::FontChange:
case QEvent::StyleChange: case QEvent::StyleChange: