aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarno Malmari <ext-jarno.malmari@nokia.com>2010-12-14 10:01:13 +0200
committerNatalia Dobrovolskaya <natalia.dobrovolskaya@nokia.com>2010-12-17 16:39:59 +0200
commit904ea8aa4dfbc33e8a1e2fe41dc7fd59fd8809b6 (patch)
tree2ef628dc5f3970b0ca70b41e37ad061ef743fc6c
parent84f3e3ffe3682f95f94fdf20da9d4bfefe09fb15 (diff)
Changes: Honor vertical panning policy correctly.
RevBy: Michael Hasselmann, MichaƂ Guminiak Details: For the sake of simplicity, horizontal panning is disabled since there is no use case for it, and it can cause incorrect behaviour in certain scenarios.
-rw-r--r--src/corelib/core/mpannableviewportscroller.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/core/mpannableviewportscroller.cpp b/src/corelib/core/mpannableviewportscroller.cpp
index be854ec4..3cea7399 100644
--- a/src/corelib/core/mpannableviewportscroller.cpp
+++ b/src/corelib/core/mpannableviewportscroller.cpp
@@ -28,10 +28,13 @@ QPoint MPannableViewportScroller::queryScrollingAmount(const QGraphicsWidget *wi
{
const MPannableViewport *viewport = static_cast<const MPannableViewport *>(widget);
- if (viewport->panDirection() == 0) {
+ if (viewport->verticalPanningPolicy() == MPannableViewport::PanningAlwaysOff) {
return QPoint(); // unable to scroll
}
+ // We won't be scrolling horizontally currently to prevent movement caused by
+ // errors in container widget margins etc. It's straightforward to add if needed.
+
// First ensure that target rectangle is inside of area of the pannable viewport.
// Note: We might even move against the wanted direction but this is required to
// ensure the visibility of the area marked by target rectangle.
@@ -49,10 +52,9 @@ QPoint MPannableViewportScroller::queryScrollingAmount(const QGraphicsWidget *wi
QRectF posRange = viewport->range();
// ...and limit our panning accordingly.
- panningPos.rx() = qBound(posRange.left(), panningPos.x(), posRange.right());
panningPos.ry() = qMax(posRange.top(), panningPos.y()); // We can extend bottom limit.
- const QPoint translation((viewport->position() - panningPos).toPoint());
+ const QPoint translation(0, viewport->position().y() - panningPos.y());
return translation;
}