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

List:       kde-commits
Subject:    kdeutils/kcalc
From:       Klaus Niederkrüger <kniederk () mi ! uni-koeln ! de>
Date:       2005-01-08 1:04:19
Message-ID: 20050108010419.EB4561B9BF () office ! kde ! org
[Download RAW message or body]

CVS commit by kniederk: 

Fixed following Bug: -123133 was represented as -,123,133 because the sign was counted as digit.

Also: '-inf' was represented as '-,inf'.


  M +10 -5     kcalcdisplay.cpp   1.29


--- kdeutils/kcalc/kcalcdisplay.cpp  #1.28:1.29
@@ -28,4 +28,5 @@
 
 #include <qclipboard.h>
+#include <qregexp.h>
 
 #include <kglobal.h>
@@ -343,6 +344,10 @@ void KCalcDisplay::setText(QString const
         QString localizedString = string;
         
+        // Only treat digits (skip the sign)
+        int first_digit = localizedString.find(QRegExp("\\d"));
+        
         // If we aren't in decimal mode, we don't need to modify the string
-        if (_num_base == NB_DECIMAL && !_error && _groupdigits)
+        if (_num_base == NB_DECIMAL  &&  !_error
+            &&  _groupdigits  &&  first_digit != -1)
         {
                 // Obtain decimal symbol and thousands separator
@@ -363,5 +368,5 @@ void KCalcDisplay::setText(QString const
                 int pos = QMIN((decimalSymbolPos - 1), (eSymbolPos-1));
                 
-                for(int index=1;pos>0;pos--,index++)
+                for(int index=1;pos>first_digit;pos--,index++)
                         if (index%3 == 0)
                                 localizedString.insert(pos,thousandsSeparator);


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

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