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

List:       kde-commits
Subject:    playground/office/kraft/src
From:       Klaas Freitag <klaas () freisturz ! de>
Date:       2011-11-07 15:46:43
Message-ID: 20111107154643.C8F09AC88A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1263064 by freitag:

Fix bug with decimal places

 U             CMakeLists.txt  
 M  +10 -5     reportgenerator.cpp  
 M  +1 -1      version.h  


--- trunk/playground/office/kraft/src/reportgenerator.cpp #1263063:1263064
@@ -190,7 +190,6 @@
   /* A placeholder has the format <!-- %VALUE --> */
 
   ArchDocPositionList posList = mArchDoc->positions();
-  QString loopResult;
   QString h;
 
   ArchDocPositionList::iterator it;
@@ -206,10 +205,16 @@
 
     // format the amount value of the item, do not show the precision if there is no fraction
     double amount = pos.amount();
-    if( amount - qRound(amount) > 0 ) // if there is no fraction
-      h = mArchDoc->locale()->formatNumber( amount, 2 );
-    else
-      h = mArchDoc->locale()->formatNumber( amount, 0 );
+    QString num;
+    num.setNum( amount ); // no locale awareness.
+    int prec = 0;
+    if( num.contains( QChar('.') ) ) {
+      // there is a decimal point
+      // calculate the precision
+      prec = num.length() - (1+num.lastIndexOf( QChar('.') ) );
+    }
+    // kDebug() << "**** " << num << " has precision " << prec;
+    h = mArchDoc->locale()->formatNumber( amount, prec );
 
     tmpl.setValue( "POSITIONS", "POS_AMOUNT", h );
     tmpl.setValue( "POSITIONS", "POS_UNIT", pos.unit() );
--- trunk/playground/office/kraft/src/version.h #1263063:1263064
@@ -1,5 +1,5 @@
 #define KPLANT_VERSION "0.4"
-#define KRAFT_VERSION "0.44"
+#define KRAFT_VERSION "0.45"
 
 #define KRAFT_CODENAME "Seelchen"
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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