diff options
author | Tobias Markmann <tm@ayena.de> | 2018-05-07 12:32:20 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-05-08 08:11:16 (GMT) |
commit | a64be9c7bf9f9a69881e8fc66069363e6af4de26 (patch) | |
tree | aa8adfad97481a50c0c8b357c1b5dae9585ed841 | |
parent | d9994a01bca43aab08fc67b789e71d28672c6ba1 (diff) | |
download | swift-a64be9c7bf9f9a69881e8fc66069363e6af4de26.zip swift-a64be9c7bf9f9a69881e8fc66069363e6af4de26.tar.bz2 |
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
-rw-r--r-- | Swift/QtUI/QtExpandedListView.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
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 <QWheelEvent> #include <QScrollArea> +#include <QDebug> 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<QScrollArea*>(parentWidget()); if (scrollArea) { + auto scrollWidget = scrollArea->widget(); QList<QPoint> 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); |