Skip to content

Commit 2634584

Browse files
qt: mask values on transactions view
1 parent 4f841cb commit 2634584

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/qt/transactiontablemodel.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
451451

452452
QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
453453
{
454-
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
454+
const bool privacy = walletModel->getOptionsModel()->getOption(OptionsModel::MaskValues).toBool();
455+
BitcoinUnit unit = walletModel->getOptionsModel()->getDisplayUnit();
456+
QString str = BitcoinUnits::formatWithPrivacy(unit, wtx->credit + wtx->debit, separators, privacy);
455457
if(showUnconfirmed)
456458
{
457459
if(!wtx->status.countsForBalance)
@@ -698,11 +700,15 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex
698700
return QModelIndex();
699701
}
700702

703+
void TransactionTableModel::refreshAmounts()
704+
{
705+
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
706+
}
707+
701708
void TransactionTableModel::updateDisplayUnit()
702709
{
703-
// emit dataChanged to update Amount column with the current unit
704710
updateAmountColumnTitle();
705-
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
711+
refreshAmounts(); // refresh 'Amount' column to update the current unit
706712
}
707713

708714
void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)

src/qt/transactiontablemodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public Q_SLOTS:
112112
void updateTransaction(const QString &hash, int status, bool showTransaction);
113113
void updateConfirmations();
114114
void updateDisplayUnit();
115+
// Triggers a re-paint of the 'Amount' column.
116+
void refreshAmounts();
115117
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
116118
void updateAmountColumnTitle();
117119
/* Needed to update fProcessingQueuedTransactions through a QueuedConnection */

src/qt/walletview.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ WalletView::WalletView(WalletModel* wallet_model, const PlatformStyle* _platform
9393
connect(transactionView, &TransactionView::message, this, &WalletView::message);
9494

9595
connect(this, &WalletView::setPrivacy, overviewPage, &OverviewPage::setPrivacy);
96+
connect(this, &WalletView::setPrivacy, walletModel->getTransactionTableModel(), &TransactionTableModel::refreshAmounts);
9697

9798
// Receive and pass through messages from wallet model
9899
connect(walletModel, &WalletModel::message, this, &WalletView::message);

0 commit comments

Comments
 (0)