gui_client: keep collapsed nodes collapsed on record updates
collect: capture apply_procedural return value Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-15
@@ -328,7 +328,7 @@ class DashboardTab(QWidget):
|
|||||||
changed = {p for p, v in curr_flat.items() if v != self._prev_flat.get(p)}
|
changed = {p for p, v in curr_flat.items() if v != self._prev_flat.get(p)}
|
||||||
self._prev_flat = curr_flat
|
self._prev_flat = curr_flat
|
||||||
|
|
||||||
expanded = self._expanded_paths()
|
collapsed = self._collapsed_paths()
|
||||||
self._tree.clear()
|
self._tree.clear()
|
||||||
|
|
||||||
bold = QFont()
|
bold = QFont()
|
||||||
@@ -365,7 +365,7 @@ class DashboardTab(QWidget):
|
|||||||
self._tree.addTopLevelItem(d_item)
|
self._tree.addTopLevelItem(d_item)
|
||||||
|
|
||||||
self._tree.expandAll()
|
self._tree.expandAll()
|
||||||
self._restore_expanded(expanded)
|
self._apply_collapsed(collapsed)
|
||||||
|
|
||||||
def _add_fields(self, parent: QTreeWidgetItem, data: dict, path: str, changed: set):
|
def _add_fields(self, parent: QTreeWidgetItem, data: dict, path: str, changed: set):
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
@@ -389,33 +389,31 @@ class DashboardTab(QWidget):
|
|||||||
item.setBackground(col, _CHANGED_BG)
|
item.setBackground(col, _CHANGED_BG)
|
||||||
parent.addChild(item)
|
parent.addChild(item)
|
||||||
|
|
||||||
# ── preserve expand state across refreshes ──────────────────────────────
|
# ── preserve collapse state across refreshes ─────────────────────────────
|
||||||
|
|
||||||
def _expanded_paths(self) -> set[str]:
|
def _collapsed_paths(self) -> set[str]:
|
||||||
paths = set()
|
paths = set()
|
||||||
root = self._tree.invisibleRootItem()
|
self._collect_collapsed(self._tree.invisibleRootItem(), "", paths)
|
||||||
self._collect_expanded(root, "", paths)
|
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def _collect_expanded(self, item, prefix, paths):
|
def _collect_collapsed(self, item, prefix, paths):
|
||||||
for i in range(item.childCount()):
|
for i in range(item.childCount()):
|
||||||
child = item.child(i)
|
child = item.child(i)
|
||||||
path = f"{prefix}/{child.text(0)}"
|
path = f"{prefix}/{child.text(0)}"
|
||||||
if child.isExpanded():
|
if child.childCount() > 0 and not child.isExpanded():
|
||||||
paths.add(path)
|
paths.add(path)
|
||||||
self._collect_expanded(child, path, paths)
|
self._collect_collapsed(child, path, paths)
|
||||||
|
|
||||||
def _restore_expanded(self, paths: set[str]):
|
def _apply_collapsed(self, paths: set[str]):
|
||||||
root = self._tree.invisibleRootItem()
|
self._set_collapsed(self._tree.invisibleRootItem(), "", paths)
|
||||||
self._apply_expanded(root, "", paths)
|
|
||||||
|
|
||||||
def _apply_expanded(self, item, prefix, paths):
|
def _set_collapsed(self, item, prefix, paths):
|
||||||
for i in range(item.childCount()):
|
for i in range(item.childCount()):
|
||||||
child = item.child(i)
|
child = item.child(i)
|
||||||
path = f"{prefix}/{child.text(0)}"
|
path = f"{prefix}/{child.text(0)}"
|
||||||
if path in paths:
|
if path in paths:
|
||||||
child.setExpanded(True)
|
child.setExpanded(False)
|
||||||
self._apply_expanded(child, path, paths)
|
self._set_collapsed(child, path, paths)
|
||||||
|
|
||||||
|
|
||||||
# ── Plot tab ──────────────────────────────────────────────────────────────────
|
# ── Plot tab ──────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ def run(args: argparse.Namespace) -> None:
|
|||||||
try:
|
try:
|
||||||
we_connect.update(wc)
|
we_connect.update(wc)
|
||||||
snapshot = extract_all(vehicle)
|
snapshot = extract_all(vehicle)
|
||||||
apply_procedural(snapshot)
|
snapshot = apply_procedural(snapshot)
|
||||||
store["records"].append(snapshot)
|
store["records"].append(snapshot)
|
||||||
save_store(out, store, args.max_records)
|
save_store(out, store, args.max_records)
|
||||||
if args.diff:
|
if args.diff:
|
||||||
|
|||||||
Reference in New Issue
Block a user