Skip to content

Commit 54980a7

Browse files
hebastoprusnak
authored andcommitted
qt: Use QRegularExpression in AddressBookSortFilterProxyModel class
1 parent c6b6106 commit 54980a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/qt/addressbookpage.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <QIcon>
1919
#include <QMenu>
2020
#include <QMessageBox>
21+
#include <QRegularExpression>
2122
#include <QSortFilterProxyModel>
2223

2324
class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
@@ -46,12 +47,19 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
4647

4748
auto address = model->index(row, AddressTableModel::Address, parent);
4849

50+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
51+
auto match_address = filterRegularExpression().match(model->data(address).toString());
52+
auto match_label = filterRegularExpression().match(model->data(label).toString());
53+
54+
return match_address.hasMatch() || match_label.hasMatch();
55+
#else
4956
if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
5057
filterRegExp().indexIn(model->data(label).toString()) < 0) {
5158
return false;
5259
}
5360

5461
return true;
62+
#endif
5563
}
5664
};
5765

0 commit comments

Comments
 (0)