Currency format updated

This commit is contained in:
Andre Jochems
2015-11-19 15:06:24 +01:00
parent 2079e3456a
commit 07e9dea07b
11 changed files with 113 additions and 86 deletions

View File

@@ -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);