| 35 | } |
| 36 | |
| 37 | inline void paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 38 | const QModelIndex &index ) const |
| 39 | { |
| 40 | painter->save(); |
| 41 | |
| 42 | QIcon icon = qvariant_cast<QIcon>(index.data(TransactionTableModel::RawDecorationRole)); |
| 43 | QRect mainRect = option.rect; |
| 44 | QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE)); |
| 45 | int xspace = DECORATION_SIZE + 8; |
| 46 | int ypad = 6; |
| 47 | int halfheight = (mainRect.height() - 2*ypad)/2; |
| 48 | QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight); |
| 49 | QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight); |
| 50 | icon = platformStyle->SingleColorIcon(icon); |
| 51 | icon.paint(painter, decorationRect); |
| 52 | |
| 53 | QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); |
| 54 | QString address = index.data(Qt::DisplayRole).toString(); |
| 55 | qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); |
| 56 | bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); |
| 57 | QVariant value = index.data(Qt::ForegroundRole); |
| 58 | QColor foreground = option.palette.color(QPalette::Text); |
| 59 | if(value.canConvert<QBrush>()) |
| 60 | { |
| 61 | QBrush brush = qvariant_cast<QBrush>(value); |
| 62 | foreground = brush.color(); |
| 63 | } |
| 64 | |
| 65 | painter->setPen(foreground); |
| 66 | QRect boundingRect; |
| 67 | painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address, &boundingRect); |
| 68 | |
| 69 | if (index.data(TransactionTableModel::WatchonlyRole).toBool()) |
| 70 | { |
| 71 | QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole)); |
| 72 | QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight); |
| 73 | iconWatchonly.paint(painter, watchonlyRect); |
| 74 | } |
| 75 | |
| 76 | if(amount < 0) |
| 77 | { |
| 78 | foreground = COLOR_NEGATIVE; |
| 79 | } |
| 80 | else if(!confirmed) |
| 81 | { |
| 82 | foreground = COLOR_UNCONFIRMED; |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | foreground = option.palette.color(QPalette::Text); |
| 87 | } |
| 88 | painter->setPen(foreground); |
| 89 | QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true, BitcoinUnits::separatorAlways); |
| 90 | if(!confirmed) |
| 91 | { |
| 92 | amountText = QString("[") + amountText + QString("]"); |
| 93 | } |
| 94 | painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText); |
nothing calls this directly
no test coverage detected