aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-30 17:42:02 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-30 17:42:02 +0200
commit2f5d380943c4f56114f81a6aee81a57579492103 (patch)
tree57d4e28176a090235845da899bf53c9645062eaa
parent1aafe34a0839153d7027fdd0251edc32bd8001aa (diff)
Hide addresses in transaction overview by default, they can be re-shown as a configuration option
-rw-r--r--src/qt/guiconstants.h2
-rw-r--r--src/qt/optionsdialog.cpp7
-rw-r--r--src/qt/optionsmodel.cpp15
-rw-r--r--src/qt/optionsmodel.h3
-rw-r--r--src/qt/transactiontablemodel.cpp54
-rw-r--r--src/qt/transactiontablemodel.h5
6 files changed, 67 insertions, 19 deletions
diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h
index deef3e3484..7fbf7fcd3a 100644
--- a/src/qt/guiconstants.h
+++ b/src/qt/guiconstants.h
@@ -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
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index a923f3ead5..e922209f01 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -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);
}
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index d72a0e9e91..4656ad08d5 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -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;
+}
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index ed26f83d55..7f489c5014 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -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);
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 99f2d5806e..27e85cebc5 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -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)
{
diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h
index 85bfeebcb3..3322ff4af1 100644
--- a/src/qt/transactiontablemodel.h
+++ b/src/qt/transactiontablemodel.h
@@ -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;