Skip to content

Commit 72d075a

Browse files
Update history_manager.py
Add undo/redo for smart annotation
1 parent d236237 commit 72d075a

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

annotation_tool/controllers/history_manager.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@ def _apply_state_change(self, cmd, is_undo):
9090
if path in self.model.manual_annotations: del self.model.manual_annotations[path]
9191
else: self.model.manual_annotations[path] = copy.deepcopy(data)
9292
self.main.refresh_ui_after_undo_redo(path)
93+
94+
# ==========================================
95+
# [NEW] Handle batch annotation confirm
96+
# ==========================================
97+
elif ctype == CmdType.BATCH_ANNOTATION_CONFIRM:
98+
batch_changes = cmd['batch_changes'] # Retrieve the packed dictionary
99+
100+
# Loop through every video that was modified in this batch
101+
for path, changes in batch_changes.items():
102+
data = changes['old_data'] if is_undo else changes['new_data']
103+
104+
# Apply the data
105+
if data:
106+
self.model.manual_annotations[path] = copy.deepcopy(data)
107+
else:
108+
if path in self.model.manual_annotations:
109+
del self.model.manual_annotations[path]
110+
111+
# Update the checkmark status in the Tree UI for this video
112+
self.main.update_action_item_status(path)
113+
114+
# Refresh the right panel if the currently selected item was affected
115+
self._refresh_active_view()
116+
# ==========================================
117+
93118

94119
elif ctype == CmdType.UI_CHANGE:
95120
path = cmd['path']
@@ -378,4 +403,4 @@ def _apply_state_change(self, cmd, is_undo):
378403
if evt.get('head') == head and evt.get('label') == src:
379404
evt['label'] = dst
380405

381-
self._refresh_active_view()
406+
self._refresh_active_view()

0 commit comments

Comments
 (0)