Browse Source

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
0.16
Jonas Schnelli 7 years ago
parent
commit
2505c5c0a9
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
  1. 27
      src/qt/transactionview.cpp
  2. 4
      src/qt/transactionview.h

27
src/qt/transactionview.cpp

@ -33,6 +33,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QSignalMapper> #include <QSignalMapper>
#include <QTableView> #include <QTableView>
#include <QTimer>
#include <QUrl> #include <QUrl>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
hlayout->addWidget(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); QVBoxLayout *vlayout = new QVBoxLayout(this);
vlayout->setContentsMargins(0,0,0,0); vlayout->setContentsMargins(0,0,0,0);
vlayout->setSpacing(0); vlayout->setSpacing(0);
@ -173,8 +185,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int))); connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int)));
connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); 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(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
@ -312,20 +326,19 @@ void TransactionView::chooseWatchonly(int idx)
(TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt()); (TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt());
} }
void TransactionView::changedPrefix(const QString &prefix) void TransactionView::changedPrefix()
{ {
if(!transactionProxyModel) if(!transactionProxyModel)
return; return;
transactionProxyModel->setAddressPrefix(prefix); transactionProxyModel->setAddressPrefix(addressWidget->text());
} }
void TransactionView::changedAmount(const QString &amount) void TransactionView::changedAmount()
{ {
if(!transactionProxyModel) if(!transactionProxyModel)
return; return;
CAmount amount_parsed = 0; CAmount amount_parsed = 0;
if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amountWidget->text(), &amount_parsed)) {
{
transactionProxyModel->setMinAmount(amount_parsed); transactionProxyModel->setMinAmount(amount_parsed);
} }
else else

4
src/qt/transactionview.h

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

Loading…
Cancel
Save