Skip to content

Commit

Permalink
feat(SortFilterProxyModel): add setFixedFilterList method
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed May 10, 2023
1 parent cb43d03 commit 9362967
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion prettyqt/core/sortfilterproxymodel.py
Expand Up @@ -33,11 +33,15 @@ def lessThan(self, left, right):
role = self.sortRole()
return left.data(role) < right.data(role)

def setFilterString(self, search_str):
def setFilterString(self, search_str: str):
pat = ".*?".join(map(re.escape, search_str))
pat = f"(?=({pat}))"
self.setFilterRegularExpression(pat)

def setFixedFilterList(self, filter_list: list[str]):
pat = "|".join(filter_list)
self.setFilterRegularExpression(pat)

def set_filter_case_sensitive(self, state: bool):
if state:
sensitivity = QtCore.Qt.CaseSensitivity.CaseSensitive
Expand Down

0 comments on commit 9362967

Please sign in to comment.