As discussed in #3141.
This adds a QTimer pause of 200ms before start to filter so it should be possible to filter big data sets easier.
179 | @@ -173,8 +180,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 180 | connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); 181 | connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); 182 | connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int))); 183 | - connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); 184 | - connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); 185 | + connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix())); 186 | + connect(inputDelayPrefix, SIGNAL(timeout()), this, SLOT(filterByPrefix())); 187 | + connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount()));
Connect to start QTimer::start() slot instead, and configure the interval above.
179 | @@ -173,8 +180,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 180 | connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); 181 | connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); 182 | connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int))); 183 | - connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); 184 | - connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); 185 | + connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix()));
Connect to start QTimer::start() slot instead, and configure the interval above.
333 | return; 334 | - transactionProxyModel->setAddressPrefix(prefix); 335 | + transactionProxyModel->setAddressPrefix(addressWidget->text()); 336 | +} 337 | + 338 | +void TransactionView::changedAmount()
Can be removed.
Should the interval be configurable? At least it's duplicated so have a const variable?
Nit, reword commit and PR title to qt: Add delay before filtering transactions?
Concept ACK
Thanks a lot for the fast review and suggestions for improvement @promag. I've updated the commit accordingly.
Should the interval be configurable?
I don't think many people want to change that. If we see 200ms is not optimal we can still change it later. Adding this as a config flag option would probably mostly add code that nobody uses in the end - but if more people think it's a good idea I can implement it.
Don't make things configurable if there is no advice for what to set it to.
69 | @@ -69,6 +70,12 @@ class TransactionView : public QWidget 70 | QLineEdit *addressWidget; 71 | QLineEdit *amountWidget; 72 | 73 | + QTimer *inputDelayPrefix; 74 | + QTimer *inputDelayAmount; 75 | + 76 | + /* Delay before before filtering transactions in ms */ 77 | + static const int inputFilterDelay = 200;
Move to .cpp?
69 | @@ -69,6 +70,12 @@ class TransactionView : public QWidget 70 | QLineEdit *addressWidget; 71 | QLineEdit *amountWidget; 72 | 73 | + QTimer *inputDelayPrefix;
The convention is to prefix with m_ in new code.
I also like the m_ convention but I don't see it in any of the other Qt code. Is the plan to slowly change to m_ over time or maybe take the effort to change (part of) the full source code at ones? Two different styles in the same file is not so nice I think.
Ok, thanks. I'll update.
69 | @@ -69,6 +70,9 @@ class TransactionView : public QWidget 70 | QLineEdit *addressWidget; 71 | QLineEdit *amountWidget; 72 | 73 | + QTimer *m_inputDelayPrefix;
please use snake_case as per developer notes.
To also drop my opinion here (though I don't care): Use the scheme of the surrounding code to not confuse new developers. New classes or complete rewrites may be different.
From the developer notes:
When writing patches, favor the new style over attempting to mimick the surrounding style, except for move-only commits.
and about symbol naming:
These are preferred in new code, but are not required when doing so would need changes to significant pieces of existing code.
Hmm.. I see. My advice is against the developer notes then. It just looked confusing to have two single instance variables with sneak case where the rest is without m_ and camel case. But I guess we have to start somewhere to adopt the style rules.
115 | @@ -112,8 +116,8 @@ public Q_SLOTS: 116 | void chooseDate(int idx); 117 | void chooseType(int idx); 118 | void chooseWatchonly(int idx); 119 | - void changedPrefix(const QString &prefix); 120 | - void changedAmount(const QString &amount); 121 | + void changedPrefix();
can be moved to the private Q_SLOTS section. All the others can as well, mabye in a separate commit?
I plan to look at Q_SLOTS in general in a separate PR. There are a few other cases in different files where some slots are public that wouldn't need to be.
+1
Agree, all is done in this PR context.
ACK 0587d2e36a0a64535e8d296fb97fcb7a258637fe
I tested that the issue existed and that this PR fixes it.
Concept ACK, thanks!
Don't make things configurable if there is no advice for what to set it to.
Indeed, just make a choice, there's no use in making this configurable. No one will bother and it will just add more things to test.
ACK 6d073a2d1c85ecc523d13c5f47514daa5de4757c
69 | @@ -69,6 +70,9 @@ class TransactionView : public QWidget 70 | QLineEdit *addressWidget; 71 | QLineEdit *amountWidget; 72 | 73 | + QTimer *m_input_delay_prefix;
There is no need to have these here..
Please remove.
utACK 6d073a2.
I couldn't really test this (all the machines where to fast). The delay seems very short (with 200ms). Will the timer be reset when entering the next char <200ms (I think so otherwise this would not work)?. Maybe @promag can do a test?
@jonasschnelli yes start() resets.
112 | @@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 113 | amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); 114 | hlayout->addWidget(amountWidget); 115 | 116 | + /* Delay before before filtering transactions in ms */ 117 | + static const int inputFilterDelay = 200;
Use snake case. Comment to indicate unit?
FWIW there is this global constant cc @sipa.
340 | {
341 | if(!transactionProxyModel)
342 | return;
343 | CAmount amount_parsed = 0;
344 | - if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed))
345 | + if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amountWidget->text(), &amount_parsed))
Missing space after if. Move below { to this line.
69 | @@ -69,6 +70,9 @@ class TransactionView : public QWidget 70 | QLineEdit *addressWidget; 71 | QLineEdit *amountWidget; 72 | 73 | + QTimer *m_input_delay_prefix; 74 | + QTimer *m_input_delay_amount;
Same as above.
115 | @@ -112,8 +116,8 @@ public Q_SLOTS: 116 | void chooseDate(int idx); 117 | void chooseType(int idx); 118 | void chooseWatchonly(int idx); 119 | - void changedPrefix(const QString &prefix); 120 | - void changedAmount(const QString &amount); 121 | + void changedPrefix(); 122 | + void changedAmount();
Nit, I would sort the slots.
112 | @@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 113 | amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); 114 | hlayout->addWidget(amountWidget); 115 | 116 | + /* Delay before before filtering transactions in ms */ 117 | + static const int inputFilterDelay = 200; 118 | + 119 | + m_input_delay_amount = new QTimer(this);
Nit, change to QTimer* amount_typing_delay = new QTimer(this);
112 | @@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 113 | amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); 114 | hlayout->addWidget(amountWidget); 115 | 116 | + /* Delay before before filtering transactions in ms */
Comments is this file are // ....
For reference https://wiki.qt.io/Delay_action_to_wait_for_user_interaction.
I'll do it on Tuesday night.
Am 07.09.2017 17:52 schrieb "Jonas Schnelli" notifications@github.com:
@lclc https://github.com/lclc, could you address @promag https://github.com/promag's points? I'd like to get this in soon.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/11015#issuecomment-327841890, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwrESCkYZHmbXMwSNGUFJuiEzuXFc7Rks5sgBEigaJpZM4OxrEB .
utACK a82976d. Will test in a couple of hours.
Tested ACK a82976d.
If the motivation is to make filtering large data sets easier, why not apply the delay only when the data set is sufficiently large? For other cases, it just reduces responsiveness. Or is the size of the data set not known when the UI is constructed?
200ms is very reasonable. See https://ux.stackexchange.com/a/38545.
Tested ACK a82976d96009680ab61bcea763f15c7594b9afb0
Fixes 3141
112 | @@ -112,6 +113,17 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa 113 | amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); 114 | hlayout->addWidget(amountWidget); 115 | 116 | + // Delay before before filtering transactions in ms
nit: comment (before before)
Thanks, fixed.
Tested ACK 7b137ac.