refactor: update path display to derive breadcrumbs from current_path instead of tree selection
This commit is contained in:
@@ -1143,36 +1143,37 @@ class SharePointApp(wx.Frame):
|
||||
self.update_path_display()
|
||||
|
||||
def update_path_display(self):
|
||||
if not self:
|
||||
return
|
||||
|
||||
if not self: return
|
||||
try:
|
||||
self.path_sizer.Clear(True)
|
||||
|
||||
# Find alle noder fra rod til nuværende selektion
|
||||
nodes = []
|
||||
curr = self.tree_ctrl.GetSelection()
|
||||
|
||||
while curr.IsOk() and curr != self.tree_root:
|
||||
nodes.insert(0, curr)
|
||||
curr = self.tree_ctrl.GetItemParent(curr)
|
||||
|
||||
# Start ikon/label
|
||||
self._add_path_segment("📍 " + self.get_txt("title"), "ROOT")
|
||||
|
||||
for node in nodes:
|
||||
# Vis stien fra self.current_path
|
||||
path_segments = self.current_path[1:] if self.current_path and self.current_path[0] == "SharePoint" else self.current_path
|
||||
|
||||
# Prøv at finde matchende noder i træet for at gøre brødkrummerne klikbare
|
||||
curr_node = self.tree_root
|
||||
for name in path_segments:
|
||||
arrow = wx.StaticText(self.path_panel, label=" > ")
|
||||
arrow.SetForegroundColour(wx.Colour(150, 150, 150))
|
||||
self.path_sizer.Add(arrow, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
|
||||
name = self.tree_ctrl.GetItemText(node)
|
||||
self._add_path_segment(name, node)
|
||||
found_node = None
|
||||
if curr_node:
|
||||
child, cookie = self.tree_ctrl.GetFirstChild(curr_node)
|
||||
while child.IsOk():
|
||||
if self.tree_ctrl.GetItemText(child) == name:
|
||||
found_node = child
|
||||
break
|
||||
child, cookie = self.tree_ctrl.GetNextChild(curr_node, cookie)
|
||||
|
||||
self._add_path_segment(name, found_node)
|
||||
curr_node = found_node # Fortsæt ned i træet hvis muligt
|
||||
|
||||
self.path_panel.Layout()
|
||||
self.path_panel.Refresh()
|
||||
self.Layout() # Tving rammen til at opdatere, så stien kommer frem
|
||||
self.Layout()
|
||||
except RuntimeError:
|
||||
# Sker oftest ved lukning hvor objekter er slettet
|
||||
pass
|
||||
|
||||
def _add_path_segment(self, label, node):
|
||||
|
||||
Reference in New Issue
Block a user