mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 06:32:53 +01:00
feat: casefold mod names before sorting
This commit is contained in:
1 parent
5757f79755
commit
8bcb64810d
5 files changed
+23
-17
No files matched your search
+1
-1
@@ -102,7 +102,7 @@ def get_delimited_mods(steam_path: Path) -> list[Any]:
|
|||||||
size = get_mod_size(mod)
|
size = get_mod_size(mod)
|
||||||
# NOTE: final col is cell renderer highlight toggle
|
# NOTE: final col is cell renderer highlight toggle
|
||||||
clean.append([meta.name, symlink, mod_dir, size, False])
|
clean.append([meta.name, symlink, mod_dir, size, False])
|
||||||
clean.sort(key=lambda row: row[0])
|
clean.sort(key=lambda row: row[0].casefold())
|
||||||
return clean
|
return clean
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Self
|
from typing import Any, Self
|
||||||
|
|
||||||
from dzgui.util import strings
|
from dzgui.util import strings
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class FilterMode(Enum):
|
|||||||
|
|
||||||
|
|
||||||
class EnumWithAttrs(Enum):
|
class EnumWithAttrs(Enum):
|
||||||
def __new__(cls, *args, **kwargs) -> Self:
|
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
|
||||||
value = len(cls.__members__) + 1
|
value = len(cls.__members__) + 1
|
||||||
obj = object.__new__(cls)
|
obj = object.__new__(cls)
|
||||||
obj._value_ = value
|
obj._value_ = value
|
||||||
|
|||||||
+15
-10
@@ -14,7 +14,7 @@ from dzgui.api.mods import (
|
|||||||
from dzgui.const.constants import APP_NAME, APPID_DAYZ, APPID_DAYZ_EXP
|
from dzgui.const.constants import APP_NAME, APPID_DAYZ, APPID_DAYZ_EXP
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.model.model_factory import ModelFactory
|
from dzgui.model.model_factory import FastInsertListStore, ModelFactory
|
||||||
from dzgui.util.format import format_mods
|
from dzgui.util.format import format_mods
|
||||||
|
|
||||||
import dzgui.api.pefile as PeFile
|
import dzgui.api.pefile as PeFile
|
||||||
@@ -44,11 +44,13 @@ class ModManager:
|
|||||||
self.path = controller.query_config(Preferences.DEFAULT)
|
self.path = controller.query_config(Preferences.DEFAULT)
|
||||||
self.treeview = self.controller.get_modtreeview()
|
self.treeview = self.controller.get_modtreeview()
|
||||||
|
|
||||||
|
self.store: FastInsertListStore
|
||||||
|
|
||||||
self.thread_man = ThreadingManager(controller)
|
self.thread_man = ThreadingManager(controller)
|
||||||
self._get_mods()
|
self._get_mods()
|
||||||
|
|
||||||
@call_on_thread("getting mods")
|
@call_on_thread("getting mods")
|
||||||
def _get_mods(self) -> list:
|
def _get_mods(self) -> None:
|
||||||
mods = get_delimited_mods(self.path)
|
mods = get_delimited_mods(self.path)
|
||||||
if len(mods) < 1:
|
if len(mods) < 1:
|
||||||
msg = self.format_mod_statusbar()
|
msg = self.format_mod_statusbar()
|
||||||
@@ -58,13 +60,13 @@ class ModManager:
|
|||||||
func = StoredFunc(self._on_mods_loaded, mods)
|
func = StoredFunc(self._on_mods_loaded, mods)
|
||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
def _on_mods_loaded(self, mods: list[int]) -> None:
|
def _on_mods_loaded(self, mods: list[list[str, str, str, float, bool]]) -> None:
|
||||||
model = ModelFactory().make_mod_store()
|
self.store = ModelFactory().make_mod_store()
|
||||||
model.extend(mods)
|
self.store.extend(mods)
|
||||||
self.treeview.set_model(model)
|
self.treeview.set_model(self.store)
|
||||||
msg = self.format_mod_statusbar()
|
msg = self.format_mod_statusbar()
|
||||||
mods = len(model)
|
total_mods = len(self.store)
|
||||||
self.emitter.emit("mods_updated", msg, mods)
|
self.emitter.emit("mods_updated", msg, total_mods)
|
||||||
|
|
||||||
@call_on_thread("deleting mods")
|
@call_on_thread("deleting mods")
|
||||||
def delete_mods(self) -> None:
|
def delete_mods(self) -> None:
|
||||||
@@ -87,7 +89,7 @@ class ModManager:
|
|||||||
mod = model.get(tree_iter, 2)[0]
|
mod = model.get(tree_iter, 2)[0]
|
||||||
return mod, tree_iter
|
return mod, tree_iter
|
||||||
|
|
||||||
def delete_single_mod(self, tree_path: Gtk.TreePath) -> None:
|
def delete_single_mod(self, tree_path: Gtk.TreePath) -> Gtk.TreeIter:
|
||||||
mod, _iter = self.get_mod_from_tree_path(tree_path)
|
mod, _iter = self.get_mod_from_tree_path(tree_path)
|
||||||
|
|
||||||
steam_path = Path(self.path)
|
steam_path = Path(self.path)
|
||||||
@@ -111,7 +113,10 @@ class ModManager:
|
|||||||
|
|
||||||
def _on_mods_deleted(self, iters: list[Gtk.TreeIter]) -> None:
|
def _on_mods_deleted(self, iters: list[Gtk.TreeIter]) -> None:
|
||||||
for _iter in iters:
|
for _iter in iters:
|
||||||
self.treeview.get_model().remove(_iter)
|
self.store.remove(_iter)
|
||||||
|
#model = self.treeview.get_model()
|
||||||
|
#if model:
|
||||||
|
# model.remove(_iter) # FIXME: do not remove from model interface directly
|
||||||
remove_stale_signatures(self.prefs.paths.config, self.prefs.paths.version)
|
remove_stale_signatures(self.prefs.paths.config, self.prefs.paths.version)
|
||||||
mods = len(self.treeview.get_model())
|
mods = len(self.treeview.get_model())
|
||||||
msg = self.format_mod_statusbar()
|
msg = self.format_mod_statusbar()
|
||||||
|
|||||||
+3
-2
@@ -1,16 +1,17 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
def read_json(path: Path) -> dict:
|
def read_json(path: Path) -> Any:
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as infile:
|
with open(path, "r") as infile:
|
||||||
try:
|
try:
|
||||||
data = json.load(infile)
|
data = json.load(infile)
|
||||||
|
return data
|
||||||
except json.decoder.JSONDecodeError as e:
|
except json.decoder.JSONDecodeError as e:
|
||||||
raise e
|
raise e
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise e
|
raise e
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def write_json(data: dict, path: Path) -> None:
|
def write_json(data: dict, path: Path) -> None:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import Any, Optional, Self
|
from typing import Any, Optional, Self, Union
|
||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
|
|
||||||
from dzgui.api.servers import ping, Record
|
from dzgui.api.servers import ping, Record
|
||||||
@@ -321,7 +321,7 @@ class ServerTreeView(ContextMixin, TreeView):
|
|||||||
def set_loaded(self, status: bool) -> None:
|
def set_loaded(self, status: bool) -> None:
|
||||||
self.loaded = status
|
self.loaded = status
|
||||||
|
|
||||||
def get_model_and_control_model(self) -> tuple["FastInsertListStore", list[Any]]:
|
def get_model_and_control_model(self) -> tuple[Union["FastInsertListStore", None], list[Any]]:
|
||||||
model = self.get_model()
|
model = self.get_model()
|
||||||
control = self.proxy_man.get_control()
|
control = self.proxy_man.get_control()
|
||||||
return model, control
|
return model, control
|
||||||
|
|||||||
Reference in new issue
Block a user