Skip to content

Commit 68698fc

Browse files
Update annotation_manager.py
Adapt to new /models
1 parent 71bf456 commit 68698fc

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

annotation_tool/controllers/classification/annotation_manager.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ def save_manual_annotation(self):
3030
self.main.update_action_item_status(path)
3131
self.main.update_save_export_button_state()
3232

33+
# [MV Fix] Auto-advance using QTreeView API
3334
tree = self.ui.classification_ui.left_panel.tree
34-
curr = tree.currentItem()
35-
nxt = tree.itemBelow(curr)
36-
if nxt:
37-
QTimer.singleShot(500, lambda: [tree.setCurrentItem(nxt), tree.scrollToItem(nxt)])
35+
curr_idx = tree.currentIndex()
36+
if curr_idx.isValid():
37+
# Try to get index below
38+
nxt_idx = tree.indexBelow(curr_idx)
39+
if nxt_idx.isValid():
40+
QTimer.singleShot(500, lambda: [tree.setCurrentIndex(nxt_idx), tree.scrollTo(nxt_idx)])
3841

3942
def clear_current_manual_annotation(self):
4043
path = self.main.get_current_action_path()
@@ -67,6 +70,10 @@ def handle_ui_selection_change(self, head, new_val):
6770

6871
self.model.push_undo(CmdType.UI_CHANGE, path=path, head=head, old_val=old_val, new_val=new_val)
6972

73+
# ... handle_add_label_head, handle_remove_label_head ...
74+
# These methods below generally don't touch the TreeView, so they are fine as is,
75+
# but I'll include them to ensure the file is complete.
76+
7077
def handle_add_label_head(self, name):
7178
clean = name.strip().replace(' ', '_').lower()
7279
if not clean or clean in self.model.label_definitions: return
@@ -145,4 +152,4 @@ def remove_custom_type(self, head, lbl):
145152
group = self.ui.classification_ui.right_panel.label_groups.get(head)
146153
if isinstance(group, DynamicSingleLabelGroup): group.update_radios(defn['labels'])
147154
else: group.update_checkboxes(defn['labels'])
148-
self.display_manual_annotation(self.main.get_current_action_path())
155+
self.display_manual_annotation(self.main.get_current_action_path())

0 commit comments

Comments
 (0)