Mercurial > hg > bitcoin
changeset 1252:3263a457d299 draft
improve tooltip over transactions
author | Wladimir J. van der Laan <laanwj@gmail.com> |
---|---|
date | Fri, 05 Aug 2011 15:35:52 +0200 |
parents | 3d004b475420 |
children | cd45f62cfeae |
files | src/qt/transactionfilterproxy.cpp src/qt/transactiontablemodel.cpp src/qt/transactiontablemodel.h |
diffstat | 3 files changed, 30 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -28,7 +28,7 @@ QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); - qint64 amount = index.data(TransactionTableModel::AbsoluteAmountRole).toLongLong(); + qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); if(!(TYPE(type) & typeFilter)) return false;
--- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -265,7 +265,7 @@ return columns.length(); } -QVariant TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) const +QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) const { QString status; @@ -289,7 +289,7 @@ } if(wtx->type == TransactionRecord::Generated) { - status += "\n\n"; + status += "\n"; switch(wtx->status.maturity) { case TransactionStatus::Immature: @@ -307,18 +307,18 @@ } } - return QVariant(status); + return status; } -QVariant TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const +QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const { if(wtx->time) { - return QVariant(GUIUtil::DateTimeStr(wtx->time)); + return GUIUtil::DateTimeStr(wtx->time); } else { - return QVariant(); + return QString(); } } @@ -418,7 +418,7 @@ return QVariant(); } -QVariant TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed) const +QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed) const { QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit); if(showUnconfirmed) @@ -428,10 +428,10 @@ str = QString("[") + str + QString("]"); } } - return QVariant(str); + return QString(str); } -QVariant TransactionTableModel::formatTxDecoration(const TransactionRecord *wtx) const +QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) const { if(wtx->type == TransactionRecord::Generated) { @@ -476,6 +476,18 @@ return QColor(0,0,0); } +QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const +{ + QString tooltip = formatTxType(rec); + if(rec->type==TransactionRecord::RecvFromIP || rec->type==TransactionRecord::SendToIP || + rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress) + { + tooltip += QString(" ") + formatTxToAddress(rec, true); + } + tooltip += QString("\n") + formatTxStatus(rec); + return tooltip; +} + QVariant TransactionTableModel::data(const QModelIndex &index, int role) const { if(!index.isValid()) @@ -487,7 +499,7 @@ switch(index.column()) { case Status: - return formatTxDecoration(rec); + return txStatusDecoration(rec); case ToAddress: return txAddressDecoration(rec); } @@ -530,8 +542,8 @@ { case Status: return formatTxStatus(rec); - case ToAddress: - return formatTxType(rec) + QString(" ") + formatTxToAddress(rec, true); + default: + return formatTooltip(rec); } } else if (role == Qt::TextAlignmentRole) @@ -574,10 +586,6 @@ { return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address)); } - else if (role == AbsoluteAmountRole) - { - return llabs(rec->credit + rec->debit); - } else if (role == AmountRole) { return rec->credit + rec->debit;
--- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -37,8 +37,6 @@ AddressRole, // Label of address related to transaction LabelRole, - // Absolute net amount of transaction, for filtering - AbsoluteAmountRole, // Net amount of transaction AmountRole, // Unique identifier @@ -63,12 +61,13 @@ 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; + QString formatTxStatus(const TransactionRecord *wtx) const; + QString formatTxDate(const TransactionRecord *wtx) const; QString formatTxType(const TransactionRecord *wtx) const; QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const; - QVariant formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const; - QVariant formatTxDecoration(const TransactionRecord *wtx) const; + QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const; + QString formatTooltip(const TransactionRecord *rec) const; + QVariant txStatusDecoration(const TransactionRecord *wtx) const; QVariant txAddressDecoration(const TransactionRecord *wtx) const; private slots: