mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 18:32:51 +00:00
karchivemanager: use KLocale::formatByteSize() for fancy size string
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d83656f7ad
commit
873b81e661
1 changed files with 2 additions and 18 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <KDebug>
|
||||
#include <KMimeType>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
|
||||
#include "karchivemanager.hpp"
|
||||
|
||||
|
@ -102,25 +103,8 @@ QString KArchiveInfo::fancyEncrypted() const {
|
|||
return QString("No");
|
||||
}
|
||||
|
||||
// it does not make very accurate estimations but is good enough
|
||||
QString KArchiveInfo::fancySize() const {
|
||||
QString result;
|
||||
|
||||
const int64_t bsize = 1024;
|
||||
const int64_t kbsize = 1024 * 1024;
|
||||
const int64_t mbsize = 1024 * 1024 * 1024;
|
||||
|
||||
if (size < bsize) {
|
||||
result = QString::number(size) + " bytes";
|
||||
} else if (size < kbsize) {
|
||||
result = QString::number(size / bsize) + " Kb";
|
||||
} else if (size < mbsize) {
|
||||
result = QString::number(size / kbsize) + " Mb";
|
||||
} else {
|
||||
result = QString::number(size / mbsize) + " Gb";
|
||||
}
|
||||
|
||||
return result;
|
||||
return KGlobal::locale()->formatByteSize(size, 1);
|
||||
}
|
||||
|
||||
QString KArchiveInfo::fancyMode() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue