diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-09-25 10:56:40 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-26 19:07:07 +0200 |
commit | 9b439161ac7e85d7c54a403907d7b18843454f83 (patch) | |
tree | d82379de14a6425c6782e4defa65f19373037fe4 /src/widgets/widgets/qscrollbar.cpp | |
parent | aec5b76b51fb1895f275ac4d413cc040cf88d519 (diff) |
QScrollBar: clean up wheelEvent() implementation
This code was moved from the general event() handler.
Remove comments and casting that were necessary there.
Task-number: QTBUG-27308
Reported-by: chenjiexin
Task-number: QTBUG-21534
Reported-by: Martin Koller
Change-Id: I14ef4c6363002032895f6840a7c68c1f5f665384
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qscrollbar.cpp')
-rw-r--r-- | src/widgets/widgets/qscrollbar.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 9ef56b7f95..aa45b4f54e 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -488,20 +488,18 @@ bool QScrollBar::event(QEvent *event) #ifndef QT_NO_WHEELEVENT void QScrollBar::wheelEvent(QWheelEvent *event) { - event->ignore(); - // override wheel event without adding virtual function override - QWheelEvent *ev = static_cast<QWheelEvent *>(event); - int delta = ev->delta(); - // scrollbar is a special case - in vertical mode it reaches minimum - // value in the upper position, however QSlider's minimum value is on - // the bottom. So we need to invert a value, but since the scrollbar is - // inverted by default, we need to inverse the delta value for the - // horizontal orientation. - if (ev->orientation() == Qt::Horizontal) - delta = -delta; - Q_D(QScrollBar); - if (d->scrollByDelta(ev->orientation(), ev->modifiers(), delta)) - event->accept(); + event->ignore(); + int delta = event->delta(); + // scrollbar is a special case - in vertical mode it reaches minimum + // value in the upper position, however QSlider's minimum value is on + // the bottom. So we need to invert a value, but since the scrollbar is + // inverted by default, we need to inverse the delta value for the + // horizontal orientation. + if (event->orientation() == Qt::Horizontal) + delta = -delta; + Q_D(QScrollBar); + if (d->scrollByDelta(event->orientation(), event->modifiers(), delta)) + event->accept(); } #endif |