* src/FamilyView.py: fix deleting of spouse and children
svn: r4863
This commit is contained in:
parent
ee876d287a
commit
e7fbc6c85e
@ -1,4 +1,5 @@
|
||||
2005-06-22 Don Allingham <don@gramps-project.org>
|
||||
* src/FamilyView.py: fix deleting of spouse and children
|
||||
* src/PlaceView.py: fix sorting
|
||||
* src/SourceView.py: fix sorting
|
||||
|
||||
|
@ -815,27 +815,41 @@ class FamilyView:
|
||||
|
||||
family = self.family
|
||||
|
||||
# determine the child
|
||||
model, node = self.child_selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
|
||||
handle = self.child_model.get_value(node,_HANDLE_COL)
|
||||
child = self.parent.db.get_person_from_handle(handle)
|
||||
|
||||
trans = self.parent.db.transaction_begin()
|
||||
|
||||
# remove the child from the family and the family from the child
|
||||
family.remove_child_handle(child.get_handle())
|
||||
child.remove_parent_family_handle(family.get_handle())
|
||||
|
||||
if len(family.get_child_handle_list()) == 0:
|
||||
if family.get_father_handle() == None:
|
||||
self.delete_family_from(family.get_mother_handle(),trans)
|
||||
elif family.get_mother_handle() == None:
|
||||
self.delete_family_from(family.get_father_handle(),trans)
|
||||
# begin transaction
|
||||
trans = self.parent.db.transaction_begin()
|
||||
|
||||
# if there are no children left, and the spouse is empty, delete the
|
||||
# family
|
||||
mother_handle = family.get_mother_handle()
|
||||
father_handle = family.get_father_handle()
|
||||
no_of_kids = len(family.get_child_handle_list())
|
||||
|
||||
self.parent.db.disable_all_signals()
|
||||
|
||||
if no_of_kids == 0 and (mother_handle == None or father_handle == None):
|
||||
if family.get_father_handle() == None:
|
||||
temp = self.parent.db.get_person_from_handle(family.get_mother_handle())
|
||||
temp.get_family_handle_list().remove(family.get_handle())
|
||||
elif family.get_mother_handle() == None:
|
||||
temp = self.parent.db.get_person_from_handle(family.get_father_handle())
|
||||
temp.get_family_handle_list().remove(family.get_handle())
|
||||
self.parent.db.remove_family(family.get_handle(),trans)
|
||||
else:
|
||||
self.parent.db.commit_family(family,trans)
|
||||
|
||||
# commit the transaction
|
||||
self.parent.db.commit_person(child,trans)
|
||||
self.parent.db.commit_family(family,trans)
|
||||
n = child.get_primary_name().get_regular_name()
|
||||
self.parent.db.transaction_commit(trans,_("Remove Child (%s)") % n)
|
||||
self.parent.db.enable_all_signals()
|
||||
@ -863,6 +877,7 @@ class FamilyView:
|
||||
cur_spouse = self.selected_spouse
|
||||
cur_family = self.family
|
||||
|
||||
# Remove spouse from the family
|
||||
if cur_spouse.get_handle() == cur_family.get_father_handle():
|
||||
cur_family.set_father_handle(None)
|
||||
else:
|
||||
@ -870,25 +885,19 @@ class FamilyView:
|
||||
|
||||
trans = self.parent.db.transaction_begin()
|
||||
|
||||
#If the spouse is defined, remove the family from the spouse
|
||||
if cur_spouse:
|
||||
cur_spouse.remove_family_handle(cur_family.get_handle())
|
||||
self.parent.db.commit_person(cur_spouse,trans)
|
||||
|
||||
self.parent.db.commit_family(cur_family,trans)
|
||||
|
||||
# if there are no children, remove it from the current person
|
||||
# and delete the family
|
||||
if len(cur_family.get_child_handle_list()) == 0:
|
||||
mother_id = cur_family.get_mother_handle()
|
||||
father_id = cur_family.get_father_handle()
|
||||
|
||||
for handle in [father_id, mother_id]:
|
||||
if handle:
|
||||
p = self.parent.db.get_person_from_handle(handle)
|
||||
p.remove_family_handle(cur_family.get_handle())
|
||||
self.parent.db.commit_person(p,trans)
|
||||
|
||||
# if len(cur_person.get_family_handle_list()) > 0:
|
||||
# handle = cur_person.get_family_handle_list()[0]
|
||||
# family = self.parent.db.find_family_from_handle(handle,trans)
|
||||
cur_person.remove_family_handle(cur_family.get_handle())
|
||||
self.parent.db.commit_person(cur_person,trans)
|
||||
self.parent.db.remove_family(cur_family.get_handle(),trans)
|
||||
else:
|
||||
self.parent.db.commit_family(cur_family,trans)
|
||||
|
||||
person_id = cur_person.get_handle()
|
||||
self.person = self.parent.db.get_person_from_handle(person_id)
|
||||
@ -1122,16 +1131,6 @@ class FamilyView:
|
||||
else:
|
||||
return _("%s: unknown") % (l)
|
||||
|
||||
def delete_family_from(self,person_handle,trans):
|
||||
person = self.parent.db.get_person_from_handle(person_handle)
|
||||
person.remove_family_handle(self.family.get_handle())
|
||||
self.parent.db.remove_family(self.family.get_handle(),trans)
|
||||
flist = self.person.get_family_handle_list()
|
||||
if len(flist) > 0:
|
||||
self.family = self.parent.db.get_family_from_handle(flist[0])
|
||||
else:
|
||||
self.family = None
|
||||
|
||||
def display_marriage(self,family):
|
||||
if not family:
|
||||
self.family = None
|
||||
|
Loading…
Reference in New Issue
Block a user