| 490 | } |
| 491 | |
| 492 | QVariant TransactionTableModel::data(const QModelIndex &index, int role) const |
| 493 | { |
| 494 | if(!index.isValid()) |
| 495 | return QVariant(); |
| 496 | TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer()); |
| 497 | |
| 498 | switch(role) |
| 499 | { |
| 500 | case RawDecorationRole: |
| 501 | switch(index.column()) |
| 502 | { |
| 503 | case Status: |
| 504 | return txStatusDecoration(rec); |
| 505 | case Watchonly: |
| 506 | return txWatchonlyDecoration(rec); |
| 507 | case ToAddress: |
| 508 | return txAddressDecoration(rec); |
| 509 | } |
| 510 | break; |
| 511 | case Qt::DecorationRole: |
| 512 | { |
| 513 | QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole)); |
| 514 | return platformStyle->TextColorIcon(icon); |
| 515 | } |
| 516 | case Qt::DisplayRole: |
| 517 | switch(index.column()) |
| 518 | { |
| 519 | case Date: |
| 520 | return formatTxDate(rec); |
| 521 | case Type: |
| 522 | return formatTxType(rec); |
| 523 | case ToAddress: |
| 524 | return formatTxToAddress(rec, false); |
| 525 | case Amount: |
| 526 | return formatTxAmount(rec, true, BitcoinUnits::separatorAlways); |
| 527 | } |
| 528 | break; |
| 529 | case Qt::EditRole: |
| 530 | // Edit role is used for sorting, so return the unformatted values |
| 531 | switch(index.column()) |
| 532 | { |
| 533 | case Status: |
| 534 | return QString::fromStdString(rec->status.sortKey); |
| 535 | case Date: |
| 536 | return rec->time; |
| 537 | case Type: |
| 538 | return formatTxType(rec); |
| 539 | case Watchonly: |
| 540 | return (rec->involvesWatchAddress ? 1 : 0); |
| 541 | case ToAddress: |
| 542 | return formatTxToAddress(rec, true); |
| 543 | case Amount: |
| 544 | return qint64(rec->credit + rec->debit); |
| 545 | } |
| 546 | break; |
| 547 | case Qt::ToolTipRole: |
| 548 | return formatTooltip(rec); |
| 549 | case Qt::TextAlignmentRole: |
nothing calls this directly
no test coverage detected