22 #include <QApplication> 24 #include <QDateTimeEdit> 25 #include <QDesktopServices> 26 #include <QDoubleValidator> 27 #include <QHBoxLayout> 28 #include <QHeaderView> 34 #include <QSignalMapper> 38 #include <QVBoxLayout> 41 QWidget(
parent), model(0), transactionProxyModel(0),
42 transactionView(0), abandonAction(0), bumpFeeAction(0), columnResizingFixer(0)
45 setContentsMargins(0,0,0,0);
47 QHBoxLayout *hlayout =
new QHBoxLayout();
48 hlayout->setContentsMargins(0,0,0,0);
51 hlayout->setSpacing(5);
52 hlayout->addSpacing(26);
54 hlayout->setSpacing(0);
55 hlayout->addSpacing(23);
99 search_widget->setPlaceholderText(tr(
"Enter address, transaction id, or label to search"));
109 QDoubleValidator *amountValidator =
new QDoubleValidator(0, 1e20, 8,
this);
110 QLocale amountLocale(QLocale::C);
111 amountLocale.setNumberOptions(QLocale::RejectGroupSeparator);
112 amountValidator->setLocale(amountLocale);
117 static const int input_filter_delay = 200;
119 QTimer* amount_typing_delay =
new QTimer(
this);
120 amount_typing_delay->setSingleShot(
true);
121 amount_typing_delay->setInterval(input_filter_delay);
123 QTimer* prefix_typing_delay =
new QTimer(
this);
124 prefix_typing_delay->setSingleShot(
true);
125 prefix_typing_delay->setInterval(input_filter_delay);
127 QVBoxLayout *vlayout =
new QVBoxLayout(
this);
128 vlayout->setContentsMargins(0,0,0,0);
129 vlayout->setSpacing(0);
131 QTableView *view =
new QTableView(
this);
132 vlayout->addLayout(hlayout);
134 vlayout->addWidget(view);
135 vlayout->setSpacing(0);
136 int width = view->verticalScrollBar()->sizeHint().width();
139 hlayout->addSpacing(width+2);
141 hlayout->addSpacing(width);
144 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
145 view->setTabKeyNavigation(
false);
146 view->setContextMenuPolicy(Qt::CustomContextMenu);
148 view->installEventFilter(
this);
154 abandonAction =
new QAction(tr(
"Abandon transaction"),
this);
155 bumpFeeAction =
new QAction(tr(
"Increase transaction fee"),
this);
157 QAction *copyAddressAction =
new QAction(tr(
"Copy address"),
this);
158 QAction *copyLabelAction =
new QAction(tr(
"Copy label"),
this);
159 QAction *copyAmountAction =
new QAction(tr(
"Copy amount"),
this);
160 QAction *copyTxIDAction =
new QAction(tr(
"Copy transaction ID"),
this);
161 QAction *copyTxHexAction =
new QAction(tr(
"Copy raw transaction"),
this);
162 QAction *
copyTxPlainText =
new QAction(tr(
"Copy full transaction details"),
this);
163 QAction *editLabelAction =
new QAction(tr(
"Edit label"),
this);
164 QAction *showDetailsAction =
new QAction(tr(
"Show transaction details"),
this);
216 this->
model = _model;
231 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
248 for (
int i = 0; i < listUrls.size(); ++i)
250 QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
253 QAction *thirdPartyTxUrlAction =
new QAction(host,
this);
257 connect(thirdPartyTxUrlAction, &QAction::triggered,
mapperThirdPartyTxUrls,
static_cast<void (QSignalMapper::*)()
>(&QSignalMapper::map));
274 QDate current = QDate::currentDate();
290 QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
292 QDateTime(startOfWeek),
298 QDateTime(QDate(current.year(), current.month(), 1)),
303 QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
304 QDateTime(QDate(current.year(), current.month(), 1)));
308 QDateTime(QDate(current.year(), 1, 1)),
331 static_cast<TransactionFilterProxy::WatchOnlyFilter>(
watchOnlyWidget->itemData(idx).toInt()));
363 tr(
"Export Transaction History"), QString(),
364 tr(
"Comma separated file (*.csv)"),
nullptr);
366 if (filename.isNull())
383 if(!writer.
write()) {
384 Q_EMIT
message(tr(
"Exporting Failed"), tr(
"There was an error trying to save the transaction history to %1.").arg(filename),
388 Q_EMIT
message(tr(
"Exporting Successful"), tr(
"The transaction history was successfully saved to %1.").arg(filename),
396 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
397 if (selection.empty())
416 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
421 hash.
SetHex(hashQStr.toStdString());
434 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
439 hash.
SetHex(hashQStr.toStdString());
448 qApp->processEvents();
487 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
488 if(!selection.isEmpty())
494 if(address.isEmpty())
505 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
533 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
534 if(!selection.isEmpty())
537 dlg->setAttribute(Qt::WA_DeleteOnClose);
546 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
547 if(!selection.isEmpty())
557 layout->setContentsMargins(0,0,0,0);
558 layout->addSpacing(23);
559 layout->addWidget(
new QLabel(tr(
"Range:")));
562 dateFrom->setDisplayFormat(
"dd/MM/yy");
565 dateFrom->setDate(QDate::currentDate().addDays(-7));
567 layout->addWidget(
new QLabel(tr(
"to")));
569 dateTo =
new QDateTimeEdit(
this);
570 dateTo->setDisplayFormat(
"dd/MM/yy");
571 dateTo->setCalendarPopup(
true);
572 dateTo->setMinimumWidth(100);
573 dateTo->setDate(QDate::currentDate());
574 layout->addWidget(
dateTo);
575 layout->addStretch();
593 QDateTime(
dateTo->date()).addDays(1));
614 QString::fromStdString(txid.
ToString()), -1);
618 for (
const QModelIndex&
index : results) {
622 QItemSelectionModel::Rows | QItemSelectionModel::Select);
636 QWidget::resizeEvent(event);
643 if (event->type() == QEvent::KeyPress)
645 QKeyEvent *ke =
static_cast<QKeyEvent *
>(event);
646 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
652 return QWidget::eventFilter(obj, event);
void stretchColumnWidth(int column)
TransactionView(const PlatformStyle *platformStyle, QWidget *parent=0)
bool eventFilter(QObject *obj, QEvent *event)
void addColumn(const QString &title, int column, int role=Qt::EditRole)
void openThirdPartyTxUrl(QString url)
interfaces::Wallet & wallet() const
QWidget * createDateRangeWidget()
QModelIndex index(int row, int column, const QModelIndex &parent) const
int lookupAddress(const QString &address) const
Dialog showing transaction details.
void updateTransaction(const QString &hash, int status, bool showTransaction)
void focusTransaction(const QModelIndex &)
void setTypeFilter(quint32 modes)
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.
void chooseWatchonly(int idx)
int getDisplayUnit() const
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
bool bumpFee(uint256 hash, uint256 &new_hash)
static quint32 TYPE(int type)
int64_t CAmount
Amount in satoshis (Can be negative)
void setModel(AddressTableModel *model)
static const QDateTime MIN_DATE
Earliest date that can be represented (far in the past)
virtual void resizeEvent(QResizeEvent *event)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
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.
virtual bool transactionCanBeAbandoned(const uint256 &txid)=0
Return whether transaction can be abandoned.
Is transaction confirmed?
Makes a QTableView last column feel as if it was being resized from its left border.
Date and time this transaction was created.
std::string ToString() const
void updateWatchOnlyColumn(bool fHaveWatchOnly)
TransactionTableModel * getTransactionTableModel()
virtual bool transactionCanBeBumped(const uint256 &txid)=0
Return whether transaction can be bumped.
void setWatchOnlyFilter(WatchOnlyFilter filter)
Qt model of the address book in the core.
void setMinAmount(const CAmount &minimum)
void bumpedFee(const uint256 &txid)
TransactionFilterProxy * transactionProxyModel
QString getThirdPartyTxUrls() const
QComboBox * watchOnlyWidget
void setModel(const QAbstractItemModel *model)
void setModel(WalletModel *model)
Filter the transaction list according to pre-specified rules.
void setAddress(const QString &address)
Interface to Bitcoin wallet from Qt view code.
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 ...
static const QString Receive
Specifies receive address.
Dialog for editing an address and associated information.
QVariant data(const QModelIndex &index, int role) const
virtual bool haveWatchOnly()=0
Return whether wallet has watch only keys.
void notifyWatchonlyChanged(bool fHaveWatchonly)
Label of address related to transaction.
static const quint32 ALL_TYPES
Type filter bit field (all types)
void setSearchString(const QString &)
void contextualMenu(const QPoint &)
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.
GUIUtil::TableViewLastColumnResizingFixer * columnResizingFixer
void SetHex(const char *psz)
TransactionRecord * index(interfaces::Wallet &wallet, int idx)
bool write()
Perform export of the model to CSV.
void doubleClicked(const QModelIndex &)
Type of address (Send or Receive)
OptionsModel * getOptionsModel()
virtual bool abandonTransaction(const uint256 &txid)=0
Abandon transaction.
Predefined combinations for certain default usage cases.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QLineEdit * search_widget