File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 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
2328class 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
You can’t perform that action at this time.
0 commit comments