[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kplato/libs/models
From:       Dag Andersen <danders () get2net ! dk>
Date:       2010-09-07 8:31:46
Message-ID: 20100907083146.091B6AC7CB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1172417 by danders:

DurationSpinBox:
Override QSpinBox's problematic cursor pos policy.
Use KLocale text-to-number conversion.


 M  +5 -2      kptdurationspinbox.cpp  


--- trunk/koffice/kplato/libs/models/kptdurationspinbox.cpp #1172416:1172417
@@ -111,6 +111,7 @@
 void DurationSpinBox::stepBy( int steps )
 {
     //kDebug()<<steps;
+    int cpos = lineEdit()->cursorPosition();
     if ( isOnUnit() ) {
         // we are in unit
         if ( steps > 0 ) {
@@ -118,9 +119,12 @@
         } else if ( steps < 0 ) {
             stepUnitDown();
         }
+        lineEdit()->setCursorPosition( cpos );
         return;
     }
     QDoubleSpinBox::stepBy( steps );
+    // QDoubleSpinBox selects the whole text and the cursor might end up at the end \
(in the unit field) +    lineEdit()->setCursorPosition( cpos ); // also deselects
 }
 
 QAbstractSpinBox::StepEnabled DurationSpinBox::stepEnabled () const
@@ -183,10 +187,9 @@
 
 double DurationSpinBox::valueFromText( const QString & text ) const
 {
-    //HACK to get around different QLocale/KLocale. Prob. needs to rewrite class to \
                not use QDoubleSpinBox
     QString s = extractValue( text ).remove( KGlobal::locale()->thousandsSeparator() \
);  bool ok = false;
-    double v = s.toDouble( &ok );
+    double v = KGlobal::locale()->readNumber( s, &ok );
     if ( ! ok ) {
         v = QDoubleSpinBox::valueFromText( s );
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic