Add option to hide ages for events after death

This commit is contained in:
Nick Hall 2022-10-22 16:27:55 +01:00
parent 6eedf4a142
commit 21c7952dc8
4 changed files with 22 additions and 2 deletions

View File

@ -282,6 +282,7 @@ register('preferences.last-view', '')
register('preferences.last-views', []) register('preferences.last-views', [])
register('preferences.family-relation-type', 3) # UNKNOWN register('preferences.family-relation-type', 3) # UNKNOWN
register('preferences.age-display-precision', 1) register('preferences.age-display-precision', 1)
register('preferences.age-after-death', True)
register('colors.scheme', 0) register('colors.scheme', 0)
register('colors.male-alive', ['#b8cee6', '#1f344a']) register('colors.male-alive', ['#b8cee6', '#1f344a'])

View File

@ -1343,6 +1343,12 @@ class GrampsPreferences(ConfigureDialog):
grid.attach(lwidget, 1, row, 1, 1) grid.attach(lwidget, 1, row, 1, 1)
grid.attach(obox, 2, row, 2, 1) grid.attach(obox, 2, row, 2, 1)
row += 1
# Display ages for events after death
self.add_checkbox(
grid, _("Display ages for events after death *"),
row, 'preferences.age-after-death', start=2, stop=3)
row += 1 row += 1
# Calendar format on report: # Calendar format on report:
obox = Gtk.ComboBoxText() obox = Gtk.ComboBoxText()

View File

@ -60,6 +60,7 @@ from gramps.gen.proxy.cache import CacheProxyDb
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
invalid_date_format = config.get('preferences.invalid-date-format') invalid_date_format = config.get('preferences.invalid-date-format')
age_precision = config.get('preferences.age-display-precision') age_precision = config.get('preferences.age-display-precision')
age_after_death = config.get('preferences.age-after-death')
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -101,6 +102,7 @@ class EventRefModel(Gtk.TreeStore):
@param kwargs: A dictionary of additional settings/values. @param kwargs: A dictionary of additional settings/values.
""" """
self.start_date = kwargs.get("start_date", None) self.start_date = kwargs.get("start_date", None)
self.end_date = kwargs.get("end_date", None)
typeobjs = (x[1] for x in self.COLS) typeobjs = (x[1] for x in self.COLS)
Gtk.TreeStore.__init__(self, *typeobjs) Gtk.TreeStore.__init__(self, *typeobjs)
self.db = CacheProxyDb(db) self.db = CacheProxyDb(db)
@ -182,6 +184,8 @@ class EventRefModel(Gtk.TreeStore):
and not (event.get_type().is_death_fallback() or and not (event.get_type().is_death_fallback() or
event.get_type() == EventType.DEATH)): event.get_type() == EventType.DEATH)):
return "" return ""
elif self.end_date and self.end_date < date and not age_after_death:
return ""
else: else:
return (date - self.start_date).format(precision=age_precision) return (date - self.start_date).format(precision=age_precision)
else: else:

View File

@ -53,7 +53,7 @@ _ = glocale.translation.sgettext
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gramps.gen.utils.thumbnails import get_thumbnail_image from gramps.gen.utils.thumbnails import get_thumbnail_image
from ..utils import is_right_click, open_file_with_default_application from ..utils import is_right_click, open_file_with_default_application
from gramps.gen.utils.db import get_birth_or_fallback from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.lib import NoteType, Person, Surname from gramps.gen.lib import NoteType, Person, Surname
from gramps.gen.db import DbTxn from gramps.gen.db import DbTxn
from .. import widgets from .. import widgets
@ -447,6 +447,14 @@ class EditPerson(EditPrimary):
event = get_birth_or_fallback(self.dbstate.db, self.obj) event = get_birth_or_fallback(self.dbstate.db, self.obj)
return event.get_date_object() if event else None return event.get_date_object() if event else None
def get_end_date(self):
"""
Get the end date for a person, usually a death date, or
something close to death.
"""
event = get_death_or_fallback(self.dbstate.db, self.obj)
return event.get_date_object() if event else None
def _create_tabbed_pages(self): def _create_tabbed_pages(self):
""" """
Create the notebook tabs and insert them into the main window. Create the notebook tabs and insert them into the main window.
@ -459,7 +467,8 @@ class EditPerson(EditPrimary):
self.uistate, self.uistate,
self.track, self.track,
self.obj, self.obj,
start_date=self.get_start_date()) start_date=self.get_start_date(),
end_date=self.get_end_date())
self._add_tab(notebook, self.event_list) self._add_tab(notebook, self.event_list)
self.track_ref_for_deletion("event_list") self.track_ref_for_deletion("event_list")