From b3048b782eba2b73dadcb693d98db62f922b9171 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 16 Oct 2014 13:38:11 +0200 Subject: [PATCH] WIP: Fix expanding of spanning items. When using HeaderView::ResizeToContents and QTreeWidgetItem::setFirstColumnSpanned(), it happens that the position of the branch icon is no longer in the first column and thus trying to expand the item results in a selection change. Check for spanning when determining the position. TODO: Is this the right line of attack - is there a better check? Task-number: QTBUG-41793 Change-Id: I14353127436fb0ebaafb0d50a31b920b8da67333 --- src/widgets/itemviews/qtreeview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 188a503..d6f027f 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3726,9 +3726,14 @@ void QTreeViewPrivate::updateScrollBars() int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const { + Q_Q(const QTreeView); executePostedLayout(); - int x = pos.x(); - int column = header->logicalIndexAt(x); + bool spanned = false; + if (!spanningIndexes.isEmpty()) { + const QModelIndex index = q->indexAt(pos); + spanned = q->isFirstColumnSpanned(index.row(), index.parent()); + } + const int column = spanned ? 0 : header->logicalIndexAt(pos.x()); if (!isTreePosition(column)) return -1; // no logical index at x -- 1.9.4.msysgit.0