improve family editor
svn: r6096
This commit is contained in:
parent
d02f77c645
commit
81fd449823
@ -1,3 +1,8 @@
|
||||
2006-03-07 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_FamilyView.py: connect up to signals correctly
|
||||
* src/Editors/_EditFamily.py: connect family members to a new family
|
||||
correctly.
|
||||
|
||||
2006-03-06 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_FamilyView.py: put the person in the correct spot
|
||||
when adding a new family
|
||||
|
@ -85,21 +85,48 @@ class FamilyView(PageView.PersonNavView):
|
||||
PageView.PersonNavView.__init__(self,'Relationship View',dbstate,uistate)
|
||||
dbstate.connect('database-changed',self.change_db)
|
||||
dbstate.connect('active-changed',self.change_person)
|
||||
dbstate.db.connect('family-update',self.redraw)
|
||||
dbstate.db.connect('family-add',self.redraw)
|
||||
dbstate.db.connect('family-delete',self.redraw)
|
||||
dbstate.db.connect('person-update',self.redraw)
|
||||
dbstate.db.connect('person-add',self.redraw)
|
||||
dbstate.db.connect('person-delete',self.redraw)
|
||||
self.show_siblings = Config.get_family_siblings()
|
||||
if self.show_siblings == None:
|
||||
self.show_siblings = True
|
||||
self.show_details = Config.get_family_details()
|
||||
if self.show_details == None:
|
||||
self.show_details = True
|
||||
self.connect_to_db(dbstate.db)
|
||||
self.redrawing = False
|
||||
self.child = None
|
||||
|
||||
def connect_to_db(self,db):
|
||||
db.connect('person-update', self.person_update)
|
||||
db.connect('person-rebuild',self.person_rebuild)
|
||||
db.connect('family-update', self.family_update)
|
||||
db.connect('family-add', self.family_add)
|
||||
db.connect('family-delete', self.family_delete)
|
||||
db.connect('family-rebuild',self.family_rebuild)
|
||||
|
||||
def person_update(self,handle_list):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def person_rebuild(self):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def family_update(self,handle_list):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def family_add(self,handle_list):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def family_delete(self,handle_list):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def family_rebuild(self):
|
||||
if self.dbstate.active:
|
||||
self.change_person(self.dbstate.active.handle)
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
Returns the name of the stock icon to use for the display.
|
||||
@ -175,6 +202,7 @@ class FamilyView(PageView.PersonNavView):
|
||||
Config.save_family_details(self.show_details)
|
||||
|
||||
def change_db(self,db):
|
||||
self.connect_to_db(db)
|
||||
if self.child:
|
||||
self.vbox.remove(self.child)
|
||||
self.child = None
|
||||
@ -209,7 +237,6 @@ class FamilyView(PageView.PersonNavView):
|
||||
old_child = self.child
|
||||
self.attach = AttachList()
|
||||
|
||||
print "PERSON",obj
|
||||
person = self.dbstate.db.get_person_from_handle(obj)
|
||||
if not person:
|
||||
self.redrawing = False
|
||||
|
@ -257,6 +257,10 @@ class EditFamily(EditPrimary):
|
||||
self._add_db_signal('person-delete', self.check_for_change)
|
||||
self._add_db_signal('person-rebuild', self.reload_people)
|
||||
|
||||
self.added = self.obj.handle == None
|
||||
if self.added:
|
||||
self.obj.handle = Utils.create_id()
|
||||
|
||||
self.load_data()
|
||||
|
||||
def check_for_change(self,handles):
|
||||
@ -537,31 +541,35 @@ class EditFamily(EditPrimary):
|
||||
self.db.commit_person(person,trans)
|
||||
|
||||
def save(self,obj):
|
||||
if self.obj.handle:
|
||||
if not self.added:
|
||||
original = self.db.get_family_from_handle(self.obj.handle)
|
||||
else:
|
||||
original = None
|
||||
|
||||
if not original:
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
# find the father, add the family handle to the father
|
||||
handle = self.obj.get_father_handle()
|
||||
if handle:
|
||||
parent = self.db.get_person_from_handle(handle)
|
||||
parent.add_family_handle(self.obj.handle)
|
||||
self.db.commit_person(parent,trans)
|
||||
|
||||
# find the mother, add the family handle to the mother
|
||||
handle = self.obj.get_mother_handle()
|
||||
if handle:
|
||||
parent = self.db.get_person_from_handle(handle)
|
||||
parent.add_family_handle(self.obj.handle)
|
||||
self.db.commit_person(parent,trans)
|
||||
|
||||
# for each child, add the family handle to the child
|
||||
for handle in self.obj.get_child_handle_list():
|
||||
child = self.db.get_person_from_handle(handle)
|
||||
# fix
|
||||
child.add_parent_family_handle(handle,
|
||||
RelLib.Person.CHILD_BIRTH,
|
||||
Rellib,Person.CHILD_BIRTH)
|
||||
RelLib.Person.CHILD_BIRTH)
|
||||
self.db.commit_person(child,trans)
|
||||
|
||||
self.db.add_family(self.obj,trans)
|
||||
@ -584,7 +592,7 @@ class EditFamily(EditPrimary):
|
||||
person.remove_parent_family_handle(self.obj.handle)
|
||||
self.db.commit_person(person,trans)
|
||||
|
||||
# add the family from children which have been removed
|
||||
# add the family from children which have been addedna
|
||||
for handle in new_set.difference(orig_set):
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
#person.remove_parent_family_handle(self.obj.handle)
|
||||
|
Loading…
Reference in New Issue
Block a user