Skip to content

Commit

Permalink
GUI: TransactionTableModel: Include unit name with formatted amount
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 8, 2019
1 parent a582fe0 commit 19c87c0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
#include <qt/transactionrecord.h>
#include <qt/walletmodel.h>

#include "assetsdir.h"
#include <core_io.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <sync.h>
#include <uint256.h>
#include <util.h>
#include <validation.h>
#include <policy/policy.h>

#include <QColor>
#include <QDateTime>
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 19c87c0

Please sign in to comment.