From b20db2bf8c4972958b7647c24c05b721352ebec7 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 6 Mar 2006 20:59:00 +0000 Subject: [PATCH] family drag-n-drop support svn: r6091 --- ChangeLog | 4 ++++ src/Editors/_EditFamily.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ChangeLog b/ChangeLog index d884d2ccc..a8f002584 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-03-06 Don Allingham + * src/Editors/_EditFamily.py: handle the fact that family + information is not a simple list. + 2006-03-05 Don Allingham * src/Editors/_EditEventRef.py: add vs. commit handling * src/Editors/_EditPerson.py: handle None as person diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index ab73c1c27..578dbf14f 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -106,6 +106,35 @@ class ChildEmbedList(EmbeddedList): EmbeddedList.__init__(self, dbstate, uistate, track, _('Children'), ChildModel) + def find_index(self,obj): + """ + returns the index of the object within the associated data + """ + return self.family.get_child_handle_list().index(obj) + + def _find_row(self,x,y): + row = self.tree.get_path_at_pos(x,y) + if row == None: + return len(self.family.get_child_handle_list()) + else: + return row[0][0] + + def _handle_drag(self, row, obj): + self.family.get_child_handle_list().insert(row,obj) + self.changed = True + self.rebuild() + + def _move(self, row_from, row_to, obj): + dlist = self.family.get_child_handle_list() + if row_from < row_to: + dlist.insert(row_to,obj) + del dlist[row_from] + else: + del dlist[row_from] + dlist.insert(row_to-1,obj) + self.changed = True + self.rebuild() + def build_columns(self): """ We can't use the default build_columns in the base class, because