handle add parent family switching

svn: r6203
This commit is contained in:
Don Allingham 2006-03-24 04:04:24 +00:00
parent de3f700428
commit 792362fcc2
2 changed files with 49 additions and 4 deletions

View File

@ -1,5 +1,6 @@
2006-03-23 Don Allingham <don@gramps-project.org> 2006-03-23 Don Allingham <don@gramps-project.org>
* src/Editors/_EditFamily.py: fix arglist to save * src/Editors/_EditFamily.py: fix arglist to save, handle add parent
family switching.
* src/DataViews/_FamilyView.py: don't use LinkLabel for unknown * src/DataViews/_FamilyView.py: don't use LinkLabel for unknown
parent parent

View File

@ -304,6 +304,7 @@ class EditFamily(EditPrimary):
if self.added and self.obj.get_father_handle() == None and \ if self.added and self.obj.get_father_handle() == None and \
self.obj.get_mother_handle() == None and \ self.obj.get_mother_handle() == None and \
len(self.obj.get_child_handle_list()) == 1: len(self.obj.get_child_handle_list()) == 1:
self.add_parent = True
if not Config.get_family_warn(): if not Config.get_family_warn():
for i in self.hidden: for i in self.hidden:
i.set_sensitive(False) i.set_sensitive(False)
@ -314,6 +315,8 @@ class EditFamily(EditPrimary):
if glade.get_widget('dont_show').get_active(): if glade.get_widget('dont_show').get_active():
Config.save_family_warn(True) Config.save_family_warn(True)
dialog.destroy() dialog.destroy()
else:
self.add_parent = False
def _local_init(self): def _local_init(self):
self.build_interface() self.build_interface()
@ -338,6 +341,7 @@ class EditFamily(EditPrimary):
break; break;
def reload_people(self): def reload_people(self):
print "REBUILDING!!!!"
fhandle = self.obj.get_father_handle() fhandle = self.obj.get_father_handle()
self.update_father(fhandle) self.update_father(fhandle)
@ -367,8 +371,6 @@ class EditFamily(EditPrimary):
self.mbox = self.top.get_widget('mbox') self.mbox = self.top.get_widget('mbox')
self.fbox = self.top.get_widget('fbox') self.fbox = self.top.get_widget('fbox')
self.child_list = self.top.get_widget('child_list')
def _connect_signals(self): def _connect_signals(self):
self.define_ok_button(self.top.get_widget('ok'), self.save) self.define_ok_button(self.top.get_widget('ok'), self.save)
self.define_cancel_button(self.top.get_widget('cancel')) self.define_cancel_button(self.top.get_widget('cancel'))
@ -494,6 +496,10 @@ class EditFamily(EditPrimary):
person = sel.run() person = sel.run()
if person: if person:
self.check_for_existing_family(self.obj.get_father_handle(),
person.handle,
self.obj.handle)
self.obj.set_mother_handle(person.handle) self.obj.set_mother_handle(person.handle)
self.update_mother(person.handle) self.update_mother(person.handle)
@ -561,9 +567,47 @@ class EditFamily(EditPrimary):
person = sel.run() person = sel.run()
if person: if person:
self.check_for_existing_family(person.handle,
self.obj.get_mother_handle(),
self.obj.handle)
self.obj.set_father_handle(person.handle) self.obj.set_father_handle(person.handle)
self.update_father(person.handle) self.update_father(person.handle)
def check_for_existing_family(self, father_handle, mother_handle,
family_handle):
if father_handle:
father = self.dbstate.db.get_person_from_handle(father_handle)
ffam = set(father.get_family_handle_list())
if mother_handle:
mother = self.dbstate.db.get_person_from_handle(mother_handle)
mfam = set(mother.get_family_handle_list())
common = list(mfam.intersection(ffam))
print common, self.obj.handle
if len(common) > 0:
if self.add_parent:
clist = self.obj.get_child_handle_list()
self.obj = self.dbstate.db.get_family_from_handle(common[0])
self.obj.add_child_handle(clist[0])
self.close_window()
EditFamily(self.dbstate,self.uistate,[],self.obj)
elif self.obj.handle not in common:
import QuestionDialog
QuestionDialog.WarningDialog(
_('Duplicate Family'),
_('A family with these parents already exists '
'in the database. If you save, you will create '
'a duplicate family.'))
else:
pass
else:
if mother_handle:
pass
else:
pass
# def father_clicked(self,obj): # def father_clicked(self,obj):
# handle = self.obj.get_father_handle() # handle = self.obj.get_father_handle()
# if handle: # if handle: