]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Revert the 2.0 decision to always use KB for file-sizes
authorPeter Penz <peter.penz19@gmail.com>
Mon, 9 Apr 2012 07:44:05 +0000 (09:44 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 9 Apr 2012 07:50:17 +0000 (09:50 +0200)
The feedback on bugs.kde.org has shown that the previous behavior
(= show size with best-matching unit) is preferred by most users.
I initially wanted to make this configurable, but for implementing
it in a non-hacky way extending KLocale from kdelibs would have
been required. I'm not sure whether the usecase in Dolphin justifies
having such a configuration in KLocale - however as kdelibs is frozen
at the moment this is no option and the old behavior has been
restored.

BUG: 289850
FIXED-IN: 4.9.0

src/kitemviews/kfileitemlistwidget.cpp
src/views/dolphinview.cpp
src/views/dolphinview.h

index af7ea1523d74c9727e6a42f5cc86c3618050a8eb..14ec1ec22f15b379722fa69b39b3a90dbf7815fc 100644 (file)
@@ -1071,11 +1071,8 @@ QString KFileItemListWidget::roleText(const QByteArray& role, const QHash<QByteA
                 }
             }
         } else {
-            // Show the size in kilobytes (always round up)
-            const KLocale* locale = KGlobal::locale();
-            const int roundInc = (locale->binaryUnitDialect() == KLocale::MetricBinaryDialect) ? 499 : 511;
-            const KIO::filesize_t size = roleValue.value<KIO::filesize_t>() + roundInc;
-            text = locale->formatByteSize(size, 0, KLocale::DefaultBinaryDialect, KLocale::UnitKiloByte);
+            const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
+            text = KGlobal::locale()->formatByteSize(size);
         }
         break;
     }
index 78fd56d50374f4289062c81596b571e76011020f..872853642a01c157f886afab194097b1f76aa16f 100644 (file)
@@ -539,9 +539,12 @@ QString DolphinView::statusBarText() const
 
     if (fileCount > 0 && folderCount > 0) {
         summary = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
-                        foldersText, filesText, fileSizeText(totalFileSize));
+                        foldersText, filesText,
+                        KGlobal::locale()->formatByteSize(totalFileSize));
     } else if (fileCount > 0) {
-        summary = i18nc("@info:status files (size)", "%1 (%2)", filesText, fileSizeText(totalFileSize));
+        summary = i18nc("@info:status files (size)", "%1 (%2)",
+                        filesText,
+                        KGlobal::locale()->formatByteSize(totalFileSize));
     } else if (folderCount > 0) {
         summary = foldersText;
     }
@@ -1471,27 +1474,4 @@ void DolphinView::updateWritableState()
     }
 }
 
-QString DolphinView::fileSizeText(KIO::filesize_t fileSize)
-{
-    const KLocale* locale = KGlobal::locale();
-    const unsigned int multiplier = (locale->binaryUnitDialect() == KLocale::MetricBinaryDialect)
-                                    ? 1000 : 1024;
-
-    QString text;
-    if (fileSize < multiplier) {
-        // Show the size in bytes
-        text = locale->formatByteSize(fileSize, 0, KLocale::DefaultBinaryDialect, KLocale::UnitByte);
-    } else if (fileSize < multiplier * multiplier) {
-        // Show the size in kilobytes and always round up. This is done
-        // for consistency with the values shown e.g. in the "Size" column
-        // of the details-view.
-        fileSize += (multiplier / 2) - 1;
-        text = locale->formatByteSize(fileSize, 0, KLocale::DefaultBinaryDialect, KLocale::UnitKiloByte);
-    } else {
-        // Show the size in the best fitting unit having one decimal
-        text = locale->formatByteSize(fileSize, 1);
-    }
-    return text;
-}
-
 #include "dolphinview.moc"
index 71128569af8bda1c4952752d189bba4775235a43..130657b166ef22baac6bc876e50390fc1ae9fe17 100644 (file)
@@ -716,12 +716,6 @@ private:
      */
     void updateWritableState();
 
-    /**
-     * Returns the text for the filesize by converting it to the best fitting
-     * unit.
-     */
-    static QString fileSizeText(KIO::filesize_t fileSize);
-
 private:
     bool m_active;
     bool m_tabsForFiles;