New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt: Enable searching by transaction id #11395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 3b35414
nit: use snake_case since you are refactoring the variable names anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
src/qt/transactionfilterproxy.cpp
Outdated
@@ -51,8 +52,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & | |||
return false; | |||
if(datetime < dateFrom || datetime > dateTo) | |||
return false; | |||
if (!address.contains(searchString, Qt::CaseInsensitive) && !label.contains(searchString, Qt::CaseInsensitive)) | |||
if (!address.contains(searchString, Qt::CaseInsensitive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid unnecessary code execution?
if (!searchString.isEmpty()) {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address.contains("") will immediately return true, so the other two clauses won't get executed. I don't know that we need to over-optimise here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, not so immediately as isEmpty
but agree with you.
src/qt/transactionfilterproxy.cpp
Outdated
@@ -36,6 +36,7 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & | |||
int type = index.data(TransactionTableModel::TypeRole).toInt(); | |||
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); | |||
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool(); | |||
QString txid = index.data(TransactionTableModel::TxIDRole).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, declare after label
(sorted and follows the same test order below)?
src/qt/transactionfilterproxy.cpp
Outdated
@@ -51,8 +52,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & | |||
return false; | |||
if(datetime < dateFrom || datetime > dateTo) | |||
return false; | |||
if (!address.contains(searchString, Qt::CaseInsensitive) && !label.contains(searchString, Qt::CaseInsensitive)) | |||
if (!address.contains(searchString, Qt::CaseInsensitive) | |||
&& ! label.contains(searchString, Qt::CaseInsensitive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, drop alignments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is clang-format
makes it one line. This is preserved by clang-format:
if (!address.contains(searchString, Qt::CaseInsensitive) &&
!label.contains(searchString, Qt::CaseInsensitive) &&
!txid.contains(searchString, Qt::CaseInsensitive)) {
src/qt/transactionfilterproxy.cpp
Outdated
@@ -66,9 +66,9 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime | |||
invalidateFilter(); | |||
} | |||
|
|||
void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix) | |||
void TransactionFilterProxy::setSearchString(const QString &_searchString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, const QString& search_string
.
src/qt/transactionfilterproxy.cpp
Outdated
@@ -20,7 +20,7 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : | |||
QSortFilterProxyModel(parent), | |||
dateFrom(MIN_DATE), | |||
dateTo(MAX_DATE), | |||
addrPrefix(), | |||
searchString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New convention m_search_string
?
src/qt/transactionview.cpp
Outdated
@@ -305,11 +305,11 @@ void TransactionView::chooseWatchonly(int idx) | |||
(TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt()); | |||
} | |||
|
|||
void TransactionView::changedPrefix(const QString &prefix) | |||
void TransactionView::changedSearch(const QString &prefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renameprefix
variable too?
src/qt/transactionview.cpp
Outdated
{ | ||
if(!transactionProxyModel) | ||
return; | ||
transactionProxyModel->setAddressPrefix(prefix); | ||
transactionProxyModel->setSearchString(prefix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion, sanitize input, like trim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a suggestion really.
src/qt/transactionfilterproxy.cpp
Outdated
{ | ||
this->addrPrefix = _addrPrefix; | ||
this->searchString = _searchString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
if (this->m_search_string == search_string) return;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would actually make performance worse...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is now yes because QLineEdit
doesn't emit unnecessary signals. But from this method perspective IMO this makes sense, the cost of the condition is way cheaper than invalidating the filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, we could lower case the stored m_search_string
to make the filter faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, we should never get to this point if the string hasn't changed, and lowercasing the search string doesn't make the filter faster because label/address aren't lowercased.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine if pressing the ESC key erases the search string, pressing it the 2nd time would do nothing if the check is there.
So why .contains(..., Qt::CaseInsensitive)
?
3b35414
to
93f0dfd
Compare
@@ -51,8 +52,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & | |||
return false; | |||
if(datetime < dateFrom || datetime > dateTo) | |||
return false; | |||
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) | |||
if (!address.contains(m_search_string, Qt::CaseInsensitive) && | |||
! label.contains(m_search_string, Qt::CaseInsensitive) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format will remove these whitespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this a shortcoming of clang-format, then. I don't consider the remaining nits as things that should be changed.
@@ -66,9 +66,9 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime | |||
invalidateFilter(); | |||
} | |||
|
|||
void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix) | |||
void TransactionFilterProxy::setSearchString(const QString &search_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const QString& search_string
.
@@ -35,7 +35,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel | |||
}; | |||
|
|||
void setDateRange(const QDateTime &from, const QDateTime &to); | |||
void setAddressPrefix(const QString &addrPrefix); | |||
void setSearchString(const QString &); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const QString&
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I prefer having the variable names in the header (all others in this header do too). Unsure if there's a general preference though
src/qt/transactionview.cpp
Outdated
@@ -305,11 +305,11 @@ void TransactionView::chooseWatchonly(int idx) | |||
(TransactionFilterProxy::WatchOnlyFilter)watchOnlyWidget->itemData(idx).toInt()); | |||
} | |||
|
|||
void TransactionView::changedPrefix(const QString &prefix) | |||
void TransactionView::changedSearch(const QString &search_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, const QString& search_string
.
@@ -66,7 +66,7 @@ class TransactionView : public QWidget | |||
QComboBox *dateWidget; | |||
QComboBox *typeWidget; | |||
QComboBox *watchOnlyWidget; | |||
QLineEdit *addressWidget; | |||
QLineEdit *search_widget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, QLineEdit* m_search_widget
.
src/qt/transactionview.h
Outdated
@@ -110,7 +110,7 @@ public Q_SLOTS: | |||
void chooseDate(int idx); | |||
void chooseType(int idx); | |||
void chooseWatchonly(int idx); | |||
void changedPrefix(const QString &prefix); | |||
void changedSearch(const QString &search_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, const QString& search_string
.
@@ -51,8 +52,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & | |||
return false; | |||
if(datetime < dateFrom || datetime > dateTo) | |||
return false; | |||
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) | |||
if (!address.contains(m_search_string, Qt::CaseInsensitive) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, back to if (!m_search_string.isEmpty()) { ... }
, it can also save querying the model for those properties:
if (!m_search_string_lowered_case.isEmpty()) {
QString address = ...toLowerCase();
...
return ...;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like more complication for little value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't significant changes so why not comply with developer notes? |
The developer notes don't say anything about which side |
Concept ACK (haven't looked at the code so far). |
Needs rebase. |
@luke-jr ping. |
It is also strange to not have the txid in the "Transactions" view. 🙄 Agree it can be improved later. |
Rebased |
93f0dfd
to
eac2abc
Compare
Restarted travis job due to unrelated error. |
utACK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK c407c61
@@ -35,7 +35,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel | |||
}; | |||
|
|||
void setDateRange(const QDateTime &from, const QDateTime &to); | |||
void setAddressPrefix(const QString &addrPrefix); | |||
void setSearchString(const QString &); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I prefer having the variable names in the header (all others in this header do too). Unsure if there's a general preference though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK c407c61
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
Summary: eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed Backport of Core PR11395 bitcoin/bitcoin#11395 Depends on D3832 Test Plan: make check ./bitcoin-qt -> transactions -> enter transaction id to filter by Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3833
Summary: eac2abca0 Qt: Enable searching by transaction id (Luke Dashjr) c407c61c5 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f634242 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed Backport of Core PR11395 bitcoin/bitcoin#11395 Depends on D3832 Test Plan: make check ./bitcoin-qt -> transactions -> enter transaction id to filter by Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3833
Summary: eac2abca0 Qt: Enable searching by transaction id (Luke Dashjr) c407c61c5 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f634242 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed Backport of Core PR11395 bitcoin/bitcoin#11395 Depends on D3832 Test Plan: make check ./bitcoin-qt -> transactions -> enter transaction id to filter by Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3833
Summary: eac2abca0 Qt: Enable searching by transaction id (Luke Dashjr) c407c61c5 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f634242 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed Backport of Core PR11395 bitcoin/bitcoin#11395 Depends on D3832 Test Plan: make check ./bitcoin-qt -> transactions -> enter transaction id to filter by Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3833
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
No description provided.