Skip to content

Commit 2505c5c

Browse files
committed
Merge #11015: [Qt] Add delay before filtering transactions
7b137ac [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
2 parents dc597bb + 7b137ac commit 2505c5c

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/qt/transactionview.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <QScrollBar>
3434
#include <QSignalMapper>
3535
#include <QTableView>
36+
#include <QTimer>
3637
#include <QUrl>
3738
#include <QVBoxLayout>
3839

@@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
112113
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
113114
hlayout->addWidget(amountWidget);
114115

116+
// Delay before filtering transactions in ms
117+
static const int input_filter_delay = 200;
118+
119+
QTimer* amount_typing_delay = new QTimer(this);
120+
amount_typing_delay->setSingleShot(true);
121+
amount_typing_delay->setInterval(input_filter_delay);
122+
123+
QTimer* prefix_typing_delay = new QTimer(this);
124+
prefix_typing_delay->setSingleShot(true);
125+
prefix_typing_delay->setInterval(input_filter_delay);
126+
115127
QVBoxLayout *vlayout = new QVBoxLayout(this);
116128
vlayout->setContentsMargins(0,0,0,0);
117129
vlayout->setSpacing(0);
@@ -173,8 +185,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
173185
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
174186
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
175187
connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int)));
176-
connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
177-
connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString)));
188+
connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
189+
connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
190+
connect(addressWidget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
191+
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedPrefix()));
178192

179193
connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
180194
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
@@ -312,20 +326,19 @@ void TransactionView::chooseWatchonly(int idx)
312326
(TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt());
313327
}
314328

315-
void TransactionView::changedPrefix(const QString &prefix)
329+
void TransactionView::changedPrefix()
316330
{
317331
if(!transactionProxyModel)
318332
return;
319-
transactionProxyModel->setAddressPrefix(prefix);
333+
transactionProxyModel->setAddressPrefix(addressWidget->text());
320334
}
321335

322-
void TransactionView::changedAmount(const QString &amount)
336+
void TransactionView::changedAmount()
323337
{
324338
if(!transactionProxyModel)
325339
return;
326340
CAmount amount_parsed = 0;
327-
if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed))
328-
{
341+
if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amountWidget->text(), &amount_parsed)) {
329342
transactionProxyModel->setMinAmount(amount_parsed);
330343
}
331344
else

src/qt/transactionview.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public Q_SLOTS:
112112
void chooseDate(int idx);
113113
void chooseType(int idx);
114114
void chooseWatchonly(int idx);
115-
void changedPrefix(const QString &prefix);
116-
void changedAmount(const QString &amount);
115+
void changedAmount();
116+
void changedPrefix();
117117
void exportClicked();
118118
void focusTransaction(const QModelIndex&);
119119

0 commit comments

Comments
 (0)