Mercurial > hg > bitcoin
changeset 1255:c5f64a805707 draft
reorganize transaction model data function, and transaction tooltip
author | Wladimir J. van der Laan <laanwj@gmail.com> |
---|---|
date | Sat, 06 Aug 2011 18:37:41 +0200 |
parents | 8af3dd3c08a4 |
children | 3a687b55c04b |
files | src/qt/transactiontablemodel.cpp |
diffstat | 1 files changed, 25 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -281,7 +281,7 @@ status = tr("Offline (%1 confirmations)").arg(wtx->status.depth); break; case TransactionStatus::Unconfirmed: - status = tr("Unconfirmed (%1 of %2 confirmations required)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations); + status = tr("Unconfirmed (%1 of %2 confirmations)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations); break; case TransactionStatus::HaveConfirmations: status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); @@ -478,13 +478,12 @@ QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const { - QString tooltip = formatTxType(rec); + QString tooltip = formatTxStatus(rec) + QString("\n") + 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; } @@ -494,8 +493,9 @@ return QVariant(); TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer()); - if(role == Qt::DecorationRole) + switch(role) { + case Qt::DecorationRole: switch(index.column()) { case Status: @@ -503,10 +503,8 @@ case ToAddress: return txAddressDecoration(rec); } - } - else if(role == Qt::DisplayRole) - { - // Delegate to specific column handlers + break; + case Qt::DisplayRole: switch(index.column()) { case Date: @@ -518,10 +516,9 @@ case Amount: return formatTxAmount(rec); } - } - else if(role == Qt::EditRole) - { - // Edit role is used for sorting so return the real values + break; + case Qt::EditRole: + // Edit role is used for sorting, so return the unformatted values switch(index.column()) { case Status: @@ -535,24 +532,13 @@ case Amount: return rec->credit + rec->debit; } - } - else if (role == Qt::ToolTipRole) - { - switch(index.column()) - { - case Status: - return formatTxStatus(rec); - default: - return formatTooltip(rec); - } - } - else if (role == Qt::TextAlignmentRole) - { + break; + case Qt::ToolTipRole: + return formatTooltip(rec); + case Qt::TextAlignmentRole: return column_alignments[index.column()]; - } - else if (role == Qt::ForegroundRole) - { - /* Non-confirmed transactions are grey */ + case Qt::ForegroundRole: + // Non-confirmed transactions are grey if(!rec->status.confirmed) { return COLOR_UNCONFIRMED; @@ -565,43 +551,26 @@ { return addressColor(rec); } - } - else if (role == TypeRole) - { + break; + case TypeRole: return rec->type; - } - else if (role == DateRole) - { + case DateRole: return QDateTime::fromTime_t(static_cast<uint>(rec->time)); - } - else if (role == LongDescriptionRole) - { + case LongDescriptionRole: return priv->describe(rec); - } - else if (role == AddressRole) - { + case AddressRole: return QString::fromStdString(rec->address); - } - else if (role == LabelRole) - { + case LabelRole: return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address)); - } - else if (role == AmountRole) - { + case AmountRole: return rec->credit + rec->debit; - } - else if (role == TxIDRole) - { + case TxIDRole: return QString::fromStdString(rec->getTxID()); - } - else if (role == ConfirmedRole) - { + case ConfirmedRole: // Return True if transaction counts for balance return rec->status.confirmed && !(rec->type == TransactionRecord::Generated && rec->status.maturity != TransactionStatus::Mature); - } - else if (role == FormattedAmountRole) - { + case FormattedAmountRole: return formatTxAmount(rec, false); } return QVariant();