add gramps-ID option to Ancestor and Descendant text reports
This commit is contained in:
parent
c6970e640c
commit
8244c7b211
@ -301,7 +301,7 @@ def run_date_format_option(report, menu):
|
||||
|
||||
def add_gramps_id_option(menu, category, ownline=False):
|
||||
"""
|
||||
Insert an option for deciding whether to include gramps IDs
|
||||
Insert an option for deciding whether to include Gramps IDs
|
||||
in the report
|
||||
|
||||
Since for some reports it makes sense to possibly have the ID on its
|
||||
@ -319,10 +319,11 @@ def add_gramps_id_option(menu, category, ownline=False):
|
||||
|
||||
include_id = EnumeratedListOption(_('Gramps ID'), 0)
|
||||
include_id.add_item(0, _('Do not include'))
|
||||
include_id.add_item(1, _('Share an existing line'))
|
||||
if ownline:
|
||||
include_id.add_item(1, _('Share an existing line'))
|
||||
include_id.add_item(2, _('On a line of its own'))
|
||||
include_id.set_help(_('Whether (and where) to include Gramps IDs'))
|
||||
else:
|
||||
include_id.add_item(1, _('Include'))
|
||||
include_id.set_help(_("Whether to include Gramps IDs"))
|
||||
menu.add_option(category, 'inc_id', include_id)
|
||||
|
@ -88,6 +88,8 @@ class AncestorReport(Report):
|
||||
pagebbg - Whether to include page breaks between generations.
|
||||
name_format - Preferred format to display names
|
||||
incl_private - Whether to include private data
|
||||
namebrk - Whether a line break should follow the name
|
||||
inc_id - Whether to include Gramps IDs
|
||||
living_people - How to handle living people
|
||||
years_past_death - Consider as living this many years after death
|
||||
"""
|
||||
@ -107,6 +109,7 @@ class AncestorReport(Report):
|
||||
self.max_generations = menu.get_option_by_name('maxgen').get_value()
|
||||
self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
|
||||
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
|
||||
self.want_ids = menu.get_option_by_name('inc_id').get_value()
|
||||
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = self.database.get_person_from_gramps_id(pid)
|
||||
@ -186,7 +189,7 @@ class AncestorReport(Report):
|
||||
|
||||
self.apply_filter(self.center_person.get_handle(), 1)
|
||||
|
||||
# Write the title line. Set in INDEX marker so that this section will be
|
||||
# Write the title line. Set an INDEX mark so that this section will be
|
||||
# identified as a major category if this is included in a Book report.
|
||||
|
||||
name = self._name_display.display_formal(self.center_person)
|
||||
@ -233,15 +236,17 @@ class AncestorReport(Report):
|
||||
self.doc.start_bold()
|
||||
self.doc.write_text(name.strip(), mark)
|
||||
self.doc.end_bold()
|
||||
if self.want_ids:
|
||||
self.doc.write_text(' (%s)' % person.get_gramps_id())
|
||||
|
||||
# terminate with a period if it is not already terminated.
|
||||
# This can happen if the person's name ends with something 'Jr.'
|
||||
if name[-1:] == '.':
|
||||
if name[-1:] == '.' and not self.want_ids:
|
||||
self.doc.write_text(" ")
|
||||
else:
|
||||
self.doc.write_text(". ")
|
||||
|
||||
# Add a line break if requested (not implemented yet)
|
||||
# Add a line break if requested
|
||||
if self.opt_namebrk:
|
||||
self.doc.write_text('\n')
|
||||
|
||||
@ -296,9 +301,11 @@ class AncestorOptions(MenuReportOptions):
|
||||
menu.add_option(category_name, "pagebbg", pagebbg)
|
||||
|
||||
namebrk = BooleanOption(_("Add linebreak after each name"), False)
|
||||
namebrk.set_help(_("Indicates if a line break should follow the name."))
|
||||
namebrk.set_help(_("Whether a line break should follow the name."))
|
||||
menu.add_option(category_name, "namebrk", namebrk)
|
||||
|
||||
stdoptions.add_gramps_id_option(menu, category_name)
|
||||
|
||||
category_name = _("Report Options (2)")
|
||||
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
@ -226,7 +226,7 @@ class Printinfo:
|
||||
This class must first be initialized with set_class_vars
|
||||
"""
|
||||
def __init__(self, doc, database, numbering, showmarriage, showdivorce,
|
||||
name_display, rlocale):
|
||||
name_display, rlocale, want_ids):
|
||||
#classes
|
||||
self._name_display = name_display
|
||||
self.doc = doc
|
||||
@ -235,6 +235,7 @@ class Printinfo:
|
||||
#variables
|
||||
self.showmarriage = showmarriage
|
||||
self.showdivorce = showdivorce
|
||||
self.want_ids = want_ids
|
||||
self._ = rlocale.translation.sgettext # needed for English
|
||||
self._get_date = rlocale.get_date
|
||||
|
||||
@ -283,6 +284,9 @@ class Printinfo:
|
||||
if tmp:
|
||||
string += ", " + tmp
|
||||
|
||||
if family and self.want_ids:
|
||||
string += ' (%s)' % family.get_gramps_id()
|
||||
|
||||
self.doc.write_text(string)
|
||||
|
||||
def print_person(self, level, person):
|
||||
@ -291,6 +295,8 @@ class Printinfo:
|
||||
self.doc.start_paragraph("DR-Level%d" % min(level, 32), display_num)
|
||||
mark = utils.get_person_mark(self.database, person)
|
||||
self.doc.write_text(self._name_display.display(person), mark)
|
||||
if self.want_ids:
|
||||
self.doc.write_text(' (%s)' % person.get_gramps_id())
|
||||
self.dump_string(person)
|
||||
self.doc.end_paragraph()
|
||||
return display_num
|
||||
@ -305,6 +311,8 @@ class Printinfo:
|
||||
name = self._name_display.display(spouse)
|
||||
self.doc.write_text(
|
||||
self._("sp. %(spouse)s") % {'spouse':name}, mark)
|
||||
if self.want_ids:
|
||||
self.doc.write_text(' (%s)' % spouse.get_gramps_id())
|
||||
self.dump_string(spouse, family_handle)
|
||||
self.doc.end_paragraph()
|
||||
else:
|
||||
@ -420,6 +428,7 @@ class DescendantReport(Report):
|
||||
incl_private - Whether to include private data
|
||||
living_people - How to handle living people
|
||||
years_past_death - Consider as living this many years after death
|
||||
inc_id - Whether to include Gramps IDs
|
||||
"""
|
||||
|
||||
Report.__init__(self, database, options, user)
|
||||
@ -435,6 +444,7 @@ class DescendantReport(Report):
|
||||
self.database = CacheProxyDb(self.database)
|
||||
|
||||
self.max_generations = menu.get_option_by_name('gen').get_value()
|
||||
self.want_ids = menu.get_option_by_name('inc_id').get_value()
|
||||
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = self.database.get_person_from_gramps_id(pid)
|
||||
@ -465,7 +475,8 @@ class DescendantReport(Report):
|
||||
stdoptions.run_name_format_option(self, menu)
|
||||
|
||||
self.obj_print = Printinfo(self.doc, self.database, obj, marrs, divs,
|
||||
self._name_display, self._locale)
|
||||
self._name_display, self._locale,
|
||||
self.want_ids)
|
||||
|
||||
def write_report(self):
|
||||
self.doc.start_paragraph("DR-Title")
|
||||
@ -524,6 +535,8 @@ class DescendantOptions(MenuReportOptions):
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name, "gen", gen)
|
||||
|
||||
stdoptions.add_gramps_id_option(menu, category_name)
|
||||
|
||||
marrs = BooleanOption(_('Show marriage info'), False)
|
||||
marrs.set_help(
|
||||
_("Whether to show marriage information in the report."))
|
||||
|
Loading…
Reference in New Issue
Block a user