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 <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2014-02-05 18:57:02 +02:00 committed by Dirk Hohndel
parent a649bcc7bc
commit 4ccd6fb3b6

View file

@ -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)