Bug 73643 - File size info for large files (>1GB) shows too few digits
Summary: File size info for large files (>1GB) shows too few digits
Status: RESOLVED FIXED
Alias: None
Product: kmldonkey
Classification: Applications
Component: general (show other bugs)
Version: 0.9.1
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Petter Stokke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-27 22:37 UTC by Henk de Leeuw
Modified: 2004-02-07 18:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henk de Leeuw 2004-01-27 22:37:47 UTC
Version:           0.9.1 (using KDE KDE 3.2.0)
OS:          Linux

When displaying Size and Downloaded, only one digit after the decimal point is printed, even when there is room for more.
E.g. instead of 1.1G, I would like to see 1.134G, so I can monitor progress better.

Patch to accomplish this:

--- infolist.old.cpp    2004-01-27 20:22:27.000000000 +0100
+++ infolist.cpp        2004-01-27 21:54:13.760975192 +0100
@@ -185,9 +185,15 @@
 {
     QString foo;
     double sz = (double)rsz;
-    if (sz >= (double)(1024 * 1024 * 1024)) {
+    if (sz >= (100.0 * 1024.0 * 1024.0 * 1024.0)) {
        sz = sz / (1024 * 1024 * 1024);
        foo.sprintf(i18n("%.1fG"), sz);
+    } else if (sz >= (10.0 * 1024.0 * 1024.0 * 1024.0)) {
+       sz = sz / (1024 * 1024 * 1024);
+       foo.sprintf(i18n("%.2fG"), sz);
+    } else if (sz >= (1024.0 * 1024.0 * 1024.0)) {
+       sz = sz / (1024 * 1024 * 1024);
+       foo.sprintf(i18n("%.3fG"), sz);
     } else if (sz >= (double)(1024 * 1024)) {
        sz = sz / (1024 * 1024);
        foo.sprintf(i18n("%.1fM"), sz);
Comment 1 Petter Stokke 2004-02-07 18:31:09 UTC
Subject: kdeextragear-2/kmldonkey/kmldonkey

CVS commit by pstokke: 

Use higher precision when displaying gigabytes if there's room available.
Thanks to Henk de Leeuw for the idea.

CCMAIL: 73643-done@bugs.kde.org


  M +16 -10    infolist.cpp   1.19


--- kdeextragear-2/kmldonkey/kmldonkey/infolist.cpp  #1.18:1.19
@@ -226,12 +226,18 @@ QString humanReadableSize(int64 rsz)
 
     if (KMLDonkey::App->humanReadableSizes) {
-        if (sz >= (double)(1024 * 1024 * 1024)) {
-            sz = sz / (1024 * 1024 * 1024);
+        if (sz >= (100.0 * 1024.0 * 1024.0 * 1024.0)) { 
+            sz = sz / (1024.0 * 1024.0 * 1024.0);
             foo = i18n("gigabyte suffix", "%1G").arg(KGlobal::locale()->formatNumber(sz, 1));
-        } else if (sz >= (double)(1024 * 1024)) {
-            sz = sz / (1024 * 1024);
+        } else if (sz >= (10.0 * 1024.0 * 1024.0 * 1024.0)) { 
+            sz = sz / (1024.0 * 1024.0 * 1024.0); 
+            foo = i18n("gigabyte suffix", "%1G").arg(KGlobal::locale()->formatNumber(sz, 2));
+        } else if (sz >= (1024.0 * 1024.0 * 1024.0)) { 
+            sz = sz / (1024.0 * 1024.0 * 1024.0); 
+            foo = i18n("gigabyte suffix", "%1G").arg(KGlobal::locale()->formatNumber(sz, 3));
+        } else if (sz >= (1024.0 * 1024.0)) {
+            sz = sz / (1024.0 * 1024.0);
             foo = i18n("megabyte suffix", "%1M").arg(KGlobal::locale()->formatNumber(sz, 1));
-        } else if (sz >= (double)1024) {
-            sz = sz / 1024;
+        } else if (sz >= 1024.0) {
+            sz = sz / 1024.0;
             foo = i18n("kilobyte suffix", "%1K").arg(KGlobal::locale()->formatNumber(sz, 1));
         } else foo = KGlobal::locale()->formatNumber(sz, 0);