25 #include <QApplication> 27 #include <QDateTimeEdit> 28 #include <QDesktopServices> 29 #include <QDoubleValidator> 30 #include <QHBoxLayout> 31 #include <QHeaderView> 41 #include <QVBoxLayout> 44 : QWidget(
parent), m_platform_style{platformStyle}
47 setContentsMargins(0,0,0,0);
49 QHBoxLayout *hlayout =
new QHBoxLayout();
50 hlayout->setContentsMargins(0,0,0,0);
52 if (platformStyle->getUseExtraSpacing()) {
53 hlayout->setSpacing(5);
54 hlayout->addSpacing(26);
56 hlayout->setSpacing(0);
57 hlayout->addSpacing(23);
60 dateWidget =
new QComboBox(
this);
61 if (platformStyle->getUseExtraSpacing()) {
62 dateWidget->setFixedWidth(121);
64 dateWidget->setFixedWidth(120);
66 dateWidget->addItem(tr(
"All"),
All);
67 dateWidget->addItem(tr(
"Today"), Today);
68 dateWidget->addItem(tr(
"This week"), ThisWeek);
69 dateWidget->addItem(tr(
"This month"), ThisMonth);
70 dateWidget->addItem(tr(
"Last month"), LastMonth);
71 dateWidget->addItem(tr(
"This year"), ThisYear);
72 dateWidget->addItem(tr(
"Rangeā¦"), Range);
73 hlayout->addWidget(dateWidget);
75 typeWidget =
new QComboBox(
this);
76 if (platformStyle->getUseExtraSpacing()) {
77 typeWidget->setFixedWidth(121);
79 typeWidget->setFixedWidth(120);
90 hlayout->addWidget(typeWidget);
92 search_widget =
new QLineEdit(
this);
93 search_widget->setPlaceholderText(tr(
"Enter address, transaction id, or label to search"));
94 hlayout->addWidget(search_widget);
96 amountWidget =
new QLineEdit(
this);
97 amountWidget->setPlaceholderText(tr(
"Min amount"));
98 if (platformStyle->getUseExtraSpacing()) {
99 amountWidget->setFixedWidth(97);
101 amountWidget->setFixedWidth(100);
103 QDoubleValidator *amountValidator =
new QDoubleValidator(0, 1e20, 8,
this);
104 QLocale amountLocale(QLocale::C);
105 amountLocale.setNumberOptions(QLocale::RejectGroupSeparator);
106 amountValidator->setLocale(amountLocale);
107 amountWidget->setValidator(amountValidator);
108 hlayout->addWidget(amountWidget);
111 static constexpr
auto input_filter_delay{200ms};
113 QTimer* amount_typing_delay =
new QTimer(
this);
114 amount_typing_delay->setSingleShot(
true);
115 amount_typing_delay->setInterval(input_filter_delay);
117 QTimer* prefix_typing_delay =
new QTimer(
this);
118 prefix_typing_delay->setSingleShot(
true);
119 prefix_typing_delay->setInterval(input_filter_delay);
121 QVBoxLayout *vlayout =
new QVBoxLayout(
this);
122 vlayout->setContentsMargins(0,0,0,0);
123 vlayout->setSpacing(0);
125 transactionView =
new QTableView(
this);
126 transactionView->setObjectName(
"transactionView");
127 vlayout->addLayout(hlayout);
128 vlayout->addWidget(createDateRangeWidget());
129 vlayout->addWidget(transactionView);
130 vlayout->setSpacing(0);
131 int width = transactionView->verticalScrollBar()->sizeHint().width();
133 if (platformStyle->getUseExtraSpacing()) {
134 hlayout->addSpacing(width+2);
136 hlayout->addSpacing(width);
138 transactionView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
139 transactionView->setTabKeyNavigation(
false);
140 transactionView->setContextMenuPolicy(Qt::CustomContextMenu);
141 transactionView->installEventFilter(
this);
142 transactionView->setAlternatingRowColors(
true);
143 transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
144 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
145 transactionView->setSortingEnabled(
true);
146 transactionView->verticalHeader()->hide();
149 if (!transactionView->horizontalHeader()->restoreState(settings.value(
"TransactionViewHeaderState-2025").toByteArray())) {
154 transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
155 transactionView->horizontalHeader()->setStretchLastSection(
true);
158 contextMenu =
new QMenu(
this);
159 contextMenu->setObjectName(
"contextMenu");
167 contextMenu->addSeparator();
168 bumpFeeAction = contextMenu->addAction(tr(
"Increase transaction &fee"));
170 bumpFeeAction->setObjectName(
"bumpFeeAction");
176 connect(amountWidget, &QLineEdit::textChanged, amount_typing_delay, qOverload<>(&QTimer::start));
178 connect(search_widget, &QLineEdit::textChanged, prefix_typing_delay, qOverload<>(&QTimer::start));
188 focusTransaction(txid);
196 settings.setValue(
"TransactionViewHeaderState-2025",
transactionView->horizontalHeader()->saveState());
201 this->
model = _model;
217 bool actions_created =
false;
218 for (
int i = 0; i < listUrls.size(); ++i)
220 QString
url = listUrls[i].trimmed();
221 QString host = QUrl(
url, QUrl::StrictMode).host();
224 if (!actions_created) {
226 actions_created =
true;
240 QWidget::changeEvent(e);
246 QDate current = QDate::currentDate();
262 QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
327 tr(
"Export Transaction History"), QString(),
330 tr(
"Comma separated file") + QLatin1String(
" (*.csv)"),
nullptr);
332 if (filename.isNull())
347 if(!writer.
write()) {
348 Q_EMIT
message(tr(
"Exporting Failed"), tr(
"There was an error trying to save the transaction history to %1.").arg(filename),
352 Q_EMIT
message(tr(
"Exporting Successful"), tr(
"The transaction history was successfully saved to %1.").arg(filename),
360 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
361 if (selection.empty())
366 std::optional<Txid> maybeHash =
Txid::FromHex(hashQStr.toStdString());
370 Txid hash = *maybeHash;
376 if (
index.isValid()) {
385 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
399 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
412 qApp->processEvents();
451 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
452 if(!selection.isEmpty())
458 if(address.isEmpty())
469 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
477 dlg->setModel(addressBook);
486 dlg->setModel(addressBook);
487 dlg->setAddress(address);
497 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
498 if(!selection.isEmpty())
501 dlg->setAttribute(Qt::WA_DeleteOnClose);
503 connect(dlg, &QObject::destroyed, [
this, dlg] {
514 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
515 if(!selection.isEmpty())
522 dateRangeWidget->setFrameStyle(static_cast<int>(QFrame::Panel) | static_cast<int>(QFrame::Raised));
525 layout->setContentsMargins(0,0,0,0);
526 layout->addSpacing(23);
527 layout->addWidget(
new QLabel(tr(
"Range:")));
530 dateFrom->setDisplayFormat(
"dd/MM/yy");
533 dateFrom->setDate(QDate::currentDate().addDays(-7));
535 layout->addWidget(
new QLabel(tr(
"to")));
537 dateTo =
new QDateTimeEdit(
this);
538 dateTo->setDisplayFormat(
"dd/MM/yy");
539 dateTo->setCalendarPopup(
true);
540 dateTo->setMinimumWidth(100);
541 dateTo->setDate(QDate::currentDate());
542 layout->addWidget(
dateTo);
543 layout->addStretch();
582 QString::fromStdString(txid.
ToString()), -1);
586 for (
const QModelIndex&
index : results) {
590 QItemSelectionModel::Rows | QItemSelectionModel::Select);
603 if (event->type() == QEvent::KeyPress)
605 QKeyEvent *ke =
static_cast<QKeyEvent *
>(event);
606 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
612 if (event->type() == QEvent::EnabledChange) {
617 return QWidget::eventFilter(obj, event);
QVariant data(const QModelIndex &index, int role) const override
void addColumn(const QString &title, int column, int role=Qt::EditRole)
QDateTime StartOfDay(const QDate &date)
Returns the start-moment of the day in local time.
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
Predefined combinations for certain default usage cases.
OptionsModel * getOptionsModel() const
void openThirdPartyTxUrl(QString url)
interfaces::Wallet & wallet() const
QWidget * createDateRangeWidget()
int lookupAddress(const QString &address) const
Dialog showing transaction details.
void PopupMenu(QMenu *menu, const QPoint &point, QAction *at_action)
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
void updateTransaction(const QString &hash, int status, bool showTransaction)
void bumpFee(bool checked)
TransactionTableModel * getTransactionTableModel() const
void focusTransaction(const QModelIndex &)
void setTypeFilter(quint32 modes)
BitcoinUnit getDisplayUnit() const
QTableView * transactionView
static bool parse(Unit unit, const QString &value, CAmount *val_out)
Parse string to coin amount.
void bumpedFee(const Txid &txid)
void ShowModalDialogAsynchronously(QDialog *dialog)
Shows a QDialog instance asynchronously, and deletes it on close.
Export a Qt table model to a CSV file.
Transaction data, hex-encoded.
TransactionTableModel * parent
static quint32 TYPE(int type)
int64_t CAmount
Amount in satoshis (Can be negative)
void closeOpenedDialogs()
Whole transaction as plain text.
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
std::string ToString() const
Is transaction confirmed?
auto ExceptionSafeConnect(Sender sender, Signal signal, Receiver receiver, Slot method, Qt::ConnectionType type=Qt::AutoConnection)
A drop-in replacement of QObject::connect function (see: https://doc.qt.io/qt-5/qobject.html#connect-3), that guaranties that all exceptions are handled within the slot.
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.
bool eventFilter(QObject *obj, QEvent *event) override
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
Qt model of the address book in the core.
void setMinAmount(const CAmount &minimum)
TransactionFilterProxy * transactionProxyModel
QString getThirdPartyTxUrls() const
QAction * copyLabelAction
void setModel(const QAbstractItemModel *model)
void setModel(WalletModel *model)
Filter the transaction list according to pre-specified rules.
Interface to Bitcoin wallet from Qt view code.
QList< TransactionDescDialog * > m_opened_dialogs
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.
bool bumpFee(Txid hash, Txid &new_hash)
Label of address related to transaction.
static const quint32 ALL_TYPES
Type filter bit field (all types)
static QString getAmountColumnTitle(Unit unit)
Gets title for amount column including current display unit if optionsModel reference available */...
void setSearchString(const QString &)
TransactionView(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
AddressTableModel * getAddressTableModel() const
QAction * copyAddressAction
virtual bool transactionCanBeAbandoned(const Txid &txid)=0
Return whether transaction can be abandoned.
void contextualMenu(const QPoint &)
void changeEvent(QEvent *e) override
Formatted amount, without brackets when unconfirmed.
virtual bool abandonTransaction(const Txid &txid)=0
Abandon transaction.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
bool write()
Perform export of the model to CSV.
void doubleClicked(const QModelIndex &)
static std::optional< transaction_identifier > FromHex(std::string_view hex)
void setDateRange(const std::optional< QDateTime > &from, const std::optional< QDateTime > &to)
Filter transactions between date range.
Type of address (Send or Receive)
virtual bool transactionCanBeBumped(const Txid &txid)=0
Return whether transaction can be bumped.
QLineEdit * search_widget