Skip to content

Commit 8ca6bd0

Browse files
author
MarcoFalke
committed
Merge #223: qt: Re-add and rename transaction "Edit Label" action
5440c07 qt: Rename "Edit label" to "Edit address label" (Wladimir J. van der Laan) 22664d6 Revert "qt: Remove Transactionview Edit Label Action" (Wladimir J. van der Laan) Pull request description: This reverts PR #211. I disagree with this change, I use the functionality a lot, it was the primary way I used to organize and edit transactions labels and am sad to see this go. > you can edit a sending address in the send tab Address Book Using the address book should not be encouraged at all! A while ago it was even proposed to remove it. There's rarely need to scroll through all historical addresses used and unused. The transaction list does just fine for this. > While all other actions apply directly to the selected transaction, the Edit Label action applies to the selected transaction's address. **In practice** when bitcoin is used in the commonly advised way, generate a new address for each transaction, those are equivalent though. I doubt I (and **luke-jr**) will be the only users that will stumblle on this. Further discussion here: #211 (comment) ACKs for top commit: hebasto: ACK 5440c07, verified that 22664d6 is a clean revert of 8f96448. Tree-SHA512: 3a86a730279bc454d0bd25d874dbfb6b1c0492480e66c3164e7c60d8658d622d4522de11bf8564876dc3ee056b53db71ecbe8a37281bf25d41a27e6e0d72ad8f
2 parents 09bc7bf + 5440c07 commit 8ca6bd0

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/qt/transactionview.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
172172
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
173173
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
174174
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
175+
QAction *editLabelAction = new QAction(tr("Edit address label"), this);
175176
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
176177

177178
contextMenu = new QMenu(this);
@@ -186,6 +187,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
186187
contextMenu->addSeparator();
187188
contextMenu->addAction(bumpFeeAction);
188189
contextMenu->addAction(abandonAction);
190+
contextMenu->addAction(editLabelAction);
189191

190192
connect(dateWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseDate);
191193
connect(typeWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseType);
@@ -206,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
206208
connect(copyTxIDAction, &QAction::triggered, this, &TransactionView::copyTxID);
207209
connect(copyTxHexAction, &QAction::triggered, this, &TransactionView::copyTxHex);
208210
connect(copyTxPlainText, &QAction::triggered, this, &TransactionView::copyTxPlainText);
211+
connect(editLabelAction, &QAction::triggered, this, &TransactionView::editLabel);
209212
connect(showDetailsAction, &QAction::triggered, this, &TransactionView::showDetails);
210213
// Double-clicking on a transaction on the transaction history page shows details
211214
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
@@ -474,6 +477,52 @@ void TransactionView::copyTxPlainText()
474477
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
475478
}
476479

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+
477526
void TransactionView::showDetails()
478527
{
479528
if(!transactionView->selectionModel())

src/qt/transactionview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ private Q_SLOTS:
9090
void dateRangeChanged();
9191
void showDetails();
9292
void copyAddress();
93+
void editLabel();
9394
void copyLabel();
9495
void copyAmount();
9596
void copyTxID();

0 commit comments

Comments
 (0)