summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <peter.penz19@gmail.com>2012-04-09 09:53:45 (GMT)
committerPeter Penz <peter.penz19@gmail.com>2012-04-09 09:53:45 (GMT)
commit5559aaaa0bf2f731ce2413f140b20f4a2d3c60b3 (patch)
tree78d45ac67feed3d296d37efd72312e3b6b7431cd
parentda87fe48976147d656f6c0157face04d729e6ceb (diff)
Revert the 2.0 decision to always use KB for file-sizes
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.8.3
-rw-r--r--dolphin/src/kitemviews/kfileitemlistwidget.cpp7
-rw-r--r--dolphin/src/views/dolphinview.cpp30
-rw-r--r--dolphin/src/views/dolphinview.h6
3 files changed, 7 insertions, 36 deletions
diff --git a/dolphin/src/kitemviews/kfileitemlistwidget.cpp b/dolphin/src/kitemviews/kfileitemlistwidget.cpp
index fb0f4df..7744dcc 100644
--- a/dolphin/src/kitemviews/kfileitemlistwidget.cpp
+++ b/dolphin/src/kitemviews/kfileitemlistwidget.cpp
@@ -251,11 +251,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;
}
diff --git a/dolphin/src/views/dolphinview.cpp b/dolphin/src/views/dolphinview.cpp
index 38afd6e..3a220e7 100644
--- a/dolphin/src/views/dolphinview.cpp
+++ b/dolphin/src/views/dolphinview.cpp
@@ -532,9 +532,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;
}
@@ -1401,27 +1404,4 @@ DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole)
return sortHash.value(sortRole);
}
-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"
diff --git a/dolphin/src/views/dolphinview.h b/dolphin/src/views/dolphinview.h
index f2f15c5..7e264d9 100644
--- a/dolphin/src/views/dolphinview.h
+++ b/dolphin/src/views/dolphinview.h
@@ -740,12 +740,6 @@ private:
QByteArray sortRoleForSorting(Sorting sorting) const;
Sorting sortingForSortRole(const QByteArray& sortRole) const;
- /**
- * 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;