* src/FamilyView.py: handle deleting of parent properly

* src/plugins/WriteGedcom.py: revert to using GRAMPS ID values
* src/plugins/WriteXML.py: use proper ID values

* src/FamilyView.py: fix removal of parents


svn: r3265
This commit is contained in:
Don Allingham 2004-07-11 23:53:02 +00:00
parent c340a04e68
commit a156ad5cbd
6 changed files with 73 additions and 24 deletions

View File

@ -1,3 +1,8 @@
2004-07-11 Don Allingham <dallingham@users.sourceforge.net>
* src/FamilyView.py: handle deleting of parent properly
* src/plugins/WriteGedcom.py: revert to using GRAMPS ID values
* src/plugins/WriteXML.py: use proper ID values
2004-07-10 Alex Roitman <shura@alex.neuro.umn.edu> 2004-07-10 Alex Roitman <shura@alex.neuro.umn.edu>
* NEWS: Update. * NEWS: Update.
* src/Exporter.py: Clean up, add doc strings. * src/Exporter.py: Clean up, add doc strings.
@ -12,6 +17,7 @@
2004-07-09 Don Allingham <dallingham@users.sourceforge.net> 2004-07-09 Don Allingham <dallingham@users.sourceforge.net>
* src/AddMedia.py: Handle the new file selector * src/AddMedia.py: Handle the new file selector
* src/MediaView.py: redraw list properly * src/MediaView.py: redraw list properly
* src/FamilyView.py: fix removal of parents
2004-07-09 Alex Roitman <shura@alex.neuro.umn.edu> 2004-07-09 Alex Roitman <shura@alex.neuro.umn.edu>
* src/gramps_main.py (on_export_activate): Switch to new Exporter. * src/gramps_main.py (on_export_activate): Switch to new Exporter.

View File

@ -249,11 +249,12 @@ class AddSpouse:
return return
spouse = self.db.get_person(idlist[0]) spouse = self.db.get_person(idlist[0])
spouse_id = spouse.get_id()
# don't do anything if the marriage already exists # don't do anything if the marriage already exists
for f in self.person.get_family_id_list(): for f in self.person.get_family_id_list():
fam = self.db.find_family_from_id(f) fam = self.db.find_family_from_id(f)
if spouse.get_id() == fam.get_mother_id() or spouse.get_id() == fam.get_father_id(): if spouse_id == fam.get_mother_id() or spouse_id == fam.get_father_id():
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
return return
@ -263,6 +264,7 @@ class AddSpouse:
self.active_family = self.db.new_family(trans) self.active_family = self.db.new_family(trans)
self.person.add_family_id(self.active_family.get_id()) self.person.add_family_id(self.active_family.get_id())
self.db.commit_person(self.person,trans) self.db.commit_person(self.person,trans)
spouse.add_family_id(self.active_family.get_id()) spouse.add_family_id(self.active_family.get_id())
self.db.commit_person(spouse,trans) self.db.commit_person(spouse,trans)
@ -277,6 +279,7 @@ class AddSpouse:
self.active_family.set_relationship(rtype) self.active_family.set_relationship(rtype)
self.db.commit_family(self.active_family,trans) self.db.commit_family(self.active_family,trans)
self.db.add_transaction(trans,_("Add Spouse")) self.db.add_transaction(trans,_("Add Spouse"))
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
self.update(self.active_family) self.update(self.active_family)
m = Marriage.Marriage(self.parent, self.active_family, m = Marriage.Marriage(self.parent, self.active_family,

View File

@ -1221,12 +1221,14 @@ class FamilyView:
model, iter = self.child_selection.get_selected() model, iter = self.child_selection.get_selected()
if iter: if iter:
id = self.child_model.get_value(iter,2) id = self.child_model.get_value(iter,2)
self.parent.change_active_person(self.parent.db.get_person(id)) child = self.parent.db.try_to_find_person_from_gramps_id(id)
self.parent.change_active_person(child)
self.load_family() self.load_family()
else: else:
list = self.family.get_child_id_list() list = self.family.get_child_id_list()
if len(list) == 1: if len(list) == 1:
self.parent.change_active_person(list[0]) p = self.parent.db.try_to_find_person_from_id(list[0])
self.parent.change_active_person(p)
self.load_family() self.load_family()
def parent_editor(self,person,selection): def parent_editor(self,person,selection):
@ -1271,7 +1273,10 @@ class FamilyView:
def parent_deleter(self,person,selection): def parent_deleter(self,person,selection):
if not person: if not person:
return return
trans = self.parent.db.start_transaction()
plist = person.get_parent_family_id_list() plist = person.get_parent_family_id_list()
if len(plist) == 0: if len(plist) == 0:
return return
if len(plist) == 1: if len(plist) == 1:
@ -1282,10 +1287,24 @@ class FamilyView:
return return
row = model.get_path(iter) row = model.get_path(iter)
fam = person.get_parent_family_id_list()[row[0]] family_id = person.get_parent_family_id_list()[row[0]][0]
person.remove_parent_family_id(fam[0]) person.remove_parent_family_id(family_id)
fam = self.parent.db.try_to_find_family_from_id(family_id)
if len(fam.get_child_id_list()) == 0:
father_id = fam.get_father_id()
mother_id = fam.get_mother_id()
if father_id == None and mother_id:
mother = self.parent.db.find_person_from_id(mother_id)
mother.remove_family_id(fam)
self.parent.db.commit_person(mother,trans)
self.parent.db.delete_family(fam,trans)
elif mother_id == None and father_id:
father = self.parent.db.find_person_from_id(father_id)
father.remove_family_id(fam,trans)
self.parent.db.commit_person(father,trans)
self.parent.db.delete_family(fam,trans)
trans = self.parent.db.start_transaction()
self.parent.db.commit_person(person,trans) self.parent.db.commit_person(person,trans)
n = person.get_primary_name().get_regular_name() n = person.get_primary_name().get_regular_name()
self.parent.db.add_transaction(trans,_("Remove Parents (%s)") % n) self.parent.db.add_transaction(trans,_("Remove Parents (%s)") % n)

View File

@ -1186,6 +1186,7 @@ class Person(SourceNote):
self.note) self.note)
def unserialize(self,data): def unserialize(self,data):
try:
(self.id, self.gid, self.gender, (self.id, self.gid, self.gender,
self.primary_name, self.alternate_names, self.nickname, self.primary_name, self.alternate_names, self.nickname,
self.death_id, self.birth_id, self.event_list, self.death_id, self.birth_id, self.event_list,
@ -1196,6 +1197,8 @@ class Person(SourceNote):
self.urls, self.urls,
self.lds_bapt, self.lds_endow, self.lds_seal, self.lds_bapt, self.lds_endow, self.lds_seal,
self.complete, self.source_list, self.note) = data self.complete, self.source_list, self.note) = data
except:
print data
def set_complete(self,val): def set_complete(self,val):
self.complete = val self.complete = val

View File

@ -237,7 +237,7 @@ class XmlWriter:
self.g.write(" <people") self.g.write(" <people")
person = self.db.get_default_person() person = self.db.get_default_person()
if person: if person:
self.g.write(' default="%s"' % person.get_gramps_id()) self.g.write(' default="%s"' % person.get_id())
self.g.write(">\n") self.g.write(">\n")
keys = self.db.get_person_keys() keys = self.db.get_person_keys()
@ -331,8 +331,10 @@ class XmlWriter:
count = count + 1 count = count + 1
self.write_family_id(family,2) self.write_family_id(family,2)
self.write_ref("father",family.get_father_id(),3) fid = family.get_father_id()
self.write_ref("mother",family.get_mother_id(),3) mid = family.get_mother_id()
self.write_ref("father",fid,3)
self.write_ref("mother",mid,3)
for event_id in family.get_event_list(): for event_id in family.get_event_list():
event = self.db.find_event_from_id(event_id) event = self.db.find_event_from_id(event_id)
self.dump_event(event,3) self.dump_event(event,3)
@ -532,7 +534,7 @@ class XmlWriter:
def write_id(self,label,person,index=1): def write_id(self,label,person,index=1):
if person: if person:
self.g.write('%s<%s id="%s"' % (" "*index,label,person.get_gramps_id())) self.g.write('%s<%s id="%s"' % (" "*index,label,person.get_id()))
comp = person.get_complete() comp = person.get_complete()
if comp: if comp:
self.g.write(' complete="1"') self.g.write(' complete="1"')
@ -791,8 +793,8 @@ class XmlWriter:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def sortById(first,second): def sortById(first,second):
fid = first.get_gramps_id() fid = first.get_id()
sid = second.get_gramps_id() sid = second.get_id()
if fid < sid: if fid < sid:
return -1 return -1

View File

@ -201,6 +201,22 @@ def sortById(first,second):
else: else:
return 1 return 1
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def sort_by_gramps_id(first,second):
fid = first.get_gramps_id()
sid = second.get_gramps_id()
if fid == sid:
return 0
elif fid < sid:
return -1
else:
return 1
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -809,7 +825,7 @@ class GedcomWriter:
# self.sbar.set_fraction(1.0) # self.sbar.set_fraction(1.0)
def write_person(self,person): def write_person(self,person):
self.writeln("0 @%s@ INDI" % self.pid(person.get_id())) self.writeln("0 @%s@ INDI" % self.pid(person.get_gramps_id()))
restricted = self.restrict and person.probably_alive (self.db) restricted = self.restrict and person.probably_alive (self.db)
self.prefn(person) self.prefn(person)
primaryname = person.get_primary_name () primaryname = person.get_primary_name ()
@ -1221,7 +1237,7 @@ class GedcomWriter:
return id return id
def prefn(self,person): def prefn(self,person):
match = _get_int.search(person.get_id()) match = _get_int.search(person.get_gramps_id())
if match: if match:
self.writeln('1 REFN %d' % int(match.groups()[0])) self.writeln('1 REFN %d' % int(match.groups()[0]))