mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-03-02 17:16:00 +00:00
Balance shown with locale specific thousands and decimal separators
Balance shown with locale specific thousands and decimal separators
This commit is contained in:
parent
91c8ddd99d
commit
776a33296d
@ -1,6 +1,7 @@
|
||||
#include "bitcoinunits.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QLocale>
|
||||
|
||||
BitcoinUnits::BitcoinUnits(QObject *parent):
|
||||
QAbstractListModel(parent),
|
||||
@ -96,7 +97,6 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus)
|
||||
qint64 n_abs = (n > 0 ? n : -n);
|
||||
qint64 quotient = n_abs / coin;
|
||||
qint64 remainder = n_abs % coin;
|
||||
QString quotient_str = QString::number(quotient);
|
||||
QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
|
||||
|
||||
// Right-trim excess zeros after the decimal point
|
||||
@ -106,10 +106,10 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus)
|
||||
remainder_str.chop(nTrim);
|
||||
|
||||
if (n < 0)
|
||||
quotient_str.insert(0, '-');
|
||||
else if (fPlus && n > 0)
|
||||
quotient_str.insert(0, '+');
|
||||
return quotient_str + QString(".") + remainder_str;
|
||||
quotient = -quotient;
|
||||
|
||||
QLocale local;
|
||||
return local.toString(quotient) + local.decimalPoint() + remainder_str;
|
||||
}
|
||||
|
||||
QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user