@@ -48,10 +48,17 @@ class qRecursiveTreeProxyFilter : public QSortFilterProxyModel
4848
4949 bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const
5050 {
51- if (filterRegularExpression ().pattern ().isEmpty ())
52- {
53- return true ;
54- }
51+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
52+ if (filterRegExp ().isEmpty () && filterRegularExpression ().pattern ().isEmpty ())
53+ {
54+ return true ;
55+ }
56+ #else
57+ if (filterRegularExpression ().pattern ().isEmpty ())
58+ {
59+ return true ;
60+ }
61+ #endif
5562 QModelIndex index = sourceModel ()->index (sourceRow, 0 , sourceParent);
5663 return filterAcceptsIndex (index);
5764 }
@@ -60,15 +67,41 @@ class qRecursiveTreeProxyFilter : public QSortFilterProxyModel
6067 bool filterAcceptsIndex (const QModelIndex index) const
6168 {
6269 // Accept item if its tag, attribute, or value text matches
63- if ((sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::TagColumn,
64- index.parent ()), Qt::DisplayRole).toString ().contains (filterRegularExpression ()))
65- || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::AttributeColumn,
66- index.parent ()), Qt::DisplayRole).toString ().contains (filterRegularExpression ()))
67- || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::ValueColumn,
68- index.parent ()), Qt::DisplayRole).toString ().contains (filterRegularExpression ())))
69- {
70- return true ;
71- }
70+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
71+ QRegExp rx = filterRegExp ();
72+ if (!rx.isEmpty () &&
73+ ((sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::TagColumn,
74+ index.parent ()), Qt::DisplayRole).toString ().contains (rx))
75+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::AttributeColumn,
76+ index.parent ()), Qt::DisplayRole).toString ().contains (rx))
77+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::ValueColumn,
78+ index.parent ()), Qt::DisplayRole).toString ().contains (rx))))
79+ {
80+ return true ;
81+ }
82+
83+ QRegularExpression re = filterRegularExpression ();
84+ if (!re.pattern ().isEmpty () && ((sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::TagColumn,
85+ index.parent ()), Qt::DisplayRole).toString ().contains (re))
86+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::AttributeColumn,
87+ index.parent ()), Qt::DisplayRole).toString ().contains (re))
88+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::ValueColumn,
89+ index.parent ()), Qt::DisplayRole).toString ().contains (re))))
90+ {
91+ return true ;
92+ }
93+ #else
94+ QRegularExpression re = filterRegularExpression ();
95+ if ((sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::TagColumn,
96+ index.parent ()), Qt::DisplayRole).toString ().contains (re))
97+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::AttributeColumn,
98+ index.parent ()), Qt::DisplayRole).toString ().contains (re))
99+ || (sourceModel ()->data (sourceModel ()->index (index.row (), ctkDICOMObjectModel::ValueColumn,
100+ index.parent ()), Qt::DisplayRole).toString ().contains (re)))
101+ {
102+ return true ;
103+ }
104+ #endif
72105 // Accept item if any child matches
73106 for (int row = 0 ; row < sourceModel ()->rowCount (index); row++)
74107 {
0 commit comments