diff --git a/gramps/gen/db/base.py b/gramps/gen/db/base.py index c1ca602df..de7b203e5 100644 --- a/gramps/gen/db/base.py +++ b/gramps/gen/db/base.py @@ -257,6 +257,13 @@ class DbReadBase(object): """ raise NotImplementedError + def get_event_attribute_types(self): + """ + Return a list of all Attribute types assocated with Event instances + in the database. + """ + raise NotImplementedError + def get_event_types(self): """ Return a list of all event types in the database. diff --git a/gramps/gen/db/read.py b/gramps/gen/db/read.py index 1c4830489..57f58407f 100644 --- a/gramps/gen/db/read.py +++ b/gramps/gen/db/read.py @@ -1507,6 +1507,13 @@ class DbBsddbRead(DbReadBase, Callback): """Set the save path for the database.""" self.path = path + def get_event_attribute_types(self): + """ + Return a list of all Attribute types assocated with Event instances + in the database. + """ + return list(self.event_attributes) + def get_event_types(self): """ Return a list of all event types in the database. diff --git a/gramps/gen/db/test/db_test.py b/gramps/gen/db/test/db_test.py index 91dffb9de..df958da0f 100644 --- a/gramps/gen/db/test/db_test.py +++ b/gramps/gen/db/test/db_test.py @@ -43,6 +43,7 @@ class DbTest(unittest.TestCase): "get_child_reference_types", "get_default_handle", "get_default_person", + "get_event_attribute_types", "get_event_bookmarks", "get_event_cursor", "get_event_from_gramps_id", diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index 9e17ad2a3..10e3ca685 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -979,6 +979,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.source_media_types = set(meta(b'sm_types')) self.url_types = set(meta(b'url_types')) self.media_attributes = set(meta(b'mattr_names')) + self.event_attributes = set(meta(b'eattr_names')) # surname list self.surname_list = meta(b'surname_list') @@ -1450,6 +1451,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): txn.put(b'sm_types', list(self.source_media_types)) txn.put(b'url_types', list(self.url_types)) txn.put(b'mattr_names', list(self.media_attributes)) + txn.put(b'eattr_names', list(self.event_attributes)) # name display formats txn.put(b'surname_list', self.surname_list) @@ -2051,10 +2053,16 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): Commit the specified Event to the database, storing the changes as part of the transaction. """ - if event.type.is_custom(): - self.event_names.add(str(event.type)) self.commit_base(event, self.event_map, EVENT_KEY, transaction, change_time) + + self.event_attributes.update( + [str(attr.type) for attr in event.attribute_list + if attr.type.is_custom() and str(attr.type)]) + + if event.type.is_custom(): + self.event_names.add(str(event.type)) + attr_list = [] for mref in event.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list diff --git a/gramps/gen/proxy/proxybase.py b/gramps/gen/proxy/proxybase.py index d381945d2..229ca7a30 100644 --- a/gramps/gen/proxy/proxybase.py +++ b/gramps/gen/proxy/proxybase.py @@ -722,6 +722,11 @@ class ProxyDbBase(DbReadBase): """returns the save path of the file, or "" if one does not exist""" return self.db.get_save_path() + def get_event_attribute_types(self): + """returns a list of all Attribute types associated with Event + instances in the database""" + return self.db.get_event_attribute_types() + def get_event_types(self): """returns a list of all event types in the database""" return self.db.get_event_types() diff --git a/gramps/gui/editors/__init__.py b/gramps/gui/editors/__init__.py index 0e57ea06d..880eed88f 100644 --- a/gramps/gui/editors/__init__.py +++ b/gramps/gui/editors/__init__.py @@ -21,7 +21,7 @@ # gui/editors/__init__.py from .editaddress import EditAddress -from .editattribute import EditAttribute, EditFamilyAttribute, EditSrcAttribute +from .editattribute import EditAttribute, EditSrcAttribute from .editchildref import EditChildRef from .editcitation import EditCitation, DeleteCitationQuery from .editdate import EditDate diff --git a/gramps/gui/editors/displaytabs/__init__.py b/gramps/gui/editors/displaytabs/__init__.py index 32a179744..36118653d 100644 --- a/gramps/gui/editors/displaytabs/__init__.py +++ b/gramps/gui/editors/displaytabs/__init__.py @@ -38,6 +38,7 @@ from .addrembedlist import AddrEmbedList from .altnameembedlist import AltNameEmbedList from .attrembedlist import AttrEmbedList from .backreflist import BackRefList +from .eventattrembedlist import EventAttrEmbedList from .eventbackreflist import EventBackRefList from .eventembedlist import EventEmbedList from .familyattrembedlist import FamilyAttrEmbedList diff --git a/gramps/gui/editors/displaytabs/eventattrembedlist.py b/gramps/gui/editors/displaytabs/eventattrembedlist.py new file mode 100644 index 000000000..8134806df --- /dev/null +++ b/gramps/gui/editors/displaytabs/eventattrembedlist.py @@ -0,0 +1,43 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +#------------------------------------------------------------------------- +# +# Gramps classes +# +#------------------------------------------------------------------------- +from .attrembedlist import AttrEmbedList + +#------------------------------------------------------------------------- +# +# EventAttrEmbedList +# +#------------------------------------------------------------------------- +class EventAttrEmbedList(AttrEmbedList): + + def __init__(self, dbstate, uistate, track, data): + AttrEmbedList.__init__(self, dbstate, uistate, track, data) + + def get_editor(self): + from .. import EditAttribute + return EditAttribute + + def get_user_values(self): + return self.dbstate.db.get_event_attribute_types() diff --git a/gramps/gui/editors/displaytabs/familyattrembedlist.py b/gramps/gui/editors/displaytabs/familyattrembedlist.py index 1510eccce..244f0b7d1 100644 --- a/gramps/gui/editors/displaytabs/familyattrembedlist.py +++ b/gramps/gui/editors/displaytabs/familyattrembedlist.py @@ -36,8 +36,8 @@ class FamilyAttrEmbedList(AttrEmbedList): AttrEmbedList.__init__(self, dbstate, uistate, track, data) def get_editor(self): - from .. import EditFamilyAttribute - return EditFamilyAttribute + from .. import EditAttribute + return EditAttribute def get_user_values(self): return self.dbstate.db.get_family_attribute_types() diff --git a/gramps/gui/editors/editevent.py b/gramps/gui/editors/editevent.py index 7f2b2e7fa..41e4f47d1 100644 --- a/gramps/gui/editors/editevent.py +++ b/gramps/gui/editors/editevent.py @@ -49,7 +49,7 @@ from .objectentries import PlaceEntry from ..glade import Glade from ..dialog import ErrorDialog from .displaytabs import (CitationEmbedList, NoteTab, GalleryTab, - EventBackRefList, AttrEmbedList) + EventBackRefList, EventAttrEmbedList) from ..widgets import (MonitoredEntry, PrivacyButton, MonitoredDataType, MonitoredDate, MonitoredTagList) from gramps.gen.utils.db import get_participant_from_event @@ -199,10 +199,10 @@ class EditEvent(EditPrimary): self.obj.get_media_list()) self._add_tab(notebook, self.gallery_list) - self.attr_list = AttrEmbedList(self.dbstate, - self.uistate, - self.track, - self.obj.get_attribute_list()) + self.attr_list = EventAttrEmbedList(self.dbstate, + self.uistate, + self.track, + self.obj.get_attribute_list()) self._add_tab(notebook, self.attr_list) handle_list = self.dbstate.db.find_backlink_handles(self.obj.handle) diff --git a/gramps/gui/editors/filtereditor.py b/gramps/gui/editors/filtereditor.py index 5616c7232..bb5ee4f4f 100644 --- a/gramps/gui/editors/filtereditor.py +++ b/gramps/gui/editors/filtereditor.py @@ -547,6 +547,8 @@ class EditRule(ManagedWindow): additional = self.db.get_person_attribute_types() elif v == _('Family attribute:'): additional = self.db.get_family_attribute_types() + elif v == _('Event attribute:'): + additional = self.db.get_event_attribute_types() elif v == _('Media attribute:'): additional = self.db.get_media_attribute_types() elif v == _('Relationship type:'): diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 7c1e35e76..55cd36358 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -291,6 +291,7 @@ gramps/gui/editors/displaytabs/childmodel.py gramps/gui/editors/displaytabs/citationbackreflist.py gramps/gui/editors/displaytabs/citationrefmodel.py gramps/gui/editors/displaytabs/datamodel.py +gramps/gui/editors/displaytabs/eventattrembedlist.py gramps/gui/editors/displaytabs/eventbackreflist.py gramps/gui/editors/displaytabs/familyattrembedlist.py gramps/gui/editors/displaytabs/grampstab.py