|
|
@ -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) |
|
|
|
{ |
|
|
|
{ |
|
|
|