Hide addresses in transaction overview by default, they can be re-shown as a configuration option
This commit is contained in:
parent
1aafe34a08
commit
2f5d380943
@ -11,5 +11,7 @@ static const int MODEL_UPDATE_DELAY = 500;
|
||||
#define COLOR_UNCONFIRMED QColor(128, 128, 128)
|
||||
/* Transaction list -- negative amount */
|
||||
#define COLOR_NEGATIVE QColor(255, 0, 0)
|
||||
/* Transaction list -- bare address (without label) */
|
||||
#define COLOR_BAREADDRESS QColor(140, 140, 140)
|
||||
|
||||
#endif // GUICONSTANTS_H
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
void setMapper(MonitoredDataMapper *mapper);
|
||||
private:
|
||||
QValueComboBox *unit;
|
||||
QCheckBox *display_addresses;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
@ -248,6 +249,7 @@ DisplayOptionsPage::DisplayOptionsPage(QWidget *parent):
|
||||
QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
|
||||
QHBoxLayout *unit_hbox = new QHBoxLayout();
|
||||
unit_hbox->addSpacing(18);
|
||||
QLabel *unit_label = new QLabel(tr("&Unit to show amounts in: "));
|
||||
@ -260,6 +262,10 @@ DisplayOptionsPage::DisplayOptionsPage(QWidget *parent):
|
||||
unit_hbox->addWidget(unit);
|
||||
|
||||
layout->addLayout(unit_hbox);
|
||||
|
||||
display_addresses = new QCheckBox(tr("Display addresses in transaction list"), this);
|
||||
layout->addWidget(display_addresses);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
setLayout(layout);
|
||||
@ -268,4 +274,5 @@ DisplayOptionsPage::DisplayOptionsPage(QWidget *parent):
|
||||
void DisplayOptionsPage::setMapper(MonitoredDataMapper *mapper)
|
||||
{
|
||||
mapper->addMapping(unit, OptionsModel::DisplayUnit);
|
||||
mapper->addMapping(display_addresses, OptionsModel::DisplayAddresses);
|
||||
}
|
||||
|
@ -8,11 +8,13 @@
|
||||
OptionsModel::OptionsModel(CWallet *wallet, QObject *parent) :
|
||||
QAbstractListModel(parent),
|
||||
wallet(wallet),
|
||||
nDisplayUnit(BitcoinUnits::BTC)
|
||||
nDisplayUnit(BitcoinUnits::BTC),
|
||||
bDisplayAddresses(false)
|
||||
{
|
||||
// Read our specific settings from the wallet db
|
||||
CWalletDB walletdb(wallet->strWalletFile);
|
||||
walletdb.ReadSetting("nDisplayUnit", nDisplayUnit);
|
||||
walletdb.ReadSetting("bDisplayAddresses", bDisplayAddresses);
|
||||
}
|
||||
|
||||
int OptionsModel::rowCount(const QModelIndex & parent) const
|
||||
@ -44,6 +46,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
return QVariant(nTransactionFee);
|
||||
case DisplayUnit:
|
||||
return QVariant(nDisplayUnit);
|
||||
case DisplayAddresses:
|
||||
return QVariant(bDisplayAddresses);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -121,6 +125,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
walletdb.WriteSetting("nDisplayUnit", nDisplayUnit);
|
||||
emit displayUnitChanged(unit);
|
||||
}
|
||||
case DisplayAddresses: {
|
||||
bDisplayAddresses = value.toBool();
|
||||
walletdb.WriteSetting("bDisplayAddresses", bDisplayAddresses);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -149,3 +157,8 @@ int OptionsModel::getDisplayUnit()
|
||||
{
|
||||
return nDisplayUnit;
|
||||
}
|
||||
|
||||
bool OptionsModel::getDisplayAddresses()
|
||||
{
|
||||
return bDisplayAddresses;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
ProxyPort, // QString
|
||||
Fee, // qint64
|
||||
DisplayUnit, // BitcoinUnits::Unit
|
||||
DisplayAddresses, // bool
|
||||
OptionIDRowCount
|
||||
};
|
||||
|
||||
@ -39,10 +40,12 @@ public:
|
||||
bool getMinimizeToTray();
|
||||
bool getMinimizeOnClose();
|
||||
int getDisplayUnit();
|
||||
bool getDisplayAddresses();
|
||||
private:
|
||||
// Wallet stores persistent options
|
||||
CWallet *wallet;
|
||||
int nDisplayUnit;
|
||||
bool bDisplayAddresses;
|
||||
signals:
|
||||
void displayUnitChanged(int unit);
|
||||
|
||||
|
@ -322,21 +322,20 @@ QVariant TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
|
||||
}
|
||||
}
|
||||
|
||||
/* Look up address in address book, if found return
|
||||
address (label)
|
||||
otherwise just return address
|
||||
/* Look up address in address book, if found return label (address)
|
||||
otherwise just return (address)
|
||||
*/
|
||||
QString TransactionTableModel::lookupAddress(const std::string &address) const
|
||||
QString TransactionTableModel::lookupAddress(const std::string &address, bool tooltip) const
|
||||
{
|
||||
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
|
||||
QString description;
|
||||
if(label.isEmpty())
|
||||
if(!label.isEmpty())
|
||||
{
|
||||
description = QString::fromStdString(address);
|
||||
description += label + QString(" ");
|
||||
}
|
||||
else
|
||||
if(label.isEmpty() || walletModel->getOptionsModel()->getDisplayAddresses() || tooltip)
|
||||
{
|
||||
description = label + QString(" (") + QString::fromStdString(address) + QString(")");
|
||||
description += QString("(") + QString::fromStdString(address) + QString(")");
|
||||
}
|
||||
return description;
|
||||
}
|
||||
@ -369,20 +368,18 @@ QVariant TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
|
||||
return QVariant(description);
|
||||
}
|
||||
|
||||
QVariant TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx) const
|
||||
QVariant TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
|
||||
{
|
||||
QString description;
|
||||
|
||||
switch(wtx->type)
|
||||
{
|
||||
case TransactionRecord::RecvWithAddress:
|
||||
description = lookupAddress(wtx->address);
|
||||
break;
|
||||
case TransactionRecord::RecvFromIP:
|
||||
description = QString::fromStdString(wtx->address);
|
||||
break;
|
||||
case TransactionRecord::RecvWithAddress:
|
||||
case TransactionRecord::SendToAddress:
|
||||
description = lookupAddress(wtx->address);
|
||||
description = lookupAddress(wtx->address, tooltip);
|
||||
break;
|
||||
case TransactionRecord::SendToIP:
|
||||
description = QString::fromStdString(wtx->address);
|
||||
@ -397,6 +394,24 @@ QVariant TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx)
|
||||
return QVariant(description);
|
||||
}
|
||||
|
||||
QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
|
||||
{
|
||||
// Show addresses without label in a less visible color
|
||||
switch(wtx->type)
|
||||
{
|
||||
case TransactionRecord::RecvWithAddress:
|
||||
case TransactionRecord::SendToAddress:
|
||||
{
|
||||
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
|
||||
if(label.isEmpty())
|
||||
return COLOR_BAREADDRESS;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed) const
|
||||
{
|
||||
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit);
|
||||
@ -478,7 +493,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
case Type:
|
||||
return formatTxType(rec);
|
||||
case ToAddress:
|
||||
return formatTxToAddress(rec);
|
||||
return formatTxToAddress(rec, false);
|
||||
case Amount:
|
||||
return formatTxAmount(rec);
|
||||
}
|
||||
@ -495,16 +510,19 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
case Type:
|
||||
return formatTxType(rec);
|
||||
case ToAddress:
|
||||
return formatTxToAddress(rec);
|
||||
return formatTxToAddress(rec, true);
|
||||
case Amount:
|
||||
return rec->credit + rec->debit;
|
||||
}
|
||||
}
|
||||
else if (role == Qt::ToolTipRole)
|
||||
{
|
||||
if(index.column() == Status)
|
||||
switch(index.column())
|
||||
{
|
||||
case Status:
|
||||
return formatTxStatus(rec);
|
||||
case ToAddress:
|
||||
return formatTxToAddress(rec, true);
|
||||
}
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole)
|
||||
@ -522,6 +540,10 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
return COLOR_NEGATIVE;
|
||||
}
|
||||
if(index.column() == ToAddress)
|
||||
{
|
||||
return addressColor(rec);
|
||||
}
|
||||
}
|
||||
else if (role == TypeRole)
|
||||
{
|
||||
|
@ -59,11 +59,12 @@ private:
|
||||
QStringList columns;
|
||||
TransactionTablePriv *priv;
|
||||
|
||||
QString lookupAddress(const std::string &address) const;
|
||||
QString lookupAddress(const std::string &address, bool tooltip) const;
|
||||
QVariant addressColor(const TransactionRecord *wtx) const;
|
||||
QVariant formatTxStatus(const TransactionRecord *wtx) const;
|
||||
QVariant formatTxDate(const TransactionRecord *wtx) const;
|
||||
QVariant formatTxType(const TransactionRecord *wtx) const;
|
||||
QVariant formatTxToAddress(const TransactionRecord *wtx) const;
|
||||
QVariant formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
|
||||
QVariant formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
|
||||
QVariant formatTxDecoration(const TransactionRecord *wtx) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user