Drop wildcard support for address/label search in AddressBookPage #592

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:220423-wildcard changing 2 files +55 −10
  1. hebasto commented at 7:32 pm on April 23, 2022: member

    Wildcard support for address/label search in AddressBookPage was introduced in bitcoin/bitcoin#12080, and it is available in release binaries since v0.17.

    But this feature has never being documented or mentioned in the GUI.

    Thus, there are no reasons to believe that users rely on this feature.

    Required for migration to Qt 6, because:

    There is no direct way to do wildcard matching in QRegularExpression.

    Tests included.

    Based on bitcoin-core/gui#591, so only last 2 commits belong to this PR.

  2. hebasto added the label Feature on Apr 23, 2022
  3. hebasto added the label Tests on Apr 23, 2022
  4. hebasto added the label UX on Apr 23, 2022
  5. DrahtBot commented at 3:50 am on April 24, 2022: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #593 (Getting ready to Qt 6 (8/n). Use QRegularExpression in AddressBookSortFilterProxyModel class by hebasto)
    • #585 (Replace QRegExp with QRegularExpression by prusnak)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. luke-jr commented at 6:12 pm on May 8, 2022: member
    cc @promag
  7. luke-jr commented at 6:15 pm on May 8, 2022: member

    “However, the wildcardToRegularExpression method is provided to translate glob patterns into a Perl-compatible regular expression that can be used for that purpose.”

    Seems like it should be trivial to retain this feature, if we want to?

  8. laanwj commented at 12:40 pm on May 9, 2022: member
    ~0 on this. As I’ve said on IRC I don’t particularly care for this feature to go (I don’t think the entire Address Book is particularly useful, searching in the Transactions tab should cover it?), though “being compatible with Qt 6” is a strange motivation. As @luke-jr says it would still be possible by rewriting the expression.
  9. hebasto referenced this in commit 3dd95cb5c2 on May 9, 2022
  10. qt: Drop wildcard support for address/label search in `AddressBookPage`
    Such support was never mentioned in release notes or in the GUI.
    Required for migration to Qt 6, because "There is no direct way to do
    wildcard matching in QRegularExpression."
    See https://doc.qt.io/qt-6/qregexp.html#porting-to-qregularexpression
    d5a4ed81f5
  11. qt, test: Add tests for searching in `AddressBookPage` dialog 555b673fbc
  12. hebasto force-pushed on May 9, 2022
  13. hebasto commented at 8:26 pm on May 9, 2022: member
    Rebased on top of the merged #591.
  14. sidhujag referenced this in commit 049283e67f on May 9, 2022
  15. hebasto commented at 8:16 pm on May 20, 2022: member

    @luke-jr

    “However, the wildcardToRegularExpression method is provided to translate glob patterns into a Perl-compatible regular expression that can be used for that purpose.”

    Seems like it should be trivial to retain this feature, if we want to?

    Would you mind provide a working example please?

  16. in src/qt/addressbookpage.cpp:144 in 555b673fbc
    139@@ -143,7 +140,9 @@ void AddressBookPage::setModel(AddressTableModel *_model)
    140     proxyModel = new AddressBookSortFilterProxyModel(type, this);
    141     proxyModel->setSourceModel(_model);
    142 
    143-    connect(ui->searchLineEdit, &QLineEdit::textChanged, proxyModel, &QSortFilterProxyModel::setFilterWildcard);
    144+    connect(ui->searchLineEdit, &QLineEdit::textChanged, [this](const QString& pattern) {
    145+        proxyModel->setFilterFixedString(pattern);
    


    promag commented at 10:05 am on May 21, 2022:

    In fact setFilterWildcard in Qt6 already handles the change noted in the porting documentation:

    There is no direct way to do wildcard matching in QRegularExpression. However, the wildcardToRegularExpression method is provided to translate glob patterns into a Perl-compatible regular expression that can be used for that purpose.

    Qt5

    0void QSortFilterProxyModel::setFilterFixedString(const QString &pattern)
    1{
    2    Q_D(QSortFilterProxyModel);
    3    d->filter_about_to_be_changed();
    4    QRegExp rx(pattern, d->filter_data.caseSensitivity(), QRegExp::FixedString);
    5    d->filter_data.setRegExp(rx);
    6    d->filter_changed();
    7}
    

    Qt6

    0void QSortFilterProxyModel::setFilterWildcard(const QString &pattern)
    1{
    2    Q_D(QSortFilterProxyModel);
    3    d->filter_regularexpression.removeBindingUnlessInWrapper();
    4    d->filter_about_to_be_changed();
    5    d->set_filter_pattern(QRegularExpression::wildcardToRegularExpression(
    6            pattern, QRegularExpression::UnanchoredWildcardConversion));
    7    d->filter_changed(QSortFilterProxyModelPrivate::Direction::Rows);
    8    d->filter_regularexpression.notify();
    9}
    

    hebasto commented at 1:47 pm on May 21, 2022:
  17. promag commented at 10:15 am on May 21, 2022: contributor

    Tested ACK 555b673fbc71412908bb73c9c71d49895270335f.

    TBH I didn’t think about using a wildcard in the search field, so setFilterFixedString would be sufficient.

    The only issue I have is breaking someone’s expectation, as this is a breaking change - using wildcard results in an empty list where before it could list some addresses. I understand it’s not documented but it’s available for some time. Maybe could validate the search field to disallow wildcard, like:

    0yle, Mode _mode,
    1 {
    2     ui->setupUi(this);
    3
    4+    auto validator = new QRegularExpressionValidator(QRegularExpression("[^\\*]*"), this);
    5+    ui->searchLineEdit->setValidator(validator);
    6+
    7     if (!platformStyle->getImagesOnButtons()) {
    8         ui->newAddress->setIcon(QIcon());
    9         ui->copyAddress->setIcon(QIcon());
    

    Finally, if we stick to supporting wildcard then no changes are required as explained in the comment below (but didn’t test with Qt6).

  18. hebasto commented at 3:51 pm on May 21, 2022: member
    Combined into #593.
  19. hebasto closed this on May 21, 2022

  20. hebasto deleted the branch on May 24, 2022
  21. bitcoin-core locked this on May 24, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 02:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me