From 631c64582e8e545357dbcf52fd9832229313c27f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 19 Dec 2017 10:46:48 +0100 Subject: QTreeView: Fix QTreeViewPrivate::itemAtCoordinate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QTreeViewPrivate::itemAtCoordinate() did not calculate the correct item when non-uniformRowHeights is enabled and vertical scroll mode is ScrollPerPixel. This results e.g. in an activation of the item above when the click happens on the very first pixel line of an item. Another, more problematic effect was that once a drop happened on the very first line of an item, QAbstractItemViewPrivate::dropOn() calculated the root as the drop index because the visualRect of the calculated item is compared with the drop position which did not match. Task-number: QTBUG-57538 Change-Id: If89571bf0fb76fc01d60ba7139f1d985b49d70db Reviewed-by: Richard Moe Gustavsen Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qtreeview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 20e99d2aee..73083773f5 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3514,7 +3514,7 @@ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const const int contentsCoordinate = coordinate + vbar->value(); for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) { viewItemCoordinate += itemHeight(viewItemIndex); - if (viewItemCoordinate >= contentsCoordinate) + if (viewItemCoordinate > contentsCoordinate) return (viewItemIndex >= itemCount ? -1 : viewItemIndex); } } else { // ScrollPerItem -- cgit v1.2.3