Browse Source

Use switch statement

adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
fbd5699786
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 17
      src/base/utils/misc.cpp

17
src/base/utils/misc.cpp

@ -250,13 +250,20 @@ QString Utils::Misc::friendlyUnit(const qint64 bytesValue, const bool isSpeed)
+ unitString(unit, isSpeed); + unitString(unit, isSpeed);
} }
int Utils::Misc::friendlyUnitPrecision(SizeUnit unit) int Utils::Misc::friendlyUnitPrecision(const SizeUnit unit)
{ {
// friendlyUnit's number of digits after the decimal point // friendlyUnit's number of digits after the decimal point
if (unit == SizeUnit::Byte) return 0; switch (unit) {
if (unit <= SizeUnit::MebiByte) return 1; case SizeUnit::Byte:
if (unit == SizeUnit::GibiByte) return 2; return 0;
return 3; case SizeUnit::KibiByte:
case SizeUnit::MebiByte:
return 1;
case SizeUnit::GibiByte:
return 2;
default:
return 3;
}
} }
qlonglong Utils::Misc::sizeInBytes(qreal size, const Utils::Misc::SizeUnit unit) qlonglong Utils::Misc::sizeInBytes(qreal size, const Utils::Misc::SizeUnit unit)

Loading…
Cancel
Save