From 9258121699a8ddade9ba97e8d8a9d09ab21902ae Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 21 Dec 2005 18:24:38 +0000 Subject: [PATCH] * src/DisplayState.py (remove_item): Add code to adjust other item's tracks after deleting an item; (move_item_down): Recursively walk the items under a given item and lower the track entry. svn: r5603 --- ChangeLog | 6 ++++++ src/DisplayState.py | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 55660c643..f9e996601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-21 Alex Roitman + * src/DisplayState.py (remove_item): Add code to adjust other + item's tracks after deleting an item; (move_item_down): + Recursively walk the items under a given item and lower the track + entry. + 2005-12-21 Richard Taylor * src/EditSource.py: fixed small mistake in display_references diff --git a/src/DisplayState.py b/src/DisplayState.py index d553edd24..a2281690a 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -242,10 +242,28 @@ class GrampsWindowManager: parent_item.pop(child_in_parent) # Adjust each item following the removed one # so that it's track is down by one on this level - # MISSING CODE HERE + for ix in range(child_in_parent,len(parent_item)): + item = parent_item[ix] + self.move_item_down(item,len(track)-1) # Rebuild menu self.build_windows_menu() + def move_item_down(self,item,index): + # This function calls children's move_item_down() method + # to subtract 1 from the children's track component given by index. + if type(item) == list: + # If this item is a branch + # move down the children except for the first one + for sub_item in item[1:]: + self.move_item_down(sub_item,index) + # return the first child + last_item = item[0] + else: + # This item is a leaf -- no children to move down + # return itself + last_item = item + last_item.track[index] -= 1 + def add_item(self,track,item): # if the item is identifiable then we need to remember # its id so that in the future we recall this window