Skip to content
Browse files

webkit/foldervis: Better formatting of the size.

  • Loading branch information...
1 parent 34cf305 commit 2ed7b9116b8880565bc029fe6b0a6ef9a5d45fde @ariya committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 webkit/foldervis/foldervis.cpp
View
10 webkit/foldervis/foldervis.cpp
@@ -74,14 +74,18 @@ Entry Crawler::search(const QString &path)
QString displayedSize(int size)
{
+ const qreal K = 1024;
+ const qreal M = K * K;
+ const qreal G = K * M;
+
if (size > 1024 * 1024 * 1024) {
- return QString::number(size / 1024 / 1024 / 1024) + "G";
+ return QString::number(size / G, 'f', 1) + "G";
}
if (size > 1024 * 1024) {
- return QString::number(size / 1024 / 1024) + "M";
+ return QString::number(size / M, 'f', 1) + "M";
}
if (size > 1024) {
- return QString::number(size / 1024) + "K";
+ return QString::number(size / K, 'f', 1) + "K";
}
return QString::number(size);
}

0 comments on commit 2ed7b91

Please sign in to comment.
Something went wrong with that request. Please try again.