diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-01-21 22:30:13 +0200 |
---|---|---|
committer | William Casarin <jb55@jb55.com> | 2022-02-22 13:50:30 -0800 |
commit | 152d5bad50f145af922011f6ec1fd9afd9076ceb (patch) | |
tree | f9911ee70ec4d4a73f943555f0ed70ecda6afc2b /src/qt | |
parent | aa23960fdf1deff321ecea435026c87db78498fb (diff) |
qt, refactor: Remove BitcoinUnits::valid function
Since BitcoinUnits::Unit became a scoped enum, BitcoinUnits::valid
function is no longer needed.
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoinunits.cpp | 26 | ||||
-rw-r--r-- | src/qt/bitcoinunits.h | 2 |
2 files changed, 3 insertions, 25 deletions
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index df2b44dc39..94722ee9f6 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -28,20 +28,6 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits() return unitlist; } -bool BitcoinUnits::valid(Unit unit) -{ - switch(unit) - { - case Unit::BTC: - case Unit::mBTC: - case Unit::uBTC: - case Unit::SAT: - return true; - default: - return false; - } -} - QString BitcoinUnits::longName(Unit unit) { switch(unit) @@ -104,8 +90,6 @@ QString BitcoinUnits::format(Unit unit, const CAmount& nIn, bool fPlus, Separato { // Note: not using straight sprintf here because we do NOT want // localized number formatting. - if(!valid(unit)) - return QString(); // Refuse to format invalid unit qint64 n = (qint64)nIn; qint64 coin = factor(unit); int num_decimals = decimals(unit); @@ -173,8 +157,9 @@ QString BitcoinUnits::formatWithPrivacy(Unit unit, const CAmount& amount, Separa bool BitcoinUnits::parse(Unit unit, const QString& value, CAmount* val_out) { - if(!valid(unit) || value.isEmpty()) + if (value.isEmpty()) { return false; // Refuse to parse invalid unit or empty string + } int num_decimals = decimals(unit); // Ignore spaces and thin spaces when parsing @@ -212,12 +197,7 @@ bool BitcoinUnits::parse(Unit unit, const QString& value, CAmount* val_out) QString BitcoinUnits::getAmountColumnTitle(Unit unit) { - QString amountTitle = QObject::tr("Amount"); - if (BitcoinUnits::valid(unit)) - { - amountTitle += " ("+BitcoinUnits::shortName(unit) + ")"; - } - return amountTitle; + return QObject::tr("Amount") + " (" + shortName(unit) + ")"; } int BitcoinUnits::rowCount(const QModelIndex &parent) const diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index 4534662046..b3b5a8fc18 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -60,8 +60,6 @@ public: //! Get list of units, for drop-down box static QList<Unit> availableUnits(); - //! Is unit ID valid? - static bool valid(Unit unit); //! Long name static QString longName(Unit unit); //! Short name |