src/gui/widgets/qabstractslider.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
--- a/src/gui/widgets/qabstractslider.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/widgets/qabstractslider.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -219,8 +219,12 @@
 #ifdef QT_KEYPAD_NAVIGATION
       , isAutoRepeating(false)
       , repeatMultiplier(1)
+{
+    firstRepeat.invalidate();
+#else
+{
 #endif
-{
+
 }
 
 QAbstractSliderPrivate::~QAbstractSliderPrivate()
@@ -712,7 +716,15 @@
             offset_accumulated = 0;
 
         offset_accumulated += stepsToScrollF;
+#ifndef Q_WS_MAC
+        // Dont't scroll more than one page in any case:
         stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep);
+#else
+        // Native UI-elements on Mac can scroll hundreds of lines at a time as
+        // a result of acceleration. So keep the same behaviour in Qt, and
+        // dont restrict stepsToScroll to certain maximum (pageStep): 
+        stepsToScroll = int(offset_accumulated);
+#endif
         offset_accumulated -= int(offset_accumulated);
         if (stepsToScroll == 0)
             return false;
@@ -756,12 +768,12 @@
     SliderAction action = SliderNoAction;
 #ifdef QT_KEYPAD_NAVIGATION
     if (ev->isAutoRepeat()) {
-        if (d->firstRepeat.isNull())
-            d->firstRepeat = QTime::currentTime();
+        if (!d->firstRepeat.isValid())
+            d->firstRepeat.start();
         else if (1 == d->repeatMultiplier) {
             // This is the interval in milli seconds which one key repetition
             // takes.
-            const int repeatMSecs = d->firstRepeat.msecsTo(QTime::currentTime());
+            const int repeatMSecs = d->firstRepeat.elapsed();
 
             /**
              * The time it takes to currently navigate the whole slider.
@@ -779,8 +791,8 @@
         }
 
     }
-    else if (!d->firstRepeat.isNull()) {
-        d->firstRepeat = QTime();
+    else if (d->firstRepeat.isValid()) {
+        d->firstRepeat.invalidate();
         d->repeatMultiplier = 1;
     }