QTreeView: 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.

Task-number: QTBUG-41793
Change-Id: I14353127436fb0ebaafb0d50a31b920b8da67333
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Friedemann Kleint 2014-10-16 13:38:11 +02:00
parent 2105f80169
commit 35ebdeb83e

View File

@ -3724,9 +3724,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