get_id updates

svn: r2846
This commit is contained in:
Don Allingham 2004-02-15 23:10:12 +00:00
parent f7ea6b50ff
commit 2e9976510b
6 changed files with 48 additions and 37 deletions

View File

@ -1,3 +1,7 @@
2004-02-15 Don Allingham <dallingham@users.sourceforge.net>
* src/Relationship.py: more fixes
* src/gramps_main.py: changed db on relationship calculator when db changes.
2004-02-15 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Relationship.py: More corrections.
* src/plugins/rel_ru.py: Corrections.

View File

@ -489,7 +489,7 @@ class ChooseParents:
class ModifyParents:
def __init__(self,db,person,family,family_update,full_update,parent_window=None):
def __init__(self,db,person,family_id,family_update,full_update,parent_window=None):
"""
Creates a ChoosePerson dialog box.
@ -501,12 +501,12 @@ class ModifyParents:
"""
self.db = db
self.person = person
self.family = family
self.family = self.db.find_family_from_id(family_id)
self.family_update = family_update
self.full_update = full_update
self.father = self.family.get_father_id()
self.mother = self.family.get_mother_id()
self.father = self.db.find_person_from_id(self.family.get_father_id())
self.mother = self.db.find_person_from_id(self.family.get_mother_id())
self.glade = gtk.glade.XML(const.gladeFile,"modparents","gramps")
self.top = self.glade.get_widget("modparents")
@ -523,7 +523,7 @@ class ModifyParents:
self.orig_mrel = _("Birth")
self.orig_frel = _("Birth")
for (f,mr,fr) in self.person.get_parent_family_id_list():
if f == self.family:
if f == self.family.get_id():
self.orig_mrel = _(mr)
self.orig_frel = _(fr)
@ -588,8 +588,8 @@ class ModifyParents:
mod = 0
if mother_rel != self.orig_mrel or father_rel != self.orig_frel:
self.person.remove_parent_family_id(self.family)
self.person.add_parent_family_id(self.family,mother_rel,father_rel)
self.person.remove_parent_family_id(self.family.get_id())
self.person.add_parent_family_id(self.family.get_id(),mother_rel,father_rel)
mod = 1
Utils.modified()
@ -599,7 +599,7 @@ class ModifyParents:
plist = self.person.get_parent_family_id_list()
if make_pref:
if self.family != plist[0]:
self.person.set_main_parent_family_id(self.family)
self.person.set_main_parent_family_id(self.family.get_id())
Utils.modified()
mod = 1
else:

View File

@ -473,11 +473,11 @@ class FamilyView:
def child_rel(self,obj):
person = self.parent.db.get_person(obj.get_data(Utils.OBJECT))
SelectChild.EditRel(person,self.family,self.load_family)
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
def child_rel_by_id(self,id):
person = self.parent.db.get_person(id)
SelectChild.EditRel(person,self.family,self.load_family)
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
def spouse_changed(self,obj):
model, iter = obj.get_selected()

View File

@ -160,18 +160,22 @@ class RelationshipCalculator:
def __init__(self,db):
self.db = db
def apply_filter(self,person_id,index,plist,pmap):
if person_id == None:
return
plist.append(person_id)
pmap[person_id] = index
def set_db(self,db):
self.db = db
def apply_filter(self,person,index,plist,pmap):
if person == None:
return
plist.append(person.get_id())
pmap[person.get_id()] = index
person = self.db.find_person_from_id(person_id)
family_id = person.get_main_parents_family_id()
family = self.db.find_family_from_id(family_id)
if family != None:
self.apply_filter(family.get_father_id(),index+1,plist,pmap)
self.apply_filter(family.get_mother_id(),index+1,plist,pmap)
father = self.db.find_person_from_id(family.get_father_id())
mother = self.db.find_person_from_id(family.get_mother_id())
self.apply_filter(father,index+1,plist,pmap)
self.apply_filter(mother,index+1,plist,pmap)
def get_cousin(self,level,removed):
if removed > len(_removed_level)-1 or level>len(_level_name)-1:
@ -254,7 +258,7 @@ class RelationshipCalculator:
secondList = []
common = []
rank = 9999999
if orig_person == None:
return ("undefined",[])
@ -265,11 +269,11 @@ class RelationshipCalculator:
return ("spouse",[])
try:
self.apply_filter(orig_person.get_id(),0,firstList,firstMap)
self.apply_filter(other_person.get_id(),0,secondList,secondMap)
self.apply_filter(orig_person,0,firstList,firstMap)
self.apply_filter(other_person,0,secondList,secondMap)
except RuntimeError,msg:
return (_("Relationship loop detected"),None)
for person_id in firstList:
if person_id in secondList:
new_rank = firstMap[person_id]
@ -286,7 +290,7 @@ class RelationshipCalculator:
person_id = common[0]
secondRel = firstMap[person_id]
firstRel = secondMap[person_id]
if firstRel == -1:
return ("",[])
elif firstRel == 0:
@ -337,8 +341,8 @@ class RelationshipCalculator:
return ('', [])
try:
self.apply_filter(orig_person.get_id(),0,firstList,firstMap)
self.apply_filter(other_person.get_id(),0,secondList,secondMap)
self.apply_filter(orig_person,0,firstList,firstMap)
self.apply_filter(other_person,0,secondList,secondMap)
except RuntimeError,msg:
return (_("Relationship loop detected"),None)

View File

@ -84,8 +84,8 @@ class SelectChild:
self.add_child = self.xml.get_widget("childlist")
if (self.family):
father = self.family.get_father_id()
mother = self.family.get_mother_id()
father = self.db.find_person_from_id(self.family.get_father_id())
mother = self.db.find_person_from_id(self.family.get_mother_id())
if father != None:
fname = father.get_primary_name().get_name()
@ -145,7 +145,7 @@ class SelectChild:
elif family.get_mother_id():
slist[ffamily.get_mother_id()] = 1
for c in family.get_child_id_list():
slist[c.get_id()] = 1
slist[c] = 1
person_list = []
for key in self.db.sort_person_keys():
@ -221,16 +221,16 @@ class SelectChild:
else:
self.family.set_mother_id(self.person)
self.family.add_child_id(select_child)
self.family.add_child_id(select_child.get_id())
mrel = const.child_relations.find_value(self.mrel.get_text())
mother = self.family.get_mother_id()
mother = self.db.find_person_from_id(self.family.get_mother_id())
if mother and mother.get_gender() != RelLib.Person.female:
if mrel == "Birth":
mrel = "Unknown"
frel = const.child_relations.find_value(self.frel.get_text())
father = self.family.get_father_id()
father = self.db.find_person_from_id(self.family.get_father_id())
if father and father.get_gender() !=RelLib. Person.male:
if frel == "Birth":
frel = "Unknown"
@ -293,7 +293,8 @@ class SelectChild:
class EditRel:
def __init__(self,child,family,update):
def __init__(self,db,child,family,update):
self.db = db
self.update = update
self.child = child
self.family = family
@ -311,8 +312,8 @@ class EditRel:
Utils.set_titles(self.top,self.xml.get_widget('title'),
_('Relationships of %s') % name)
father = self.family.get_father_id()
mother = self.family.get_mother_id()
father = self.db.find_person_from_id(self.family.get_father_id())
mother = self.db.find_person_from_id(self.family.get_mother_id())
if father:
fname = father.get_primary_name().get_name()
@ -354,17 +355,17 @@ class EditRel:
def on_ok_clicked(self,obj):
mrel = const.child_relations.find_value(self.mentry.get_text())
mother = self.family.get_mother_id()
mother = self.db.find_person_from_id(self.family.get_mother_id())
if mother and mother.get_gender() != RelLib.Person.female:
if mrel == "Birth":
mrel = "Unknown"
frel = const.child_relations.find_value(self.fentry.get_text())
father = self.family.get_father_id()
father = self.db.find_person_from_id(self.family.get_father_id())
if father and father.get_gender() !=RelLib. Person.male:
if frel == "Birth":
frel = "Unknown"
self.child.change_parent_family_id(self.family,mrel,frel)
self.child.change_parent_family_id(self.family.get_id(),mrel,frel)
self.update()
self.top.destroy()

View File

@ -886,6 +886,8 @@ class Gramps:
self.db.set_sprefix(GrampsCfg.sprefix)
self.db.set_pprefix(GrampsCfg.pprefix)
self.relationship.set_db(self.db)
self.place_view.change_db(self.db)
self.people_view.change_db(self.db)
self.source_view.change_db(self.db)