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

List:       kde-commits
Subject:    kdebase/ksysguard/gui/SensorDisplayLib
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2002-12-31 11:44:02
[Download RAW message or body]

CVS commit by tokoe: 


add support for localized number representation to ListView


  M +20 -11    ListView.cc   1.5
  M +5 -4      ListView.h   1.5


--- kdebase/ksysguard/gui/SensorDisplayLib/ListView.cc  #1.4:1.5
@@ -34,5 +34,6 @@
 #include <kcolorbutton.h>
 #include <kdebug.h>
-
+#include <kglobal.h>
+#include <klocale.h>
 #include <ksgrd/ColorPicker.h>
 #include <ksgrd/SensorManager.h>
@@ -93,10 +94,10 @@ diskStatKey(const char* text)
         char *number, *dev;
         char tmp[1024];
-        int i, val;
+        int val;
         static char key[100];
 
-        strlcpy(tmp, text, sizeof(tmp) - 1);
+        strlcpy( tmp, text, sizeof(tmp) - 1 );
         number = tmp;
-        for (i = 0; i < strlen(tmp); i++) {
+        for ( uint i = 0; i < strlen(tmp); i++ ) {
                 number++;
                 if (isdigit(tmp[i])) {
@@ -152,6 +153,12 @@ void PrivateListView::update(const QStri
                 PrivateListViewItem *item = new PrivateListViewItem(this);
                 KSGRD::SensorTokenizer records(lines[i], '\t');
-                for (uint j = 0; j < records.numberOfTokens(); j++)
+                for (uint j = 0; j < records.numberOfTokens(); j++) {
+      if ( mColumnTypes[ j ] == "f" )
+        item->setText(j, KGlobal::locale()->formatNumber( records[j].toFloat() ) );
+      else if ( mColumnTypes[ j ] == "D" )
+        item->setText(j, KGlobal::locale()->formatNumber( records[j].toDouble(), 0 ) );
+      else
                         item->setText(j, records[j]);
+    }
 
                 insertItem(item);
@@ -179,5 +186,5 @@ PrivateListView::addColumn(const QString
                 sortFunc.append(0);
         }
-        else if (type == "d")
+        else if (type == "d" || type == "D")
         {
                 setColumnAlignment(col, AlignRight);
@@ -206,4 +213,6 @@ PrivateListView::addColumn(const QString
                 return;
         }
+
+  mColumnTypes.append( type );
 
         /* Just use some sensible default values as initial setting. */

--- kdebase/ksysguard/gui/SensorDisplayLib/ListView.h  #1.4:1.5
@@ -17,6 +17,6 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-        KSysGuard is currently maintained by Chris Schlaeger <cs@kde.org>. Please do
-        not commit any changes without consulting me first. Thanks!
+    KSysGuard is currently maintained by Chris Schlaeger <cs@kde.org>.
+    Please do not commit any changes without consulting me first. Thanks!
 
         $Id$
@@ -50,4 +50,5 @@ public:
 private:
         QValueList<KeyFunc> sortFunc;
+  QStringList mColumnTypes;
 };
 


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

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