Skip to content
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

Merged
merged 3 commits into from Nov 29, 2017

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Sep 25, 2017

No description provided.

@fanquake fanquake added the GUI label Sep 25, 2017
Copy link
Contributor

@meshcollider meshcollider left a 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

Copy link
Member

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@@ -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)
Copy link
Member

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()) {
    ...
}

Copy link
Member Author

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.

Copy link
Member

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.

@@ -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();
Copy link
Member

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)?

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, drop alignments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

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)) {

@@ -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)
Copy link
Member

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.

@@ -20,7 +20,7 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
QSortFilterProxyModel(parent),
dateFrom(MIN_DATE),
dateTo(MAX_DATE),
addrPrefix(),
searchString(),
Copy link
Member

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?

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renameprefix variable too?

{
if(!transactionProxyModel)
return;
transactionProxyModel->setAddressPrefix(prefix);
transactionProxyModel->setSearchString(prefix);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a suggestion really.

{
this->addrPrefix = _addrPrefix;
this->searchString = _searchString;
Copy link
Member

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;

Copy link
Member Author

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...?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good points.

Copy link
Member Author

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.

Copy link
Member

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)?

@@ -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) &&
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

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 &);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const QString&.

Copy link
Contributor

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

@@ -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)
Copy link
Member

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;
Copy link
Member

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.

@@ -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);
Copy link
Member

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) &&
Copy link
Member

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 ...;

}

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, maybe @lclc can bench the change in #11015 for his use case.

@promag
Copy link
Member

promag commented Sep 26, 2017

I don't consider the remaining nits as things that should be changed.

These aren't significant changes so why not comply with developer notes?

@luke-jr
Copy link
Member Author

luke-jr commented Sep 26, 2017

The developer notes don't say anything about which side * and & should hug, or the rest. Nitpicking such minor details seems like just a waste of time.

@jonasschnelli
Copy link
Contributor

Concept ACK (haven't looked at the code so far).

@promag
Copy link
Member

promag commented Oct 7, 2017

Needs rebase.

@Sjors
Copy link
Member

Sjors commented Nov 9, 2017

Concept ACK. It's a bit strange to search for a field that's not visible in the table. Adding (part of) the transaction hash as a column would be more consistent, but obviously a bigger change and perhaps a waste of horizontal space. However that could all be added later.

It works for me:
schermafbeelding 2017-11-09 om 14 40 31

@promag
Copy link
Member

promag commented Nov 9, 2017

@luke-jr ping.

@promag
Copy link
Member

promag commented Nov 9, 2017

It's a bit strange to search for a field that's not visible in the table

It is also strange to not have the txid in the "Transactions" view. 🙄 Agree it can be improved later.

@luke-jr
Copy link
Member Author

luke-jr commented Nov 10, 2017

Rebased

@promag
Copy link
Member

promag commented Nov 12, 2017

Restarted travis job due to unrelated error.

@promag
Copy link
Member

promag commented Nov 12, 2017

utACK.

Copy link
Contributor

@meshcollider meshcollider left a 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 &);
Copy link
Contributor

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

Copy link
Contributor

@jonasschnelli jonasschnelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK c407c61

@jonasschnelli jonasschnelli merged commit eac2abc into bitcoin:master Nov 29, 2017
jonasschnelli added a commit that referenced this pull request Nov 29, 2017
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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 16, 2019
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
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 8, 2019
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
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 8, 2019
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
proteanx pushed a commit to devaultcrypto/devault that referenced this pull request Dec 12, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 17, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
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
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 26, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants