Skip to content

Commit

Permalink
Merge #11015: [Qt] Add delay before filtering transactions
Browse files Browse the repository at this point in the history
Summary:
7b137aced [Qt] Add delay before filtering transactions Fixes 3141 (Lucas Betschart)

Pull request description:

  As discussed in bitcoin/bitcoin#3141.

  This adds a QTimer pause of 200ms before start to filter so it should be possible to filter big data sets easier.

Tree-SHA512: ee599367794eac2c5b8bc7ecac47f44295e40c0ff543ff2f2c4860590f917b59b1cfb273fa564e6eb4c44016c0ef412d49f1a8f1b36b07e034022f51bb76653c

Backport of Core PR11015
bitcoin/bitcoin#11015

Test Plan:
  make check
  ./bitcoin-qt -> transactions -> enter a filter

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3832
  • Loading branch information
jonasschnelli authored and proteanx committed Dec 12, 2019
1 parent 06da6ac commit 0f9e053
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
29 changes: 23 additions & 6 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QPoint>
#include <QScrollBar>
#include <QTableView>
#include <QTimer>
#include <QUrl>
#include <QVBoxLayout>

Expand Down Expand Up @@ -123,6 +124,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle,
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
hlayout->addWidget(amountWidget);

// Delay before filtering transactions in ms
static const int input_filter_delay = 200;

QTimer *amount_typing_delay = new QTimer(this);
amount_typing_delay->setSingleShot(true);
amount_typing_delay->setInterval(input_filter_delay);

QTimer *prefix_typing_delay = new QTimer(this);
prefix_typing_delay->setSingleShot(true);
prefix_typing_delay->setInterval(input_filter_delay);

QVBoxLayout *vlayout = new QVBoxLayout(this);
vlayout->setContentsMargins(0, 0, 0, 0);
vlayout->setSpacing(0);
Expand Down Expand Up @@ -176,7 +188,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle,
contextMenu->addAction(editLabelAction);

// Connect actions
connect(amountWidget, &QLineEdit::textChanged, this, &TransactionView::changedAmount);
connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
connect(addressWidget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedPrefix()));

connect(dateWidget,
static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
Expand All @@ -200,6 +215,8 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle,
connect(copyTxPlainText, &QAction::triggered, this, &TransactionView::copyTxPlainText);
connect(editLabelAction, &QAction::triggered, this, &TransactionView::editLabel);
connect(showDetailsAction, &QAction::triggered, this, &TransactionView::showDetails);


}

void TransactionView::setModel(WalletModel *_model) {
Expand Down Expand Up @@ -336,22 +353,22 @@ void TransactionView::chooseWatchonly(int idx) {
watchOnlyWidget->itemData(idx).toInt()));
}

void TransactionView::changedPrefix(const QString &prefix) {
void TransactionView::changedPrefix() {
if (!transactionProxyModel) {
return;
}

transactionProxyModel->setAddressPrefix(prefix);
transactionProxyModel->setAddressPrefix(addressWidget->text());
}

void TransactionView::changedAmount(const QString &amount) {
void TransactionView::changedAmount() {
if (!transactionProxyModel) {
return;
}

Amount amount_parsed = Amount::zero();
if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount,
&amount_parsed)) {
if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(),
amountWidget->text(), &amount_parsed)) {
transactionProxyModel->setMinAmount(amount_parsed);
} else {
transactionProxyModel->setMinAmount(Amount::zero());
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public Q_SLOTS:
void chooseDate(int idx);
void chooseType(int idx);
void chooseWatchonly(int idx);
void changedPrefix(const QString &prefix);
void changedAmount(const QString &amount);
void changedAmount();
void changedPrefix();
void exportClicked();
void focusTransaction(const QModelIndex &);
void focusTransaction(const uint256 &txid);
Expand Down

0 comments on commit 0f9e053

Please sign in to comment.