|
|
|
@ -358,12 +358,20 @@ QString Utils::Misc::friendlyUnit(qint64 bytesValue, bool isSpeed)
@@ -358,12 +358,20 @@ QString Utils::Misc::friendlyUnit(qint64 bytesValue, bool isSpeed)
|
|
|
|
|
if (unit == SizeUnit::Byte) |
|
|
|
|
ret = QString::number(bytesValue) + " " + unitString(unit); |
|
|
|
|
else |
|
|
|
|
ret = Utils::String::fromDouble(friendlyVal, 1) + " " + unitString(unit); |
|
|
|
|
ret = Utils::String::fromDouble(friendlyVal, friendlyUnitPrecision(unit)) + " " + unitString(unit); |
|
|
|
|
if (isSpeed) |
|
|
|
|
ret += QCoreApplication::translate("misc", "/s", "per second"); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int Utils::Misc::friendlyUnitPrecision(SizeUnit unit) |
|
|
|
|
{ |
|
|
|
|
// friendlyUnit's number of digits after the decimal point
|
|
|
|
|
if (unit <= SizeUnit::MebiByte) return 1; |
|
|
|
|
else if (unit == SizeUnit::GibiByte) return 2; |
|
|
|
|
else return 3; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < static_cast<int>(unit); ++i) |
|
|
|
|