Utils: improve bytes formatting

This commit is contained in:
tobtoht 2020-12-24 13:20:44 +01:00
parent bd4400a7f2
commit 200f16ecf2
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C

View file

@ -553,14 +553,14 @@ QString Utils::formatBytes(quint64 bytes)
int i; int i;
double _data; double _data;
for (i = 0; i < sizes.count() && bytes >= 1000; i++, bytes /= 1000) for (i = 0; i < sizes.count() && bytes >= 10000; i++, bytes /= 1000)
_data = bytes / 1000.0; _data = bytes / 1000.0;
if (_data < 0) if (_data < 0)
_data = 0; _data = 0;
// unrealistic // unrealistic
if (_data > 1000) if (_data > 10000)
_data = 0; _data = 0;
return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]); return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]);