2385: drawreports and multiple calendars

svn: r13925
This commit is contained in:
Jérôme Rapinat 2009-12-27 11:09:58 +00:00
parent d06feb67ca
commit bf944b0de3
2 changed files with 19 additions and 20 deletions

View File

@ -40,6 +40,7 @@ from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
from gen.plug.menu import EnumeratedListOption, NumberOption, PersonOption from gen.plug.menu import EnumeratedListOption, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions from ReportBase import Report, ReportUtils, MenuReportOptions
from SubstKeywords import SubstKeywords from SubstKeywords import SubstKeywords
import config
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -58,6 +59,8 @@ RADIAL_ROUNDABOUT = 1
pt2cm = ReportUtils.pt2cm pt2cm = ReportUtils.pt2cm
cal = config.get('preferences.calendar-format-report')
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# private functions # private functions
@ -269,7 +272,7 @@ class FanChart(Report):
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
if birth_ref: if birth_ref:
birth = self.database.get_event_from_handle(birth_ref.ref) birth = self.database.get_event_from_handle(birth_ref.ref)
b = birth.get_date_object().get_year() b = birth.get_date_object().to_calendar(cal).get_year()
if b == 0: if b == 0:
b = "" b = ""
else: else:
@ -278,7 +281,7 @@ class FanChart(Report):
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
if death_ref: if death_ref:
death = self.database.get_event_from_handle(death_ref.ref) death = self.database.get_event_from_handle(death_ref.ref)
d = death.get_date_object().get_year() d = death.get_date_object().to_calendar(cal).get_year()
if d == 0: if d == 0:
d = "" d = ""
else: else:

View File

@ -47,9 +47,16 @@ from QuestionDialog import ErrorDialog
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import probably_alive from Utils import probably_alive
from gui.utils import ProgressMeter from gui.utils import ProgressMeter
import gen.lib import config
from gen.utils import get_birth_or_fallback, get_death_or_fallback from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
# private constants
#
#------------------------------------------------------------------------
cal = config.get('preferences.calendar-format-report')
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Private Functions # Private Functions
@ -97,7 +104,6 @@ class TimeLine(Report):
sort_functions = _get_sort_functions(Sort.Sort(database)) sort_functions = _get_sort_functions(Sort.Sort(database))
self.sort_name = sort_functions[sort_func_num][0] self.sort_name = sort_functions[sort_func_num][0]
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
self.calendar = gen.lib.date.Date.ui_calendar_names[menu.get_option_by_name('calendar').get_value()]
def write_report(self): def write_report(self):
self.progress = ProgressMeter(_('Timeline')) self.progress = ProgressMeter(_('Timeline'))
@ -142,13 +148,13 @@ class TimeLine(Report):
p = self.database.get_person_from_handle(p_id) p = self.database.get_person_from_handle(p_id)
birth = get_birth_or_fallback(self.database, p) birth = get_birth_or_fallback(self.database, p)
if birth: if birth:
b = birth.get_date_object().to_calendar(self.calendar).get_year() b = birth.get_date_object().to_calendar(cal).get_year()
else: else:
b = None b = None
death = get_death_or_fallback(self.database, p) death = get_death_or_fallback(self.database, p)
if death: if death:
d = death.get_date_object().to_calendar(self.calendar).get_year() d = death.get_date_object().to_calendar(cal).get_year()
else: else:
d = None d = None
@ -214,9 +220,7 @@ class TimeLine(Report):
normal_font = style_sheet.get_paragraph_style('TLG-Name').get_font() normal_font = style_sheet.get_paragraph_style('TLG-Name').get_font()
label_font = style_sheet.get_paragraph_style('TLG-Label').get_font() label_font = style_sheet.get_paragraph_style('TLG-Label').get_font()
byline = _("%(calendar_type)s Calendar, Sorted by %(sortby)s") % \ byline = _("Sorted by %s") % self.sort_name
{"calendar_type": self.calendar,
"sortby": self.sort_name}
self.doc.center_text('TLG-title',self.title + "\n" + byline,width/2.0,0) self.doc.center_text('TLG-title',self.title + "\n" + byline,width/2.0,0)
@ -245,13 +249,13 @@ class TimeLine(Report):
p = self.database.get_person_from_handle(p_id) p = self.database.get_person_from_handle(p_id)
birth = get_birth_or_fallback(self.database, p) birth = get_birth_or_fallback(self.database, p)
if birth: if birth:
b = birth.get_date_object().to_calendar(self.calendar).get_year() b = birth.get_date_object().to_calendar(cal).get_year()
else: else:
b = None b = None
death = get_death_or_fallback(self.database, p) death = get_death_or_fallback(self.database, p)
if death: if death:
d = death.get_date_object().to_calendar(self.calendar).get_year() d = death.get_date_object().to_calendar(cal).get_year()
else: else:
d = None d = None
@ -332,14 +336,6 @@ class TimeLineOptions(MenuReportOptions):
sortby.set_help( _("Sorting method to use")) sortby.set_help( _("Sorting method to use"))
menu.add_option(category_name,"sortby",sortby) menu.add_option(category_name,"sortby",sortby)
self.__calendar = EnumeratedListOption(_("Calendar"), 0)
self.__calendar.set_help(_("The calendar which determines the year span"))
idx = 0
for calendar in gen.lib.date.Date.ui_calendar_names:
self.__calendar.add_item(idx, calendar)
idx += 1
menu.add_option(category_name, "calendar", self.__calendar)
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