Skip to content

Commit e280087

Browse files
hebastopromag
andcommitted
qt: Use QRegularExpression in AddressBookSortFilterProxyModel class
Co-authored-by: João Barbosa <[email protected]>
1 parent 5c5d8f2 commit e280087

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/qt/addressbookpage.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
#include <QMenu>
2020
#include <QMessageBox>
2121
#include <QSortFilterProxyModel>
22+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
23+
#include <QRegularExpression>
24+
#else
25+
#include <QRegExp>
26+
#endif
2227

2328
class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
2429
{
@@ -46,12 +51,13 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
4651

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

49-
if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
50-
filterRegExp().indexIn(model->data(label).toString()) < 0) {
51-
return false;
52-
}
53-
54-
return true;
54+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
55+
const auto pattern = filterRegularExpression();
56+
#else
57+
const auto pattern = filterRegExp();
58+
#endif
59+
return (model->data(address).toString().contains(pattern) ||
60+
model->data(label).toString().contains(pattern));
5561
}
5662
};
5763

0 commit comments

Comments
 (0)