71 QString formatFileSize(qint64 size) |
71 QString formatFileSize(qint64 size) |
72 { |
72 { |
73 static const QString suffixes[] = {" bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; |
73 static const QString suffixes[] = {" bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; |
74 int magnitude = (size > 0) ? floor(log10(size) / 3.0 + 1e-10) : 0; |
74 int magnitude = (size > 0) ? floor(log10(size) / 3.0 + 1e-10) : 0; |
75 magnitude = qBound(0, magnitude, countof(suffixes) - 1); |
75 magnitude = qBound(0, magnitude, countof(suffixes) - 1); |
76 return QString::number(size / pow(1000, magnitude)) + suffixes[magnitude]; |
76 return QString::number(size / pow(1000, magnitude), 'f', 3) + suffixes[magnitude]; |
77 } |
77 } |
78 |
78 |
79 /* |
79 /* |
80 * Returns a settings object that interfaces the ini file. |
80 * Returns a settings object that interfaces the ini file. |
81 */ |
81 */ |