diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-05-21 16:07:23 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-05-21 17:44:57 +0200 |
commit | e280087946184b37c8a1eb345fae30ebb07f3384 (patch) | |
tree | 69b40dda5f5143860ad576faeaca0502787f7591 /src/qt/addressbookpage.cpp | |
parent | 5c5d8f2465be70cbc256ec59913ac0a3c7c958be (diff) | |
download | bitcoin-e280087946184b37c8a1eb345fae30ebb07f3384.tar.xz |
qt: Use `QRegularExpression` in `AddressBookSortFilterProxyModel` class
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
Diffstat (limited to 'src/qt/addressbookpage.cpp')
-rw-r--r-- | src/qt/addressbookpage.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index d59a4345f3..a82bd5f73e 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -19,6 +19,11 @@ #include <QMenu> #include <QMessageBox> #include <QSortFilterProxyModel> +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include <QRegularExpression> +#else +#include <QRegExp> +#endif class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel { @@ -46,12 +51,13 @@ protected: auto address = model->index(row, AddressTableModel::Address, parent); - if (filterRegExp().indexIn(model->data(address).toString()) < 0 && - filterRegExp().indexIn(model->data(label).toString()) < 0) { - return false; - } - - return true; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + const auto pattern = filterRegularExpression(); +#else + const auto pattern = filterRegExp(); +#endif + return (model->data(address).toString().contains(pattern) || + model->data(label).toString().contains(pattern)); } }; |