Skip to content

Commit

Permalink
gui - proper search for ovl files
Browse files Browse the repository at this point in the history
  • Loading branch information
HENDRIX-ZT2 committed Oct 28, 2024
1 parent 41ff291 commit 044174a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions __version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# this file is auto-generated by a pre-commit hook
VERSION = "3.0.2"
COMMIT_HASH = "fd79b09de"
COMMIT_TIME = "Sun Oct 27 20:46:07 2024 +0100"
COMMIT_HASH = "41ff291c1"
COMMIT_TIME = "Mon Oct 28 09:06:39 2024 +0100"
26 changes: 12 additions & 14 deletions gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,6 @@ def __init__(self, parent: "MainWindow",
self.dirs.doubleClicked.connect(self.item_dbl_clicked)

self.filters = QWidget()
# self.filter_entry = IconEdit("filter", "Filter OVL Files", ) # callback=self.proxy.setFilterRegExp)
self.filter_entry = IconEdit("filter", "Filter OVL Files", callback=self.set_filter)
self.filter_entry.setToolTip("Filter by name - only show items matching this name")
self.show_official_button = IconButton("ovl")
Expand Down Expand Up @@ -2101,18 +2100,30 @@ def set_dirs_regexp(self, regexp):

def show_modded_toggle(self, checked: bool) -> None:
if checked:
self.filter_entry.entry.setText("")
self.show_official_button.setChecked(False)
self.set_dirs_regexp("^((?!(Content|DLC|GameMain)).)*$")
else:
self.set_dirs_regexp("")

def show_official_toggle(self, checked: bool) -> None:
if checked:
self.filter_entry.entry.setText("")
self.show_modded_button.setChecked(False)
self.set_dirs_regexp("^.*(Content|GameMain|.*DLC).*$")
else:
self.set_dirs_regexp("")

def set_filter(self, s):
if s:
# turn off the other filters if a filter search string was entered
self.show_modded_button.setChecked(False)
self.show_official_button.setChecked(False)
# expand to also filter folders have not been opened before - sometimes slow but easy
self.dirs.expandAll()
# set filter function for search string
self.set_dirs_regexp(f"^.*({s}).*$")

def force_lowercase(self, text):
self.search_entry.setText(text.lower())

Expand Down Expand Up @@ -2268,19 +2279,6 @@ def get_exe_from_ovldata(self, ovldata):
exe_path = os.path.join(game_dir, exe)
return exe_path

def set_filter(self, s):
# # todo - when matching file names, it only accepts _files_ whose folders have been opened before
# self.dirs.proxy.setFilterRegularExpression(QRegularExpression(f"^.*({s}).*$",
# options=QRegularExpression.PatternOption.CaseInsensitiveOption))
# todo - setNameFilters are OR linked, not AND, so they are useless for the intended purpose
# self.dirs.file_model.setNameFilters(["*.ovl", f"*{s}*"])
pass

# def set_filter(self, proxy_cls: type[OvlDataFilterProxy]) -> None:
# self.proxy = proxy_cls(self)
# self.proxy.setSourceModel(self.model)
# self.dirs.setModel(self.proxy)

def set_games(self) -> None:
self.cfg["games"].update(self.get_steam_games())
self.set_data(self.cfg["games"])
Expand Down

0 comments on commit 044174a

Please sign in to comment.