[kde-doc-english] [trojita] src/Imap/Model: GUI: don't show the decimal part for numbers greater than 100
Jan Kundrát
jkt at flaska.net
Fri Jan 4 15:15:48 UTC 2013
Git commit 0ecd1603a657f25fdc4f4463a983697af2df9add by Jan Kundrát.
Committed on 04/01/2013 at 04:59.
Pushed by jkt into branch 'master'.
GUI: don't show the decimal part for numbers greater than 100
M +3 -1 src/Imap/Model/Utils.cpp
http://commits.kde.org/trojita/0ecd1603a657f25fdc4f4463a983697af2df9add
diff --git a/src/Imap/Model/Utils.cpp b/src/Imap/Model/Utils.cpp
index 315c89b..cd0c7de 100644
--- a/src/Imap/Model/Utils.cpp
+++ b/src/Imap/Model/Utils.cpp
@@ -49,6 +49,8 @@ QString PrettySize::prettySize(uint bytes, const ShowBytesSuffix compactUnitForm
return tr("0");
}
int order = std::log(static_cast<double>(bytes)) / std::log(1024.0);
+ double number = bytes / std::pow(1024.0, order);
+
QString suffix;
if (order <= 0) {
if (compactUnitFormat == COMPACT_FORM)
@@ -66,7 +68,7 @@ QString PrettySize::prettySize(uint bytes, const ShowBytesSuffix compactUnitForm
order = 4;
suffix = tr("TB"); // shame on you for such mails
}
- return tr("%1 %2").arg(QString::number(bytes / std::pow(1024.0, order), 'f', 1), suffix);
+ return tr("%1 %2").arg(QString::number(number, 'f', number < 100 ? 1 : 0), suffix);
}
QString persistentLogFileName()
More information about the kde-doc-english
mailing list