mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
fix usage of filteregexp
This commit is contained in:
parent
b5b8119f49
commit
940cb35e0d
4 changed files with 27 additions and 11 deletions
|
|
@ -482,8 +482,13 @@ class FilterProxyModel(QtCore.QSortFilterProxyModel):
|
|||
return True
|
||||
|
||||
# Filter by regex
|
||||
if not self.filterRegExp().isEmpty():
|
||||
pattern = re.escape(self.filterRegExp().pattern())
|
||||
if hasattr(self, "filterRegularExpression"):
|
||||
regex = self.filterRegularExpression()
|
||||
else:
|
||||
regex = self.filterRegExp()
|
||||
pattern = regex.pattern()
|
||||
if pattern:
|
||||
pattern = re.escape(pattern)
|
||||
|
||||
if not self._matches(row, parent, pattern):
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ class RecursiveSortFilterProxyModel(QtCore.QSortFilterProxyModel):
|
|||
if not parent.isValid():
|
||||
return False
|
||||
|
||||
regex = self.filterRegExp()
|
||||
if not regex.isEmpty() and regex.isValid():
|
||||
if hasattr(self, "filterRegularExpression"):
|
||||
regex = self.filterRegularExpression()
|
||||
else:
|
||||
regex = self.filterRegExp()
|
||||
|
||||
pattern = regex.pattern()
|
||||
if pattern and regex.isValid():
|
||||
pattern = regex.pattern()
|
||||
compiled_regex = re.compile(pattern, re.IGNORECASE)
|
||||
source_model = self.sourceModel()
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ from qtpy import QtCore
|
|||
class RecursiveSortFilterProxyModel(QtCore.QSortFilterProxyModel):
|
||||
"""Filters to the regex if any of the children matches allow parent"""
|
||||
def filterAcceptsRow(self, row, parent):
|
||||
|
||||
regex = self.filterRegExp()
|
||||
if not regex.isEmpty():
|
||||
pattern = regex.pattern()
|
||||
if hasattr(self, "filterRegularExpression"):
|
||||
regex = self.filterRegularExpression()
|
||||
else:
|
||||
regex = self.filterRegExp()
|
||||
pattern = regex.pattern()
|
||||
if pattern:
|
||||
model = self.sourceModel()
|
||||
source_index = model.index(row, self.filterKeyColumn(), parent)
|
||||
if source_index.isValid():
|
||||
|
||||
# Check current index itself
|
||||
key = model.data(source_index, self.filterRole())
|
||||
if re.search(pattern, key, re.IGNORECASE):
|
||||
|
|
|
|||
|
|
@ -203,8 +203,13 @@ class RecursiveSortFilterProxyModel(QtCore.QSortFilterProxyModel):
|
|||
the filter string but first checks if any children does.
|
||||
"""
|
||||
def filterAcceptsRow(self, row, parent_index):
|
||||
regex = self.filterRegExp()
|
||||
if not regex.isEmpty():
|
||||
if hasattr(self, "filterRegularExpression"):
|
||||
regex = self.filterRegularExpression()
|
||||
else:
|
||||
regex = self.filterRegExp()
|
||||
|
||||
pattern = regex.pattern()
|
||||
if pattern:
|
||||
model = self.sourceModel()
|
||||
source_index = model.index(
|
||||
row, self.filterKeyColumn(), parent_index
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue