From ac235ff7be685d3abce6d6801fcdbc43618649b5 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 4 Aug 2005 20:46:41 +0000 Subject: [PATCH] * src/AttrEdit.py: don't used reserved word "list" * src/EditPerson.py: Pass correct attribute list to editor * src/GrampsBSDDB.py: persistently load/save attribute lists * src/GrampsDbBase.py: update attributes on commit * src/Marriage.py: Pass correct attribute list to editor svn: r5017 --- gramps2/ChangeLog | 7 +++++++ gramps2/src/AttrEdit.py | 6 +++--- gramps2/src/EditPerson.py | 9 ++++++--- gramps2/src/GrampsBSDDB.py | 4 ++++ gramps2/src/GrampsDbBase.py | 12 ++++++++++-- gramps2/src/Marriage.py | 9 +++++---- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 07e8bc276..0980609b4 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2005-08-04 Don Allingham + * src/AttrEdit.py: don't used reserved word "list" + * src/EditPerson.py: Pass correct attribute list to editor + * src/GrampsBSDDB.py: persistently load/save attribute lists + * src/GrampsDbBase.py: update attributes on commit + * src/Marriage.py: Pass correct attribute list to editor + 2005-08-04 Alex Roitman * NEWS: Update. * src/MergePeople.py: Typos. diff --git a/gramps2/src/AttrEdit.py b/gramps2/src/AttrEdit.py index 6b8c2d1fc..2c6ec0b03 100644 --- a/gramps2/src/AttrEdit.py +++ b/gramps2/src/AttrEdit.py @@ -64,7 +64,7 @@ class AttributeEditor: """ Displays a dialog that allows the user to edit an attribute. """ - def __init__(self, parent, attrib, title, list, callback, + def __init__(self, parent, attrib, title, data_list, callback, parent_window=None): """ Displays the dialog box. @@ -88,7 +88,7 @@ class AttributeEditor: self.attrib = attrib self.callback = callback self.child_windows = {} - self.alist = list + self.alist = data_list self.top = gtk.glade.XML(const.dialogFile, "attr_edit","gramps") self.slist = self.top.get_widget("slist") @@ -122,7 +122,7 @@ class AttributeEditor: l = self.top.get_widget("title") Utils.set_titles(self.window,l,title,_('Attribute Editor')) - AutoComp.fill_combo(self.attrib_menu,list) + AutoComp.fill_combo(self.attrib_menu,data_list) if attrib != None: self.type_field.set_text(const.display_attr(attrib.get_type())) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 7af47b1f2..d48c249cf 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -28,6 +28,7 @@ import cPickle as pickle import os import locale +import sets from gettext import gettext as _ #------------------------------------------------------------------------- @@ -1182,8 +1183,9 @@ class EditPerson: """Brings up the AttributeEditor for a new attribute""" import AttrEdit pname = self.nd.display(self.person) - AttrEdit.AttributeEditor(self,None,pname,const.personalAttributes, - self.attr_edit_callback,self.window) + attr_list = list(sets.Set(const.personalAttributes + self.db.get_person_attribute_types())) + AttrEdit.AttributeEditor( + self,None,pname, attr_list, self.attr_edit_callback,self.window) def on_up_clicked(self,obj): sel = obj.get_selection() @@ -1465,7 +1467,8 @@ class EditPerson: if node: attr = self.atree.get_object(node) pname = self.nd.display(self.person) - AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes, + attr_list = list(sets.Set(const.personalAttributes + self.db.get_person_attribute_types())) + AttrEdit.AttributeEditor(self,attr,pname,attr_list, self.attr_edit_callback,self.window) def on_update_addr_clicked(self,obj): diff --git a/gramps2/src/GrampsBSDDB.py b/gramps2/src/GrampsBSDDB.py index 0c5d524f8..a6909dcc0 100644 --- a/gramps2/src/GrampsBSDDB.py +++ b/gramps2/src/GrampsBSDDB.py @@ -186,6 +186,8 @@ class GrampsBSDDB(GrampsDbBase): self.bookmarks = self.metadata.get('bookmarks') self.family_event_names = sets.Set(self.metadata.get('fevent_names',[])) self.individual_event_names = sets.Set(self.metadata.get('pevent_names',[])) + self.family_attributes = sets.Set(self.metadata.get('fattr_names',[])) + self.individual_attributes = sets.Set(self.metadata.get('pattr_names',[])) gstats = self.metadata.get('gender_stats') @@ -314,6 +316,8 @@ class GrampsBSDDB(GrampsDbBase): self.metadata['gender_stats'] = self.genderStats.save_stats() self.metadata['fevent_names'] = list(self.family_event_names) self.metadata['pevent_names'] = list(self.individual_event_names) + self.metadata['fattr_names'] = list(self.family_attributes) + self.metadata['pattr_names'] = list(self.individual_attributes) self.metadata.close() self.surnames.close() self.id_trans.close() diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index 5fc8b9d8f..3fce4afe6 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -155,6 +155,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): self.family_event_names = sets.Set() self.individual_event_names = sets.Set() + self.individual_attributes = sets.Set() + self.family_attributes = sets.Set() self.set_person_id_prefix(GrampsKeys.get_person_id_prefix()) self.set_object_id_prefix(GrampsKeys.get_object_id_prefix()) @@ -297,6 +299,9 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): self.genderStats.count_person(person,self) else: self.genderStats.count_person(person,self) + + for attr in person.attribute_list: + self.individual_attributes.add(attr.type) self.person_map[handle] = person.serialize() if old_data: @@ -409,6 +414,9 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): transaction.add(FAMILY_KEY,handle,old_data) self.family_map[handle] = family.serialize() + for attr in family.attribute_list: + self.family_attributes.add(attr.type) + if old_data: self.emit('family-update',([handle],)) else: @@ -1137,12 +1145,12 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): def get_person_attribute_types(self): """returns a list of all Attribute types assocated with Person instances in the database""" - return [] + return list(self.individual_attributes) def get_family_attribute_types(self): """returns a list of all Attribute types assocated with Family instances in the database""" - return [] + return list(self.family_attributes) def get_family_event_types(self): """returns a list of all Event types assocated with Family diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index 9f075bc76..0f262e3b1 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -27,6 +27,7 @@ #------------------------------------------------------------------------- import cPickle as pickle from gettext import gettext as _ +import sets #------------------------------------------------------------------------- # @@ -814,9 +815,9 @@ class Marriage: name = NameDisplay.displayer.display(father) else: name = NameDisplay.displayer.display(mother) + attr_list = list(sets.Set(const.familyAttributes + self.db.get_family_attribute_types())) AttrEdit.AttributeEditor( - self, attr, name, const.familyAttributes, - self.attr_edit_callback, self.window) + self, attr, name, attr_list, self.attr_edit_callback, self.window) def on_delete_attr_clicked(self,obj): if Utils.delete_selected(obj,self.alist): @@ -837,9 +838,9 @@ class Marriage: name = NameDisplay.displayer.display(father) else: name = NameDisplay.displayer.display(mother) + attr_list = list(sets.Set(const.familyAttributes + self.db.get_family_attribute_types())) AttrEdit.AttributeEditor( - self, None, name, const.familyAttributes, - self.attr_edit_callback, self.window) + self, None, name, attr_list, self.attr_edit_callback, self.window) def move_element(self,list,src,dest): if src == -1: