MainFamily to MainParents

svn: r857
This commit is contained in:
Don Allingham 2002-03-24 20:57:53 +00:00
parent e352461f94
commit 507cde7298
27 changed files with 99 additions and 112 deletions

View File

@ -78,18 +78,14 @@ class ChooseParents:
self.mlabel = self.glade.get_widget("mlabel")
self.fcombo.set_popdown_strings(const.familyRelations)
if self.family and self.family == self.person.getMainFamily():
for (f,mr,fr) in self.person.getParentList():
if f == self.family:
self.mother_rel.set_text(_(mr))
self.father_rel.set_text(_(fr))
break
else:
self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth"))
else:
for (f,mr,fr) in self.person.getAltFamilyList():
if f == self.family:
self.mother_rel.set_text(_(mr))
self.father_rel.set_text(_(fr))
break
else:
self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth"))
self.glade.signal_autoconnect({
"on_motherList_select_row" : self.mother_list_select_row,
@ -261,7 +257,7 @@ class ChooseParents:
"""
if self.person not in family.getChildList():
family.addChild(self.person)
for fam in self.person.getAltFamilyList():
for fam in self.person.getParentList():
if family == fam[0]:
if mother_rel == fam[1] and father_rel == fam[2]:
return

View File

@ -374,8 +374,8 @@ class EditPerson:
index = 0
hist = 0
flist = [self.person.getMainFamily()]
for (fam,mrel,frel) in self.person.getAltFamilyList():
flist = [self.person.getMainParents()]
for (fam,mrel,frel) in self.person.getParentList():
flist.append(fam)
for fam in flist:
if fam == None:
@ -1121,11 +1121,11 @@ class EditPerson:
# Update each of the families child lists to reflect any
# change in ordering due to the new birth date
family = self.person.getMainFamily()
family = self.person.getMainParents()
if (family):
new_order = reorder_child_list(self.person,family.getChildList())
family.setChildList(new_order)
for (family, rel1, rel2) in self.person.getAltFamilyList():
for (family, rel1, rel2) in self.person.getParentList():
new_order = reorder_child_list(self.person,family.getChildList())
family.setChildList(new_order)

View File

@ -58,8 +58,8 @@ class MergePeople:
label_text = "Merge %s and %s" % (GrampsCfg.nameof(person1),GrampsCfg.nameof(person2))
self.glade.get_widget("progress").set_text(label_text)
f1 = person1.getMainFamily()
f2 = person2.getMainFamily()
f1 = person1.getMainParents()
f2 = person2.getMainParents()
name1 = GrampsCfg.nameof(person1)
death1 = person1.getDeath().getDate()
@ -311,11 +311,11 @@ class MergePeople:
self.p1.addEvent(event)
if self.glade.get_widget("bfather2").get_active():
orig_family = self.p1.getMainFamily()
orig_family = self.p1.getMainParents()
if orig_family:
orig_family.removeChild(self.p1)
source_family = self.p2.getMainFamily()
source_family = self.p2.getMainParents()
self.p1.setMainFamily(source_family)
if source_family:
@ -324,10 +324,10 @@ class MergePeople:
if self.p1 not in source_family.getChildList():
source_family.addChild(self.p1)
else:
source_family = self.p2.getMainFamily()
source_family = self.p2.getMainParents()
if source_family:
source_family.removeChild(self.p2)
self.p2.setMainFamily(None)
self.p2.setMainParents(None)
self.merge_families()
@ -429,8 +429,8 @@ class MergePeople:
for child in src_family.getChildList():
if child not in tgt_family.getChildList():
tgt_family.addChild(child)
if child.getMainFamily() == src_family:
child.setMainFamily(tgt_family)
if child.getMainParents() == src_family:
child.setMainParents(tgt_family)
else:
index = 0
for fam in child.getAltFamilies():
@ -484,8 +484,8 @@ class MergePeople:
def delete_empty_family(self,family):
for child in family.getChildList():
if child.getMainFamily() == family:
child.setMainFamily(None)
if child.getMainParents() == family:
child.setMainParents(None)
else:
child.removeAltFamily(family)
self.db.deleteFamily(family)
@ -534,8 +534,8 @@ def compare_people(p1,p2):
if p1 in ancestors:
return -1.0
f1 = p1.getMainFamily()
f2 = p2.getMainFamily()
f1 = p1.getMainParents()
f2 = p2.getMainParents()
if f1 and f1.getFather():
dad1 = f1.getFather().getPrimaryName()
@ -778,7 +778,7 @@ def ancestors_of(p1,list):
if p1 == None:
return
list.append(p1)
f1 = p1.getMainFamily()
f1 = p1.getMainParents()
if f1 != None:
ancestors_of(f1.getFather(),list)
ancestors_of(f1.getMother(),list)

View File

@ -382,7 +382,7 @@ class PedigreeView:
if depth > 5 or person == None:
return
(family,m,f) = person.getMainFamilyRel()
(family,m,f) = person.getMainParentsRel()
if family:
mrel = (m != "Birth")
frel = (f != "Birth")

View File

@ -1071,7 +1071,7 @@ class Person:
"""sets the attribute list to the specified list"""
self.attributeList = list
def getAltFamilyList(self):
def getParentList(self):
"""returns the list of alternate Family instances, in which the Person
is a child of the family, but not a natural child of both parents"""
return self.AltFamilyList
@ -1085,9 +1085,7 @@ class Person:
def removeAltFamily(self,family):
"""removes a Family instance from the alternate family list"""
for f in self.AltFamilyList[:]:
print "+",f[0],family
if f[0] == family:
print f, family
self.AltFamilyList.remove(f)
return f
else:
@ -1100,7 +1098,7 @@ class Person:
else:
return None
def setMainFamily(self,family):
def setMainParents(self,family):
"""sets the main Family of the Person, the Family in which the
Person is a natural born child"""
assert(family in self.AltFamilyList)
@ -1108,7 +1106,7 @@ class Person:
if f:
self.AltFamilyList = [f] + self.AltFamilyList
def getMainFamily(self):
def getMainParents(self):
"""returns the main Family of the Person, the Family in which the
Person is a natural born child"""
if len(self.AltFamilyList) == 0:
@ -1116,7 +1114,7 @@ class Person:
else:
return self.AltFamilyList[0][0]
def getMainFamilyRel(self):
def getMainParentsRel(self):
"""returns the main Family of the Person, the Family in which the
Person is a natural born child"""
if len(self.AltFamilyList) == 0:

View File

@ -113,7 +113,7 @@ class SelectChild:
dday = self.person.getDeath().getDateObj()
slist = []
for f in [self.person.getMainFamily()] + self.person.getFamilyList():
for f in self.person.getParentList():
if f:
if f.getFather():
slist.append(f.getFather())
@ -125,7 +125,7 @@ class SelectChild:
person_list = []
for person in self.db.getPersonMap().values():
if filter:
if person in slist or person.getMainFamily():
if person in slist or person.getMainParents():
continue
pdday = person.getDeath().getDateObj()

View File

@ -250,7 +250,7 @@ class XmlWriter:
self.write_attribute_list(person.getAttributeList())
self.write_url_list(person.getUrlList())
for alt in person.getAltFamilyList():
for alt in person.getParentList():
if alt[1] != "Birth":
mrel=' mrel="%s"' % alt[1]
else:

View File

@ -29,7 +29,7 @@ class HaveAltFamilies(Filter.Filter):
"People who were adopted"
def match(self,person):
return len(person.getAltFamilyList()) > 1
return len(person.getParentList()) > 1
Filter.register_filter(HaveAltFamilies,

View File

@ -29,7 +29,7 @@ class Disconnected(Filter.Filter):
"Disconnected individuals"
def match(self,person):
return person.getMainFamily() == None and len(person.getFamilyList()) == 0
return person.getMainParents() == None and len(person.getFamilyList()) == 0
#------------------------------------------------------------------------
#

View File

@ -842,7 +842,7 @@ class Gramps:
else:
family.setMother(None)
family = self.active_person.getMainFamily()
family = self.active_person.getMainParents()
if family:
family.removeChild(self.active_person)
@ -1312,7 +1312,7 @@ class Gramps:
def on_preferred_fam_toggled(self,obj):
obj.set_active(0)
self.active_person.setMainFamily(self.active_parents)
self.active_person.setMainParents(self.active_parents)
self.change_parents(self.active_parents)
Utils.modified()
@ -1403,10 +1403,10 @@ class Gramps:
self.person_text.set_text(GrampsCfg.nameof(self.active_person))
if self.active_person:
main_family = self.active_person.getMainFamily()
main_family = self.active_person.getMainParents()
self.active_parents = main_family
self.parents_index = 0
family_types = self.active_person.getAltFamilyList()
family_types = self.active_person.getParentList()
if self.active_parents == None and len(family_types) > 0:
self.active_parents = family_types[0][0]
@ -1497,8 +1497,8 @@ class Gramps:
pframe = self.gtop.get_widget('parent_frame')
if self.active_parents:
val = len(self.active_person.getAltFamilyList())
if self.active_parents == self.active_person.getMainFamily():
val = len(self.active_person.getParentList())
if self.active_parents == self.active_person.getMainParents():
self.gtop.get_widget('preffam').set_sensitive(0)
if val > 1:
pframe.set_label(_("Preferred Parents (%d of %d)") % \
@ -1540,7 +1540,7 @@ class Gramps:
else :
fv_mother.set_text("")
mother_next.set_sensitive(0)
for f in self.active_person.getAltFamilyList():
for f in self.active_person.getParentList():
if f[0] == family:
self.gtop.get_widget("mrel").set_text(_(f[1]))
self.gtop.get_widget("frel").set_text(_(f[2]))
@ -1603,15 +1603,12 @@ class Gramps:
gender = const.female
else:
gender = const.unknown
if child.getMainFamily() == family:
status = _("Birth")
else:
for fam in child.getAltFamilyList():
if fam[0] == family:
if self.active_person == family.getFather():
status = "%s/%s" % (_(fam[2]),_(fam[1]))
else:
status = "%s/%s" % (_(fam[1]),_(fam[2]))
for fam in child.getParentList():
if fam[0] == family:
if self.active_person == family.getFather():
status = "%s/%s" % (_(fam[2]),_(fam[1]))
else:
status = "%s/%s" % (_(fam[1]),_(fam[2]))
if GrampsCfg.show_detail:
attr = ""
@ -1839,7 +1836,7 @@ class Gramps:
def family_up_clicked(self,obj):
if self.active_parents == None:
return
flist = self.active_person.getAltFamilyList()
flist = self.active_person.getParentList()
if self.parents_index == 0:
self.parents_index = len(flist)-1
else:
@ -1850,7 +1847,7 @@ class Gramps:
def family_down_clicked(self,obj):
if self.active_parents == None:
return
flist = self.active_person.getAltFamilyList()
flist = self.active_person.getParentList()
if self.parents_index == len(flist)-1:
self.parents_index = 0
else:

View File

@ -114,7 +114,7 @@ class AncestorChart:
self.lines = max(self.lines,len(self.text[index]))
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
self.filter(family.getFather(),index*2)
self.filter(family.getMother(),(index*2)+1)

View File

@ -68,7 +68,7 @@ class AncestorReport(Report):
return
self.map[index] = person
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
self.filter(family.getFather(),index*2)
self.filter(family.getMother(),(index*2)+1)

View File

@ -74,9 +74,9 @@ class CheckIntegrity:
family_list = self.db.getFamilyMap().values()[:]
for family in family_list:
for child in family.getChildList():
if family == child.getMainFamily():
if family == child.getMainParents():
continue
for family_type in child.getAltFamilyList():
for family_type in child.getParentList():
if family_type[0] == family:
break
else:
@ -110,10 +110,7 @@ class CheckIntegrity:
def delete_empty_family(self,family):
for child in self.db.getPersonMap().values():
if child.getMainFamily() == family:
child.setMainFamily(None)
else:
child.removeAltFamily(family)
child.removeAltFamily(family)
self.db.deleteFamily(family)
#-------------------------------------------------------------------------

View File

@ -69,7 +69,7 @@ class DetAncestorReport(Report):
return
self.map[index] = person
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
self.filter(family.getFather(),index*2)
self.filter(family.getMother(),(index*2)+1)
@ -265,7 +265,7 @@ class DetAncestorReport(Report):
t= ""
def write_parents(self, person, firstName):
ext_family= person.getMainFamily()
ext_family= person.getMainParents()
if ext_family != None:
if ext_family.getFather() != None:
father= ext_family.getFather().getPrimaryName().getRegularName()

View File

@ -168,7 +168,7 @@ class FamilyGroup:
self.doc.end_cell()
self.doc.end_row()
family = person.getMainFamily()
family = person.getMainParents()
if family == None or family.getFather() == None:
father_name = ""
else:

View File

@ -77,7 +77,7 @@ def calc_gen( person, gen):
done[ id ] = TRUE
# going into the past...
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
father = family.getFather()
mother = family.getMother()
@ -164,7 +164,7 @@ def report(database,person):
b = boxes[i]
id = b[3]
person = personList[id]
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
father = family.getFather()
f=""

View File

@ -45,7 +45,7 @@ def ancestor_filter(database,person,list,generations):
if generations <= 1:
return
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
ancestor_filter(database,family.getFather(),list,generations-1)
ancestor_filter(database,family.getMother(),list,generations-1)
@ -239,7 +239,7 @@ def report(database,person):
#------------------------------------------------------------------------
def dump_person(person_list,file):
for person in person_list:
family = person.getMainFamily()
family = person.getMainParents()
if family == None:
continue
father = family.getFather()

View File

@ -247,7 +247,7 @@ class IndivSummary:
self.d.end_cell()
self.d.end_row()
family = self.person.getMainFamily()
family = self.person.getMainParents()
if family:
father_inst = family.getFather()
if father_inst:

View File

@ -54,7 +54,7 @@ def ancestors_of(p1,list):
if p1 == None or p1 in list:
return
list.append(p1)
f1 = p1.getMainFamily()
f1 = p1.getMainParents()
if f1 != None:
ancestors_of(f1.getFather(),list)
ancestors_of(f1.getMother(),list)
@ -431,8 +431,8 @@ class Merge:
if p1 in ancestors:
return -1
f1 = p1.getMainFamily()
f2 = p2.getMainFamily()
f1 = p1.getMainParents()
f2 = p2.getMainParents()
if f1 and f2:
dad1 = get_name_obj(f1.getFather())

View File

@ -488,15 +488,15 @@ class GedcomParser:
child = self.db.findPerson(matches[2],self.pmap)
self.family.addChild(child)
for f in child.getAltFamilyList():
for f in child.getParentList():
if f[0] == self.family:
break
else:
if (mrel=="Birth" or mrel=="") and (frel=="Birth" or frel==""):
child.setMainFamily(self.family)
child.setMainParents(self.family)
else:
if child.getMainFamily() == self.family:
child.setMainFamily(None)
if child.getMainParents() == self.family:
child.setMainParents(None)
child.addAltFamily(self.family,mrel,frel)
elif matches[1] == "NCHI":
a = Attribute()
@ -627,18 +627,18 @@ class GedcomParser:
type,note = self.parse_famc_type(2)
family = self.db.findFamily(matches[2],self.fmap)
for f in self.person.getAltFamilyList():
for f in self.person.getParentList():
if f[0] == family:
break
else:
if type == "" or type == "Birth":
if self.person.getMainFamily() == None:
self.person.setMainFamily(family)
if self.person.getMainParents() == None:
self.person.setMainParents(family)
else:
self.person.addAltFamily(family,"Unknown","Unknown")
else:
if self.person.getMainFamily() == family:
self.person.setMainFamily(None)
if self.person.getMainParents() == family:
self.person.setMainParents(None)
self.person.addAltFamily(family,type,type)
elif matches[1] == "RESI":
addr = Address()
@ -1108,8 +1108,8 @@ class GedcomParser:
elif matches[1] == "FAMC":
family = self.db.findFamily(matches[2],self.fmap)
mrel,frel = self.parse_adopt_famc(level+1);
if self.person.getMainFamily() == family:
self.person.setMainFamily(None)
if self.person.getMainParents() == family:
self.person.setMainParents(None)
self.person.addAltFamily(family,mrel,frel)
elif matches[1] == "PLAC":
val = matches[2]

View File

@ -44,7 +44,7 @@ def filter(person,index,list,map):
list.append(person)
map[person] = index
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
filter(family.getFather(),index+1,list,map)
filter(family.getMother(),index+1,list,map)

View File

@ -78,7 +78,7 @@ def report(database,person):
name = person.getPrimaryName()
if name.getFirstName() == "" or name.getSurname() == "":
incomp_names = incomp_names + 1
if person.getMainFamily() == None and len(person.getFamilyList()) == 0:
if person.getMainParents() == None and len(person.getFamilyList()) == 0:
disconnected = disconnected + 1
if person.getBirth().getDate() == "":
missing_bday = missing_bday + 1

View File

@ -157,7 +157,7 @@ def on_apply_clicked(obj):
waswidstr = " was a widow "
# multiple parentage check
if( len(person.getAltFamilyList()) > 1 ):
if( len(person.getParentList()) > 1 ):
warn = "%sMultiple parentage %s.\n" % (warn, idstr)
# marriage checks

View File

@ -239,7 +239,7 @@ class IndividualPage:
else:
self.write_normal_row("%s:" % _("Gender"), _("Female"),None)
family = self.person.getMainFamily()
family = self.person.getMainParents()
if family:
self.write_link_row("%s:" % _("Father"), family.getFather())
self.write_link_row("%s:" % _("Mother"), family.getMother())
@ -564,7 +564,7 @@ def ancestor_filter(database,person,list,generations):
if generations <= 1:
return
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
ancestor_filter(database,family.getFather(),list,generations-1)
ancestor_filter(database,family.getMother(),list,generations-1)
@ -616,13 +616,13 @@ def an_des_of_gparents_filter(database,person,list,generations):
my_list = []
family = person.getMainFamily()
family = person.getMainParents()
if family == None:
return
for p in [ family.getMother(), family.getFather() ]:
if p:
pf = p.getMainFamily()
pf = p.getMainParents()
if pf:
if pf.getFather():
my_list.append(pf.getFather())

View File

@ -136,7 +136,7 @@ def ancestors(person,plist,flist,slist,private):
return
plist.append(person)
add_persons_sources(person,slist,private)
family = person.getMainFamily()
family = person.getMainParents()
if family == None or family in flist:
return
add_familys_sources(family,slist,private)
@ -156,8 +156,8 @@ def walk(person,plist,flist,slist,private):
plist.append(person)
add_persons_sources(person,slist,private)
families = person.getFamilyList()
families.append(person.getMainFamily())
for f in person.getAltFamilyList():
families.append(person.getMainParents())
for f in person.getParentList():
families.append(f[0])
for family in families:
if family == None or family in flist:
@ -626,17 +626,17 @@ class GedcomWriter:
for person in family.getChildList():
self.g.write("1 CHIL @%s@\n" % self.pid(person.getId()))
if self.adopt == ADOPT_FTW:
if person.getMainFamily() == family:
if person.getMainParents() == family:
self.g.write('2 _FREL Natural\n')
self.g.write('2 _MREL Natural\n')
else:
for f in person.getAltFamilyList():
for f in person.getParentList():
if f[0] == family:
self.g.write('2 _FREL %s\n' % f[2])
self.g.write('2 _MREL %s\n' % f[1])
break
if self.adopt == ADOPT_LEGACY:
for f in person.getAltFamilyList():
for f in person.getAltParentList():
if f[0] == family:
self.g.write('2 _STAT %s\n' % f[2])
break
@ -722,7 +722,7 @@ class GedcomWriter:
ad = 1
self.g.write('1 ADOP\n')
fam = None
for f in person.getAltFamilyList():
for f in person.getParentList():
mrel = string.lower(f[1])
frel = string.lower(f[2])
if mrel=="adopted" or mrel=="adopted":
@ -745,10 +745,10 @@ class GedcomWriter:
self.dump_event_stats(event)
if self.adopt == ADOPT_EVENT and ad == 0 and len(person.getAltFamilyList()) != 0:
if self.adopt == ADOPT_EVENT and ad == 0 and len(person.getParentList()) != 0:
self.g.write('1 ADOP\n')
fam = None
for f in person.getAltFamilyList():
for f in person.getParentList():
mrel = string.lower(f[1])
frel = string.lower(f[2])
if mrel=="adopted" or mrel=="adopted":
@ -810,11 +810,11 @@ class GedcomWriter:
for srcref in addr.getSourceRefList():
self.write_source_ref(3,srcref)
family = person.getMainFamily()
family = person.getMainParents()
if family != None and family in self.flist:
self.g.write("1 FAMC @%s@\n" % self.fid(family.getId()))
for family in person.getAltFamilyList():
for family in person.getParentList():
self.g.write("1 FAMC @%s@\n" % self.fid(family[0].getId()))
if self.adopt == ADOPT_PEDI:
if string.lower(family[1]) == "adopted":

View File

@ -159,7 +159,7 @@ def ancestors(person):
return
people_list.append(person)
add_persons_sources(person)
family = person.getMainFamily()
family = person.getMainParents()
if family == None or family in family_list:
return
add_familys_sources(family)
@ -178,8 +178,7 @@ def walk(person):
people_list.append(person)
add_persons_sources(person)
families = person.getFamilyList()
families.append(person.getMainFamily())
for f in person.getAltFamilyList():
for f in person.getAltParentList():
families.append(f[0])
for family in families:
if family == None or family in family_list:
@ -408,8 +407,8 @@ def exportData(database, filename):
data = data + write_16_bit( get_year(person.getBirth()) )
data = data + write_16_bit( get_year(person.getDeath()) )
if person.getMainFamily() != None:
data = data + write_16_bit( fid_to_record[person.getMainFamily().getId()] )
if person.getMainParents() != None:
data = data + write_16_bit( fid_to_record[person.getMainParents().getId()] )
else:
data = data + "\xff\xff"

View File

@ -61,7 +61,7 @@ def report(database,person):
temp = thisgen
thisgen = []
for person in temp:
family = person.getMainFamily()
family = person.getMainParents()
if family != None:
father = family.getFather()
mother = family.getMother()