src/gui/widgets/qscrollbar.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    45 #include "qpainter.h"
    45 #include "qpainter.h"
    46 #include "qscrollbar.h"
    46 #include "qscrollbar.h"
    47 #include "qstyle.h"
    47 #include "qstyle.h"
    48 #include "qstyleoption.h"
    48 #include "qstyleoption.h"
    49 #include "qmenu.h"
    49 #include "qmenu.h"
    50 #include <QtCore/qdatetime.h>
    50 #include <QtCore/qelapsedtimer.h>
    51 
    51 
    52 #ifndef QT_NO_SCROLLBAR
    52 #ifndef QT_NO_SCROLLBAR
    53 
    53 
    54 #ifndef QT_NO_ACCESSIBILITY
    54 #ifndef QT_NO_ACCESSIBILITY
    55 #include "qaccessible.h"
    55 #include "qaccessible.h"
   521     if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
   521     if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
   522         d_func()->updateHoverControl(he->pos());
   522         d_func()->updateHoverControl(he->pos());
   523         break;
   523         break;
   524 #ifndef QT_NO_WHEELEVENT
   524 #ifndef QT_NO_WHEELEVENT
   525     case QEvent::Wheel: {
   525     case QEvent::Wheel: {
       
   526         event->ignore();
   526         // override wheel event without adding virtual function override
   527         // override wheel event without adding virtual function override
   527         QWheelEvent *ev = static_cast<QWheelEvent *>(event);
   528         QWheelEvent *ev = static_cast<QWheelEvent *>(event);
   528         int delta = ev->delta();
   529         int delta = ev->delta();
   529         // scrollbar is a special case - in vertical mode it reaches minimum
   530         // scrollbar is a special case - in vertical mode it reaches minimum
   530         // value in the upper position, however QSlider's minimum value is on
   531         // value in the upper position, however QSlider's minimum value is on
   610         d->pressedControl = QStyle::SC_ScrollBarSlider;
   611         d->pressedControl = QStyle::SC_ScrollBarSlider;
   611         d->clickOffset = sliderLength / 2;
   612         d->clickOffset = sliderLength / 2;
   612     }
   613     }
   613     const int initialDelay = 500; // default threshold
   614     const int initialDelay = 500; // default threshold
   614     d->activateControl(d->pressedControl, initialDelay);
   615     d->activateControl(d->pressedControl, initialDelay);
   615     QTime time;
   616     QElapsedTimer time;
   616     time.start();
   617     time.start();
   617     repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
   618     repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
   618     if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
   619     if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
   619         // It took more than 500ms (the initial timer delay) to process the repaint(), we
   620         // It took more than 500ms (the initial timer delay) to process the repaint(), we
   620         // therefore need to restart the timer in case we have a pending mouse release event;
   621         // therefore need to restart the timer in case we have a pending mouse release event;