Handle multiple send in tx table
This commit is contained in:
@@ -366,10 +366,13 @@ void Controller::refreshTransactions() {
|
|||||||
total_amount = total_amount + amount;
|
total_amount = total_amount + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.length() == 1) {
|
{
|
||||||
address = items[0].address;
|
// Concat all the addresses
|
||||||
} else {
|
QList<QString> addresses;
|
||||||
address = "(Multiple)";
|
for (auto item : items) {
|
||||||
|
addresses.push_back(item.address);
|
||||||
|
}
|
||||||
|
address = addresses.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
txdata.push_back(TransactionItem{
|
txdata.push_back(TransactionItem{
|
||||||
|
|||||||
@@ -69,10 +69,20 @@ bool TxTableModel::exportToCsv(QString fileName) const {
|
|||||||
return headers.size();
|
return headers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TxTableModel::concatMultipleMemos(const TransactionItem& dat) const {
|
||||||
|
// Concat all the memos
|
||||||
|
QString memo;
|
||||||
|
for (auto item : dat.items) {
|
||||||
|
if (!item.memo.trimmed().isEmpty()) {
|
||||||
|
memo += item.address + ": \"" + item.memo + "\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant TxTableModel::data(const QModelIndex &index, int role) const
|
return memo;
|
||||||
{
|
};
|
||||||
// Align numeric columns (confirmations, amount) right
|
|
||||||
|
QVariant TxTableModel::data(const QModelIndex &index, int role) const {
|
||||||
|
// Align numeric columns (confirmations, amount) right
|
||||||
if (role == Qt::TextAlignmentRole &&
|
if (role == Qt::TextAlignmentRole &&
|
||||||
(index.column() == Column::Confirmations || index.column() == Column::Amount))
|
(index.column() == Column::Confirmations || index.column() == Column::Amount))
|
||||||
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
@@ -127,7 +137,7 @@ bool TxTableModel::exportToCsv(QString fileName) const {
|
|||||||
(memo.isEmpty() ? "" : " tx memo: \"" + memo + "\"");
|
(memo.isEmpty() ? "" : " tx memo: \"" + memo + "\"");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return "Multiple";
|
return concatMultipleMemos(dat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Column::Address: {
|
case Column::Address: {
|
||||||
@@ -202,20 +212,8 @@ QString TxTableModel::getTxId(int row) const {
|
|||||||
|
|
||||||
QString TxTableModel::getMemo(int row) const {
|
QString TxTableModel::getMemo(int row) const {
|
||||||
auto dat = modeldata->at(row);
|
auto dat = modeldata->at(row);
|
||||||
bool hasMemo = false;
|
|
||||||
for (int i=0; i < dat.items.length(); i++) {
|
|
||||||
if (!dat.items[i].memo.isEmpty()) {
|
|
||||||
hasMemo = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dat.items.length() == 1) {
|
return concatMultipleMemos(dat);
|
||||||
return dat.items[0].memo;
|
|
||||||
} else if (hasMemo) {
|
|
||||||
return "(Multiple)";
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 TxTableModel::getConfirmations(int row) const {
|
qint64 TxTableModel::getConfirmations(int row) const {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString concatMultipleMemos(const TransactionItem&) const;
|
||||||
|
|
||||||
QList<TransactionItem>* modeldata = nullptr;
|
QList<TransactionItem>* modeldata = nullptr;
|
||||||
|
|
||||||
QList<QString> headers;
|
QList<QString> headers;
|
||||||
|
|||||||
Reference in New Issue
Block a user