Transfers: Show a decimal for single digit MB rates #4428
authorChristian Kamm <mail@ckamm.de>
Tue, 4 Apr 2017 07:54:06 +0000 (09:54 +0200)
committerChristian Kamm <mail@ckamm.de>
Tue, 4 Apr 2017 07:54:06 +0000 (09:54 +0200)
src/libsync/utility.cpp
test/testutility.cpp

index 7868aeb5a2d5bd4ecbe145437a02579296a06c7c..2a140f89ef98e668090a11a41b873e7bad28dfd4 100644 (file)
@@ -122,8 +122,8 @@ QString Utility::octetsToString( qint64 octets )
     QString s;
     qreal value = octets;
 
-    // Whether we care about decimals: only for GB and only
-    // if it's less than 10 GB.
+    // Whether we care about decimals: only for GB/MB and only
+    // if it's less than 10 units.
     bool round = true;
 
     // do not display terra byte with the current units, as when
@@ -137,6 +137,7 @@ QString Utility::octetsToString( qint64 octets )
     } else if (octets >= mb) {
         s = QCoreApplication::translate("Utility", "%L1 MB");
         value /= mb;
+        round = false;
     } else if (octets >= kb) {
         s = QCoreApplication::translate("Utility", "%L1 KB");
         value /= kb;
index ce3905a6ea418cce93e121a9b692c4ffe2175cfd..5a656ac846bf31cd2a7b47cb115bd2ab6ec17052 100644 (file)
@@ -40,7 +40,7 @@ private slots:
         QCOMPARE(octetsToString(10240) , QString("10 KB"));
 
         QCOMPARE(octetsToString(123456) , QString("121 KB"));
-        QCOMPARE(octetsToString(1234567) , QString("1 MB"));
+        QCOMPARE(octetsToString(1234567) , QString("1.2 MB"));
         QCOMPARE(octetsToString(12345678) , QString("12 MB"));
         QCOMPARE(octetsToString(123456789) , QString("118 MB"));
         QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("4.7 GB"));