diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2017-12-19 10:46:48 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-01-02 19:35:47 +0000 |
commit | 631c64582e8e545357dbcf52fd9832229313c27f (patch) | |
tree | 379569c755ad85fa4c7154af1165fffdfcc08e18 | |
parent | 4f76c2dbadb09a27cecaba5a36512f68fac3d319 (diff) |
QTreeView: Fix QTreeViewPrivate::itemAtCoordinate()
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 <richard.gustavsen@qt.io>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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 |