Merge #12074: [qt] Optimizes boolean expression model && model->haveWatchOnly()
[bitcoinplatinum.git] / src / qt / transactionview.cpp
blobfa43ab750a7bbef3cdd4570c64289435fef3cce5
1 // Copyright (c) 2011-2017 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #include <qt/transactionview.h>
7 #include <qt/addresstablemodel.h>
8 #include <qt/bitcoinunits.h>
9 #include <qt/csvmodelwriter.h>
10 #include <qt/editaddressdialog.h>
11 #include <qt/optionsmodel.h>
12 #include <qt/platformstyle.h>
13 #include <qt/sendcoinsdialog.h>
14 #include <qt/transactiondescdialog.h>
15 #include <qt/transactionfilterproxy.h>
16 #include <qt/transactionrecord.h>
17 #include <qt/transactiontablemodel.h>
18 #include <qt/walletmodel.h>
20 #include <ui_interface.h>
22 #include <QComboBox>
23 #include <QDateTimeEdit>
24 #include <QDesktopServices>
25 #include <QDoubleValidator>
26 #include <QHBoxLayout>
27 #include <QHeaderView>
28 #include <QLabel>
29 #include <QLineEdit>
30 #include <QMenu>
31 #include <QPoint>
32 #include <QScrollBar>
33 #include <QSignalMapper>
34 #include <QTableView>
35 #include <QTimer>
36 #include <QUrl>
37 #include <QVBoxLayout>
39 TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
40 QWidget(parent), model(0), transactionProxyModel(0),
41 transactionView(0), abandonAction(0), bumpFeeAction(0), columnResizingFixer(0)
43 // Build filter row
44 setContentsMargins(0,0,0,0);
46 QHBoxLayout *hlayout = new QHBoxLayout();
47 hlayout->setContentsMargins(0,0,0,0);
49 if (platformStyle->getUseExtraSpacing()) {
50 hlayout->setSpacing(5);
51 hlayout->addSpacing(26);
52 } else {
53 hlayout->setSpacing(0);
54 hlayout->addSpacing(23);
57 watchOnlyWidget = new QComboBox(this);
58 watchOnlyWidget->setFixedWidth(24);
59 watchOnlyWidget->addItem("", TransactionFilterProxy::WatchOnlyFilter_All);
60 watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_plus"), "", TransactionFilterProxy::WatchOnlyFilter_Yes);
61 watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_minus"), "", TransactionFilterProxy::WatchOnlyFilter_No);
62 hlayout->addWidget(watchOnlyWidget);
64 dateWidget = new QComboBox(this);
65 if (platformStyle->getUseExtraSpacing()) {
66 dateWidget->setFixedWidth(121);
67 } else {
68 dateWidget->setFixedWidth(120);
70 dateWidget->addItem(tr("All"), All);
71 dateWidget->addItem(tr("Today"), Today);
72 dateWidget->addItem(tr("This week"), ThisWeek);
73 dateWidget->addItem(tr("This month"), ThisMonth);
74 dateWidget->addItem(tr("Last month"), LastMonth);
75 dateWidget->addItem(tr("This year"), ThisYear);
76 dateWidget->addItem(tr("Range..."), Range);
77 hlayout->addWidget(dateWidget);
79 typeWidget = new QComboBox(this);
80 if (platformStyle->getUseExtraSpacing()) {
81 typeWidget->setFixedWidth(121);
82 } else {
83 typeWidget->setFixedWidth(120);
86 typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
87 typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
88 TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther));
89 typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
90 TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
91 typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
92 typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
93 typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
95 hlayout->addWidget(typeWidget);
97 search_widget = new QLineEdit(this);
98 #if QT_VERSION >= 0x040700
99 search_widget->setPlaceholderText(tr("Enter address, transaction id, or label to search"));
100 #endif
101 hlayout->addWidget(search_widget);
103 amountWidget = new QLineEdit(this);
104 #if QT_VERSION >= 0x040700
105 amountWidget->setPlaceholderText(tr("Min amount"));
106 #endif
107 if (platformStyle->getUseExtraSpacing()) {
108 amountWidget->setFixedWidth(97);
109 } else {
110 amountWidget->setFixedWidth(100);
112 amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
113 hlayout->addWidget(amountWidget);
115 // Delay before filtering transactions in ms
116 static const int input_filter_delay = 200;
118 QTimer* amount_typing_delay = new QTimer(this);
119 amount_typing_delay->setSingleShot(true);
120 amount_typing_delay->setInterval(input_filter_delay);
122 QTimer* prefix_typing_delay = new QTimer(this);
123 prefix_typing_delay->setSingleShot(true);
124 prefix_typing_delay->setInterval(input_filter_delay);
126 QVBoxLayout *vlayout = new QVBoxLayout(this);
127 vlayout->setContentsMargins(0,0,0,0);
128 vlayout->setSpacing(0);
130 QTableView *view = new QTableView(this);
131 vlayout->addLayout(hlayout);
132 vlayout->addWidget(createDateRangeWidget());
133 vlayout->addWidget(view);
134 vlayout->setSpacing(0);
135 int width = view->verticalScrollBar()->sizeHint().width();
136 // Cover scroll bar width with spacing
137 if (platformStyle->getUseExtraSpacing()) {
138 hlayout->addSpacing(width+2);
139 } else {
140 hlayout->addSpacing(width);
142 // Always show scroll bar
143 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
144 view->setTabKeyNavigation(false);
145 view->setContextMenuPolicy(Qt::CustomContextMenu);
147 view->installEventFilter(this);
149 transactionView = view;
150 transactionView->setObjectName("transactionView");
152 // Actions
153 abandonAction = new QAction(tr("Abandon transaction"), this);
154 bumpFeeAction = new QAction(tr("Increase transaction fee"), this);
155 bumpFeeAction->setObjectName("bumpFeeAction");
156 QAction *copyAddressAction = new QAction(tr("Copy address"), this);
157 QAction *copyLabelAction = new QAction(tr("Copy label"), this);
158 QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
159 QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
160 QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
161 QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
162 QAction *editLabelAction = new QAction(tr("Edit label"), this);
163 QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
165 contextMenu = new QMenu(this);
166 contextMenu->setObjectName("contextMenu");
167 contextMenu->addAction(copyAddressAction);
168 contextMenu->addAction(copyLabelAction);
169 contextMenu->addAction(copyAmountAction);
170 contextMenu->addAction(copyTxIDAction);
171 contextMenu->addAction(copyTxHexAction);
172 contextMenu->addAction(copyTxPlainText);
173 contextMenu->addAction(showDetailsAction);
174 contextMenu->addSeparator();
175 contextMenu->addAction(bumpFeeAction);
176 contextMenu->addAction(abandonAction);
177 contextMenu->addAction(editLabelAction);
179 mapperThirdPartyTxUrls = new QSignalMapper(this);
181 // Connect actions
182 connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString)));
184 connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
185 connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
186 connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int)));
187 connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
188 connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
189 connect(search_widget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
190 connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedSearch()));
192 connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
193 connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
195 connect(bumpFeeAction, SIGNAL(triggered()), this, SLOT(bumpFee()));
196 connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx()));
197 connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
198 connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
199 connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
200 connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
201 connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex()));
202 connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
203 connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
204 connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
207 void TransactionView::setModel(WalletModel *_model)
209 this->model = _model;
210 if(_model)
212 transactionProxyModel = new TransactionFilterProxy(this);
213 transactionProxyModel->setSourceModel(_model->getTransactionTableModel());
214 transactionProxyModel->setDynamicSortFilter(true);
215 transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
216 transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
218 transactionProxyModel->setSortRole(Qt::EditRole);
220 transactionView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
221 transactionView->setModel(transactionProxyModel);
222 transactionView->setAlternatingRowColors(true);
223 transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
224 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
225 transactionView->setSortingEnabled(true);
226 transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
227 transactionView->verticalHeader()->hide();
229 transactionView->setColumnWidth(TransactionTableModel::Status, STATUS_COLUMN_WIDTH);
230 transactionView->setColumnWidth(TransactionTableModel::Watchonly, WATCHONLY_COLUMN_WIDTH);
231 transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
232 transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
233 transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
235 columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
237 if (_model->getOptionsModel())
239 // Add third party transaction URLs to context menu
240 QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
241 for (int i = 0; i < listUrls.size(); ++i)
243 QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
244 if (!host.isEmpty())
246 QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
247 if (i == 0)
248 contextMenu->addSeparator();
249 contextMenu->addAction(thirdPartyTxUrlAction);
250 connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map()));
251 mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
256 // show/hide column Watch-only
257 updateWatchOnlyColumn(_model->haveWatchOnly());
259 // Watch-only signal
260 connect(_model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyColumn(bool)));
264 void TransactionView::chooseDate(int idx)
266 if(!transactionProxyModel)
267 return;
268 QDate current = QDate::currentDate();
269 dateRangeWidget->setVisible(false);
270 switch(dateWidget->itemData(idx).toInt())
272 case All:
273 transactionProxyModel->setDateRange(
274 TransactionFilterProxy::MIN_DATE,
275 TransactionFilterProxy::MAX_DATE);
276 break;
277 case Today:
278 transactionProxyModel->setDateRange(
279 QDateTime(current),
280 TransactionFilterProxy::MAX_DATE);
281 break;
282 case ThisWeek: {
283 // Find last Monday
284 QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
285 transactionProxyModel->setDateRange(
286 QDateTime(startOfWeek),
287 TransactionFilterProxy::MAX_DATE);
289 } break;
290 case ThisMonth:
291 transactionProxyModel->setDateRange(
292 QDateTime(QDate(current.year(), current.month(), 1)),
293 TransactionFilterProxy::MAX_DATE);
294 break;
295 case LastMonth:
296 transactionProxyModel->setDateRange(
297 QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
298 QDateTime(QDate(current.year(), current.month(), 1)));
299 break;
300 case ThisYear:
301 transactionProxyModel->setDateRange(
302 QDateTime(QDate(current.year(), 1, 1)),
303 TransactionFilterProxy::MAX_DATE);
304 break;
305 case Range:
306 dateRangeWidget->setVisible(true);
307 dateRangeChanged();
308 break;
312 void TransactionView::chooseType(int idx)
314 if(!transactionProxyModel)
315 return;
316 transactionProxyModel->setTypeFilter(
317 typeWidget->itemData(idx).toInt());
320 void TransactionView::chooseWatchonly(int idx)
322 if(!transactionProxyModel)
323 return;
324 transactionProxyModel->setWatchOnlyFilter(
325 (TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt());
328 void TransactionView::changedSearch()
330 if(!transactionProxyModel)
331 return;
332 transactionProxyModel->setSearchString(search_widget->text());
335 void TransactionView::changedAmount()
337 if(!transactionProxyModel)
338 return;
339 CAmount amount_parsed = 0;
340 if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amountWidget->text(), &amount_parsed)) {
341 transactionProxyModel->setMinAmount(amount_parsed);
343 else
345 transactionProxyModel->setMinAmount(0);
349 void TransactionView::exportClicked()
351 if (!model || !model->getOptionsModel()) {
352 return;
355 // CSV is currently the only supported format
356 QString filename = GUIUtil::getSaveFileName(this,
357 tr("Export Transaction History"), QString(),
358 tr("Comma separated file (*.csv)"), nullptr);
360 if (filename.isNull())
361 return;
363 CSVModelWriter writer(filename);
365 // name, column, role
366 writer.setModel(transactionProxyModel);
367 writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
368 if (model->haveWatchOnly())
369 writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
370 writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
371 writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
372 writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);
373 writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole);
374 writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDisplayUnit()), 0, TransactionTableModel::FormattedAmountRole);
375 writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole);
377 if(!writer.write()) {
378 Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename),
379 CClientUIInterface::MSG_ERROR);
381 else {
382 Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename),
383 CClientUIInterface::MSG_INFORMATION);
387 void TransactionView::contextualMenu(const QPoint &point)
389 QModelIndex index = transactionView->indexAt(point);
390 QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
391 if (selection.empty())
392 return;
394 // check if transaction can be abandoned, disable context menu action in case it doesn't
395 uint256 hash;
396 hash.SetHex(selection.at(0).data(TransactionTableModel::TxHashRole).toString().toStdString());
397 abandonAction->setEnabled(model->transactionCanBeAbandoned(hash));
398 bumpFeeAction->setEnabled(model->transactionCanBeBumped(hash));
400 if(index.isValid())
402 contextMenu->popup(transactionView->viewport()->mapToGlobal(point));
406 void TransactionView::abandonTx()
408 if(!transactionView || !transactionView->selectionModel())
409 return;
410 QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
412 // get the hash from the TxHashRole (QVariant / QString)
413 uint256 hash;
414 QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();
415 hash.SetHex(hashQStr.toStdString());
417 // Abandon the wallet transaction over the walletModel
418 model->abandonTransaction(hash);
420 // Update the table
421 model->getTransactionTableModel()->updateTransaction(hashQStr, CT_UPDATED, false);
424 void TransactionView::bumpFee()
426 if(!transactionView || !transactionView->selectionModel())
427 return;
428 QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
430 // get the hash from the TxHashRole (QVariant / QString)
431 uint256 hash;
432 QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();
433 hash.SetHex(hashQStr.toStdString());
435 // Bump tx fee over the walletModel
436 if (model->bumpFee(hash)) {
437 // Update the table
438 model->getTransactionTableModel()->updateTransaction(hashQStr, CT_UPDATED, true);
442 void TransactionView::copyAddress()
444 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::AddressRole);
447 void TransactionView::copyLabel()
449 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::LabelRole);
452 void TransactionView::copyAmount()
454 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole);
457 void TransactionView::copyTxID()
459 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole);
462 void TransactionView::copyTxHex()
464 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxHexRole);
467 void TransactionView::copyTxPlainText()
469 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
472 void TransactionView::editLabel()
474 if(!transactionView->selectionModel() ||!model)
475 return;
476 QModelIndexList selection = transactionView->selectionModel()->selectedRows();
477 if(!selection.isEmpty())
479 AddressTableModel *addressBook = model->getAddressTableModel();
480 if(!addressBook)
481 return;
482 QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();
483 if(address.isEmpty())
485 // If this transaction has no associated address, exit
486 return;
488 // Is address in address book? Address book can miss address when a transaction is
489 // sent from outside the UI.
490 int idx = addressBook->lookupAddress(address);
491 if(idx != -1)
493 // Edit sending / receiving address
494 QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
495 // Determine type of address, launch appropriate editor dialog type
496 QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
498 EditAddressDialog dlg(
499 type == AddressTableModel::Receive
500 ? EditAddressDialog::EditReceivingAddress
501 : EditAddressDialog::EditSendingAddress, this);
502 dlg.setModel(addressBook);
503 dlg.loadRow(idx);
504 dlg.exec();
506 else
508 // Add sending address
509 EditAddressDialog dlg(EditAddressDialog::NewSendingAddress,
510 this);
511 dlg.setModel(addressBook);
512 dlg.setAddress(address);
513 dlg.exec();
518 void TransactionView::showDetails()
520 if(!transactionView->selectionModel())
521 return;
522 QModelIndexList selection = transactionView->selectionModel()->selectedRows();
523 if(!selection.isEmpty())
525 TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
526 dlg->setAttribute(Qt::WA_DeleteOnClose);
527 dlg->show();
531 void TransactionView::openThirdPartyTxUrl(QString url)
533 if(!transactionView || !transactionView->selectionModel())
534 return;
535 QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
536 if(!selection.isEmpty())
537 QDesktopServices::openUrl(QUrl::fromUserInput(url.replace("%s", selection.at(0).data(TransactionTableModel::TxHashRole).toString())));
540 QWidget *TransactionView::createDateRangeWidget()
542 dateRangeWidget = new QFrame();
543 dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
544 dateRangeWidget->setContentsMargins(1,1,1,1);
545 QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
546 layout->setContentsMargins(0,0,0,0);
547 layout->addSpacing(23);
548 layout->addWidget(new QLabel(tr("Range:")));
550 dateFrom = new QDateTimeEdit(this);
551 dateFrom->setDisplayFormat("dd/MM/yy");
552 dateFrom->setCalendarPopup(true);
553 dateFrom->setMinimumWidth(100);
554 dateFrom->setDate(QDate::currentDate().addDays(-7));
555 layout->addWidget(dateFrom);
556 layout->addWidget(new QLabel(tr("to")));
558 dateTo = new QDateTimeEdit(this);
559 dateTo->setDisplayFormat("dd/MM/yy");
560 dateTo->setCalendarPopup(true);
561 dateTo->setMinimumWidth(100);
562 dateTo->setDate(QDate::currentDate());
563 layout->addWidget(dateTo);
564 layout->addStretch();
566 // Hide by default
567 dateRangeWidget->setVisible(false);
569 // Notify on change
570 connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
571 connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
573 return dateRangeWidget;
576 void TransactionView::dateRangeChanged()
578 if(!transactionProxyModel)
579 return;
580 transactionProxyModel->setDateRange(
581 QDateTime(dateFrom->date()),
582 QDateTime(dateTo->date()).addDays(1));
585 void TransactionView::focusTransaction(const QModelIndex &idx)
587 if(!transactionProxyModel)
588 return;
589 QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx);
590 transactionView->scrollTo(targetIdx);
591 transactionView->setCurrentIndex(targetIdx);
592 transactionView->setFocus();
595 // We override the virtual resizeEvent of the QWidget to adjust tables column
596 // sizes as the tables width is proportional to the dialogs width.
597 void TransactionView::resizeEvent(QResizeEvent* event)
599 QWidget::resizeEvent(event);
600 columnResizingFixer->stretchColumnWidth(TransactionTableModel::ToAddress);
603 // Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text
604 bool TransactionView::eventFilter(QObject *obj, QEvent *event)
606 if (event->type() == QEvent::KeyPress)
608 QKeyEvent *ke = static_cast<QKeyEvent *>(event);
609 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
611 GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
612 return true;
615 return QWidget::eventFilter(obj, event);
618 // show/hide column Watch-only
619 void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
621 watchOnlyWidget->setVisible(fHaveWatchOnly);
622 transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly);