diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 615129c16..8ad9f7e02 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,16 @@ +2004-02-24 Don Allingham + * src/plugins/WebPage.py: media reference fixes + * src/plugins/ReadGedcom.py: media reference fixes + * src/plugins/IndivSummary.py: media reference fixes + * src/plugins/IndivComplete.py: media reference fixes + * src/plugins/DetAncestralReport.py: media reference fixes + * src/plugins/DetDescendantReport.py: media reference fixes + * src/plugins/Check.py: media reference fixes + * src/gramps_main.py: media reference fixes + * src/Utils.py: gnome.vfs vs. grampslib + * src/RelLib.py: single db file, media reference fixes + * src/MediaView.py: media reference fixes + 2004-02-24 Alex Roitman * src/RelLib.py (sortbysource): Low-level implementation; (sortbyplace): Typo. diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index 2b2d39b40..20f771e22 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -53,6 +53,7 @@ import const import Utils import GrampsCfg import ListModel +import Date #------------------------------------------------------------------------- # @@ -195,7 +196,9 @@ class AddSpouse: if not self.active_family: self.active_family = self.db.new_family() self.person.add_family_id(self.active_family.get_id()) + self.db.commit_person(self.person) spouse.add_family_id(self.active_family.get_id()) + self.db.commit_person(spouse) if self.person.get_gender() == RelLib.Person.male: self.active_family.set_mother_id(spouse.get_id()) @@ -205,6 +208,7 @@ class AddSpouse: self.active_family.set_mother_id(self.person.get_id()) self.active_family.set_relationship(const.save_frel(unicode(self.relation_type.get_text()))) + self.db.commit_family(self.active_family) Utils.destroy_passed_object(obj) self.update(self.active_family) @@ -224,8 +228,21 @@ class AddSpouse: # the potential spouse list. If Partners is selected, use # the same gender as the current person. gender = self.person.get_gender() - bday = self.person.get_birth().get_date_object() - dday = self.person.get_death().get_date_object() + + birth_id = self.person.get_birth_id() + death_id = self.person.get_death_id() + + bday = self.db.find_event_from_id(birth_id) + dday = self.db.find_event_from_id(death_id) + if birth_id: + bday = self.db.find_event_from_id(birth_id).get_date_object() + else: + bday = Date.Date() + + if death_id: + dday = self.db.find_event_from_id(death_id).get_date_object() + else: + dday = Date.Date() if text == _("Partners"): if gender == RelLib.Person.male: @@ -247,9 +264,18 @@ class AddSpouse: continue if not self.showall.get_active(): - pdday = self.db.get_person(key).get_death().get_date_object() - pbday = self.db.get_person(key).get_birth().get_date_object() - + pd_id = self.db.get_person(key).get_death_id() + pb_id = self.db.get_person(key).get_birth_id() + + if pd_id: + pdday = self.db.find_event_from_id(pd_id).get_date_object() + else: + pdday = Date.Date() + if pb_id: + pbday = self.db.find_event_from_id(pb_id).get_date_object() + else: + pbday = Date.Date() + if bday.getYearValid(): if pbday.getYearValid(): # reject if person birthdate differs more than diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index 42aa37777..ba0985ed9 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -48,6 +48,7 @@ import gnome # gramps modules # #------------------------------------------------------------------------- +import Date import RelLib import const import Utils @@ -305,12 +306,12 @@ class ChooseParents: if birth_event: bday = birth_event.get_date_object() else: - bday = None + bday = Date.Date() death_event = self.db.find_event_from_id(self.person.get_death_id()) if death_event: dday = death_event.get_date_object() else: - dday = None + dday = Date.Date() person_list = [] for key in self.db.sort_person_keys(): @@ -329,13 +330,13 @@ class ChooseParents: if birth_event: pbday = birth_event.get_date_object() else: - pbday = None + pbday = Date.Date() death_event = self.db.find_event_from_id(person.get_death_id()) if death_event: pdday = death_event.get_date_object() else: - pdday = None + pdday = Date.Date() if bday and bday.getYearValid(): if pbday and pbday.getYearValid(): @@ -401,8 +402,8 @@ class ChooseParents: if not father_id and not mother_id: return None - families = self.db.get_family_id_map().values() - for family in families: + for family_id in self.db.get_family_keys(): + family = self.db.find_family_from_id(family_id) if family.get_father_id() == father_id and family.get_mother_id() == mother_id: return family elif family.get_father_id() == mother_id and family.get_mother_id() == father_id: @@ -416,10 +417,13 @@ class ChooseParents: if father_id: father = self.db.find_person_from_id(father_id) father.add_family_id(family.get_id()) - if mother: + self.db.commit_person(father) + if mother_id: mother = self.db.find_person_from_id(mother_id) mother.add_family_id(family.get_id()) + self.db.commit_person(mother) + self.db.commit_family(family) return family def mother_list_select_row(self,obj): diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 31a64af30..eecc66bd3 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -531,12 +531,14 @@ class FamilyView: def set_preferred_spouse(self,obj): if self.selected_spouse: self.person.set_preferred_family_id(self.family) + self.parent.db.commit_person(self.person) self.load_family() def edit_spouse_callback(self,obj): if self.selected_spouse: try: - EditPerson.EditPerson(self.parent, self.selected_spouse, self.parent.db, self.spouse_after_edit) + EditPerson.EditPerson(self.parent, self.selected_spouse, + self.parent.db, self.spouse_after_edit) except: DisplayTrace.DisplayTrace() @@ -588,7 +590,8 @@ class FamilyView: else: person.set_gender(RelLib.Person.male) try: - EditPerson.EditPerson(self.parent, person, self.parent.db, self.new_spouse_after_edit) + EditPerson.EditPerson(self.parent, person, self.parent.db, + self.new_spouse_after_edit) except: DisplayTrace.DisplayTrace() @@ -596,6 +599,7 @@ class FamilyView: ap = self.parent.active_person if epo: self.parent.db.build_person_display(epo.person.get_id(),epo.original_id) + self.parent.db.commit_person(epo.person) self.parent.people_view.remove_from_person_list(epo.person,epo.original_id) self.parent.people_view.redisplay_person_list(epo.person) @@ -609,20 +613,22 @@ class FamilyView: else: self.parent.db.add_person_no_map(epo.person,epo.person.get_id()) - self.parent.db.build_person_display(epo.person.get_id()) self.parent.people_view.add_to_person_list(epo.person,0) - self.family = self.parent.db.new_family() self.person.add_family_id(self.family.get_id()) epo.person.add_family_id(self.family.get_id()) + self.parent.db.commit_person(epo.person) + self.parent.db.commit_person(self.person) + if self.person.get_gender() == RelLib.Person.male: self.family.set_mother_id(epo.person.get_id()) self.family.set_father_id(self.person.get_id()) else: self.family.set_father_id(epo.person.get_id()) self.family.set_mother_id(self.person.get_id()) - + + self.parent.db.commit_family(self.family) self.load_family(self.family) Marriage.Marriage(self.parent,self.family,self.parent.db, @@ -718,6 +724,8 @@ class FamilyView: elif self.family.get_mother_id() == None: self.delete_family_from(self.family.get_father_id()) + self.parent.db.commit_person(child) + self.parent.db.commit_family(self.family) Utils.modified() self.load_family() @@ -738,23 +746,29 @@ class FamilyView: """Delete the currently selected spouse from the family""" if self.person == None: return - if self.selected_spouse == self.family.get_father_id(): + + if self.selected_spouse.get_id() == self.family.get_father_id(): self.family.set_father_id(None) else: self.family.set_mother_id(None) if self.selected_spouse: self.selected_spouse.remove_family_id(self.family.get_id()) + self.parent.db.commit_person(self.selected_spouse) + + self.parent.db.commit_family(self.family) if len(self.family.get_child_id_list()) == 0: self.person.remove_family_id(self.family.get_id()) + self.parent.db.commit_person(self.person) self.parent.db.delete_family(self.family.get_id()) if len(self.person.get_family_id_list()) > 0: - self.load_family(self.person.get_family_id_list()[0]) + family_id = self.person.get_family_id_list()[0] + self.load_family(self.parent.db.find_family_from_id(family_id)) else: - self.load_family() + self.load_family(self.family) else: - self.load_family() + self.load_family(self.family) if len(self.person.get_family_id_list()) <= 1: self.spouse_selection.set_mode(gtk.SELECTION_NONE) @@ -793,6 +807,8 @@ class FamilyView: person_id = family.get_mother_id() person = self.parent.db.find_person_from_id(person_id) self.parent.change_active_person(person) + + self.parent.db.commit_family(family) self.load_family(family) def clear(self): @@ -849,12 +865,12 @@ class FamilyView: sp_id = fm.get_mother_id() else: sp_id = fm.get_father_id() - sp = self.parent.db.find_person_from_id(sp_id) iter = self.spouse_model.append() flist[f] = iter - if sp: + if sp_id: + sp = self.parent.db.find_person_from_id(sp_id) event = self.find_marriage(fm) if event: mdate = " - %s" % event.get_date() @@ -939,9 +955,17 @@ class FamilyView: return if family.get_father_id() == self.person.get_id(): - self.selected_spouse = self.parent.db.find_person_from_id(family.get_mother_id()) + sp_id = family.get_mother_id() + if sp_id: + self.selected_spouse = self.parent.db.find_person_from_id(sp_id) + else: + self.selected_spouse = None else: - self.selected_spouse = self.parent.db.find_person_from_id(family.get_father_id()) + sp_id = family.get_father_id() + if sp_id: + self.selected_spouse = self.parent.db.find_person_from_id(sp_id) + else: + self.selected_spouse = None if self.selected_spouse: self.update_list(self.sp_parents_model,self.sp_parents, @@ -1197,6 +1221,8 @@ class FamilyView: row = model.get_path(iter) fam = person.get_parent_family_id_list()[row[0]] person.remove_parent_family_id(fam[0]) + + self.parent.db.commit_person(person) Utils.modified() self.load_family() diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index dc103da6c..7d03e50f3 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -128,8 +128,18 @@ class Marriage: }) - father = self.db.find_person_from_id(family.get_father_id()) - mother = self.db.find_person_from_id(family.get_mother_id()) + fid = family.get_father_id() + mid = family.get_mother_id() + + if fid: + father = self.db.find_person_from_id(family.get_father_id()) + else: + father = None + + if mid: + mother = self.db.find_person_from_id(family.get_mother_id()) + else: + mother = None self.title = _("%s and %s") % (GrampsCfg.nameof(father), GrampsCfg.nameof(mother)) diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index f1ed4914d..3742962d0 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -194,7 +194,7 @@ class PeopleView: def add_to_person_list(self,person,change): key = person.get_id() - val = self.parent.db.get_person_display(person.get_id()) + val = self.parent.db.get_person_display(key) pg = unicode(val[5]) pg = pg[0] model = None @@ -224,7 +224,12 @@ class PeopleView: if change: self.parent.change_active_person(person) - self.goto_active_person() + + try: + self.goto_active_person() + except: + print "goto failed" + if model: model.enable_sort() @@ -242,10 +247,10 @@ class PeopleView: return id = self.parent.active_person.get_id() + val = self.parent.db.get_person_display(id) if self.id2col.has_key(id): (model,iter) = self.id2col[id] else: - val = self.parent.db.get_person_display(id) pg = val[5] if pg and pg != '@': pg = pg[0] @@ -268,10 +273,10 @@ class PeopleView: if not iter: self.parent.status_text(_('Updating display...')) - model.expand_row(val[-1]) + model.fill_row(val[-1]) (m,iter) = self.id2col[id] self.parent.modify_statusbar() - + try: model.selection.unselect_all() model.selection.select_iter(iter) diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 8ed0b7f72..af9a6f6e3 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -2385,8 +2385,6 @@ class GrampsDB: def build_person_display(self,nkey,okey=None): pass -# name = self.person_map.get(str(nkey))[2] -# self.add_surname(name.get_surname()) def rebuild_person_table(self): pass