From 4ccd6fb3b6b593bf5de4b668afe612a916853efb Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Wed, 5 Feb 2014 18:57:02 +0200 Subject: Fix the zoom-panning for the new profile This works in a different way compared to the old widget. To make it work we use vieport()'s height() and width() and simplify the scroll position to: scrollPosition = (mousePosition / totalLength) * scrollMaximum Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 0de11966c..8c255c8be 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -518,15 +518,10 @@ void ProfileWidget2::scrollViewTo(const QPoint& pos) return; QScrollBar *vs = verticalScrollBar(); QScrollBar *hs = horizontalScrollBar(); - const qreal yRat = pos.y() / sceneRect().height(); - const qreal xRat = pos.x() / sceneRect().width(); - const int vMax = vs->maximum(); - const int hMax = hs->maximum(); - const int vMin = vs->minimum(); - const int hMin = hs->minimum(); - /* QScrollBar receives crazy negative values for minimum */ - vs->setValue(yRat * (vMax - vMin) + vMin * 0.9); - hs->setValue(xRat * (hMax - hMin) + hMin * 0.9); + const qreal yRat = (qreal)pos.y() / viewport()->height(); + const qreal xRat = (qreal)pos.x() / viewport()->width(); + vs->setValue(yRat * vs->maximum()); + hs->setValue(xRat * hs->maximum()); } void ProfileWidget2::mouseMoveEvent(QMouseEvent* event) -- cgit v1.2.3-70-g09d2