From 7f2174b22541be8b416eeab05776688714d0cd41 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 28 Dec 2009 18:09:40 +0000 Subject: [PATCH] Improve event type defaults for new events in display tabs svn: r13933 --- src/gui/editors/displaytabs/eventembedlist.py | 21 ++++++++++++++- .../displaytabs/personeventembedlist.py | 26 +++++-------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/gui/editors/displaytabs/eventembedlist.py b/src/gui/editors/displaytabs/eventembedlist.py index 0962c96cf..881b360be 100644 --- a/src/gui/editors/displaytabs/eventembedlist.py +++ b/src/gui/editors/displaytabs/eventembedlist.py @@ -187,8 +187,27 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList): """ return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)) + def default_types(self): + return [ + gen.lib.EventType(gen.lib.EventType.MARRIAGE), + gen.lib.EventType(gen.lib.EventType.DIVORCE), + ] + def default_type(self): - return gen.lib.EventType(gen.lib.EventType.MARRIAGE) + type_list = [] + + # combine return info into a single flat sequence + + event = None + for event_ref in self.get_data()[0]: + event = self.dbstate.db.get_event_from_handle(event_ref.ref) + type_list.append(event.get_type()) + + _std_types = self.default_types() + for etype in _std_types: + if etype not in type_list: + return gen.lib.EventType(etype) + return _std_types[0] def default_role(self): return gen.lib.EventRoleType(gen.lib.EventRoleType.FAMILY) diff --git a/src/gui/editors/displaytabs/personeventembedlist.py b/src/gui/editors/displaytabs/personeventembedlist.py index e42da57da..048472e2d 100644 --- a/src/gui/editors/displaytabs/personeventembedlist.py +++ b/src/gui/editors/displaytabs/personeventembedlist.py @@ -38,12 +38,6 @@ from BasicUtils import name_displayer from eventembedlist import EventEmbedList from eventrefmodel import EventRefModel -_std_types = [ - gen.lib.EventType(gen.lib.EventType.BIRTH), - gen.lib.EventType(gen.lib.EventType.DEATH), - ] - - #------------------------------------------------------------------------- # # PersonEventEmbedList @@ -101,20 +95,12 @@ class PersonEventEmbedList(EventEmbedList): def default_role(self): return gen.lib.EventRoleType(gen.lib.EventRoleType.PRIMARY) - def default_type(self): - type_list = [] - - # combine return info into a single flat sequence - - event = None - for event_ref in self.get_data()[0]: - event = self.dbstate.db.get_event_from_handle(event_ref.ref) - type_list.append(event.get_type()) - - for etype in _std_types: - if etype not in type_list: - return gen.lib.EventType(etype) - return gen.lib.EventType(gen.lib.EventType.BIRTH) + def default_types(self): + return [ + gen.lib.EventType(gen.lib.EventType.BIRTH), + gen.lib.EventType(gen.lib.EventType.DEATH), + gen.lib.EventType(gen.lib.EventType.BURIAL), + ] def get_ref_editor(self): from gui.editors import EditEventRef