mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-22 06:26:43 +02:00
qt, refactor: Remove BitcoinUnits::valid function
Since BitcoinUnits::Unit became a scoped enum, BitcoinUnits::valid function is no longer needed.
This commit is contained in:
parent
aa23960fdf
commit
152d5bad50
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user