diff options
| author | Peter Penz <[email protected]> | 2011-11-04 21:54:01 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-11-04 21:58:32 +0100 |
| commit | eadbf920b5dffdf2d1548240c25ec2eaf835aad5 (patch) | |
| tree | fec0857c4a8b95cdaaa6756f50b9412c35b58668 /src/kitemviews/kfileitemlistwidget.cpp | |
| parent | d27f776cd2675e67b70556ad4033230435d89d8e (diff) | |
Don't use mixed units in size-column of details-view
This makes it tricky to compare the filesizes without adjusting
the sort-order, so now all sizes in the size-column are shown
in KiB or KB (dependent on the KLocale setting).
BUG: 219932
FIXED-IN: 4.8.0
Related fixes:
- Stay consistent with the rounding when using the KiB/KB unit
in the statusbar.
- Fix sorting-by-size issue for folders
- Show "Unknown" in the size-column when the number of items
cannot be determined.
Diffstat (limited to 'src/kitemviews/kfileitemlistwidget.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 5f659a1f6..d6b892658 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -192,13 +192,18 @@ QString KFileItemListWidget::roleText(const QByteArray& role, const QHash<QByteA if (values.value("isDir").toBool()) { // The item represents a directory. Show the number of sub directories // instead of the file size of the directory. - if (!roleValue.isNull()) { + if (roleValue.isNull()) { + text = i18nc("@item:intable", "Unknown"); + } else { const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); text = i18ncp("@item:intable", "%1 item", "%1 items", size); } } else { - const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); - text = KIO::convertSize(size); + // 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); } break; } |
