mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-05 12:49:47 -08:00
Currency format updated
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "currencies.h"
|
||||
#include <QStringList>
|
||||
#include <QLocale>
|
||||
|
||||
Currencies::Currencies(QObject *parent):
|
||||
QAbstractListModel(parent),
|
||||
@@ -59,6 +60,34 @@ QString Currencies::description(int currency)
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::symbol(int currency)
|
||||
{
|
||||
switch(currency)
|
||||
{
|
||||
case USD: return QString("$");
|
||||
case EUR: return QString("€");
|
||||
case CNY: return QString("¥");
|
||||
case JPY: return QString("¥");
|
||||
case RUB: return QString("₽");
|
||||
default: return QString("$");
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::format(int currency, double value, bool useSymbol)
|
||||
{
|
||||
// divide by satoshi
|
||||
double fiatValue = value * 0.00000001;
|
||||
QString formattedValue = "";
|
||||
if(useSymbol)
|
||||
{
|
||||
formattedValue.append(symbol(currency)).append(" ");
|
||||
}
|
||||
// apply format
|
||||
QLocale::setDefault( QLocale(QLocale::English, QLocale::UnitedStates) );
|
||||
formattedValue.append(QString("%L1").arg(fiatValue, 0, 'f', 2)).append(" ").append(name(currency));
|
||||
return formattedValue;
|
||||
}
|
||||
|
||||
int Currencies::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
Reference in New Issue
Block a user