mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +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;
|
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)
|
QString BitcoinUnits::longName(Unit unit)
|
||||||
{
|
{
|
||||||
switch(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
|
// Note: not using straight sprintf here because we do NOT want
|
||||||
// localized number formatting.
|
// localized number formatting.
|
||||||
if(!valid(unit))
|
|
||||||
return QString(); // Refuse to format invalid unit
|
|
||||||
qint64 n = (qint64)nIn;
|
qint64 n = (qint64)nIn;
|
||||||
qint64 coin = factor(unit);
|
qint64 coin = factor(unit);
|
||||||
int num_decimals = decimals(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)
|
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
|
return false; // Refuse to parse invalid unit or empty string
|
||||||
|
}
|
||||||
int num_decimals = decimals(unit);
|
int num_decimals = decimals(unit);
|
||||||
|
|
||||||
// Ignore spaces and thin spaces when parsing
|
// 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 BitcoinUnits::getAmountColumnTitle(Unit unit)
|
||||||
{
|
{
|
||||||
QString amountTitle = QObject::tr("Amount");
|
return QObject::tr("Amount") + " (" + shortName(unit) + ")";
|
||||||
if (BitcoinUnits::valid(unit))
|
|
||||||
{
|
|
||||||
amountTitle += " ("+BitcoinUnits::shortName(unit) + ")";
|
|
||||||
}
|
|
||||||
return amountTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitcoinUnits::rowCount(const QModelIndex &parent) const
|
int BitcoinUnits::rowCount(const QModelIndex &parent) const
|
||||||
|
@ -60,8 +60,6 @@ public:
|
|||||||
|
|
||||||
//! Get list of units, for drop-down box
|
//! Get list of units, for drop-down box
|
||||||
static QList<Unit> availableUnits();
|
static QList<Unit> availableUnits();
|
||||||
//! Is unit ID valid?
|
|
||||||
static bool valid(Unit unit);
|
|
||||||
//! Long name
|
//! Long name
|
||||||
static QString longName(Unit unit);
|
static QString longName(Unit unit);
|
||||||
//! Short name
|
//! Short name
|
||||||
|
Loading…
Reference in New Issue
Block a user