From 4a4458d1cf5ec7885c6f63f739b7ee80c70ad211 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 23 Mar 2010 15:34:38 +0100 Subject: Wrong repaint when changing the default row height in QTreeView When in QTreeView::dataChanged(), we didn't check for the actual change in the value before setting QTreeViewPrivate::defaultItemHeight. Hence, if uniformRowHeights is true, we completely miss any resizing of the items. Reviewed-by: Thierry Task-number: QTBUG-9216 --- src/gui/itemviews/qtreeview.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 61ad79d..4636c50 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -674,15 +674,19 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto // refresh the height cache here; we don't really lose anything by getting the size hint, // since QAbstractItemView::dataChanged() will get the visualRect for the items anyway - int topViewIndex = d->viewIndex(topLeft); - if (topViewIndex == 0) - d->defaultItemHeight = indexRowSizeHint(topLeft); bool sizeChanged = false; + int topViewIndex = d->viewIndex(topLeft); + if (topViewIndex == 0) { + int newDefaultItemHeight = indexRowSizeHint(topLeft); + sizeChanged = d->defaultItemHeight != newDefaultItemHeight; + d->defaultItemHeight = newDefaultItemHeight; + } + if (topViewIndex != -1) { if (topLeft.row() == bottomRight.row()) { int oldHeight = d->itemHeight(topViewIndex); d->invalidateHeightCache(topViewIndex); - sizeChanged = (oldHeight != d->itemHeight(topViewIndex)); + sizeChanged |= (oldHeight != d->itemHeight(topViewIndex)); if (topLeft.column() == 0) d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); } else { -- cgit v0.12