Added est date modifier type (about, or after/before)

svn: r14117
This commit is contained in:
Doug Blank 2010-01-24 16:19:55 +00:00
parent ca35196f49
commit 09b0e50d41

View File

@ -125,6 +125,12 @@ class CalcEstDateOptions(MenuToolOptions):
num.set_help(_("Average years between two generations")) num.set_help(_("Average years between two generations"))
menu.add_option(category_name, "AVG_GENERATION_GAP", num) menu.add_option(category_name, "AVG_GENERATION_GAP", num)
dates = EnumeratedListOption(_("Estimated Dates"), 0)
dates.add_item(0, _("Approximate (about)"))
dates.add_item(1, _("Extremes (after and before)"))
dates.set_help( _("Dates on events are either about or after/before"))
menu.add_option(category_name, "dates", dates)
def __update_filters(self): def __update_filters(self):
""" """
Update the filter list based on the selected person Update the filter list based on the selected person
@ -439,9 +445,10 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
explanation = _("Added birth event based on %s, from %s") % (evidence, other_name) explanation = _("Added birth event based on %s, from %s") % (evidence, other_name)
else: else:
explanation = _("Added birth event based on %s") % evidence explanation = _("Added birth event based on %s") % evidence
modifier = self.get_modifier("birth")
birth = self.create_event(_("Estimated birth date"), birth = self.create_event(_("Estimated birth date"),
gen.lib.EventType.BIRTH, gen.lib.EventType.BIRTH,
date1, source, explanation) date1, source, explanation, modifier)
event_ref = gen.lib.EventRef() event_ref = gen.lib.EventRef()
event_ref.set_reference_handle(birth.get_handle()) event_ref.set_reference_handle(birth.get_handle())
person.set_birth_ref(event_ref) person.set_birth_ref(event_ref)
@ -453,9 +460,10 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
explanation = _("Added death event based on %s, from %s") % (evidence, other_name) explanation = _("Added death event based on %s, from %s") % (evidence, other_name)
else: else:
explanation = _("Added death event based on %s") % evidence explanation = _("Added death event based on %s") % evidence
modifier = self.get_modifier("death")
death = self.create_event(_("Estimated death date"), death = self.create_event(_("Estimated death date"),
gen.lib.EventType.DEATH, gen.lib.EventType.DEATH,
date2, source, explanation) date2, source, explanation, modifier)
event_ref = gen.lib.EventRef() event_ref = gen.lib.EventRef()
event_ref.set_reference_handle(death.get_handle()) event_ref.set_reference_handle(death.get_handle())
person.set_death_ref(event_ref) person.set_death_ref(event_ref)
@ -472,6 +480,19 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
self.results_write("\n\n") self.results_write("\n\n")
self.progress.close() self.progress.close()
def get_modifier(self, event_type):
setting = self.options.handler.options_dict['dates']
if event_type == "birth":
if setting == 0:
return gen.lib.Date.MOD_ABOUT
else:
return gen.lib.Date.MOD_AFTER
else:
if setting == 0:
return gen.lib.Date.MOD_ABOUT
else:
return gen.lib.Date.MOD_BEFORE
def get_or_create_source(self, source_text): def get_or_create_source(self, source_text):
source_list = self.db.get_source_handles() source_list = self.db.get_source_handles()
for source_handle in source_list: for source_handle in source_list:
@ -485,7 +506,7 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
def create_event(self, description=_("Estimated date"), def create_event(self, description=_("Estimated date"),
type=None, date=None, source=None, type=None, date=None, source=None,
note_text=""): note_text="", modifier=None):
event = gen.lib.Event() event = gen.lib.Event()
event.set_description(description) event.set_description(description)
note = gen.lib.Note() note = gen.lib.Note()
@ -497,7 +518,8 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
if type: if type:
event.set_type(gen.lib.EventType(type)) event.set_type(gen.lib.EventType(type))
if date: if date:
date.set_modifier(gen.lib.Date.MOD_ABOUT) if modifier:
date.set_modifier(modifier)
date.set_quality(gen.lib.Date.QUAL_ESTIMATED) date.set_quality(gen.lib.Date.QUAL_ESTIMATED)
date.set_yr_mon_day(date.get_year(), 0, 0) date.set_yr_mon_day(date.get_year(), 0, 0)
event.set_date_object(date) event.set_date_object(date)