reorganize transaction model data function, and transaction tooltip
This commit is contained in:
parent
d4e3cb4c03
commit
e74e8a184a
1 changed files with 25 additions and 56 deletions
|
@ -281,7 +281,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons
|
||||||
status = tr("Offline (%1 confirmations)").arg(wtx->status.depth);
|
status = tr("Offline (%1 confirmations)").arg(wtx->status.depth);
|
||||||
break;
|
break;
|
||||||
case TransactionStatus::Unconfirmed:
|
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;
|
break;
|
||||||
case TransactionStatus::HaveConfirmations:
|
case TransactionStatus::HaveConfirmations:
|
||||||
status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
|
status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
|
||||||
|
@ -478,13 +478,12 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
|
||||||
|
|
||||||
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
|
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 ||
|
if(rec->type==TransactionRecord::RecvFromIP || rec->type==TransactionRecord::SendToIP ||
|
||||||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
|
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
|
||||||
{
|
{
|
||||||
tooltip += QString(" ") + formatTxToAddress(rec, true);
|
tooltip += QString(" ") + formatTxToAddress(rec, true);
|
||||||
}
|
}
|
||||||
tooltip += QString("\n") + formatTxStatus(rec);
|
|
||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,8 +493,9 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
|
TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
|
||||||
|
|
||||||
if(role == Qt::DecorationRole)
|
switch(role)
|
||||||
{
|
{
|
||||||
|
case Qt::DecorationRole:
|
||||||
switch(index.column())
|
switch(index.column())
|
||||||
{
|
{
|
||||||
case Status:
|
case Status:
|
||||||
|
@ -503,10 +503,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
case ToAddress:
|
case ToAddress:
|
||||||
return txAddressDecoration(rec);
|
return txAddressDecoration(rec);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(role == Qt::DisplayRole)
|
case Qt::DisplayRole:
|
||||||
{
|
|
||||||
// Delegate to specific column handlers
|
|
||||||
switch(index.column())
|
switch(index.column())
|
||||||
{
|
{
|
||||||
case Date:
|
case Date:
|
||||||
|
@ -518,10 +516,9 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
case Amount:
|
case Amount:
|
||||||
return formatTxAmount(rec);
|
return formatTxAmount(rec);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(role == Qt::EditRole)
|
case Qt::EditRole:
|
||||||
{
|
// Edit role is used for sorting, so return the unformatted values
|
||||||
// Edit role is used for sorting so return the real values
|
|
||||||
switch(index.column())
|
switch(index.column())
|
||||||
{
|
{
|
||||||
case Status:
|
case Status:
|
||||||
|
@ -535,24 +532,13 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
case Amount:
|
case Amount:
|
||||||
return rec->credit + rec->debit;
|
return rec->credit + rec->debit;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (role == Qt::ToolTipRole)
|
case Qt::ToolTipRole:
|
||||||
{
|
|
||||||
switch(index.column())
|
|
||||||
{
|
|
||||||
case Status:
|
|
||||||
return formatTxStatus(rec);
|
|
||||||
default:
|
|
||||||
return formatTooltip(rec);
|
return formatTooltip(rec);
|
||||||
}
|
case Qt::TextAlignmentRole:
|
||||||
}
|
|
||||||
else if (role == Qt::TextAlignmentRole)
|
|
||||||
{
|
|
||||||
return column_alignments[index.column()];
|
return column_alignments[index.column()];
|
||||||
}
|
case Qt::ForegroundRole:
|
||||||
else if (role == Qt::ForegroundRole)
|
// Non-confirmed transactions are grey
|
||||||
{
|
|
||||||
/* Non-confirmed transactions are grey */
|
|
||||||
if(!rec->status.confirmed)
|
if(!rec->status.confirmed)
|
||||||
{
|
{
|
||||||
return COLOR_UNCONFIRMED;
|
return COLOR_UNCONFIRMED;
|
||||||
|
@ -565,43 +551,26 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
return addressColor(rec);
|
return addressColor(rec);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (role == TypeRole)
|
case TypeRole:
|
||||||
{
|
|
||||||
return rec->type;
|
return rec->type;
|
||||||
}
|
case DateRole:
|
||||||
else if (role == DateRole)
|
|
||||||
{
|
|
||||||
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
|
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
|
||||||
}
|
case LongDescriptionRole:
|
||||||
else if (role == LongDescriptionRole)
|
|
||||||
{
|
|
||||||
return priv->describe(rec);
|
return priv->describe(rec);
|
||||||
}
|
case AddressRole:
|
||||||
else if (role == AddressRole)
|
|
||||||
{
|
|
||||||
return QString::fromStdString(rec->address);
|
return QString::fromStdString(rec->address);
|
||||||
}
|
case LabelRole:
|
||||||
else if (role == LabelRole)
|
|
||||||
{
|
|
||||||
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
|
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
|
||||||
}
|
case AmountRole:
|
||||||
else if (role == AmountRole)
|
|
||||||
{
|
|
||||||
return rec->credit + rec->debit;
|
return rec->credit + rec->debit;
|
||||||
}
|
case TxIDRole:
|
||||||
else if (role == TxIDRole)
|
|
||||||
{
|
|
||||||
return QString::fromStdString(rec->getTxID());
|
return QString::fromStdString(rec->getTxID());
|
||||||
}
|
case ConfirmedRole:
|
||||||
else if (role == ConfirmedRole)
|
|
||||||
{
|
|
||||||
// Return True if transaction counts for balance
|
// Return True if transaction counts for balance
|
||||||
return rec->status.confirmed && !(rec->type == TransactionRecord::Generated &&
|
return rec->status.confirmed && !(rec->type == TransactionRecord::Generated &&
|
||||||
rec->status.maturity != TransactionStatus::Mature);
|
rec->status.maturity != TransactionStatus::Mature);
|
||||||
}
|
case FormattedAmountRole:
|
||||||
else if (role == FormattedAmountRole)
|
|
||||||
{
|
|
||||||
return formatTxAmount(rec, false);
|
return formatTxAmount(rec, false);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
Loading…
Reference in a new issue