@@ -967,19 +967,44 @@ def editorEvent(self, event, model, option, index):
967967
968968 # Handle PureRef badge click for folders
969969 if item_type == "folder" and getattr (self , "pureref_manager" , None ):
970- folder_path = index .data (Qt .ItemDataRole .UserRole )
971- root_path = index .data (Qt .ItemDataRole .UserRole + 3 )
972- if folder_path and root_path :
973- full_folder = Path (root_path ) / folder_path
974- icon_rect = self ._get_folder_icon_rect (option .rect , index )
975- badge_rect = self .get_pureref_badge_rect (icon_rect )
976- if badge_rect .contains (QPointF (event .pos ())):
977- tree = self .parent ()
978- if tree :
979- window = tree .window ()
980- if hasattr (window , "open_pureref_for_folder" ):
981- window .open_pureref_for_folder (full_folder )
982- return True
970+ # Check if PureRef badges should be shown
971+ show_badges = self .config .get ("show_pureref_badges" , True )
972+ show_when_missing = self .config .get (
973+ "show_pureref_badges_when_missing" , False
974+ )
975+
976+ logging .debug (f"[PUREREF editorEvent] show_badges={ show_badges } , show_when_missing={ show_when_missing } " )
977+
978+ # Only process clicks if badges are enabled
979+ if show_badges :
980+ folder_path = index .data (Qt .ItemDataRole .UserRole )
981+ root_path = index .data (Qt .ItemDataRole .UserRole + 3 )
982+ if folder_path and root_path :
983+ full_folder = Path (root_path ) / folder_path
984+ has_file = self .pureref_manager .has_pur_file (full_folder )
985+ should_show_badge = has_file or show_when_missing
986+
987+ logging .debug (f"[PUREREF editorEvent] has_file={ has_file } , should_show_badge={ should_show_badge } " )
988+
989+ # Only handle clicks if badge is actually visible
990+ if should_show_badge :
991+ icon_rect = self ._get_folder_icon_rect (option .rect , index )
992+ badge_rect = self .get_pureref_badge_rect (icon_rect )
993+
994+ logging .debug (f"[PUREREF editorEvent] badge_rect={ badge_rect } , click_pos={ event .pos ()} , contains={ badge_rect .contains (QPointF (event .pos ()))} " )
995+
996+ if badge_rect .contains (QPointF (event .pos ())):
997+ logging .info (f"[PUREREF editorEvent] Opening PureRef for folder: { full_folder } " )
998+ tree = self .parent ()
999+ if tree :
1000+ window = tree .window ()
1001+ if hasattr (window , "open_pureref_for_folder" ):
1002+ window .open_pureref_for_folder (full_folder )
1003+ return True
1004+ else :
1005+ logging .debug (f"[PUREREF editorEvent] Skipped - badge should not be shown" )
1006+ else :
1007+ logging .debug (f"[PUREREF editorEvent] Skipped - badges disabled" )
9831008
9841009 # Original marker logic
9851010 marker = self .get_marker_at_pos (option .rect , event .pos (), index )
@@ -1459,18 +1484,30 @@ def mouseMoveEvent(self, event):
14591484
14601485 visual_rect = self .visualRect (index )
14611486 if not visual_rect .isNull ():
1462- icon_rect = delegate ._get_folder_icon_rect (
1463- visual_rect , index
1487+ # Check if PureRef badge should be shown
1488+ show_badges = delegate .config .get ("show_pureref_badges" , True )
1489+ show_when_missing = delegate .config .get (
1490+ "show_pureref_badges_when_missing" , False
14641491 )
1465- badge_rect = delegate .get_pureref_badge_rect (icon_rect )
1466-
1467- # Check if mouse is over icon or badge
1468- if icon_rect .contains (
1469- QPointF (event .pos ())
1470- ) or badge_rect .contains (QPointF (event .pos ())):
1471- self .viewport ().setCursor (
1472- Qt .CursorShape .PointingHandCursor
1473- )
1492+
1493+ should_show_badge = False
1494+ if show_badges and getattr (delegate , "pureref_manager" , None ):
1495+ folder_path = index .data (Qt .ItemDataRole .UserRole )
1496+ root_path = index .data (Qt .ItemDataRole .UserRole + 3 )
1497+ if folder_path and root_path :
1498+ full_folder = Path (root_path ) / folder_path
1499+ has_file = delegate .pureref_manager .has_pur_file (full_folder )
1500+ should_show_badge = has_file or show_when_missing
1501+
1502+ # Only show hand cursor over badge when it's actually displayed
1503+ if should_show_badge :
1504+ icon_rect = delegate ._get_folder_icon_rect (visual_rect , index )
1505+ badge_rect = delegate .get_pureref_badge_rect (icon_rect )
1506+
1507+ if badge_rect .contains (QPointF (event .pos ())):
1508+ self .viewport ().setCursor (Qt .CursorShape .PointingHandCursor )
1509+ else :
1510+ self .viewport ().setCursor (Qt .CursorShape .ArrowCursor )
14741511 else :
14751512 self .viewport ().setCursor (Qt .CursorShape .ArrowCursor )
14761513
@@ -1515,42 +1552,47 @@ def mousePressEvent(self, event):
15151552 main_window .play_video_in_player (item , resume = True )
15161553 return # Stop processing to avoid standard row selection
15171554
1518- # Handle folder icon/ badge clicks
1555+ # Handle folder badge clicks (PureRef)
15191556 elif item_type == "folder" :
1520- visual_rect = self .visualRect (index )
1521- if not visual_rect .isNull ():
1522- icon_rect = delegate ._get_folder_icon_rect (visual_rect , index )
1523-
1524- # Check if PureRef badges should be shown
1525- show_badges = delegate .config .get ("show_pureref_badges" , True )
1526- show_when_missing = delegate .config .get (
1527- "show_pureref_badges_when_missing" , False
1528- )
1557+ # Check if PureRef badges should be shown FIRST
1558+ show_badges = delegate .config .get ("show_pureref_badges" , True )
1559+ show_when_missing = delegate .config .get (
1560+ "show_pureref_badges_when_missing" , False
1561+ )
15291562
1530- if show_badges and getattr (delegate , "pureref_manager" , None ):
1531- folder_path = index .data (Qt .ItemDataRole .UserRole )
1532- root_path = index .data (Qt .ItemDataRole .UserRole + 3 )
1533- if folder_path and root_path :
1534- full_folder = Path (root_path ) / folder_path
1535- has_file = delegate .pureref_manager .has_pur_file (
1536- full_folder
1537- )
1538- should_show_badge = has_file or show_when_missing
1539-
1540- if should_show_badge :
1541- badge_rect = delegate .get_pureref_badge_rect (
1542- icon_rect
1543- )
1544- # If click is on icon or badge, open PureRef
1545- if icon_rect .contains (
1546- QPointF (event .pos ())
1547- ) or badge_rect .contains (QPointF (event .pos ())):
1563+ logging .debug (f"[PUREREF CLICK] show_badges={ show_badges } , show_when_missing={ show_when_missing } " )
1564+
1565+ # Only process clicks if badges are enabled and pureref_manager exists
1566+ if show_badges and getattr (delegate , "pureref_manager" , None ):
1567+ folder_path = index .data (Qt .ItemDataRole .UserRole )
1568+ root_path = index .data (Qt .ItemDataRole .UserRole + 3 )
1569+ if folder_path and root_path :
1570+ full_folder = Path (root_path ) / folder_path
1571+ has_file = delegate .pureref_manager .has_pur_file (full_folder )
1572+ should_show_badge = has_file or show_when_missing
1573+
1574+ logging .debug (f"[PUREREF CLICK] has_file={ has_file } , should_show_badge={ should_show_badge } " )
1575+
1576+ # Only handle clicks if badge is actually visible
1577+ if should_show_badge :
1578+ visual_rect = self .visualRect (index )
1579+ if not visual_rect .isNull ():
1580+ icon_rect = delegate ._get_folder_icon_rect (visual_rect , index )
1581+ badge_rect = delegate .get_pureref_badge_rect (icon_rect )
1582+
1583+ logging .debug (f"[PUREREF CLICK] badge_rect={ badge_rect } , click_pos={ event .pos ()} , contains={ badge_rect .contains (QPointF (event .pos ()))} " )
1584+
1585+ # Only handle clicks on the badge button itself, not the folder icon
1586+ if badge_rect .contains (QPointF (event .pos ())):
1587+ logging .info (f"[PUREREF CLICK] Opening PureRef for folder: { full_folder } " )
15481588 item = self .itemFromIndex (index )
15491589 if item :
15501590 main_window = self .window ()
15511591 if hasattr (main_window , "open_pureref" ):
15521592 main_window .open_pureref (item )
15531593 return # Stop processing to avoid standard row selection
1594+ else :
1595+ logging .debug (f"[PUREREF CLICK] Skipped - badges disabled or no pureref_manager" )
15541596
15551597 super ().mousePressEvent (event )
15561598
0 commit comments