0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

qt, refactor: Remove default cases for scoped enum

This commit is contained in:
Hennadii Stepanov 2021-01-21 22:30:58 +02:00 committed by William Casarin
parent 152d5bad50
commit ffbc2fe459

View file

@ -30,60 +30,57 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits()
QString BitcoinUnits::longName(Unit unit) QString BitcoinUnits::longName(Unit unit)
{ {
switch(unit) switch (unit) {
{
case Unit::BTC: return QString("BTC"); case Unit::BTC: return QString("BTC");
case Unit::mBTC: return QString("mBTC"); case Unit::mBTC: return QString("mBTC");
case Unit::uBTC: return QString::fromUtf8("µBTC (bits)"); case Unit::uBTC: return QString::fromUtf8("µBTC (bits)");
case Unit::SAT: return QString("Satoshi (sat)"); case Unit::SAT: return QString("Satoshi (sat)");
default: return QString("???"); } // no default case, so the compiler can warn about missing cases
} assert(false);
} }
QString BitcoinUnits::shortName(Unit unit) QString BitcoinUnits::shortName(Unit unit)
{ {
switch(unit) switch (unit) {
{ case Unit::BTC: return longName(unit);
case Unit::uBTC: return QString::fromUtf8("bits"); case Unit::mBTC: return longName(unit);
case Unit::uBTC: return QString("bits");
case Unit::SAT: return QString("sat"); case Unit::SAT: return QString("sat");
default: return longName(unit); } // no default case, so the compiler can warn about missing cases
} assert(false);
} }
QString BitcoinUnits::description(Unit unit) QString BitcoinUnits::description(Unit unit)
{ {
switch(unit) switch (unit) {
{
case Unit::BTC: return QString("Bitcoins"); case Unit::BTC: return QString("Bitcoins");
case Unit::mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)"); case Unit::mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
case Unit::uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)"); case Unit::uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
case Unit::SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)"); case Unit::SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default: return QString("???"); } // no default case, so the compiler can warn about missing cases
} assert(false);
} }
qint64 BitcoinUnits::factor(Unit unit) qint64 BitcoinUnits::factor(Unit unit)
{ {
switch(unit) switch (unit) {
{
case Unit::BTC: return 100'000'000; case Unit::BTC: return 100'000'000;
case Unit::mBTC: return 100'000; case Unit::mBTC: return 100'000;
case Unit::uBTC: return 100; case Unit::uBTC: return 100;
case Unit::SAT: return 1; case Unit::SAT: return 1;
default: return 100'000'000; } // no default case, so the compiler can warn about missing cases
} assert(false);
} }
int BitcoinUnits::decimals(Unit unit) int BitcoinUnits::decimals(Unit unit)
{ {
switch(unit) switch (unit) {
{
case Unit::BTC: return 8; case Unit::BTC: return 8;
case Unit::mBTC: return 5; case Unit::mBTC: return 5;
case Unit::uBTC: return 2; case Unit::uBTC: return 2;
case Unit::SAT: return 0; case Unit::SAT: return 0;
default: return 0; } // no default case, so the compiler can warn about missing cases
} assert(false);
} }
QString BitcoinUnits::format(Unit unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify) QString BitcoinUnits::format(Unit unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify)