21 #include <QDateTimeEdit> 22 #include <QDesktopServices> 23 #include <QDoubleValidator> 24 #include <QHBoxLayout> 25 #include <QHeaderView> 34 #include <QVBoxLayout> 38 : QWidget(parent), model(nullptr), transactionProxyModel(nullptr),
39 transactionView(nullptr), abandonAction(nullptr),
40 columnResizingFixer(nullptr) {
42 setContentsMargins(0, 0, 0, 0);
44 QHBoxLayout *hlayout =
new QHBoxLayout();
45 hlayout->setContentsMargins(0, 0, 0, 0);
48 hlayout->setSpacing(5);
49 hlayout->addSpacing(26);
51 hlayout->setSpacing(0);
52 hlayout->addSpacing(23);
107 tr(
"Enter address, transaction id, or label to search"));
117 QDoubleValidator *amountValidator =
new QDoubleValidator(0, 1e20, 8,
this);
118 QLocale amountLocale(QLocale::C);
119 amountLocale.setNumberOptions(QLocale::RejectGroupSeparator);
120 amountValidator->setLocale(amountLocale);
125 static const int input_filter_delay = 200;
127 QTimer *amount_typing_delay =
new QTimer(
this);
128 amount_typing_delay->setSingleShot(
true);
129 amount_typing_delay->setInterval(input_filter_delay);
131 QTimer *prefix_typing_delay =
new QTimer(
this);
132 prefix_typing_delay->setSingleShot(
true);
133 prefix_typing_delay->setInterval(input_filter_delay);
135 QVBoxLayout *vlayout =
new QVBoxLayout(
this);
136 vlayout->setContentsMargins(0, 0, 0, 0);
137 vlayout->setSpacing(0);
139 QTableView *view =
new QTableView(
this);
140 vlayout->addLayout(hlayout);
142 vlayout->addWidget(view);
143 vlayout->setSpacing(0);
144 int width = view->verticalScrollBar()->sizeHint().width();
147 hlayout->addSpacing(width + 2);
149 hlayout->addSpacing(width);
152 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
153 view->setTabKeyNavigation(
false);
154 view->setContextMenuPolicy(Qt::CustomContextMenu);
156 view->installEventFilter(
this);
161 abandonAction =
new QAction(tr(
"Abandon transaction"),
this);
162 QAction *copyAddressAction =
new QAction(tr(
"Copy address"),
this);
163 QAction *copyLabelAction =
new QAction(tr(
"Copy label"),
this);
164 QAction *copyAmountAction =
new QAction(tr(
"Copy amount"),
this);
165 QAction *copyTxIDAction =
new QAction(tr(
"Copy transaction ID"),
this);
166 QAction *copyTxHexAction =
new QAction(tr(
"Copy raw transaction"),
this);
168 new QAction(tr(
"Copy full transaction details"),
this);
169 QAction *editLabelAction =
new QAction(tr(
"Edit label"),
this);
170 QAction *showDetailsAction =
171 new QAction(tr(
"Show transaction details"),
this);
186 static_cast<void (QComboBox::*)(
int)
>(&QComboBox::activated),
this,
189 static_cast<void (QComboBox::*)(
int)
>(&QComboBox::activated),
this,
192 static_cast<void (QComboBox::*)(
int)
>(&QComboBox::activated),
this,
194 connect(
amountWidget, &QLineEdit::textChanged, amount_typing_delay,
195 static_cast<void (QTimer::*)()
>(&QTimer::start));
196 connect(amount_typing_delay, &QTimer::timeout,
this,
198 connect(
search_widget, &QLineEdit::textChanged, prefix_typing_delay,
199 static_cast<void (QTimer::*)()
>(&QTimer::start));
200 connect(prefix_typing_delay, &QTimer::timeout,
this,
203 connect(view, &QTableView::doubleClicked,
this,
205 connect(view, &QTableView::customContextMenuRequested,
this,
210 connect(copyAddressAction, &QAction::triggered,
this,
212 connect(copyLabelAction, &QAction::triggered,
this,
214 connect(copyAmountAction, &QAction::triggered,
this,
216 connect(copyTxIDAction, &QAction::triggered,
this,
218 connect(copyTxHexAction, &QAction::triggered,
this,
220 connect(copyTxPlainText, &QAction::triggered,
this,
222 connect(editLabelAction, &QAction::triggered,
this,
224 connect(showDetailsAction, &QAction::triggered,
this,
233 this->
model = _model;
248 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
273 for (
int i = 0; i < listUrls.size(); ++i) {
274 QString
url = listUrls[i].trimmed();
275 QString host = QUrl(url, QUrl::StrictMode).host();
276 if (!host.isEmpty()) {
278 QAction *thirdPartyTxUrlAction =
new QAction(host,
this);
283 connect(thirdPartyTxUrlAction, &QAction::triggered,
303 const QDate currentDate = QDate::currentDate();
305 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) 306 const QDateTime startofDay = currentDate.startOfDay();
308 const QDateTime startofDay = QDateTime(currentDate);
310 const QDateTime startOfWeek =
311 startofDay.addDays(-(currentDate.dayOfWeek() - 1));
312 const QDateTime startOfMonth = startofDay.addDays(-(currentDate.day() - 1));
313 const QDateTime startOfYear =
314 startofDay.addDays(-(currentDate.dayOfYear() - 1));
369 static_cast<TransactionFilterProxy::WatchOnlyFilter>(
402 this, tr(
"Export Transaction History"), QString(),
403 tr(
"Comma separated file (*.csv)"),
nullptr);
405 if (filename.isNull()) {
426 if (!writer.
write()) {
427 Q_EMIT
message(tr(
"Exporting Failed"),
428 tr(
"There was an error trying to save the transaction " 434 tr(
"Exporting Successful"),
435 tr(
"The transaction history was successfully saved to %1.")
443 QModelIndexList selection =
445 if (selection.empty()) {
452 txid.
SetHex(selection.at(0)
458 if (index.isValid()) {
468 QModelIndexList selection =
476 txid.
SetHex(hashQStr.toStdString());
520 QModelIndexList selection =
522 if (!selection.isEmpty()) {
530 if (address.isEmpty()) {
539 QModelIndex modelIdx = addressBook->
index(idx, 0, QModelIndex());
566 QModelIndexList selection =
568 if (!selection.isEmpty()) {
570 dlg->setAttribute(Qt::WA_DeleteOnClose);
580 QModelIndexList selection =
582 if (!selection.isEmpty()) {
583 QDesktopServices::openUrl(QUrl::fromUserInput(
584 url.replace(
"%s", selection.at(0)
595 layout->setContentsMargins(0, 0, 0, 0);
596 layout->addSpacing(23);
597 layout->addWidget(
new QLabel(tr(
"Range:")));
600 dateFrom->setDisplayFormat(
"dd/MM/yy");
603 dateFrom->setDate(QDate::currentDate().addDays(-7));
605 layout->addWidget(
new QLabel(tr(
"to")));
607 dateTo =
new QDateTimeEdit(
this);
608 dateTo->setDisplayFormat(
"dd/MM/yy");
609 dateTo->setCalendarPopup(
true);
610 dateTo->setMinimumWidth(100);
611 dateTo->setDate(QDate::currentDate());
612 layout->addWidget(
dateTo);
613 layout->addStretch();
619 connect(
dateFrom, &QDateTimeEdit::dateChanged,
this,
621 connect(
dateTo, &QDateTimeEdit::dateChanged,
this,
632 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) 633 const QDateTime rangeFrom =
dateFrom->date().startOfDay();
634 const QDateTime rangeTo =
dateTo->date().endOfDay();
636 const QDateTime rangeFrom = QDateTime(
dateFrom->date());
637 const QDateTime rangeTo = QDateTime(
dateTo->date()).addDays(1);
659 const QModelIndexList results =
663 QString::fromStdString(txid.
ToString()), -1);
667 for (
const QModelIndex &
index : results) {
668 const QModelIndex targetIndex =
672 QItemSelectionModel::Rows | QItemSelectionModel::Select);
678 if (
index == results[0]) {
687 QWidget::resizeEvent(event);
694 if (event->type() == QEvent::KeyPress) {
695 QKeyEvent *ke =
static_cast<QKeyEvent *
>(event);
696 if (ke->key() == Qt::Key_C &&
697 ke->modifiers().testFlag(Qt::ControlModifier)) {
703 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)
void openThirdPartyTxUrl(QString url)
interfaces::Wallet & wallet() const
static constexpr Amount zero()
QWidget * createDateRangeWidget()
int lookupAddress(const QString &address) const
QStringList splitSkipEmptyParts(const QString &s, const QString &separator)
Dialog showing transaction details.
void updateTransaction(const QString &hash, int status, bool showTransaction)
New transaction, or transaction changed status.
void focusTransaction(const QModelIndex &)
void setTypeFilter(quint32 modes)
virtual bool transactionCanBeAbandoned(const TxId &txid)=0
Return whether transaction can be abandoned.
QTableView * transactionView
AddressTableModel * getAddressTableModel()
Export a Qt table model to a CSV file.
Transaction data, hex-encoded.
TransactionTableModel * parent
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...
static quint32 TYPE(int type)
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.
virtual bool abandonTransaction(const TxId &txid)=0
Abandon transaction.
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 setMinAmount(const Amount minimum)
Is transaction confirmed?
Makes a QTableView last column feel as if it was being resized from its left border.
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
void setWatchOnlyFilter(WatchOnlyFilter filter)
Qt model of the address book in the core.
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.
A TxId is the identifier of a transaction.
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)
void contextualMenu(const QPoint &)
TransactionRecord * index(interfaces::Wallet &wallet, const int cur_num_blocks, const int idx)
Formatted amount, without brackets when unconfirmed.
static bool parse(int unit, const QString &value, Amount *val_out)
Parse string to coin amount.
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)
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()
Predefined combinations for certain default usage cases.
QLineEdit * search_widget