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);
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)),
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);
int64_t CAmount
Amount in satoshis (Can be negative)
Qt model of the address book in the core.
@ TypeRole
Type of address (Send or Receive)
int lookupAddress(const QString &address) const
QVariant data(const QModelIndex &index, int role) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
static const QString Receive
Specifies receive address.
static bool parse(int unit, const QString &value, CAmount *val_out)
Parse string to coin amount.
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */.
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Export a Qt table model to a CSV file.
bool write()
Perform export of the model to CSV.
void setModel(const QAbstractItemModel *model)
void addColumn(const QString &title, int column, int role=Qt::EditRole)
Dialog for editing an address and associated information.
void setModel(AddressTableModel *model)
void setAddress(const QString &address)
Makes a QTableView last column feel as if it was being resized from its left border.
void stretchColumnWidth(int column)
int getDisplayUnit() const
QString getThirdPartyTxUrls() const
Dialog showing transaction details.
Filter the transaction list according to pre-specified rules.
void setMinAmount(const CAmount &minimum)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
void setWatchOnlyFilter(WatchOnlyFilter filter)
static const quint32 ALL_TYPES
Type filter bit field (all types)
static quint32 TYPE(int type)
static const QDateTime MIN_DATE
Earliest date that can be represented (far in the past)
void setSearchString(const QString &)
void setDateRange(const QDateTime &from, const QDateTime &to)
void setTypeFilter(quint32 modes)
@ TxPlainTextRole
Whole transaction as plain text.
@ LabelRole
Label of address related to transaction.
@ DateRole
Date and time this transaction was created.
@ TxHashRole
Transaction hash.
@ TxHexRole
Transaction data, hex-encoded.
@ AddressRole
Address of transaction.
@ ConfirmedRole
Is transaction confirmed?
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
void updateTransaction(const QString &hash, int status, bool showTransaction)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void chooseWatchonly(int idx)
TransactionView(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
QLineEdit * search_widget
bool eventFilter(QObject *obj, QEvent *event) override
@ AMOUNT_MINIMUM_COLUMN_WIDTH
QWidget * createDateRangeWidget()
void setModel(WalletModel *model)
GUIUtil::TableViewLastColumnResizingFixer * columnResizingFixer
void updateWatchOnlyColumn(bool fHaveWatchOnly)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
virtual void resizeEvent(QResizeEvent *event) override
QComboBox * watchOnlyWidget
TransactionFilterProxy * transactionProxyModel
QTableView * transactionView
void focusTransaction(const QModelIndex &)
void contextualMenu(const QPoint &)
QAction * copyAddressAction
void bumpedFee(const uint256 &txid)
void openThirdPartyTxUrl(QString url)
QAction * copyLabelAction
void doubleClicked(const QModelIndex &)
Interface to Bitcoin wallet from Qt view code.
void notifyWatchonlyChanged(bool fHaveWatchonly)
AddressTableModel * getAddressTableModel()
OptionsModel * getOptionsModel()
interfaces::Wallet & wallet() const
bool bumpFee(uint256 hash, uint256 &new_hash)
TransactionTableModel * getTransactionTableModel()
void SetHex(const char *psz)
const unsigned char * data() const
std::string ToString() const
virtual bool transactionCanBeBumped(const uint256 &txid)=0
Return whether transaction can be bumped.
virtual bool transactionCanBeAbandoned(const uint256 &txid)=0
Return whether transaction can be abandoned.
virtual bool haveWatchOnly()=0
Return whether wallet has watch only keys.
virtual bool abandonTransaction(const uint256 &txid)=0
Abandon transaction.
void PopupMenu(QMenu *menu, const QPoint &point, QAction *at_action)
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
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 ...
bool hasEntryData(const QAbstractItemView *view, int column, int role)
Returns true if the specified field of the currently selected view entry is not empty.