From 940cb35e0d2f56feec5eefd7de81005971456307 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 21 Dec 2022 15:55:05 +0100 Subject: [PATCH] fix usage of filteregexp --- openpype/tools/sceneinventory/model.py | 9 +++++++-- openpype/tools/settings/settings/search_dialog.py | 9 +++++++-- .../widgets/model_filter_proxy_recursive_sort.py | 11 ++++++----- openpype/tools/utils/models.py | 9 +++++++-- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/openpype/tools/sceneinventory/model.py b/openpype/tools/sceneinventory/model.py index 9b45ed6cc1..3398743aec 100644 --- a/openpype/tools/sceneinventory/model.py +++ b/openpype/tools/sceneinventory/model.py @@ -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 diff --git a/openpype/tools/settings/settings/search_dialog.py b/openpype/tools/settings/settings/search_dialog.py index 71d258febe..33a4d16e98 100644 --- a/openpype/tools/settings/settings/search_dialog.py +++ b/openpype/tools/settings/settings/search_dialog.py @@ -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() diff --git a/openpype/tools/standalonepublish/widgets/model_filter_proxy_recursive_sort.py b/openpype/tools/standalonepublish/widgets/model_filter_proxy_recursive_sort.py index 727d3a97d7..5c72e2049b 100644 --- a/openpype/tools/standalonepublish/widgets/model_filter_proxy_recursive_sort.py +++ b/openpype/tools/standalonepublish/widgets/model_filter_proxy_recursive_sort.py @@ -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): diff --git a/openpype/tools/utils/models.py b/openpype/tools/utils/models.py index b26ec566fe..270e00b2ef 100644 --- a/openpype/tools/utils/models.py +++ b/openpype/tools/utils/models.py @@ -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