add filter name to report's title, tweak report's filter option display
This commit is contained in:
parent
f53d6482da
commit
d984e5796b
@ -386,6 +386,7 @@ class Extract(object):
|
|||||||
def get_surname(self, person):
|
def get_surname(self, person):
|
||||||
"return surnames for given person"
|
"return surnames for given person"
|
||||||
# TODO: return all surnames, not just primary ones...
|
# TODO: return all surnames, not just primary ones...
|
||||||
|
# TODO: have the surname fromatted according to the name_format too
|
||||||
surnames = person.get_primary_name().get_surname().strip()
|
surnames = person.get_primary_name().get_surname().strip()
|
||||||
if surnames:
|
if surnames:
|
||||||
return surnames.split()
|
return surnames.split()
|
||||||
@ -727,8 +728,14 @@ class StatisticsChart(Report):
|
|||||||
get_option_by_name = menu.get_option_by_name
|
get_option_by_name = menu.get_option_by_name
|
||||||
get_value = lambda name: get_option_by_name(name).get_value()
|
get_value = lambda name: get_option_by_name(name).get_value()
|
||||||
|
|
||||||
|
lang = menu.get_option_by_name('trans').get_value()
|
||||||
|
rlocale = self.set_locale(lang)
|
||||||
|
# override default gettext, or English output will have "person|Title"
|
||||||
|
self._ = rlocale.translation.sgettext
|
||||||
|
|
||||||
self.filter_option = get_option_by_name('filter')
|
self.filter_option = get_option_by_name('filter')
|
||||||
self.filter = self.filter_option.get_filter()
|
self.filter = self.filter_option.get_filter()
|
||||||
|
filter_name = self.filter.get_name(rlocale)
|
||||||
|
|
||||||
self.bar_items = get_value('bar_items')
|
self.bar_items = get_value('bar_items')
|
||||||
year_from = get_value('year_from')
|
year_from = get_value('year_from')
|
||||||
@ -737,9 +744,9 @@ class StatisticsChart(Report):
|
|||||||
|
|
||||||
# title needs both data extraction method name + gender name
|
# title needs both data extraction method name + gender name
|
||||||
if gender == Person.MALE:
|
if gender == Person.MALE:
|
||||||
genders = _("Men")
|
genders = self._("Men")
|
||||||
elif gender == Person.FEMALE:
|
elif gender == Person.FEMALE:
|
||||||
genders = _("Women")
|
genders = self._("Women")
|
||||||
else:
|
else:
|
||||||
genders = None
|
genders = None
|
||||||
|
|
||||||
@ -750,10 +757,14 @@ class StatisticsChart(Report):
|
|||||||
'year_to': year_to
|
'year_to': year_to
|
||||||
}
|
}
|
||||||
|
|
||||||
lang = menu.get_option_by_name('trans').get_value()
|
if genders:
|
||||||
rlocale = self.set_locale(lang)
|
span_string = self._("%(genders)s born "
|
||||||
# override default gettext, or English output will have "person|Title"
|
"%(year_from)04d-%(year_to)04d"
|
||||||
self._ = rlocale.translation.sgettext
|
% mapping )
|
||||||
|
else:
|
||||||
|
span_string = self._("Persons born "
|
||||||
|
"%(year_from)04d-%(year_to)04d"
|
||||||
|
% mapping )
|
||||||
|
|
||||||
# extract requested items from the database and count them
|
# extract requested items from the database and count them
|
||||||
self._user.begin_progress(_('Statistics Charts'),
|
self._user.begin_progress(_('Statistics Charts'),
|
||||||
@ -774,15 +785,10 @@ class StatisticsChart(Report):
|
|||||||
# generate sorted item lookup index index
|
# generate sorted item lookup index index
|
||||||
lookup = self.index_items(table[1], sortby, reverse)
|
lookup = self.index_items(table[1], sortby, reverse)
|
||||||
# document heading
|
# document heading
|
||||||
mapping['chart_title'] = self._(table[0])
|
heading = "%(str1)s -- %(str2)s\n%(str3)s" % {
|
||||||
if genders:
|
'str1' : self._(table[0]),
|
||||||
heading = self._("%(genders)s born "
|
'str2' : span_string,
|
||||||
"%(year_from)04d-%(year_to)04d: "
|
'str3' : filter_name }
|
||||||
"%(chart_title)s") % mapping
|
|
||||||
else:
|
|
||||||
heading = self._("Persons born "
|
|
||||||
"%(year_from)04d-%(year_to)04d: "
|
|
||||||
"%(chart_title)s") % mapping
|
|
||||||
self.data.append((heading, table[0], table[1], lookup))
|
self.data.append((heading, table[0], table[1], lookup))
|
||||||
self._user.step_progress()
|
self._user.step_progress()
|
||||||
self._user.end_progress()
|
self._user.end_progress()
|
||||||
@ -892,7 +898,7 @@ class StatisticsChart(Report):
|
|||||||
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
||||||
self.doc.center_text('SC-title', title, middle, 0, mark)
|
self.doc.center_text('SC-title', title, middle, 0, mark)
|
||||||
pstyle = style_sheet.get_paragraph_style('SC-Title')
|
pstyle = style_sheet.get_paragraph_style('SC-Title')
|
||||||
yoffset = pt2cm(pstyle.get_font().get_size())
|
yoffset = 2 * pt2cm(pstyle.get_font().get_size())
|
||||||
#print title
|
#print title
|
||||||
|
|
||||||
# header
|
# header
|
||||||
@ -950,9 +956,12 @@ class StatisticsChartOptions(MenuReportOptions):
|
|||||||
|
|
||||||
self.__pid = PersonOption(_("Filter Person"))
|
self.__pid = PersonOption(_("Filter Person"))
|
||||||
self.__pid.set_help(_("The center person for the filter."))
|
self.__pid.set_help(_("The center person for the filter."))
|
||||||
add_option("pid", self.__pid)
|
menu.add_option(category_name, "pid", self.__pid)
|
||||||
self.__pid.connect('value-changed', self.__update_filters)
|
self.__pid.connect('value-changed', self.__update_filters)
|
||||||
|
|
||||||
|
self._nf = stdoptions.add_name_format_option(menu, category_name)
|
||||||
|
self._nf.connect('value-changed', self.__update_filters)
|
||||||
|
|
||||||
self.__update_filters()
|
self.__update_filters()
|
||||||
|
|
||||||
sortby = EnumeratedListOption(_('Sort chart items by'),
|
sortby = EnumeratedListOption(_('Sort chart items by'),
|
||||||
@ -1031,7 +1040,10 @@ class StatisticsChartOptions(MenuReportOptions):
|
|||||||
"""
|
"""
|
||||||
gid = self.__pid.get_value()
|
gid = self.__pid.get_value()
|
||||||
person = self.__db.get_person_from_gramps_id(gid)
|
person = self.__db.get_person_from_gramps_id(gid)
|
||||||
filter_list = ReportUtils.get_person_filters(person, False)
|
nfv = self._nf.get_value()
|
||||||
|
filter_list = ReportUtils.get_person_filters(person,
|
||||||
|
include_single=False,
|
||||||
|
name_format=nfv)
|
||||||
self.__filter.set_filters(filter_list)
|
self.__filter.set_filters(filter_list)
|
||||||
|
|
||||||
def __filter_changed(self):
|
def __filter_changed(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user