add megadoge and kilodoge as selectable units

This commit is contained in:
Jannis Froese 2014-03-25 20:25:44 +01:00
parent b21c097383
commit c100579e2e
2 changed files with 25 additions and 7 deletions

View file

@ -15,6 +15,8 @@ BitcoinUnits::BitcoinUnits(QObject *parent):
QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits() QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits()
{ {
QList<BitcoinUnits::Unit> unitlist; QList<BitcoinUnits::Unit> unitlist;
unitlist.append(MDOGE);
unitlist.append(kDOGE);
unitlist.append(DOGE); unitlist.append(DOGE);
unitlist.append(mDOGE); unitlist.append(mDOGE);
unitlist.append(uDOGE); unitlist.append(uDOGE);
@ -26,6 +28,8 @@ bool BitcoinUnits::valid(int unit)
{ {
switch(unit) switch(unit)
{ {
case MDOGE:
case kDOGE:
case DOGE: case DOGE:
case mDOGE: case mDOGE:
case uDOGE: case uDOGE:
@ -40,6 +44,8 @@ QString BitcoinUnits::name(int unit)
{ {
switch(unit) switch(unit)
{ {
case MDOGE: return QString("MDOGE");
case kDOGE: return QString("kDOGE");
case DOGE: return QString("DOGE"); case DOGE: return QString("DOGE");
case mDOGE: return QString("mDOGE"); case mDOGE: return QString("mDOGE");
case uDOGE: return QString::fromUtf8("μDOGE"); case uDOGE: return QString::fromUtf8("μDOGE");
@ -52,6 +58,8 @@ QString BitcoinUnits::description(int unit)
{ {
switch(unit) switch(unit)
{ {
case MDOGE: return QString("Mega-Dogecoin (1,000,000 DOGE)");
case kDOGE: return QString("Kilo-Dogecoin (1000 DOGE)");
case DOGE: return QString("Dogecoin"); case DOGE: return QString("Dogecoin");
case mDOGE: return QString("Milli-Dogecoin (1 / 1,000)"); case mDOGE: return QString("Milli-Dogecoin (1 / 1,000)");
case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)"); case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)");
@ -64,11 +72,13 @@ qint64 BitcoinUnits::factor(int unit)
{ {
switch(unit) switch(unit)
{ {
case DOGE: return 100000000; case MDOGE: return Q_INT64_C(100000000000000);
case mDOGE: return 100000; case kDOGE: return Q_INT64_C(100000000000);
case uDOGE: return 100; case DOGE: return Q_INT64_C(100000000);
case Koinu: return 1; case mDOGE: return Q_INT64_C(100000);
default: return 100000000; case uDOGE: return Q_INT64_C(100);
case Koinu: return Q_INT64_C(1);
default: return Q_INT64_C(100000000);
} }
} }
@ -76,6 +86,8 @@ qint64 BitcoinUnits::maxAmount(int unit)
{ {
switch(unit) switch(unit)
{ {
case MDOGE: return Q_INT64_C(900000);
case kDOGE: return Q_INT64_C(900000000);
case DOGE: return Q_INT64_C(900000000000); //less than the coin supply until the year 2170 case DOGE: return Q_INT64_C(900000000000); //less than the coin supply until the year 2170
case mDOGE: return Q_INT64_C(900000000000000); case mDOGE: return Q_INT64_C(900000000000000);
case uDOGE: return Q_INT64_C(900000000000000000); case uDOGE: return Q_INT64_C(900000000000000000);
@ -88,7 +100,9 @@ int BitcoinUnits::amountDigits(int unit)
{ {
switch(unit) switch(unit)
{ {
case DOGE: return 12; // 900,000,000,000 (# digits, without commas) case MDOGE: return 6; // 900,000 (# digits, without commas)
case kDOGE: return 9; // 900,000,000
case DOGE: return 12; // 900,000,000,000
case mDOGE: return 15; // 900,000,000,000,000 case mDOGE: return 15; // 900,000,000,000,000
case uDOGE: return 18; // 900,000,000,000,000,000 case uDOGE: return 18; // 900,000,000,000,000,000
case Koinu: return 20; // 90,000,000,000,000,000,000 case Koinu: return 20; // 90,000,000,000,000,000,000
@ -100,6 +114,8 @@ int BitcoinUnits::decimals(int unit)
{ {
switch(unit) switch(unit)
{ {
case MDOGE: return 14;
case kDOGE: return 11;
case DOGE: return 8; case DOGE: return 8;
case mDOGE: return 5; case mDOGE: return 5;
case uDOGE: return 2; case uDOGE: return 2;

View file

@ -21,11 +21,13 @@ public:
/** Bitcoin units. /** Bitcoin units.
@note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones
*/ */
enum Unit enum Unit //Note: preserve positions in order to preserve existing settings
{ {
DOGE, DOGE,
mDOGE, mDOGE,
uDOGE, uDOGE,
MDOGE,
kDOGE,
Koinu Koinu
}; };