Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

transactionview.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 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.
4 
5 #include <qt/transactionview.h>
6 
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/qrdialog.h>
15 #include <qt/transactionrecord.h>
17 #include <qt/walletmodel.h>
18 
20 #include <ui_interface.h>
21 
22 #include <QCalendarWidget>
23 #include <QComboBox>
24 #include <QDateTimeEdit>
25 #include <QDesktopServices>
26 #include <QDoubleValidator>
27 #include <QHBoxLayout>
28 #include <QHeaderView>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QListView>
32 #include <QMenu>
33 #include <QPoint>
34 #include <QScrollBar>
35 #include <QSettings>
36 #include <QSignalMapper>
37 #include <QTableView>
38 #include <QTextCharFormat>
39 #include <QTimer>
40 #include <QUrl>
41 #include <QVBoxLayout>
42 
44 static const char* PERSISTENCE_DATE_FORMAT = "yyyy-MM-dd";
45 
47  QWidget(parent), model(0), transactionProxyModel(0),
48  transactionView(0), abandonAction(0), columnResizingFixer(0)
49 {
50  QSettings settings;
51  // Build filter row
52  setContentsMargins(0,0,0,0);
53 
54  QHBoxLayout *hlayout = new QHBoxLayout();
55  hlayout->setContentsMargins(0,0,0,0);
56  hlayout->setSpacing(1);
57  hlayout->addSpacing(STATUS_COLUMN_WIDTH - 2);
58 
59  watchOnlyWidget = new QComboBox(this);
60  watchOnlyWidget->setFixedWidth(24);
64  hlayout->addWidget(watchOnlyWidget);
65 
66  dateWidget = new QComboBox(this);
67  dateWidget->setFixedWidth(120);
68  dateWidget->addItem(tr("All"), All);
69  dateWidget->addItem(tr("Today"), Today);
70  dateWidget->addItem(tr("This week"), ThisWeek);
71  dateWidget->addItem(tr("This month"), ThisMonth);
72  dateWidget->addItem(tr("Last month"), LastMonth);
73  dateWidget->addItem(tr("This year"), ThisYear);
74  dateWidget->addItem(tr("Range..."), Range);
75  dateWidget->setCurrentIndex(settings.value("transactionDate").toInt());
76  hlayout->addWidget(dateWidget);
77 
78  typeWidget = new QComboBox(this);
79  typeWidget->setFixedWidth(TYPE_COLUMN_WIDTH - 1);
80  typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
81  typeWidget->addItem(tr("Most Common"), TransactionFilterProxy::COMMON_TYPES);
87  typeWidget->addItem(tr("PrivateSend Make Collateral Inputs"), TransactionFilterProxy::TYPE(TransactionRecord::PrivateSendMakeCollaterals));
88  typeWidget->addItem(tr("PrivateSend Create Denominations"), TransactionFilterProxy::TYPE(TransactionRecord::PrivateSendCreateDenominations));
90  typeWidget->addItem(tr("PrivateSend Collateral Payment"), TransactionFilterProxy::TYPE(TransactionRecord::PrivateSendCollateralPayment));
94  typeWidget->setCurrentIndex(settings.value("transactionType").toInt());
95 
96  hlayout->addWidget(typeWidget);
97 
98  search_widget = new QLineEdit(this);
99 #if QT_VERSION >= 0x040700
100  search_widget->setPlaceholderText(tr("Enter address, transaction id, or label to search"));
101 #endif
102  search_widget->setObjectName("search_widget");
103  hlayout->addWidget(search_widget);
104 
105  amountWidget = new QLineEdit(this);
106 #if QT_VERSION >= 0x040700
107  amountWidget->setPlaceholderText(tr("Min amount"));
108 #endif
109  amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
110  amountWidget->setObjectName("amountWidget");
111  hlayout->addWidget(amountWidget);
112 
113  // Delay before filtering transactions in ms
114  static const int input_filter_delay = 200;
115 
116  QTimer* amount_typing_delay = new QTimer(this);
117  amount_typing_delay->setSingleShot(true);
118  amount_typing_delay->setInterval(input_filter_delay);
119 
120  QTimer* prefix_typing_delay = new QTimer(this);
121  prefix_typing_delay->setSingleShot(true);
122  prefix_typing_delay->setInterval(input_filter_delay);
123 
124  QVBoxLayout *vlayout = new QVBoxLayout(this);
125  vlayout->setContentsMargins(0,0,0,0);
126  vlayout->setSpacing(0);
127 
128  QTableView *view = new QTableView(this);
129  vlayout->addLayout(hlayout);
130  vlayout->addWidget(createDateRangeWidget());
131  vlayout->addWidget(view);
132  vlayout->setSpacing(0);
133 #ifndef Q_OS_MAC
134  int width = view->verticalScrollBar()->sizeHint().width();
135  // Cover scroll bar width with spacing
136  hlayout->addSpacing(width);
137  // Always show scroll bar
138  view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
139 #endif
140  view->setTabKeyNavigation(false);
141  view->setContextMenuPolicy(Qt::CustomContextMenu);
142 
143  view->installEventFilter(this);
144 
145  transactionView = view;
146  transactionView->setObjectName("transactionView");
147 
148  // Actions
149  abandonAction = new QAction(tr("Abandon transaction"), this);
150  QAction *copyAddressAction = new QAction(tr("Copy address"), this);
151  QAction *copyLabelAction = new QAction(tr("Copy label"), this);
152  QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
153  QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
154  QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
155  QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
156  QAction *editLabelAction = new QAction(tr("Edit label"), this);
157  QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
158  QAction *showAddressQRCodeAction = new QAction(tr("Show address QR code"), this);
159 
160  contextMenu = new QMenu(this);
161  contextMenu->setObjectName("contextMenu");
162  contextMenu->addAction(copyAddressAction);
163  contextMenu->addAction(copyLabelAction);
164  contextMenu->addAction(copyAmountAction);
165  contextMenu->addAction(copyTxIDAction);
166  contextMenu->addAction(copyTxHexAction);
167  contextMenu->addAction(copyTxPlainText);
168  contextMenu->addAction(showDetailsAction);
169  contextMenu->addAction(showAddressQRCodeAction);
170  contextMenu->addSeparator();
171  contextMenu->addAction(abandonAction);
172  contextMenu->addAction(editLabelAction);
173 
174  mapperThirdPartyTxUrls = new QSignalMapper(this);
175 
176  // Connect actions
177  connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString)));
178 
179  connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
180  connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
181  connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int)));
182  connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
183  connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
184  connect(search_widget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
185  connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedSearch()));
186 
187  connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
188  connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(computeSum()));
189  connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
190 
191  connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx()));
192  connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
193  connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
194  connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
195  connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
196  connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex()));
197  connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
198  connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
199  connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
200  connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(showAddressQRCode()));
201 
203 }
204 
206 {
207  QSettings settings;
208  this->model = _model;
209  if(_model)
210  {
212  transactionProxyModel->setSourceModel(_model->getTransactionTableModel());
213  transactionProxyModel->setDynamicSortFilter(true);
214  transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
215  transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
216 
217  transactionProxyModel->setSortRole(Qt::EditRole);
218 
219  transactionView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
221  transactionView->setAlternatingRowColors(true);
222  transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
223  transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
224  transactionView->setSortingEnabled(true);
225  transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
226  transactionView->verticalHeader()->hide();
227 
233 
234  // Note: it's a good idea to connect this signal AFTER the model is set
235  connect(transactionView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(computeSum()));
236 
238 
239  if (_model->getOptionsModel())
240  {
241  // Add third party transaction URLs to context menu
242  QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
243  for (int i = 0; i < listUrls.size(); ++i)
244  {
245  QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
246  if (!host.isEmpty())
247  {
248  QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
249  if (i == 0)
250  contextMenu->addSeparator();
251  contextMenu->addAction(thirdPartyTxUrlAction);
252  connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map()));
253  mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
254  }
255  }
256 
257  connect(_model->getOptionsModel(), SIGNAL(privateSendEnabledChanged()), this, SLOT(updatePrivateSendVisibility()));
258  }
259 
260  // show/hide column Watch-only
262 
263  // Watch-only signal
264  connect(_model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyColumn(bool)));
265 
266  // Update transaction list with persisted settings
267  chooseType(settings.value("transactionType").toInt());
268  chooseDate(settings.value("transactionDate").toInt());
269  }
270 }
271 
273 {
275  return;
276 
277  QSettings settings;
278  QDate current = QDate::currentDate();
279  dateRangeWidget->setVisible(false);
280  switch(dateWidget->itemData(idx).toInt())
281  {
282  case All:
286  break;
287  case Today:
289  QDateTime(current),
291  break;
292  case ThisWeek: {
293  // Find last Monday
294  QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
296  QDateTime(startOfWeek),
298 
299  } break;
300  case ThisMonth:
302  QDateTime(QDate(current.year(), current.month(), 1)),
304  break;
305  case LastMonth:
307  QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
308  QDateTime(QDate(current.year(), current.month(), 1)));
309  break;
310  case ThisYear:
312  QDateTime(QDate(current.year(), 1, 1)),
314  break;
315  case Range:
316  dateRangeWidget->setVisible(true);
318  break;
319  }
320  // Persist new date settings
321  settings.setValue("transactionDate", idx);
322  if (dateWidget->itemData(idx).toInt() == Range){
323  settings.setValue("transactionDateFrom", dateFrom->date().toString(PERSISTENCE_DATE_FORMAT));
324  settings.setValue("transactionDateTo", dateTo->date().toString(PERSISTENCE_DATE_FORMAT));
325  }
326 }
327 
329 {
331  return;
333  typeWidget->itemData(idx).toInt());
334  // Persist settings
335  QSettings settings;
336  settings.setValue("transactionType", idx);
337 }
338 
340 {
342  return;
345 }
346 
348 {
350  return;
352 }
353 
355 {
357  return;
358  CAmount amount_parsed = 0;
359 
360  // Replace "," by "." so BitcoinUnits::parse will not fail for users entering "," as decimal separator
361  QString newAmount = amountWidget->text();
362  newAmount.replace(QString(","), QString("."));
363 
364  if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), newAmount, &amount_parsed)) {
365  transactionProxyModel->setMinAmount(amount_parsed);
366  }
367  else
368  {
370  }
371 }
372 
374 {
375  if (!model || !model->getOptionsModel()) {
376  return;
377  }
378 
379  // CSV is currently the only supported format
380  QString filename = GUIUtil::getSaveFileName(this,
381  tr("Export Transaction History"), QString(),
382  tr("Comma separated file (*.csv)"), nullptr);
383 
384  if (filename.isNull())
385  return;
386 
387  CSVModelWriter writer(filename);
388 
389  // name, column, role
391  writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
392  if (model->haveWatchOnly())
393  writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
394  writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
395  writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
396  writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);
397  writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole);
399  writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole);
400 
401  if(!writer.write()) {
402  Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename),
404  }
405  else {
406  Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename),
408  }
409 }
410 
411 void TransactionView::contextualMenu(const QPoint &point)
412 {
413  if (!transactionView || !transactionView->selectionModel())
414  return;
415  QModelIndex index = transactionView->indexAt(point);
416  QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
417  if (selection.empty())
418  return;
419 
420  // check if transaction can be abandoned, disable context menu action in case it doesn't
421  uint256 hash;
422  hash.SetHex(selection.at(0).data(TransactionTableModel::TxHashRole).toString().toStdString());
423  abandonAction->setEnabled(model->transactionCanBeAbandoned(hash));
424 
425  if(index.isValid())
426  {
427  contextMenu->popup(transactionView->viewport()->mapToGlobal(point));
428  }
429 }
430 
432 {
433  if(!transactionView || !transactionView->selectionModel())
434  return;
435  QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
436 
437  // get the hash from the TxHashRole (QVariant / QString)
438  uint256 hash;
439  QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString();
440  hash.SetHex(hashQStr.toStdString());
441 
442  // Abandon the wallet transaction over the walletModel
443  model->abandonTransaction(hash);
444 
445  // Update the table
447 }
448 
450 {
452 }
453 
455 {
457 }
458 
460 {
462 }
463 
465 {
467 }
468 
470 {
472 }
473 
475 {
477 }
478 
480 {
481  if(!transactionView->selectionModel() ||!model)
482  return;
483  QModelIndexList selection = transactionView->selectionModel()->selectedRows();
484  if(!selection.isEmpty())
485  {
486  AddressTableModel *addressBook = model->getAddressTableModel();
487  if(!addressBook)
488  return;
489  QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();
490  if(address.isEmpty())
491  {
492  // If this transaction has no associated address, exit
493  return;
494  }
495  // Is address in address book? Address book can miss address when a transaction is
496  // sent from outside the UI.
497  int idx = addressBook->lookupAddress(address);
498  if(idx != -1)
499  {
500  // Edit sending / receiving address
501  QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
502  // Determine type of address, launch appropriate editor dialog type
503  QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
504 
505  EditAddressDialog dlg(
509  dlg.setModel(addressBook);
510  dlg.loadRow(idx);
511  dlg.exec();
512  }
513  else
514  {
515  // Add sending address
517  this);
518  dlg.setModel(addressBook);
519  dlg.setAddress(address);
520  dlg.exec();
521  }
522  }
523 }
524 
526 {
527  if(!transactionView->selectionModel())
528  return;
529  QModelIndexList selection = transactionView->selectionModel()->selectedRows();
530  if(!selection.isEmpty())
531  {
532  TransactionDescDialog* dlg = new TransactionDescDialog(selection.at(0), this);
533  dlg->setAttribute(Qt::WA_DeleteOnClose);
534  dlg->show();
535  }
536 }
537 
539 {
540  QList<QModelIndex> entries = GUIUtil::getEntryData(transactionView, 0);
541  if (entries.empty()) {
542  return;
543  }
544 
545  QString strAddress = entries.at(0).data(TransactionTableModel::AddressRole).toString();
546  QRDialog* dialog = new QRDialog(this);
547  OptionsModel *model = new OptionsModel(nullptr, false);
548 
549  dialog->setModel(model);
550  dialog->setAttribute(Qt::WA_DeleteOnClose);
551  dialog->setInfo(tr("QR code"), "dash:"+strAddress, "", strAddress);
552  dialog->show();
553 }
554 
557 {
558  qint64 amount = 0;
559  int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
560  if(!transactionView->selectionModel())
561  return;
562  QModelIndexList selection = transactionView->selectionModel()->selectedRows();
563 
564  for (QModelIndex index : selection){
565  amount += index.data(TransactionTableModel::AmountRole).toLongLong();
566  }
567  QString strAmount(BitcoinUnits::formatWithUnit(nDisplayUnit, amount, true, BitcoinUnits::separatorAlways));
568  if (amount < 0) strAmount = "<span style='" + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR) + "'>" + strAmount + "</span>";
569  Q_EMIT trxAmount(strAmount);
570 }
571 
573 {
574  if(!transactionView || !transactionView->selectionModel())
575  return;
576  QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
577  if(!selection.isEmpty())
578  QDesktopServices::openUrl(QUrl::fromUserInput(url.replace("%s", selection.at(0).data(TransactionTableModel::TxHashRole).toString())));
579 }
580 
582 {
583  // Create default dates in case nothing is persisted
584  QString defaultDateFrom = QDate::currentDate().toString(PERSISTENCE_DATE_FORMAT);
585  QString defaultDateTo = QDate::currentDate().addDays(1).toString(PERSISTENCE_DATE_FORMAT);
586  QSettings settings;
587 
588  dateRangeWidget = new QFrame();
589  dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
590  dateRangeWidget->setContentsMargins(1,1,1,1);
591  QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
592  layout->setContentsMargins(0,0,0,0);
593  layout->addSpacing(23);
594  layout->addWidget(new QLabel(tr("Range:")));
595 
596  dateFrom = new QDateTimeEdit(this);
597  dateFrom->setCalendarPopup(true);
598  dateFrom->setMinimumWidth(100);
599  // Load persisted FROM date
600  dateFrom->setDate(QDate::fromString(settings.value("transactionDateFrom", defaultDateFrom).toString(), PERSISTENCE_DATE_FORMAT));
601 
602  layout->addWidget(dateFrom);
603  layout->addWidget(new QLabel(tr("to")));
604 
605  dateTo = new QDateTimeEdit(this);
606  dateTo->setCalendarPopup(true);
607  dateTo->setMinimumWidth(100);
608  // Load persisted TO date
609  dateTo->setDate(QDate::fromString(settings.value("transactionDateTo", defaultDateTo).toString(), PERSISTENCE_DATE_FORMAT));
610 
611  layout->addWidget(dateTo);
612  layout->addStretch();
613 
614  // Hide by default
615  dateRangeWidget->setVisible(false);
616 
617  // Notify on change
618  connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
619  connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
620 
622 
623  return dateRangeWidget;
624 }
625 
627 {
628  auto adjustWeekEndColors = [](QCalendarWidget* w) {
629  QTextCharFormat format = w->weekdayTextFormat(Qt::Saturday);
630  format.setForeground(QBrush(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT), Qt::SolidPattern));
631 
632  w->setWeekdayTextFormat(Qt::Saturday, format);
633  w->setWeekdayTextFormat(Qt::Sunday, format);
634  };
635 
636  adjustWeekEndColors(dateFrom->calendarWidget());
637  adjustWeekEndColors(dateTo->calendarWidget());
638 }
639 
641 {
643  return;
644 
645  // Persist new date range
646  QSettings settings;
647  settings.setValue("transactionDateFrom", dateFrom->date().toString(PERSISTENCE_DATE_FORMAT));
648  settings.setValue("transactionDateTo", dateTo->date().toString(PERSISTENCE_DATE_FORMAT));
649 
651  QDateTime(dateFrom->date()),
652  QDateTime(dateTo->date()));
653 }
654 
655 void TransactionView::focusTransaction(const QModelIndex &idx)
656 {
658  return;
659  QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx);
660  transactionView->selectRow(targetIdx.row());
661  computeSum();
662  transactionView->scrollTo(targetIdx);
663  transactionView->setCurrentIndex(targetIdx);
664  transactionView->setFocus();
665 }
666 
667 // We override the virtual resizeEvent of the QWidget to adjust tables column
668 // sizes as the tables width is proportional to the dialogs width.
669 void TransactionView::resizeEvent(QResizeEvent* event)
670 {
671  QWidget::resizeEvent(event);
673 }
674 
676 {
677  QWidget::changeEvent(e);
678  if (e->type() == QEvent::StyleChange) {
680  }
681 }
682 
683 // Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text
684 bool TransactionView::eventFilter(QObject *obj, QEvent *event)
685 {
686  if (event->type() == QEvent::KeyPress)
687  {
688  QKeyEvent *ke = static_cast<QKeyEvent *>(event);
689  if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
690  {
692  return true;
693  }
694  }
695  if (event->type() == QEvent::Show) {
696  // Give the search field the first focus on startup
697  static bool fGotFirstFocus = false;
698  if (!fGotFirstFocus) {
699  search_widget->setFocus();
700  fGotFirstFocus = true;
701  }
702  }
703  return QWidget::eventFilter(obj, event);
704 }
705 
706 // show/hide column Watch-only
707 void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
708 {
709  watchOnlyWidget->setVisible(fHaveWatchOnly);
710  transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly);
711 }
712 
714 {
715  bool fEnabled = privateSendClient.fEnablePrivateSend;
716  // If PrivateSend gets enabled use "All" else "Most common"
717  typeWidget->setCurrentIndex(fEnabled ? 0 : 1);
718  // Hide all PrivateSend related filters
719  QListView* typeList = qobject_cast<QListView*>(typeWidget->view());
720  std::vector<int> vecRows{4, 5, 6, 7, 8};
721  for (auto nRow : vecRows) {
722  typeList->setRowHidden(nRow, !fEnabled);
723  }
724 }
bool abandonTransaction(uint256 hash) const
uint8_t data[WIDTH]
Definition: uint256.h:24
TransactionView(QWidget *parent=0)
void addColumn(const QString &title, int column, int role=Qt::EditRole)
void openThirdPartyTxUrl(QString url)
void setInfo(QString strWindowtitle, QString strQRCode, QString strTextInfo, QString strQRCodeTitle)
Definition: qrdialog.cpp:128
QList< QModelIndex > getEntryData(QAbstractItemView *view, int column)
Return a field of the currently selected entry as a QString.
Definition: guiutil.cpp:514
QWidget * createDateRangeWidget()
QModelIndex index(int row, int column, const QModelIndex &parent) const
int lookupAddress(const QString &address) const
Dialog showing transaction details.
QColor getThemedQColor(ThemedColor color)
Helper to get colors for various themes which can&#39;t be applied via css for some reason.
Definition: guiutil.cpp:204
QAction * abandonAction
void setModel(OptionsModel *model)
Definition: qrdialog.cpp:117
void updateTransaction(const QString &hash, int status, bool showTransaction)
void focusTransaction(const QModelIndex &)
TransactionRecord * index(int idx)
void setTypeFilter(quint32 modes)
static const char * PERSISTENCE_DATE_FORMAT
Date format for persistence.
bool transactionCanBeAbandoned(uint256 hash) const
QTableView * transactionView
AddressTableModel * getAddressTableModel()
Export a Qt table model to a CSV file.
Transaction data, hex-encoded.
TransactionTableModel * parent
static bool parse(int unit, const QString &value, CAmount *val_out)
Parse string to coin amount.
bool haveWatchOnly() const
void chooseWatchonly(int idx)
int getDisplayUnit() const
Definition: optionsmodel.h:82
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
static quint32 TYPE(int type)
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void trxAmount(QString amount)
Send computed sum back to wallet-view.
QDateTimeEdit * dateTo
void setModel(AddressTableModel *model)
static const QDateTime MIN_DATE
Earliest date that can be represented (far in the past)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
void computeSum()
Compute sum of all selected transactions.
Whole transaction as plain text.
QSignalMapper * mapperThirdPartyTxUrls
void setDateRange(const QDateTime &from, const QDateTime &to)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
void format(std::ostream &out, const char *fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:967
QIcon getIcon(const QString &strIcon, const ThemedColor color, const ThemedColor colorAlternative, const QString &strIconPath)
Helper to get an icon colorized with the given color (replaces black) and colorAlternative (replaces ...
Definition: guiutil.cpp:216
Makes a QTableView last column feel as if it was being resized from its left border.
Definition: guiutil.h:221
Date and time this transaction was created.
void updateWatchOnlyColumn(bool fHaveWatchOnly)
TransactionTableModel * getTransactionTableModel()
bool eventFilter(QObject *obj, QEvent *event) override
void setWatchOnlyFilter(WatchOnlyFilter filter)
Qt model of the address book in the core.
void setMinAmount(const CAmount &minimum)
TransactionFilterProxy * transactionProxyModel
QString getThirdPartyTxUrls() const
Definition: optionsmodel.h:83
static const quint32 COMMON_TYPES
Type filter bit field (all types but Darksend-SPAM)
QComboBox * watchOnlyWidget
256-bit opaque blob.
Definition: uint256.h:123
void chooseDate(int idx)
void setModel(const QAbstractItemModel *model)
void setModel(WalletModel *model)
QLineEdit * amountWidget
CPrivateSendClientManager privateSendClient
QComboBox * typeWidget
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:25
Filter the transaction list according to pre-specified rules.
void setAddress(const QString &address)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:100
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
Definition: guiutil.cpp:521
virtual void resizeEvent(QResizeEvent *event) override
static const QString Receive
Specifies receive address.
Dialog for editing an address and associated information.
QVariant data(const QModelIndex &index, int role) const
QString getThemedStyleQString(ThemedStyle style)
Helper to get css style strings which are injected into rich text through qt.
Definition: guiutil.cpp:210
QFrame * dateRangeWidget
void updatePrivateSendVisibility()
Label of address related to transaction.
static const quint32 ALL_TYPES
Type filter bit field (all types)
void setSearchString(const QString &)
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
void contextualMenu(const QPoint &)
void changeEvent(QEvent *e) override
Formatted amount, without brackets when unconfirmed.
void copyEntryData(QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
Definition: guiutil.cpp:501
void chooseType(int idx)
GUIUtil::TableViewLastColumnResizingFixer * columnResizingFixer
QDateTimeEdit * dateFrom
void SetHex(const char *psz)
Definition: uint256.cpp:27
bool write()
Perform export of the model to CSV.
void doubleClicked(const QModelIndex &)
Type of address (Send or Receive)
WalletModel * model
OptionsModel * getOptionsModel()
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:70
QComboBox * dateWidget
QLineEdit * search_widget
Released under the MIT license