Merge #11015: [Qt] Add delay before filtering transactions

7b137aced [Qt] Add delay before filtering transactions Fixes 3141 (Lucas Betschart)

Pull request description:

  As discussed in https://github.com/bitcoin/bitcoin/issues/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
This commit is contained in:
Jonas Schnelli 2017-09-26 15:59:01 -06:00 committed by Alexander Block
parent 654c78fa29
commit 61c5fb9ef7
2 changed files with 23 additions and 10 deletions

View File

@ -34,6 +34,7 @@
#include <QSettings>
#include <QSignalMapper>
#include <QTableView>
#include <QTimer>
#include <QUrl>
#include <QVBoxLayout>
@ -133,6 +134,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
amountWidget->setObjectName("amountWidget");
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);
@ -192,8 +204,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int)));
connect(instantsendWidget, SIGNAL(activated(int)), this, SLOT(chooseInstantSend(int)));
connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString)));
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(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(computeSum()));
@ -360,25 +374,24 @@ void TransactionView::chooseInstantSend(int idx)
(TransactionFilterProxy::InstantSendFilter)instantsendWidget->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;
CAmount amount_parsed = 0;
// Replace "," by "." so BitcoinUnits::parse will not fail for users entering "," as decimal separator
QString newAmount = amount;
QString newAmount = amountWidget->text();
newAmount.replace(QString(","), QString("."));
if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), newAmount, &amount_parsed))
{
if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), newAmount, &amount_parsed)) {
transactionProxyModel->setMinAmount(amount_parsed);
}
else

View File

@ -117,8 +117,8 @@ public Q_SLOTS:
void chooseType(int idx);
void chooseWatchonly(int idx);
void chooseInstantSend(int idx);
void changedPrefix(const QString &prefix);
void changedAmount(const QString &amount);
void changedAmount();
void changedPrefix();
void exportClicked();
void focusTransaction(const QModelIndex&);
void computeSum();