MCPcopy Create free account
hub / github.com/ElementsProject/elements / data

Method data

src/qt/transactiontablemodel.cpp:525–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
526{
527 if(!index.isValid())
528 return QVariant();
529 TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
530
531 const auto column = static_cast<ColumnIndex>(index.column());
532 switch (role) {
533 case RawDecorationRole:
534 switch (column) {
535 case Status:
536 return txStatusDecoration(rec);
537 case Watchonly:
538 return txWatchonlyDecoration(rec);
539 case Date: return {};
540 case Type: return {};
541 case ToAddress:
542 return txAddressDecoration(rec);
543 case Amount: return {};
544 } // no default case, so the compiler can warn about missing cases
545 assert(false);
546 case Qt::DecorationRole:
547 {
548 QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
549 return platformStyle->TextColorIcon(icon);
550 }
551 case Qt::DisplayRole:
552 switch (column) {
553 case Status: return {};
554 case Watchonly: return {};
555 case Date:
556 return formatTxDate(rec);
557 case Type:
558 return formatTxType(rec);
559 case ToAddress:
560 return formatTxToAddress(rec, false);
561 case Amount:
562 return formatTxAmount(rec, true, BitcoinUnits::SeparatorStyle::ALWAYS);
563 } // no default case, so the compiler can warn about missing cases
564 assert(false);
565 case Qt::EditRole:
566 // Edit role is used for sorting, so return the unformatted values
567 switch (column) {
568 case Status:
569 return QString::fromStdString(rec->status.sortKey);
570 case Date:
571 return QString::fromStdString(strprintf("%020-%s", rec->time, rec->status.sortKey));
572 case Type:
573 return formatTxType(rec);
574 case Watchonly:
575 return (rec->involvesWatchAddress ? 1 : 0);
576 case ToAddress:
577 return formatTxToAddress(rec, true);
578 case Amount:
579 return qint64(rec->amount);
580 } // no default case, so the compiler can warn about missing cases
581 assert(false);
582 case Qt::ToolTipRole:

Callers

nothing calls this directly

Calls 11

TextColorIconMethod · 0.80
describeMethod · 0.80
getDisplayUnitMethod · 0.80
labelForAddressMethod · 0.80
getAddressTableModelMethod · 0.80
getTxHashMethod · 0.80
getTxHexMethod · 0.80
isValidMethod · 0.45
walletMethod · 0.45
getOptionsModelMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected