Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoinunits.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "bitcoinunits.h" | #include "bitcoinunits.h" | ||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include <QStringList> | #include <QStringList> | ||||
BitcoinUnits::BitcoinUnits(QObject *parent) | BitcoinUnits::BitcoinUnits(QObject *parent) | ||||
: QAbstractListModel(parent), unitlist(availableUnits()) {} | : QAbstractListModel(parent), unitlist(availableUnits()) {} | ||||
QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits() { | QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits() { | ||||
QList<BitcoinUnits::Unit> unitlist; | QList<BitcoinUnits::Unit> unitlist; | ||||
unitlist.append(BCC); | unitlist.append(BCH); | ||||
unitlist.append(mBCC); | unitlist.append(mBCH); | ||||
unitlist.append(uBCC); | unitlist.append(uBCH); | ||||
return unitlist; | return unitlist; | ||||
} | } | ||||
bool BitcoinUnits::valid(int unit) { | bool BitcoinUnits::valid(int unit) { | ||||
switch (unit) { | switch (unit) { | ||||
case BCC: | case BCH: | ||||
case mBCC: | case mBCH: | ||||
case uBCC: | case uBCH: | ||||
return true; | return true; | ||||
default: | default: | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
QString BitcoinUnits::name(int unit) { | QString BitcoinUnits::name(int unit) { | ||||
switch (unit) { | switch (unit) { | ||||
case BCC: | case BCH: | ||||
return QString("BCC"); | return QString("BCH"); | ||||
case mBCC: | case mBCH: | ||||
return QString("mBCC"); | return QString("mBCH"); | ||||
case uBCC: | case uBCH: | ||||
return QString::fromUtf8("μBCC"); | return QString::fromUtf8("μBCH"); | ||||
default: | default: | ||||
return QString("???"); | return QString("???"); | ||||
} | } | ||||
} | } | ||||
QString BitcoinUnits::description(int unit) { | QString BitcoinUnits::description(int unit) { | ||||
switch (unit) { | switch (unit) { | ||||
case BCC: | case BCH: | ||||
return QString("Bitcoins"); | return QString("Bitcoins"); | ||||
case mBCC: | case mBCH: | ||||
return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)"); | return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)"); | ||||
case uBCC: | case uBCH: | ||||
return QString("Micro-Bitcoins (1 / 1" THIN_SP_UTF8 | return QString("Micro-Bitcoins (1 / 1" THIN_SP_UTF8 | ||||
"000" THIN_SP_UTF8 "000)"); | "000" THIN_SP_UTF8 "000)"); | ||||
default: | default: | ||||
return QString("???"); | return QString("???"); | ||||
} | } | ||||
} | } | ||||
qint64 BitcoinUnits::factor(int unit) { | qint64 BitcoinUnits::factor(int unit) { | ||||
switch (unit) { | switch (unit) { | ||||
case BCC: | case BCH: | ||||
return 100000000; | return 100000000; | ||||
case mBCC: | case mBCH: | ||||
return 100000; | return 100000; | ||||
case uBCC: | case uBCH: | ||||
return 100; | return 100; | ||||
default: | default: | ||||
return 100000000; | return 100000000; | ||||
} | } | ||||
} | } | ||||
int BitcoinUnits::decimals(int unit) { | int BitcoinUnits::decimals(int unit) { | ||||
switch (unit) { | switch (unit) { | ||||
case BCC: | case BCH: | ||||
return 8; | return 8; | ||||
case mBCC: | case mBCH: | ||||
return 5; | return 5; | ||||
case uBCC: | case uBCH: | ||||
return 2; | return 2; | ||||
default: | default: | ||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
QString BitcoinUnits::format(int unit, const CAmount &nIn, bool fPlus, | QString BitcoinUnits::format(int unit, const CAmount &nIn, bool fPlus, | ||||
SeparatorStyle separators) { | SeparatorStyle separators) { | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |