mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Full support for other units, add configuration option for default unit (used when displaying amounts)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "optionsmodel.h"
|
||||
#include "bitcoinunits.h"
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
@@ -6,8 +7,12 @@
|
||||
|
||||
OptionsModel::OptionsModel(CWallet *wallet, QObject *parent) :
|
||||
QAbstractListModel(parent),
|
||||
wallet(wallet)
|
||||
wallet(wallet),
|
||||
nDisplayUnit(BitcoinUnits::BTC)
|
||||
{
|
||||
// Read our specific settings from the wallet db
|
||||
CWalletDB walletdb(wallet->strWalletFile);
|
||||
walletdb.ReadSetting("nDisplayUnit", nDisplayUnit);
|
||||
}
|
||||
|
||||
int OptionsModel::rowCount(const QModelIndex & parent) const
|
||||
@@ -37,6 +42,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
return QVariant(QString::fromStdString(addrProxy.ToStringPort()));
|
||||
case Fee:
|
||||
return QVariant(nTransactionFee);
|
||||
case DisplayUnit:
|
||||
return QVariant(nDisplayUnit);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -108,6 +115,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
walletdb.WriteSetting("nTransactionFee", nTransactionFee);
|
||||
}
|
||||
break;
|
||||
case DisplayUnit: {
|
||||
int unit = value.toInt();
|
||||
nDisplayUnit = unit;
|
||||
walletdb.WriteSetting("nDisplayUnit", nDisplayUnit);
|
||||
emit displayUnitChanged(unit);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -131,3 +144,8 @@ bool OptionsModel::getMinimizeOnClose()
|
||||
{
|
||||
return fMinimizeOnClose;
|
||||
}
|
||||
|
||||
int OptionsModel::getDisplayUnit()
|
||||
{
|
||||
return nDisplayUnit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user