diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -115,8 +115,8 @@ 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); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -116,6 +117,17 @@ 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); @@ -176,10 +188,14 @@ connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(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))); @@ -332,22 +348,22 @@ 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());