@@ -172,6 +172,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
172
172
QAction *copyTxIDAction = new QAction (tr (" Copy transaction ID" ), this );
173
173
QAction *copyTxHexAction = new QAction (tr (" Copy raw transaction" ), this );
174
174
QAction *copyTxPlainText = new QAction (tr (" Copy full transaction details" ), this );
175
+ QAction *editLabelAction = new QAction (tr (" Edit label" ), this );
175
176
QAction *showDetailsAction = new QAction (tr (" Show transaction details" ), this );
176
177
177
178
contextMenu = new QMenu (this );
@@ -186,6 +187,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
186
187
contextMenu->addSeparator ();
187
188
contextMenu->addAction (bumpFeeAction);
188
189
contextMenu->addAction (abandonAction);
190
+ contextMenu->addAction (editLabelAction);
189
191
190
192
connect (dateWidget, static_cast <void (QComboBox::*)(int )>(&QComboBox::activated), this , &TransactionView::chooseDate);
191
193
connect (typeWidget, static_cast <void (QComboBox::*)(int )>(&QComboBox::activated), this , &TransactionView::chooseType);
@@ -206,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
206
208
connect (copyTxIDAction, &QAction::triggered, this , &TransactionView::copyTxID);
207
209
connect (copyTxHexAction, &QAction::triggered, this , &TransactionView::copyTxHex);
208
210
connect (copyTxPlainText, &QAction::triggered, this , &TransactionView::copyTxPlainText);
211
+ connect (editLabelAction, &QAction::triggered, this , &TransactionView::editLabel);
209
212
connect (showDetailsAction, &QAction::triggered, this , &TransactionView::showDetails);
210
213
// Double-clicking on a transaction on the transaction history page shows details
211
214
connect (this , &TransactionView::doubleClicked, this , &TransactionView::showDetails);
@@ -474,6 +477,52 @@ void TransactionView::copyTxPlainText()
474
477
GUIUtil::copyEntryData (transactionView, 0 , TransactionTableModel::TxPlainTextRole);
475
478
}
476
479
480
+ void TransactionView::editLabel ()
481
+ {
482
+ if (!transactionView->selectionModel () ||!model)
483
+ return ;
484
+ QModelIndexList selection = transactionView->selectionModel ()->selectedRows ();
485
+ if (!selection.isEmpty ())
486
+ {
487
+ AddressTableModel *addressBook = model->getAddressTableModel ();
488
+ if (!addressBook)
489
+ return ;
490
+ QString address = selection.at (0 ).data (TransactionTableModel::AddressRole).toString ();
491
+ if (address.isEmpty ())
492
+ {
493
+ // If this transaction has no associated address, exit
494
+ return ;
495
+ }
496
+ // Is address in address book? Address book can miss address when a transaction is
497
+ // sent from outside the UI.
498
+ int idx = addressBook->lookupAddress (address);
499
+ if (idx != -1 )
500
+ {
501
+ // Edit sending / receiving address
502
+ QModelIndex modelIdx = addressBook->index (idx, 0 , QModelIndex ());
503
+ // Determine type of address, launch appropriate editor dialog type
504
+ QString type = modelIdx.data (AddressTableModel::TypeRole).toString ();
505
+
506
+ EditAddressDialog dlg (
507
+ type == AddressTableModel::Receive
508
+ ? EditAddressDialog::EditReceivingAddress
509
+ : EditAddressDialog::EditSendingAddress, this );
510
+ dlg.setModel (addressBook);
511
+ dlg.loadRow (idx);
512
+ dlg.exec ();
513
+ }
514
+ else
515
+ {
516
+ // Add sending address
517
+ EditAddressDialog dlg (EditAddressDialog::NewSendingAddress,
518
+ this );
519
+ dlg.setModel (addressBook);
520
+ dlg.setAddress (address);
521
+ dlg.exec ();
522
+ }
523
+ }
524
+ }
525
+
477
526
void TransactionView::showDetails ()
478
527
{
479
528
if (!transactionView->selectionModel ())
0 commit comments