Updates to use ChildRef

svn: r6335
This commit is contained in:
Martin Hawlisch 2006-04-13 19:20:11 +00:00
parent 46ba3c97b5
commit 64a54f8de4
3 changed files with 53 additions and 43 deletions

View File

@ -1,3 +1,7 @@
2006-04-13 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DataViews/_PedigreeView.py: Adapt to changes in RelLib
* src/plugins/TestcaseGenerator.py: Adapt to changes in RelLib
2006-04-13 Don Allingham <don@gramps-project.org>
* src/DataViews/_FamilyView.py: remove bad tab

View File

@ -1117,24 +1117,28 @@ class PedigreeView(PageView.PersonNavView):
parent_families = person.get_parent_family_handle_list()
if parent_families:
(family_handle,m,f) = parent_families[0]
family_handle = parent_families[0]
else:
return
if family_handle:
mrel = m != RelLib.ChildRef.CHILD_BIRTH
frel = f != RelLib.ChildRef.CHILD_BIRTH
mrel = True
frel = True
family = self.db.get_family_from_handle(family_handle)
if family != None:
lst[index] = (person,val,family)
father_handle = family.get_father_handle()
if father_handle != None:
father = self.db.get_person_from_handle(father_handle)
self.find_tree(father,(2*index)+1,depth+1,lst,frel)
mother_handle = family.get_mother_handle()
if mother_handle != None:
mother = self.db.get_person_from_handle(mother_handle)
self.find_tree(mother,(2*index)+2,depth+1,lst,mrel)
for child_ref in family.get_child_ref_list():
if child_ref.ref == person.handle:
mrel = child_ref.mrel != RelLib.ChildRef.CHILD_BIRTH
frel = child_ref.frel != RelLib.ChildRef.CHILD_BIRTH
lst[index] = (person,val,family)
father_handle = family.get_father_handle()
if father_handle != None:
father = self.db.get_person_from_handle(father_handle)
self.find_tree(father,(2*index)+1,depth+1,lst,frel)
mother_handle = family.get_mother_handle()
if mother_handle != None:
mother = self.db.get_person_from_handle(mother_handle)
self.find_tree(mother,(2*index)+2,depth+1,lst,mrel)
def add_nav_portion_to_menu(self,menu):
"""
@ -1329,10 +1333,11 @@ class PedigreeView(PageView.PersonNavView):
item = gtk.MenuItem(_("Siblings"))
pfam_list = person.get_parent_family_handle_list()
no_siblings = 1
for (f,mrel,frel) in pfam_list:
for f in pfam_list:
fam = self.db.get_family_from_handle(f)
sib_list = fam.get_child_handle_list()
for sib_id in sib_list:
sib_list = fam.get_child_ref_list()
for sib_ref in sib_list:
sib_id = sib_ref.ref
if sib_id == person.get_handle():
continue
sib = self.db.get_person_from_handle(sib_id)
@ -1501,8 +1506,8 @@ def find_children(db,p):
childlist = []
for family_handle in p.get_family_handle_list():
family = db.get_family_from_handle(family_handle)
for child_handle in family.get_child_handle_list():
childlist.append(child_handle)
for child_ref in family.get_child_ref_list():
childlist.append(child_ref.ref)
return childlist
#-------------------------------------------------------------------------
@ -1515,7 +1520,7 @@ def find_parents(db,p):
Returns the unique list of all parents' IDs for a person.
"""
parentlist = []
for (f,mrel,frel) in p.get_parent_family_handle_list():
for f in p.get_parent_family_handle_list():
family = db.get_family_from_handle(f)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()

View File

@ -818,12 +818,13 @@ class TestcaseGenerator(Tool.Tool):
np.set_birth_ref(eref)
# some shared events
while randint(0,5) == 1:
e_h = choice(self.generated_events)
ref = RelLib.EventRef()
self.fill_object( ref)
ref.set_reference_handle(e_h)
ref.set_role( self.rand_type(Utils.event_roles))
if self.generated_events:
while randint(0,5) == 1:
e_h = choice(self.generated_events)
ref = RelLib.EventRef()
self.fill_object( ref)
ref.set_reference_handle(e_h)
ref.set_role( self.rand_type(Utils.event_roles))
person_handle = self.db.add_person(np,self.trans)
@ -898,16 +899,13 @@ class TestcaseGenerator(Tool.Tool):
(born,died) = self.person_dates[child_h]
alive_in_year = born
fam = self.db.get_family_from_handle(fam_h)
fam.add_child_handle(child_h)
child_ref = RelLib.ChildRef()
child_ref.set_reference_handle(child_h)
self.fill_object(child_ref)
fam.add_child_ref(child_ref)
self.db.commit_family(fam,self.trans)
child = self.db.get_person_from_handle(child_h)
rel1 = (RelLib.ChildRef.CHILD_BIRTH,'')
if randint(0,2) == 1:
rel1 = self.rand_type(Utils.child_relations)
rel2 = (RelLib.ChildRef.CHILD_BIRTH,'')
if randint(0,2) == 1:
rel2 = self.rand_type(Utils.child_relations)
child.add_parent_family_handle(fam_h, rel1, rel2)
child.add_parent_family_handle(fam_h)
self.db.commit_person(child,self.trans)
if randint(0,3) > 0:
self.persons_todo.append(child_h)
@ -942,7 +940,10 @@ class TestcaseGenerator(Tool.Tool):
fam.set_relationship( self.rand_type(Utils.family_relations))
else:
fam.set_relationship( (RelLib.Family.MARRIED,'') )
fam.add_child_handle(child_h)
child_ref = RelLib.ChildRef()
child_ref.set_reference_handle(child_h)
self.fill_object(child_ref)
fam.add_child_ref(child_ref)
fam_h = self.db.add_family(fam,self.trans)
self.generated_families.append(fam_h)
fam = self.db.commit_family(fam,self.trans)
@ -952,13 +953,7 @@ class TestcaseGenerator(Tool.Tool):
person2 = self.db.get_person_from_handle(person2_h)
person2.add_family_handle(fam_h)
self.db.commit_person(person2,self.trans)
rel1 = (RelLib.ChildRef.CHILD_BIRTH,'')
if randint(0,2) == 1:
rel1 = self.rand_type(Utils.child_relations)
rel2 = (RelLib.ChildRef.CHILD_BIRTH,'')
if randint(0,2) == 1:
rel2 = self.rand_type(Utils.child_relations)
child.add_parent_family_handle(fam_h, rel1, rel2)
child.add_parent_family_handle(fam_h)
self.db.commit_person(child,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -1053,6 +1048,12 @@ class TestcaseGenerator(Tool.Tool):
self.fill_object(a)
o.add_attribute( a)
if isinstance(o,RelLib.ChildRef):
if randint(0,3) == 1:
o.set_mother_relation( self.rand_type( Utils.child_relations))
if randint(0,3) == 1:
o.set_father_relation( self.rand_type( Utils.child_relations))
if issubclass(o.__class__,RelLib._DateBase.DateBase):
if randint(0,1) == 1:
(y,d) = self.rand_date()
@ -1162,7 +1163,7 @@ class TestcaseGenerator(Tool.Tool):
self.fill_object(r)
o.add_repo_reference( r)
if issubclass(o.__class__,RelLib._SourceNote.SourceNote):
if issubclass(o.__class__,RelLib._SourceBase.SourceBase):
while randint(0,1) == 1:
s = RelLib.SourceRef()
self.fill_object(s)