| 56 | } |
| 57 | |
| 58 | QVariant RecentRequestsTableModel::data(const QModelIndex &index, int role) const |
| 59 | { |
| 60 | if(!index.isValid() || index.row() >= list.length()) |
| 61 | return QVariant(); |
| 62 | |
| 63 | if(role == Qt::DisplayRole || role == Qt::EditRole) |
| 64 | { |
| 65 | const RecentRequestEntry *rec = &list[index.row()]; |
| 66 | switch(index.column()) |
| 67 | { |
| 68 | case Date: |
| 69 | return GUIUtil::dateTimeStr(rec->date); |
| 70 | case Label: |
| 71 | if(rec->recipient.label.isEmpty() && role == Qt::DisplayRole) |
| 72 | { |
| 73 | return tr("(no label)"); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | return rec->recipient.label; |
| 78 | } |
| 79 | case Message: |
| 80 | if(rec->recipient.message.isEmpty() && role == Qt::DisplayRole) |
| 81 | { |
| 82 | return tr("(no message)"); |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | return rec->recipient.message; |
| 87 | } |
| 88 | case Amount: |
| 89 | if (rec->recipient.amount == 0 && role == Qt::DisplayRole) |
| 90 | return tr("(no amount requested)"); |
| 91 | else if (role == Qt::EditRole) |
| 92 | return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount, false, BitcoinUnits::SeparatorStyle::NEVER); |
| 93 | else |
| 94 | return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount); |
| 95 | } |
| 96 | } |
| 97 | else if (role == Qt::TextAlignmentRole) |
| 98 | { |
| 99 | if (index.column() == Amount) |
| 100 | return (int)(Qt::AlignRight|Qt::AlignVCenter); |
| 101 | } |
| 102 | return QVariant(); |
| 103 | } |
| 104 | |
| 105 | bool RecentRequestsTableModel::setData(const QModelIndex &index, const QVariant &value, int role) |
| 106 | { |
nothing calls this directly
no test coverage detected