| 48 | } |
| 49 | |
| 50 | QVariant RecentRequestsTableModel::data(const QModelIndex& index, int role) const |
| 51 | { |
| 52 | if (!index.isValid() || index.row() >= list.length()) |
| 53 | return QVariant(); |
| 54 | |
| 55 | const RecentRequestEntry* rec = &list[index.row()]; |
| 56 | |
| 57 | if (role == Qt::DisplayRole || role == Qt::EditRole) { |
| 58 | switch (index.column()) { |
| 59 | case Date: |
| 60 | return GUIUtil::dateTimeStr(rec->date); |
| 61 | case Label: |
| 62 | if (rec->recipient.label.isEmpty() && role == Qt::DisplayRole) { |
| 63 | return tr("(no label)"); |
| 64 | } else { |
| 65 | return rec->recipient.label; |
| 66 | } |
| 67 | case Message: |
| 68 | if (rec->recipient.message.isEmpty() && role == Qt::DisplayRole) { |
| 69 | return tr("(no message)"); |
| 70 | } else { |
| 71 | return rec->recipient.message; |
| 72 | } |
| 73 | case Amount: |
| 74 | if (rec->recipient.amount == 0 && role == Qt::DisplayRole) |
| 75 | return tr("(no amount)"); |
| 76 | else if (role == Qt::EditRole) |
| 77 | return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount, false, BitcoinUnits::separatorNever); |
| 78 | else |
| 79 | return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount); |
| 80 | } |
| 81 | } else if (role == Qt::TextAlignmentRole) { |
| 82 | if (index.column() == Amount) |
| 83 | return (int)(Qt::AlignRight | Qt::AlignVCenter); |
| 84 | } |
| 85 | return QVariant(); |
| 86 | } |
| 87 | |
| 88 | bool RecentRequestsTableModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 89 | { |
nothing calls this directly
no test coverage detected