Skip to content

Commit b9accc0

Browse files
Update localization_manager.py
Adapt to new /models
1 parent 42b8223 commit b9accc0

1 file changed

Lines changed: 1 addition & 23 deletions

File tree

annotation_tool/controllers/localization/localization_manager.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from PyQt6.QtGui import QColor
66
from PyQt6.QtMultimedia import QMediaPlayer
77

8-
# [Refactor] Updated imports based on new structure recommendations
9-
# If you haven't moved files yet, change these imports back to where they are.
108
from utils import natural_sort_key
119
from models import CmdType
1210
# Assuming ProjectTreeModel is accessible via main_window or imports if needed for type hinting
@@ -20,8 +18,6 @@ def __init__(self, main_window):
2018
self.main = main_window
2119
self.model = main_window.model
2220

23-
# [MV] Access the shared Tree Model created in viewer.py
24-
# Ensure viewer.py initializes: self.tree_model = ProjectTreeModel(self)
2521
self.tree_model = main_window.tree_model
2622

2723
self.ui_root = main_window.ui.localization_ui
@@ -98,7 +94,6 @@ def _on_media_position_changed(self, ms):
9894
self.right_panel.annot_mgmt.tabs.update_current_time(time_str)
9995

10096
# --- Head Management (Tab Operations) ---
101-
# ... (Kept as is, these logic parts are fine) ...
10297
def _on_head_selected(self, head_name):
10398
self.current_head = head_name
10499

@@ -420,10 +415,6 @@ def _remove_single_video(self, path, index):
420415
# ----------------------------------------------
421416

422417
def populate_tree(self):
423-
"""
424-
[MV] Re-populates the tree model entirely from action_item_data.
425-
Useful when loading a full JSON project.
426-
"""
427418
# Block signals on the VIEW, not the widget (though View inherits Widget)
428419
self.left_panel.tree.blockSignals(True)
429420

@@ -469,14 +460,11 @@ def populate_tree(self):
469460
self.left_panel.tree.blockSignals(False)
470461

471462
def refresh_tree_icons(self):
472-
"""[MV] Efficiently update icons without rebuilding tree."""
473463
for path, item in self.model.action_item_map.items():
474464
events = self.model.localization_events.get(path, [])
475465
item.setIcon(self.main.done_icon if events else self.main.empty_icon)
476466

477467
def _apply_clip_filter(self, combo_index):
478-
# [MV] QTreeView uses setRowHidden.
479-
# Note: Ideally use QSortFilterProxyModel, but iterating rows works for simple cases.
480468
root = self.tree_model.invisibleRootItem()
481469
for i in range(root.rowCount()):
482470
item = root.child(i)
@@ -487,13 +475,10 @@ def _apply_clip_filter(self, combo_index):
487475
should_hide = False
488476
if combo_index == 1 and not has_anno: should_hide = True # Show Labelled
489477
elif combo_index == 2 and has_anno: should_hide = True # Show No Labelled
490-
478+
491479
self.left_panel.tree.setRowHidden(i, QModelIndex(), should_hide)
492480

493481
def on_clip_selected(self, current_idx, previous_idx):
494-
"""
495-
[MV] Slot for QItemSelectionModel.currentChanged
496-
"""
497482
if not current_idx.isValid():
498483
self.current_video_path = None
499484
return
@@ -510,7 +495,6 @@ def on_clip_selected(self, current_idx, previous_idx):
510495
else:
511496
if path: QMessageBox.warning(self.main, "Error", f"File not found: {path}")
512497

513-
# ... [Rest of methods like _display_events_for_item, _navigate_clip need minimal adjustments] ...
514498

515499
def _display_events_for_item(self, path):
516500
# Unchanged
@@ -527,20 +511,14 @@ def _display_events_for_item(self, path):
527511
self.center_panel.timeline.set_markers(markers)
528512

529513
def _navigate_clip(self, step):
530-
# [MV] Navigate based on Visible rows in View
531514
tree = self.left_panel.tree
532515
curr_idx = tree.currentIndex()
533516
if not curr_idx.isValid(): return
534517

535-
# Simplified navigation logic for MV
536-
# We can just move selection up/down using the View's native methods or loop indices
537518
next_idx = tree.indexBelow(curr_idx) if step > 0 else tree.indexAbove(curr_idx)
538519

539-
# Check if we should skip hidden items (indexBelow usually handles visual order)
540520
if next_idx.isValid():
541521
tree.setCurrentIndex(next_idx)
542-
543-
# _navigate_annotation, _select_row_by_time, _fmt_ms ... Unchanged
544522
def _navigate_annotation(self, step):
545523
if not self.current_video_path: return
546524
events = self.model.localization_events.get(self.current_video_path, [])

0 commit comments

Comments
 (0)