From a64be9c7bf9f9a69881e8fc66069363e6af4de26 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Mon, 7 May 2018 14:32:20 +0200 Subject: Fix scrolling to currently selected item in QtExpandedListView Test-Information: Verified this by running Swift and using a large roster. Clicking on items near the top resulted in the scroll area jumping around. It does not anymore and works as expected. Change-Id: Ic543015aa46120cf0ec082c10b72c944b5559ef8 diff --git a/Swift/QtUI/QtExpandedListView.cpp b/Swift/QtUI/QtExpandedListView.cpp index 8cbfab6..84769c5 100644 --- a/Swift/QtUI/QtExpandedListView.cpp +++ b/Swift/QtUI/QtExpandedListView.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace Swift { @@ -60,12 +61,13 @@ void QtExpandedListView::currentChanged(const QModelIndex ¤t, const QModel // Make sure that the current selected index is visible in the parent QScrollArea. auto scrollArea = getParentOfType(parentWidget()); if (scrollArea) { + auto scrollWidget = scrollArea->widget(); QList points; auto visRect = visualRect(current); - points << pos() + visRect.topLeft(); - points << pos() + visRect.topRight(); - points << pos() + visRect.bottomLeft(); - points << pos() + visRect.bottomRight(); + points << mapTo(scrollWidget, visRect.topLeft()); + points << mapTo(scrollWidget, visRect.topRight()); + points << mapTo(scrollWidget, visRect.bottomLeft()); + points << mapTo(scrollWidget, visRect.bottomRight()); for (auto&& point : points) { scrollArea->ensureVisible(point.x(), point.y(), 0, 0); -- cgit v0.10.2-6-g49f6