22 #include <QApplication> 24 #include <QDateTimeEdit> 25 #include <QDesktopServices> 26 #include <QDoubleValidator> 27 #include <QHBoxLayout> 28 #include <QHeaderView> 38 #include <QVBoxLayout> 41 : QWidget(
parent), m_platform_style{platformStyle}
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);
53 hlayout->setSpacing(0);
54 hlayout->addSpacing(23);
57 watchOnlyWidget =
new QComboBox(
this);
58 watchOnlyWidget->setFixedWidth(24);
62 hlayout->addWidget(watchOnlyWidget);
64 dateWidget =
new QComboBox(
this);
65 if (platformStyle->getUseExtraSpacing()) {
66 dateWidget->setFixedWidth(121);
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);
83 typeWidget->setFixedWidth(120);
95 hlayout->addWidget(typeWidget);
97 search_widget =
new QLineEdit(
this);
98 search_widget->setPlaceholderText(tr(
"Enter address, transaction id, or label to search"));
99 hlayout->addWidget(search_widget);
101 amountWidget =
new QLineEdit(
this);
102 amountWidget->setPlaceholderText(tr(
"Min amount"));
103 if (platformStyle->getUseExtraSpacing()) {
104 amountWidget->setFixedWidth(97);
106 amountWidget->setFixedWidth(100);
108 QDoubleValidator *amountValidator =
new QDoubleValidator(0, 1e20, 8,
this);
109 QLocale amountLocale(QLocale::C);
110 amountLocale.setNumberOptions(QLocale::RejectGroupSeparator);
111 amountValidator->setLocale(amountLocale);
112 amountWidget->setValidator(amountValidator);
113 hlayout->addWidget(amountWidget);
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 transactionView =
new QTableView(
this);
131 transactionView->setObjectName(
"transactionView");
132 vlayout->addLayout(hlayout);
133 vlayout->addWidget(createDateRangeWidget());
134 vlayout->addWidget(transactionView);
135 vlayout->setSpacing(0);
136 int width = transactionView->verticalScrollBar()->sizeHint().width();
138 if (platformStyle->getUseExtraSpacing()) {
139 hlayout->addSpacing(width+2);
141 hlayout->addSpacing(width);
143 transactionView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
144 transactionView->setTabKeyNavigation(
false);
145 transactionView->setContextMenuPolicy(Qt::CustomContextMenu);
146 transactionView->installEventFilter(
this);
147 transactionView->setAlternatingRowColors(
true);
148 transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
149 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
150 transactionView->setSortingEnabled(
true);
151 transactionView->verticalHeader()->hide();
154 if (!transactionView->horizontalHeader()->restoreState(settings.value(
"TransactionViewHeaderState").toByteArray())) {
160 transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
161 transactionView->horizontalHeader()->setStretchLastSection(
true);
164 contextMenu =
new QMenu(
this);
165 contextMenu->setObjectName(
"contextMenu");
173 contextMenu->addSeparator();
174 bumpFeeAction = contextMenu->addAction(tr(
"Increase transaction &fee"));
176 bumpFeeAction->setObjectName(
"bumpFeeAction");
183 connect(amountWidget, &QLineEdit::textChanged, amount_typing_delay, qOverload<>(&QTimer::start));
185 connect(search_widget, &QLineEdit::textChanged, prefix_typing_delay, qOverload<>(&QTimer::start));
195 focusTransaction(txid);
202 settings.setValue(
"TransactionViewHeaderState",
transactionView->horizontalHeader()->saveState());
207 this->
model = _model;
223 for (
int i = 0; i < listUrls.size(); ++i)
225 QString
url = listUrls[i].trimmed();
226 QString host = QUrl(
url, QUrl::StrictMode).host();
229 QAction *thirdPartyTxUrlAction =
new QAction(host,
this);
248 if (e->type() == QEvent::PaletteChange) {
257 QWidget::changeEvent(e);
263 QDate current = QDate::currentDate();
279 QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
320 static_cast<TransactionFilterProxy::WatchOnlyFilter>(
watchOnlyWidget->itemData(idx).toInt()));
352 tr(
"Export Transaction History"), QString(),
355 tr(
"Comma separated file") + QLatin1String(
" (*.csv)"),
nullptr);
357 if (filename.isNull())
374 if(!writer.
write()) {
375 Q_EMIT
message(tr(
"Exporting Failed"), tr(
"There was an error trying to save the transaction history to %1.").arg(filename),
379 Q_EMIT
message(tr(
"Exporting Successful"), tr(
"The transaction history was successfully saved to %1.").arg(filename),
387 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
388 if (selection.empty())
399 if (
index.isValid()) {
408 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
413 hash.
SetHex(hashQStr.toStdString());
426 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
431 hash.
SetHex(hashQStr.toStdString());
440 qApp->processEvents();
479 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
480 if(!selection.isEmpty())
486 if(address.isEmpty())
497 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
525 QModelIndexList selection =
transactionView->selectionModel()->selectedRows();
526 if(!selection.isEmpty())
529 dlg->setAttribute(Qt::WA_DeleteOnClose);
538 QModelIndexList selection =
transactionView->selectionModel()->selectedRows(0);
539 if(!selection.isEmpty())
549 layout->setContentsMargins(0,0,0,0);
550 layout->addSpacing(23);
551 layout->addWidget(
new QLabel(tr(
"Range:")));
554 dateFrom->setDisplayFormat(
"dd/MM/yy");
557 dateFrom->setDate(QDate::currentDate().addDays(-7));
559 layout->addWidget(
new QLabel(tr(
"to")));
561 dateTo =
new QDateTimeEdit(
this);
562 dateTo->setDisplayFormat(
"dd/MM/yy");
563 dateTo->setCalendarPopup(
true);
564 dateTo->setMinimumWidth(100);
565 dateTo->setDate(QDate::currentDate());
566 layout->addWidget(
dateTo);
567 layout->addStretch();
606 QString::fromStdString(txid.
ToString()), -1);
610 for (
const QModelIndex&
index : results) {
614 QItemSelectionModel::Rows | QItemSelectionModel::Select);
627 if (event->type() == QEvent::KeyPress)
629 QKeyEvent *ke =
static_cast<QKeyEvent *
>(event);
630 if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
636 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)
void openThirdPartyTxUrl(QString url)
interfaces::Wallet & wallet() const
QWidget * createDateRangeWidget()
int lookupAddress(const QString &address) const
Dialog showing transaction details.
const PlatformStyle * m_platform_style
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)
void focusTransaction(const QModelIndex &)
void setTypeFilter(quint32 modes)
QTableView * transactionView
const unsigned char * data() const
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)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
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?
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.
std::string ToString() const
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
QString getThirdPartyTxUrls() const
QAction * copyLabelAction
QComboBox * watchOnlyWidget
QStringList SplitSkipEmptyParts(const QString &string, const SeparatorType &separator)
Splits the string into substrings wherever separator occurs, and returns the list of those strings...
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.
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 &)
void changeEvent(QEvent *e) override
Formatted amount, without brackets when unconfirmed.
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