GUI: TransactionTableModel: Include unit name with formatted amount

This commit is contained in:
Luke Dashjr 2018-12-15 19:31:20 +00:00 committed by Gregory Sanders
parent a582fe03e4
commit 19c87c0ae7

View file

@ -13,6 +13,7 @@
#include <qt/transactionrecord.h>
#include <qt/walletmodel.h>
#include "assetsdir.h"
#include <core_io.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
@ -20,6 +21,7 @@
#include <uint256.h>
#include <util.h>
#include <validation.h>
#include <policy/policy.h>
#include <QColor>
#include <QDateTime>
@ -428,7 +430,22 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
{
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->amount, false, separators);
QString str;
if (wtx->asset == ::policyAsset) {
str = BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), wtx->amount, false, separators);
} else {
qlonglong whole = wtx->amount / 100000000;
qlonglong fraction = wtx->amount % 100000000;
str = QString("%1").arg(whole);
if (fraction) {
str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0'));
}
std::string asset_label = gAssetsDir.GetLabel(wtx->asset);
if (asset_label.empty()) {
asset_label = wtx->asset.GetHex();
}
str += QString(" ") + QString::fromStdString(asset_label);
}
if(showUnconfirmed)
{
if(!wtx->status.countsForBalance)