* 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
This commit is contained in:
Julio Sánchez 2005-02-27 18:56:31 +00:00
parent ca2f90e4d0
commit c24d8ba944
4 changed files with 71 additions and 29 deletions

View File

@ -1,3 +1,9 @@
2005-02-27 Julio Sanchez <jsanchez@users.sourceforge.net>
* 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 <dallingham@users.sourceforge.net> 2005-02-26 Don Allingham <dallingham@users.sourceforge.net>
* src/AddrEdit.py: update main source list after source addition * src/AddrEdit.py: update main source list after source addition
* src/AttrEdit.py: update main source list after source addition * src/AttrEdit.py: update main source list after source addition

View File

@ -379,6 +379,64 @@ class MergePeople:
return myfamily return myfamily
return None 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): def merge_families(self):
family_num = 0 family_num = 0
@ -409,19 +467,7 @@ class MergePeople:
src_family in tgt_family.get_mother_handle().get_family_handle_list(): src_family in tgt_family.get_mother_handle().get_family_handle_list():
tgt_family.get_mother_handle().remove_family_handle(src_family) tgt_family.get_mother_handle().remove_family_handle(src_family)
# copy children from source to target self.merge_family_pair(tgt_family,src_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
# delete the old source family # delete the old source family
del self.db.get_family_handle_map()[src_family.get_handle()] 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 # transfer child to new family, alter children to
# point to the correct family # point to the correct family
for child in src_family.get_child_handle_list(): self.merge_family_pair(tgt_family,src_family)
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)
# change parents of the family to point to the new # change parents of the family to point to the new
# family # family

View File

@ -81,6 +81,7 @@ class PeopleView:
self.columns = [] self.columns = []
self.build_columns() self.build_columns()
self.person_selection = self.person_tree.get_selection() 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_selection.connect('changed',self.row_changed)
self.person_tree.connect('row_activated', self.alpha_event) self.person_tree.connect('row_activated', self.alpha_event)
self.person_tree.connect('button-press-event', self.person_tree.connect('button-press-event',

View File

@ -823,7 +823,10 @@ class GedcomParser:
a.set_type("Number of Children") a.set_type("Number of Children")
a.set_value(matches[2]) a.set_value(matches[2])
self.family.add_attribute(a) 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) self.ignore_sub_junk(2)
elif matches[1] == "OBJE": elif matches[1] == "OBJE":
if matches[2] and matches[2][0] == '@': if matches[2] and matches[2][0] == '@':