QHeaderView - minor cleanup in viewportEvent
authorThorbjørn Lund Martsum <tmartsum@gmail.com>
Thu, 23 Feb 2012 07:24:21 +0000 (08:24 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 27 Feb 2012 19:52:45 +0000 (20:52 +0100)
This is an improvement to a previous fix with
SHA e62e71162606fec134600955a89b7e0c34a7840b

We actually never want to call resizeSections if the parent is hidden.
Therefore we can both simplify and improve the code with this patch.

When we do show/hide on parent then the visible status is updated
before we get into this code. I have verified the patch on the code
from:

Task-number: QTBUG-14234

Change-Id: If7bfa3b3813c97b4a545e48423526e9cfe118de4
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
src/widgets/itemviews/qheaderview.cpp

index ed71c5a..5d2acea 100644 (file)
@@ -2433,20 +2433,15 @@ bool QHeaderView::viewportEvent(QEvent *e)
         }
         return true; }
 #endif // QT_NO_STATUSTIP
-    case QEvent::Hide: {
-        d->invalidateCachedSizeHint();
+    case QEvent::Hide:
+    case QEvent::Show:
+    case QEvent::FontChange:
+    case QEvent::StyleChange:{
         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::FontChange:
-    case QEvent::StyleChange:
-        d->invalidateCachedSizeHint();
-        resizeSections();
-        emit geometriesChanged();
-        break;
     case QEvent::ContextMenu: {
         d->state = QHeaderViewPrivate::NoState;
         d->pressed = d->section = d->target = -1;