From 249bb2f461db826b51760bd4d287a647f037fcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20S=C3=A1nchez?= Date: Sun, 27 Feb 2005 18:56:31 +0000 Subject: [PATCH] * src/MergeData.py: preserve most data while merging families * src/PeopleView.py: allow multiple selection in people list * src/ReadGedcom.py: keep source information in families * src/RelLib.py svn: r4100 --- gramps2/ChangeLog | 6 +++ gramps2/src/MergeData.py | 88 ++++++++++++++++++++++++++------------- gramps2/src/PeopleView.py | 1 + gramps2/src/ReadGedcom.py | 5 ++- 4 files changed, 71 insertions(+), 29 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b66ec364a..79e1112d8 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-02-27 Julio Sanchez + * src/MergeData.py: preserve most data while merging families + * src/PeopleView.py: allow multiple selection in people list + * src/ReadGedcom.py: keep source information in families + * src/RelLib.py + 2005-02-26 Don Allingham * src/AddrEdit.py: update main source list after source addition * src/AttrEdit.py: update main source list after source addition diff --git a/gramps2/src/MergeData.py b/gramps2/src/MergeData.py index de264795a..d66f2b05e 100644 --- a/gramps2/src/MergeData.py +++ b/gramps2/src/MergeData.py @@ -379,6 +379,64 @@ class MergePeople: return myfamily return None + def merge_family_pair(self,tgt_family,src_family): + + # copy children from source to target + + for child in src_family.get_child_handle_list(): + if child not in tgt_family.get_child_handle_list(): + parents = child.get_parent_family_handle_list() + tgt_family.add_child_handle(child) + if child.get_main_parents_family_handle() == src_family: + child.set_main_parent_family_handle(tgt_family) + i = 0 + for fam in parents[:]: + if fam[0] == src_family: + parents[i] = (tgt_family,fam[1],fam[2]) + i = i + 1 + + # merge family events + + lst = tgt_family.get_event_list()[:] + for xdata in src_family.get_event_list(): + for data in lst: + if data.are_equal(xdata): + self.copy_note(data,xdata) + self.copy_sources(data,xdata) + break + else: + tgt_family.add_event(xdata) + + # merge family attributes + + lst = tgt_family.get_attribute_list()[:] + for xdata in src_family.get_attribute_list(): + for data in lst: + if data.get_type() == xdata.get_type() and \ + data.getValue() == xdata.get_value(): + self.copy_note(data,xdata) + self.copy_sources(data,xdata) + break + else: + tgt_family.add_attribute(xdata) + + # merge family notes + + if src_family.get_note() != "": + old_note = tgt_family.get_note() + if old_note: + old_note = old_note + "\n\n" + tgt_family.set_note(old_note + src_family.get_note()) + + # merge family top-level sources + + self.copy_sources(tgt_family,src_family) + + # merge multimedia objects + + for photo in src_family.get_media_list(): + tgt_family.add_media_reference(photo) + def merge_families(self): family_num = 0 @@ -409,19 +467,7 @@ class MergePeople: src_family in tgt_family.get_mother_handle().get_family_handle_list(): tgt_family.get_mother_handle().remove_family_handle(src_family) - # copy children from source to target - - for child in src_family.get_child_handle_list(): - if child not in tgt_family.get_child_handle_list(): - parents = child.get_parent_family_handle_list() - tgt_family.add_child_handle(child) - if child.get_main_parents_family_handle() == src_family: - child.set_main_parent_family_handle(tgt_family) - i = 0 - for fam in parents[:]: - if fam[0] == src_family: - parents[i] = (tgt_family,fam[1],fam[2]) - i = i + 1 + self.merge_family_pair(tgt_family,src_family) # delete the old source family del self.db.get_family_handle_map()[src_family.get_handle()] @@ -440,21 +486,7 @@ class MergePeople: # transfer child to new family, alter children to # point to the correct family - for child in src_family.get_child_handle_list(): - if child not in tgt_family.get_child_handle_list(): - parents = child.get_parent_family_handle_list() - tgt_family.add_child_handle(child) - if child.get_main_parents_family_handle() == src_family: - child.set_main_parent_family_handle(tgt_family) - i = 0 - for fam in parents[:]: - if fam[0] == src_family: - parents[i] = (tgt_family,fam[1],fam[2]) - i = i + 1 - - # add family events from the old to the new - for event in src_family.get_event_list(): - tgt_family.add_event(event) + self.merge_family_pair(tgt_family,src_family) # change parents of the family to point to the new # family diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index 05f7a7e5b..687acf582 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -81,6 +81,7 @@ class PeopleView: self.columns = [] self.build_columns() self.person_selection = self.person_tree.get_selection() + self.person_selection.set_mode(gtk.SELECTION_MULTIPLE) self.person_selection.connect('changed',self.row_changed) self.person_tree.connect('row_activated', self.alpha_event) self.person_tree.connect('button-press-event', diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index 0243518d4..a29e0fbc7 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -823,7 +823,10 @@ class GedcomParser: a.set_type("Number of Children") a.set_value(matches[2]) self.family.add_attribute(a) - elif matches[1] in ["RIN", "SUBM", "REFN","CHAN","SOUR"]: + elif matches[1] == "SOUR": + source_ref = self.handle_source(matches,2) + self.family.add_source_reference(source_ref) + elif matches[1] in ["RIN", "SUBM", "REFN","CHAN"]: self.ignore_sub_junk(2) elif matches[1] == "OBJE": if matches[2] and matches[2][0] == '@':