From 1026ca71d34eea0f1e1e0cff152fd0cc37f22219 Mon Sep 17 00:00:00 2001 From: jwiechers Date: Tue, 25 Mar 2014 00:07:07 +0100 Subject: [PATCH 1/5] Update bitcoinunits.cpp Adding a name for the smallest possible unit. :> --- src/qt/bitcoinunits.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index e9a865de0..136250aad 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -18,6 +18,7 @@ QList BitcoinUnits::availableUnits() unitlist.append(DOGE); unitlist.append(mDOGE); unitlist.append(uDOGE); + unitlist.append(Koinu); return unitlist; } @@ -28,6 +29,7 @@ bool BitcoinUnits::valid(int unit) case DOGE: case mDOGE: case uDOGE: + case Koinu: return true; default: return false; @@ -41,6 +43,7 @@ QString BitcoinUnits::name(int unit) case DOGE: return QString("DOGE"); case mDOGE: return QString("mDOGE"); case uDOGE: return QString::fromUtf8("μDOGE"); + case Koinu: return QString("Koinu") default: return QString("???"); } } @@ -52,6 +55,7 @@ QString BitcoinUnits::description(int unit) case DOGE: return QString("Dogecoin"); case mDOGE: return QString("Milli-Dogecoin (1 / 1,000)"); case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)"); + case Koinu: return QString("Koinu (1 / 100,000,000") default: return QString("???"); } } @@ -63,6 +67,7 @@ qint64 BitcoinUnits::factor(int unit) case DOGE: return 100000000; case mDOGE: return 100000; case uDOGE: return 100; + case Koinu: return 1; default: return 100000000; } } @@ -74,6 +79,7 @@ qint64 BitcoinUnits::maxAmount(int unit) case DOGE: return Q_INT64_C(900000000000); //less than the coin supply until the year 2170 case mDOGE: return Q_INT64_C(900000000000000); case uDOGE: return Q_INT64_C(900000000000000000); + case Koinu: return Q_INT64_C(90000000000000000000); default: return 0; } } @@ -85,6 +91,7 @@ int BitcoinUnits::amountDigits(int unit) case DOGE: return 12; // 900,000,000,000 (# digits, without commas) case mDOGE: return 15; // 900,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 default: return 0; } } @@ -96,6 +103,7 @@ int BitcoinUnits::decimals(int unit) case DOGE: return 8; case mDOGE: return 5; case uDOGE: return 2; + case Koinu: return 0; default: return 0; } } From 6f01b6338876a86364a23815dce58d165e159002 Mon Sep 17 00:00:00 2001 From: jwiechers Date: Tue, 25 Mar 2014 00:08:26 +0100 Subject: [PATCH 2/5] Update bitcoinunits.cpp --- src/qt/bitcoinunits.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 136250aad..41d33c6fd 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -43,7 +43,7 @@ QString BitcoinUnits::name(int unit) case DOGE: return QString("DOGE"); case mDOGE: return QString("mDOGE"); case uDOGE: return QString::fromUtf8("μDOGE"); - case Koinu: return QString("Koinu") + case Koinu: return QString("Koinu"); default: return QString("???"); } } @@ -55,7 +55,7 @@ QString BitcoinUnits::description(int unit) case DOGE: return QString("Dogecoin"); case mDOGE: return QString("Milli-Dogecoin (1 / 1,000)"); case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)"); - case Koinu: return QString("Koinu (1 / 100,000,000") + case Koinu: return QString("Koinu (1 / 100,000,000"); default: return QString("???"); } } From b21c0973830db86d9417f9f83d957becee6f643d Mon Sep 17 00:00:00 2001 From: jwiechers Date: Tue, 25 Mar 2014 00:00:26 +0100 Subject: [PATCH 3/5] Update bitcoinunits.h Adding Koinu @leofidus :D --- src/qt/bitcoinunits.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index 393b8209e..c9436e288 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -25,7 +25,8 @@ public: { DOGE, mDOGE, - uDOGE + uDOGE, + Koinu }; //! @name Static API From c100579e2e1384e2c25687d25688ebacedb0579e Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Tue, 25 Mar 2014 20:25:44 +0100 Subject: [PATCH 4/5] add megadoge and kilodoge as selectable units --- src/qt/bitcoinunits.cpp | 28 ++++++++++++++++++++++------ src/qt/bitcoinunits.h | 4 +++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 41d33c6fd..cca8e4b6c 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -15,6 +15,8 @@ BitcoinUnits::BitcoinUnits(QObject *parent): QList BitcoinUnits::availableUnits() { QList unitlist; + unitlist.append(MDOGE); + unitlist.append(kDOGE); unitlist.append(DOGE); unitlist.append(mDOGE); unitlist.append(uDOGE); @@ -26,6 +28,8 @@ bool BitcoinUnits::valid(int unit) { switch(unit) { + case MDOGE: + case kDOGE: case DOGE: case mDOGE: case uDOGE: @@ -40,6 +44,8 @@ QString BitcoinUnits::name(int unit) { switch(unit) { + case MDOGE: return QString("MDOGE"); + case kDOGE: return QString("kDOGE"); case DOGE: return QString("DOGE"); case mDOGE: return QString("mDOGE"); case uDOGE: return QString::fromUtf8("μDOGE"); @@ -52,6 +58,8 @@ QString BitcoinUnits::description(int 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 mDOGE: return QString("Milli-Dogecoin (1 / 1,000)"); case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)"); @@ -64,11 +72,13 @@ qint64 BitcoinUnits::factor(int unit) { switch(unit) { - case DOGE: return 100000000; - case mDOGE: return 100000; - case uDOGE: return 100; - case Koinu: return 1; - default: return 100000000; + case MDOGE: return Q_INT64_C(100000000000000); + case kDOGE: return Q_INT64_C(100000000000); + case DOGE: return Q_INT64_C(100000000); + case mDOGE: return Q_INT64_C(100000); + 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) { + 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 mDOGE: return Q_INT64_C(900000000000000); case uDOGE: return Q_INT64_C(900000000000000000); @@ -88,7 +100,9 @@ int BitcoinUnits::amountDigits(int 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 uDOGE: return 18; // 900,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) { + case MDOGE: return 14; + case kDOGE: return 11; case DOGE: return 8; case mDOGE: return 5; case uDOGE: return 2; diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index c9436e288..a7701a9f9 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -21,11 +21,13 @@ public: /** Bitcoin units. @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, mDOGE, uDOGE, + MDOGE, + kDOGE, Koinu }; From 493f1e9168e435047b7f0934697519c902be05c9 Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Tue, 25 Mar 2014 20:51:48 +0100 Subject: [PATCH 5/5] remove millidoge and microdoge units Users who have set them as display unit fall back to Doge with this change --- src/qt/bitcoinunits.cpp | 16 ---------------- src/qt/bitcoinunits.h | 10 +++++----- src/qt/optionsmodel.cpp | 2 ++ 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index cca8e4b6c..f12976a90 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -18,8 +18,6 @@ QList BitcoinUnits::availableUnits() unitlist.append(MDOGE); unitlist.append(kDOGE); unitlist.append(DOGE); - unitlist.append(mDOGE); - unitlist.append(uDOGE); unitlist.append(Koinu); return unitlist; } @@ -31,8 +29,6 @@ bool BitcoinUnits::valid(int unit) case MDOGE: case kDOGE: case DOGE: - case mDOGE: - case uDOGE: case Koinu: return true; default: @@ -47,8 +43,6 @@ QString BitcoinUnits::name(int unit) case MDOGE: return QString("MDOGE"); case kDOGE: return QString("kDOGE"); case DOGE: return QString("DOGE"); - case mDOGE: return QString("mDOGE"); - case uDOGE: return QString::fromUtf8("μDOGE"); case Koinu: return QString("Koinu"); default: return QString("???"); } @@ -61,8 +55,6 @@ QString BitcoinUnits::description(int 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 mDOGE: return QString("Milli-Dogecoin (1 / 1,000)"); - case uDOGE: return QString("Micro-Dogecoin (1 / 1,000,000)"); case Koinu: return QString("Koinu (1 / 100,000,000"); default: return QString("???"); } @@ -75,8 +67,6 @@ qint64 BitcoinUnits::factor(int unit) case MDOGE: return Q_INT64_C(100000000000000); case kDOGE: return Q_INT64_C(100000000000); case DOGE: return Q_INT64_C(100000000); - case mDOGE: return Q_INT64_C(100000); - case uDOGE: return Q_INT64_C(100); case Koinu: return Q_INT64_C(1); default: return Q_INT64_C(100000000); } @@ -89,8 +79,6 @@ qint64 BitcoinUnits::maxAmount(int 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 mDOGE: return Q_INT64_C(900000000000000); - case uDOGE: return Q_INT64_C(900000000000000000); case Koinu: return Q_INT64_C(90000000000000000000); default: return 0; } @@ -103,8 +91,6 @@ int BitcoinUnits::amountDigits(int unit) 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 uDOGE: return 18; // 900,000,000,000,000,000 case Koinu: return 20; // 90,000,000,000,000,000,000 default: return 0; } @@ -117,8 +103,6 @@ int BitcoinUnits::decimals(int unit) case MDOGE: return 14; case kDOGE: return 11; case DOGE: return 8; - case mDOGE: return 5; - case uDOGE: return 2; case Koinu: return 0; default: return 0; } diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index a7701a9f9..9f51b59b1 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -24,11 +24,11 @@ public: enum Unit //Note: preserve positions in order to preserve existing settings { DOGE, - mDOGE, - uDOGE, - MDOGE, - kDOGE, - Koinu + //formerly mDOGE + //formerly uDOGE + MDOGE = 3, + kDOGE = 4, + Koinu = 5 }; //! @name Static API diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index a1972ad51..f3b63dbdf 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -53,6 +53,8 @@ void OptionsModel::Init() if (!settings.contains("nDisplayUnit")) settings.setValue("nDisplayUnit", BitcoinUnits::DOGE); nDisplayUnit = settings.value("nDisplayUnit").toInt(); + if(!BitcoinUnits::valid(nDisplayUnit)) + nDisplayUnit = BitcoinUnits::DOGE; if (!settings.contains("bDisplayAddresses")) settings.setValue("bDisplayAddresses", false);