@@ -64,6 +64,16 @@ def __init__(
6464 self ._tempfile = tempfile
6565 self .core_name = core_name
6666
67+ self ._tab_widget = parent
68+
69+ def __tab_widget__ (self ):
70+ """Return the tab widget which contains this workbox
71+
72+ Returns:
73+ GroupedTabWidget: The tab widget which contains this workbox
74+ """
75+ return self ._tab_widget
76+
6777 def __auto_complete_enabled__ (self ):
6878 raise NotImplementedError ("Mixin method not overridden." )
6979
@@ -189,7 +199,57 @@ def __workbox_trace_title__(self, selection=False):
189199 if group == - 1 or editor == - 1 :
190200 return '<{}>' .format (title )
191201 else :
192- return '<{}>:{},{}' .format (title , group , editor )
202+ name = self .__workbox_name__ ()
203+ return '<{}>:{}' .format (title , name )
204+
205+ def __workbox_name__ (self , workbox = None ):
206+ """Returns the name for this workbox or a given workbox.
207+ The name is the group tab text and the workbox tab text joined by a `/`"""
208+ workboxTAB = self .window ().uiWorkboxTAB
209+ group_name = None
210+ workbox_name = None
211+
212+ if workbox :
213+ grouped_tab_widget = workbox .__tab_widget__ ()
214+ for group_idx in range (workboxTAB .count ()):
215+ # If a previous iteration determine workbox_name, bust out
216+ if workbox_name :
217+ break
218+ # Check if current group is the workboxes parent group
219+ cur_group_widget = workboxTAB .widget (group_idx )
220+ if cur_group_widget == grouped_tab_widget :
221+ group_name = workboxTAB .tabText (group_idx )
222+
223+ # Found the group, now find workbox
224+ for workbox_idx in range (cur_group_widget .count ()):
225+ cur_workbox_widget = cur_group_widget .widget (workbox_idx )
226+ if cur_workbox_widget == workbox :
227+ workbox_name = cur_group_widget .tabText (workbox_idx )
228+ break
229+ else :
230+ grouped = self .__tab_widget__ ()
231+ groupedTabBar = grouped .tabBar ()
232+
233+ idx = - 1
234+ for idx in range (grouped .count ()):
235+ if grouped .widget (idx ) == self :
236+ break
237+ workbox_name = groupedTabBar .tabText (idx )
238+
239+ group = grouped .tab_widget ()
240+ groupTabBar = group .tabBar ()
241+ idx = - 1
242+ for idx in range (group .count ()):
243+ if group .widget (idx ) == grouped :
244+ break
245+ group_name = groupTabBar .tabText (idx )
246+
247+ # If both found, construct workbox name
248+ if group_name and workbox_name :
249+ name = WorkboxName (group_name , workbox_name )
250+ else :
251+ name = WorkboxName ("" , "" )
252+ return name
193253
194254 def __goto_line__ (self , line ):
195255 raise NotImplementedError ("Mixin method not overridden." )
0 commit comments