mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
feat: update history on connect
This commit is contained in:
1 parent
cdcd38c326
commit
f7fe62e661
5 files changed
+47
-21
No files matched your search
@@ -389,7 +389,13 @@ class Controller(GObject.GObject):
|
|||||||
saved_tree = self.get_servers().get_saved()
|
saved_tree = self.get_servers().get_saved()
|
||||||
ServerModelManager(self, saved_tree).remove_by_record(record)
|
ServerModelManager(self, saved_tree).remove_by_record(record)
|
||||||
|
|
||||||
|
def add_to_history(self, record: dict[str, Any]) -> None:
|
||||||
|
tv = self.get_servers().get_recent()
|
||||||
|
ServerModelManager(self, tv).add_to_history(record)
|
||||||
|
|
||||||
def remove_from_history(self, record: "Record") -> None:
|
def remove_from_history(self, record: "Record") -> None:
|
||||||
|
# NOTE: remove action is only possible from history tree context menu,
|
||||||
|
# i.e., the active tree
|
||||||
tv = self.get_active_treeview()
|
tv = self.get_active_treeview()
|
||||||
ServerModelManager(self, tv).remove_from_history(record)
|
ServerModelManager(self, tv).remove_from_history(record)
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class ConnectionManager:
|
|||||||
self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
|
self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.history = res.as_row()
|
||||||
record = res.get_record()
|
record = res.get_record()
|
||||||
|
|
||||||
# NOTE: store metadata for later connection
|
# NOTE: store metadata for later connection
|
||||||
@@ -263,11 +264,14 @@ class ConnectionManager:
|
|||||||
if is_dayz_running():
|
if is_dayz_running():
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
# TODO: add self.record to history file and list store
|
|
||||||
# proxy_model.append_to_history()
|
func = StoredFunc(self._add_to_history_and_return)
|
||||||
func = StoredFunc(self.controller.open_page, NotebookPage.SERVERS)
|
|
||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
|
def _add_to_history_and_return(self) -> None:
|
||||||
|
self.controller.add_to_history(self.history)
|
||||||
|
self.controller.open_page(NotebookPage.SERVERS)
|
||||||
|
|
||||||
def _update_mods(self, raise_window: bool) -> None:
|
def _update_mods(self, raise_window: bool) -> None:
|
||||||
# NOTE: fast enqueue all mods in auto mode
|
# NOTE: fast enqueue all mods in auto mode
|
||||||
prefs = self.controller.get_prefs()
|
prefs = self.controller.get_prefs()
|
||||||
|
|||||||
@@ -55,10 +55,27 @@ class ProxyModelManager:
|
|||||||
self.proxy_model[treeiter][4] = playercount.players
|
self.proxy_model[treeiter][4] = playercount.players
|
||||||
self.proxy_model[treeiter][6] = playercount.queue
|
self.proxy_model[treeiter][6] = playercount.queue
|
||||||
|
|
||||||
# def append_to_history(self, row: list) -> None:
|
def append_row_to_history(
|
||||||
# if len(self.control_model) == 10:
|
self, history: list[str, str, str, str, int, int, int, str, int, int, str, bool]
|
||||||
# del self.control_model[0]
|
) -> None:
|
||||||
# self.control_model.append(row)
|
addr = history[7]
|
||||||
|
qport = history[8]
|
||||||
|
|
||||||
|
found = False
|
||||||
|
for i, row in enumerate(self.control_model):
|
||||||
|
if addr == row[7] and qport == row[8]:
|
||||||
|
print("record exists in history")
|
||||||
|
item = self.control_model.pop(i)
|
||||||
|
self.control_model.append(item)
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if found is False:
|
||||||
|
self.control_model.append(history)
|
||||||
|
if len(self.control_model) == 11:
|
||||||
|
del self.control_model[0]
|
||||||
|
|
||||||
|
self.filter(FilterMode.INITIAL, skip_cache=True)
|
||||||
|
|
||||||
def remove_row_from_control(self, record: "Record") -> None:
|
def remove_row_from_control(self, record: "Record") -> None:
|
||||||
if self.control_model is None:
|
if self.control_model is None:
|
||||||
|
|||||||
+12
-14
@@ -214,22 +214,9 @@ class ServerModelManager:
|
|||||||
res = Servers.query_by_record(record)
|
res = Servers.query_by_record(record)
|
||||||
self._parse_single_record(res, delete=True)
|
self._parse_single_record(res, delete=True)
|
||||||
|
|
||||||
# TODO:
|
def update_history(self) -> None:
|
||||||
# def add_to_history(self, record: Servers.Record) -> None:
|
|
||||||
# functionally similar to remove action
|
|
||||||
# # needs to be called from controller against history tree, not current tree
|
|
||||||
# proxy_man = self._get_proxy_man()
|
|
||||||
# # proxy_man.append_row_to_history
|
|
||||||
# control_model = proxy_man.get_control()
|
|
||||||
# config_man = self.controller.get_config_man()
|
|
||||||
# config_man.update_history_file(control_model)
|
|
||||||
|
|
||||||
def remove_from_history(self, record: Servers.Record) -> None:
|
|
||||||
"""Fully unthreaded, just removes a row"""
|
|
||||||
proxy_man = self._get_proxy_man()
|
proxy_man = self._get_proxy_man()
|
||||||
proxy_man.remove_row_from_control(record)
|
|
||||||
control_model = proxy_man.get_control()
|
control_model = proxy_man.get_control()
|
||||||
|
|
||||||
config_man = self.controller.get_config_man()
|
config_man = self.controller.get_config_man()
|
||||||
config_man.update_history_file(control_model)
|
config_man.update_history_file(control_model)
|
||||||
|
|
||||||
@@ -246,6 +233,17 @@ class ServerModelManager:
|
|||||||
self.first_iteration = False
|
self.first_iteration = False
|
||||||
self.emitter.emit("servers_loaded_init")
|
self.emitter.emit("servers_loaded_init")
|
||||||
|
|
||||||
|
def add_to_history(self, record: dict[str, Any]) -> None:
|
||||||
|
proxy_man = self._get_proxy_man()
|
||||||
|
row = Servers.parse_json([record])
|
||||||
|
proxy_man.append_row_to_history(row[0])
|
||||||
|
self.update_history()
|
||||||
|
|
||||||
|
def remove_from_history(self, record: Servers.Record) -> None:
|
||||||
|
proxy_man = self._get_proxy_man()
|
||||||
|
proxy_man.remove_row_from_control(record)
|
||||||
|
self.update_history()
|
||||||
|
|
||||||
def add_by_str(self, addr: str) -> None:
|
def add_by_str(self, addr: str) -> None:
|
||||||
if addr.isdigit():
|
if addr.isdigit():
|
||||||
self.add_by_id(addr)
|
self.add_by_id(addr)
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ servers = {
|
|||||||
"Ctrl-m": "jump to maps field",
|
"Ctrl-m": "jump to maps field",
|
||||||
"Ctrl-d": "select default LAN port",
|
"Ctrl-d": "select default LAN port",
|
||||||
"Ctrl-n": "select custom LAN port",
|
"Ctrl-n": "select custom LAN port",
|
||||||
|
"Ctrl-u": "connect to server from preconnect dialog",
|
||||||
"Ctrl-i": "jump to IP insert field",
|
"Ctrl-i": "jump to IP insert field",
|
||||||
"n": "navigate to next tab",
|
"n": "navigate to next tab",
|
||||||
"p": "navigate to previous tab",
|
"p": "navigate to previous tab",
|
||||||
|
|||||||
Reference in new issue
Block a user