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