22 #include <QApplication>
24 #include <QDateTimeEdit>
25 #include <QDesktopServices>
26 #include <QDoubleValidator>
27 #include <QHBoxLayout>
28 #include <QHeaderView>
37 #include <QVBoxLayout>
43 setContentsMargins(0,0,0,0);
45 QHBoxLayout *hlayout =
new QHBoxLayout();
46 hlayout->setContentsMargins(0,0,0,0);
49 hlayout->setSpacing(5);
50 hlayout->addSpacing(26);
52 hlayout->setSpacing(0);
53 hlayout->addSpacing(23);
97 search_widget->setPlaceholderText(tr(
"Enter address, transaction id, or label to search"));
107 QDoubleValidator *amountValidator =
new QDoubleValidator(0, 1e20, 8,
this);
108 QLocale amountLocale(QLocale::C);
109 amountLocale.setNumberOptions(QLocale::RejectGroupSeparator);
110 amountValidator->setLocale(amountLocale);
115 static const int input_filter_delay = 200;
117 QTimer* amount_typing_delay =
new QTimer(
this);
118 amount_typing_delay->setSingleShot(
true);
119 amount_typing_delay->setInterval(input_filter_delay);
121 QTimer* prefix_typing_delay =
new QTimer(
this);
122 prefix_typing_delay->setSingleShot(
true);
123 prefix_typing_delay->setInterval(input_filter_delay);
125 QVBoxLayout *vlayout =
new QVBoxLayout(
this);
126 vlayout->setContentsMargins(0,0,0,0);
127 vlayout->setSpacing(0);
129 QTableView *view =
new QTableView(
this);
130 vlayout->addLayout(hlayout);
132 vlayout->addWidget(view);
133 vlayout->setSpacing(0);
134 int width = view->verticalScrollBar()->sizeHint().width();
137 hlayout->addSpacing(width+2);
139 hlayout->addSpacing(width);
142 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
143 view->setTabKeyNavigation(
false);
144 view->setContextMenuPolicy(Qt::CustomContextMenu);
146 view->installEventFilter(
this);
152 abandonAction =
new QAction(tr(
"Abandon transaction"),
this);
153 bumpFeeAction =
new QAction(tr(
"Increase transaction fee"),
this);
157 QAction *copyAmountAction =
new QAction(tr(
"Copy amount"),
this);
158 QAction *copyTxIDAction =
new QAction(tr(
"Copy transaction ID"),
this);
159 QAction *copyTxHexAction =
new QAction(tr(
"Copy raw transaction"),
this);
160 QAction *
copyTxPlainText =
new QAction(tr(
"Copy full transaction details"),
this);
161 QAction *editLabelAction =
new QAction(tr(
"Edit label"),
this);
162 QAction *showDetailsAction =
new QAction(tr(
"Show transaction details"),
this);
181 connect(
amountWidget, &QLineEdit::textChanged, amount_typing_delay,
static_cast<void (QTimer::*)()
>(&QTimer::start));
183 connect(
search_widget, &QLineEdit::textChanged, prefix_typing_delay,
static_cast<void (QTimer::*)()
>(&QTimer::start));
209 this->
model = _model;
224 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
241 for (
int i = 0; i < listUrls.size(); ++i)
243 QString
url = listUrls[i].trimmed();
244 QString host = QUrl(url, QUrl::StrictMode).host();
247 QAction *thirdPartyTxUrlAction =
new QAction(host,
this);
251 connect(thirdPartyTxUrlAction, &QAction::triggered, [
this, url] {
openThirdPartyTxUrl(url); });
267 QDate current = QDate::currentDate();
283 QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
285 QDateTime(startOfWeek),
291 QDateTime(QDate(current.year(), current.month(), 1)),
296 QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
297 QDateTime(QDate(current.year(), current.month(), 1)));
301 QDateTime(QDate(current.year(), 1, 1)),
324 static_cast<TransactionFilterProxy::WatchOnlyFilter>(
watchOnlyWidget->itemData(idx).toInt()));
356 tr(
"Export Transaction History"), QString(),
357 tr(
"Comma separated file (*.csv)"),
nullptr);
359 if (filename.isNull())
376 if(!writer.
write()) {
377 Q_EMIT
message(tr(
"Exporting Failed"), tr(
"There was an error trying to save the transaction history to %1.").arg(filename),
381 Q_EMIT
message(tr(
"Exporting Successful"), tr(
"The transaction history was successfully saved to %1.").arg(filename),
389 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
390 if (selection.empty())
401 if (index.isValid()) {
410 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
415 hash.
SetHex(hashQStr.toStdString());
428 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
433 hash.
SetHex(hashQStr.toStdString());
442 qApp->processEvents();
481 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
482 if(!selection.isEmpty())
488 if(address.isEmpty())
499 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
527 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
528 if(!selection.isEmpty())
531 dlg->setAttribute(Qt::WA_DeleteOnClose);
540 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
541 if(!selection.isEmpty())
551 layout->setContentsMargins(0,0,0,0);
552 layout->addSpacing(23);
553 layout->addWidget(
new QLabel(tr(
"Range:")));
556 dateFrom->setDisplayFormat(
"dd/MM/yy");
559 dateFrom->setDate(QDate::currentDate().addDays(-7));
561 layout->addWidget(
new QLabel(tr(
"to")));
563 dateTo =
new QDateTimeEdit(
this);
564 dateTo->setDisplayFormat(
"dd/MM/yy");
565 dateTo->setCalendarPopup(
true);
566 dateTo->setMinimumWidth(100);
567 dateTo->setDate(QDate::currentDate());
568 layout->addWidget(
dateTo);
569 layout->addStretch();
587 QDateTime(
dateTo->date()).addDays(1));
608 QString::fromStdString(txid.
ToString()), -1);
612 for (
const QModelIndex&
index : results) {
616 QItemSelectionModel::Rows | QItemSelectionModel::Select);
630 QWidget::resizeEvent(event);
637 if (event->type() == QEvent::KeyPress)
639 QKeyEvent *ke =
static_cast<QKeyEvent *
>(event);
640 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
646 return QWidget::eventFilter(obj, event);
void stretchColumnWidth(int column)
QVariant data(const QModelIndex &index, int role) const override
void addColumn(const QString &title, int column, int role=Qt::EditRole)
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
void openThirdPartyTxUrl(QString url)
QWidget * createDateRangeWidget()
Dialog showing transaction details.
void PopupMenu(QMenu *menu, const QPoint &point, QAction *at_action)
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
int lookupAddress(const QString &address) const
void updateTransaction(const QString &hash, int status, bool showTransaction)
void focusTransaction(const QModelIndex &)
interfaces::Wallet & wallet() const
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)
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
std::string ToString() const
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)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
QString getThirdPartyTxUrls() const
Whole transaction as plain text.
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.
bool hasEntryData(const QAbstractItemView *view, int column, int role)
Returns true if the specified field of the currently selected view entry is not empty.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Date and time this transaction was created.
void updateWatchOnlyColumn(bool fHaveWatchOnly)
TransactionTableModel * getTransactionTableModel()
bool eventFilter(QObject *obj, QEvent *event) override
virtual bool transactionCanBeBumped(const uint256 &txid)=0
Return whether transaction can be bumped.
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
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
int getDisplayUnit() const
QAction * copyLabelAction
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 ...
virtual void resizeEvent(QResizeEvent *event) override
static const QString Receive
Specifies receive address.
Dialog for editing an address and associated information.
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 &)
TransactionView(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
QAction * copyAddressAction
void contextualMenu(const QPoint &)
Formatted amount, without brackets when unconfirmed.
const unsigned char * data() const
GUIUtil::TableViewLastColumnResizingFixer * columnResizingFixer
void SetHex(const char *psz)
QModelIndex index(int row, int column, const QModelIndex &parent) const override
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.
QLineEdit * search_widget