summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qtreewidget.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2017-12-22 20:56:23 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-01-03 07:53:41 +0000
commit2dedf75819d838ef1964de4b8d391655f5bde85d (patch)
tree52c9769fc87bd947076200a26a24af3b7ad4f9e0 /src/widgets/itemviews/qtreewidget.cpp
parenta13a0024d6a65f893dd0aef45f9eb3e897103d60 (diff)
QTreeWidget: fix visualItemRect()
QTreeWidget::visualItemRect() returned an invalid QRect when a column was moved and then hidden (or the other way round). The reason was that the logical index returned by QHeaderView::logicalIndexAt() was again passed to QHeaderView::logicalIndex() to create the QModelIndexes needed for QTreeView::visualRect() Task-number: QTBUG-28733 Change-Id: I8676f21bcab8c05c2260b85d483902f18cbf3e24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'src/widgets/itemviews/qtreewidget.cpp')
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index e5f73407cd..d06128d012 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -2859,11 +2859,11 @@ QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const
Q_D(const QTreeWidget);
//the visual rect for an item is across all columns. So we need to determine
//what is the first and last column and get their visual index rects
- QModelIndex base = d->index(item);
+ const QModelIndex base = d->index(item);
const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
- QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
- QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
+ const QModelIndex first = base.sibling(base.row(), firstVisiblesection);
+ const QModelIndex last = base.sibling(base.row(), lastVisibleSection);
return visualRect(first) | visualRect(last);
}