* src/plugings/FamiyGroup.py: options for "Recursive", "Generation

Number", "Parent Events", "Parent Addresses", "Parent Alternate
Names", "Parent Notes".


svn: r5830
This commit is contained in:
Don Allingham 2006-01-25 19:10:09 +00:00
parent 8eddbe7462
commit d3753628c9
2 changed files with 319 additions and 136 deletions

View File

@ -1,3 +1,8 @@
2006-01-25 Brian Matherly <pez4brian@users.sourceforge.net>
* src/plugings/FamiyGroup.py: options for "Recursive", "Generation
Number", "Parent Events", "Parent Addresses", "Parent Alternate
Names", "Parent Notes".
2006-01-16 Alex Roitman <shura@gramps-project.org>
* src/GenericFilter.py
(IsLessThanNthGenerationAncestorOfBookmarked): Typo.

View File

@ -46,7 +46,7 @@ import Report
import BaseDoc
import ReportOptions
from DateHandler import displayer as _dd
import const
#------------------------------------------------------------------------
#
# FamilyGroup
@ -71,7 +71,7 @@ class FamilyGroup(Report.Report):
"""
Report.Report.__init__(self,database,person,options_class)
self.family = None
self.family_handle = None
spouse_id = options_class.handler.options_dict['spouse_id']
if spouse_id:
@ -85,9 +85,18 @@ class FamilyGroup(Report.Report):
this_spouse = database.get_person_from_handle(this_spouse_handle)
this_spouse_id = this_spouse.get_gramps_id()
if spouse_id == this_spouse_id:
self.family = family
self.family_handle = family_handle
break
self.recursive = options_class.handler.options_dict['recursive']
self.missingInfo = options_class.handler.options_dict['missinginfo']
self.generations = options_class.handler.options_dict['generations']
self.incParEvents = options_class.handler.options_dict['incParEvents']
self.incParAddr = options_class.handler.options_dict['incParAddr']
self.incParNotes = options_class.handler.options_dict['incParNotes']
self.incParNames = options_class.handler.options_dict['incParNames']
self.incRelDates = options_class.handler.options_dict['incRelDates']
def define_table_styles(self):
"""
Define the table styles used by the report.
@ -151,6 +160,46 @@ class FamilyGroup(Report.Report):
table.set_column_width(3,40)
self.doc.add_table_style('FGR-ChildTable',table)
def dump_parent_event(self,name,event):
place = ""
date = ""
if event:
date = event.get_date()
place_handle = event.get_place_handle()
if place_handle:
place = self.database.get_place_from_handle(place_handle).get_title()
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(name)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(date)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(place)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
def dump_parent_line(self,name,text):
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(name)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd",2)
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(text)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
def dump_parent(self,person_handle):
if not person_handle:
@ -174,60 +223,18 @@ class FamilyGroup(Report.Report):
self.doc.end_row()
birth_handle = person.get_birth_handle()
bdate = ""
bplace = ""
birth = None
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle)
bdate = birth.get_date()
bplace_handle = birth.get_place_handle()
if bplace_handle:
bplace = self.database.get_place_from_handle(bplace_handle).get_title()
if birth or self.missingInfo:
self.dump_parent_event(_("Birth"),birth)
death_handle = person.get_death_handle()
ddate = ""
dplace = ""
death = None
if death_handle:
death = self.database.get_event_from_handle(death_handle)
ddate = death.get_date()
dplace_handle = death.get_place_handle()
if dplace_handle:
dplace = self.database.get_place_from_handle(dplace_handle).get_title()
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(_("Birth"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(bdate)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(bplace)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(_("Death"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(ddate)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(dplace)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
if death or self.missingInfo:
self.dump_parent_event(_("Death"),death)
family_handle = person.get_main_parents_family_handle()
father_name = ""
@ -236,36 +243,81 @@ class FamilyGroup(Report.Report):
family = self.database.get_family_from_handle(family_handle)
father_handle = family.get_father_handle()
if father_handle:
father_name = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
father = self.database.get_person_from_handle(father_handle)
father_name = father.get_primary_name().get_regular_name()
if self.incRelDates:
birth_handle = father.get_birth_handle()
birth = " "
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle).get_date()
death_handle = father.get_death_handle()
death = " "
if death_handle:
death = self.database.get_event_from_handle(death_handle).get_date()
if birth_handle or death_handle:
father_name = "%s (%s - %s)" % (father_name,birth,death)
mother_handle = family.get_mother_handle()
if mother_handle:
mother_name = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
mother = self.database.get_person_from_handle(mother_handle)
mother_name = mother.get_primary_name().get_regular_name()
if self.incRelDates:
birth_handle = mother.get_birth_handle()
birth = " "
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle).get_date()
death_handle = mother.get_death_handle()
death = " "
if death_handle:
death = self.database.get_event_from_handle(death_handle).get_date()
if birth_handle or death_handle:
mother_name = "%s (%s - %s)" % (mother_name,birth,death)
if self.missingInfo or father_name != "":
self.dump_parent_line(_("Father"),father_name)
if self.missingInfo or mother_name != "":
self.dump_parent_line(_("Mother"),mother_name)
if self.incParEvents:
for event_handle in person.get_event_list():
event = self.database.get_event_from_handle(event_handle)
evtName = event.get_name()
if (evtName != "Death") and (evtName != "Birth"):
self.dump_parent_event(evtName,event)
if self.incParAddr:
addrlist = person.get_address_list()[:]
for addr in addrlist:
location = "%s %s %s %s" % (addr.get_street(),addr.get_city(),
addr.get_state(),addr.get_country())
date = addr.get_date()
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(_("Father"))
self.doc.write_text(_("Address"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd",2)
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(father_name)
self.doc.write_text(date)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(location)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.doc.start_row()
self.doc.start_cell("FGR-TextContents")
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(_("Mother"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd",2)
self.doc.start_paragraph('FGR-Normal')
self.doc.write_text(mother_name)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
if self.incParNotes and (person.get_note() != ""):
self.dump_parent_line(_("Notes"),person.get_note())
if self.incParNames:
for alt_name in person.get_alternate_names():
type = const.NameTypesMap.find_value(alt_name.get_type())
name = alt_name.get_regular_name()
self.dump_parent_line(type,name)
self.doc.end_table()
@ -330,7 +382,11 @@ class FamilyGroup(Report.Report):
death = self.database.get_event_from_handle(death_handle)
else:
death = None
if self.missingInfo or birth != None:
self.dump_child_event('FGR-TextChild1',_('Birth'),birth)
if self.missingInfo or death != None:
if families == 0:
self.dump_child_event('FGR-TextChild2',_('Death'),death)
else:
@ -352,6 +408,8 @@ class FamilyGroup(Report.Report):
spouse_id = family.get_mother_handle()
else:
spouse_id = family.get_father_handle()
if self.missingInfo or spouse_id:
self.doc.start_row()
self.doc.start_cell('FGR-TextChild1')
self.doc.start_paragraph('FGR-Normal')
@ -366,29 +424,45 @@ class FamilyGroup(Report.Report):
self.doc.start_paragraph('FGR-Normal')
if spouse_id:
spouse = self.database.get_person_from_handle(spouse_id)
self.doc.write_text(spouse.get_primary_name().get_regular_name())
spouse_name = spouse.get_primary_name().get_regular_name()
if self.incRelDates:
birth_handle = spouse.get_birth_handle()
birth = " "
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle).get_date()
death_handle = spouse.get_death_handle()
death = " "
if death_handle:
death = self.database.get_event_from_handle(death_handle).get_date()
if birth_handle or death_handle:
spouse_name = "%s (%s - %s)" % (spouse_name,birth,death)
self.doc.write_text(spouse_name)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
if self.missingInfo or m:
if index == families:
self.dump_child_event('FGR-TextChild2',_("Married"),m)
else:
self.dump_child_event('FGR-TextChild1',_("Married"),m)
def write_report(self):
def dump_family(self,family_handle,generation):
self.doc.start_paragraph('FGR-Title')
self.doc.write_text(_("Family Group Report"))
if self.recursive and self.generations:
self.doc.write_text(_("Family Group Report - Generation %d") % generation)
else:
self.doc.write_text(_("Family Group Report") )
self.doc.end_paragraph()
if self.family:
self.dump_parent(self.family.get_father_handle())
family = self.database.get_family_from_handle(family_handle)
self.dump_parent(family.get_father_handle())
self.doc.start_paragraph("FGR-blank")
self.doc.end_paragraph()
self.dump_parent(self.family.get_mother_handle())
self.dump_parent(family.get_mother_handle())
length = len(self.family.get_child_handle_list())
length = len(family.get_child_handle_list())
if length > 0:
self.doc.start_paragraph("FGR-blank")
self.doc.end_paragraph()
@ -401,11 +475,27 @@ class FamilyGroup(Report.Report):
self.doc.end_cell()
self.doc.end_row()
index = 1
for child_handle in self.family.get_child_handle_list():
for child_handle in family.get_child_handle_list():
self.dump_child(index,child_handle)
index = index + 1
self.doc.end_table()
if self.recursive:
for child_handle in family.get_child_handle_list():
child = self.database.get_person_from_handle(child_handle)
for child_family_handle in child.get_family_handle_list():
if child_family_handle != family_handle:
self.doc.page_break()
self.dump_family(child_family_handle,(generation+1))
def write_report(self):
if self.family_handle:
self.dump_family(self.family_handle,1)
else:
self.doc.start_paragraph('FGR-Title')
self.doc.write_text(_("Family Group Report"))
self.doc.end_paragraph()
#------------------------------------------------------------------------
#
#
@ -424,6 +514,14 @@ class FamilyGroupOptions(ReportOptions.ReportOptions):
# Options specific for this report
self.options_dict = {
'spouse_id' : '',
'recursive' : 0,
'missinginfo' : 1,
'generations' : 1,
'incParEvents' : 0,
'incParAddr' : 0,
'incParNotes' : 0,
'incParNames' : 0,
'incRelDates' : 0,
}
self.options_help = {
@ -432,6 +530,37 @@ class FamilyGroupOptions(ReportOptions.ReportOptions):
#[item[0] for item in self.get_spouses(None,None)],
#False
),
'recursive' : ("=0/1","Create reports for all decendants of this family.",
["Do not create reports for decendants","Create reports for decendants"],
False),
'missinginfo' : ("=0/1","Whether to include fields for missing information.",
["Do not include missing info","Include missing info"],
True),
'generations' : ("=0/1","Whether to include the generation on each report (recursive only).",
["Do not include the generation","Include the generation"],
True),
'incParEvents' : ("=0/1","Whether to include events for parents.",
["Do not include parental events","Include parental events"],
True),
'incParAddr' : ("=0/1","Whether to include addresses for parents.",
["Do not include parental addresses","Include parental addresses"],
True),
'incParNotes' : ("=0/1","Whether to include notes for parents.",
["Do not include parental notes","Include parental notes"],
True),
'incParNames' : ("=0/1","Whether to include alternate names for parents.",
["Do not include parental names","Include parental names"],
True),
'incRelDates' : ("=0/1","Whether to include dates for relatives.",
["Do not include dates of relatives","Include dates of relatives"],
True),
}
def get_spouses(self,database,person):
@ -477,7 +606,47 @@ class FamilyGroupOptions(ReportOptions.ReportOptions):
index = index + 1
self.spouse_menu.set_active(spouse_index)
# Recursive
self.recursive_option = gtk.CheckButton(_(""))
self.recursive_option.set_active(self.options_dict['recursive'])
# Missing Info
self.missing_info_option = gtk.CheckButton(_("Print fields for missing information"))
self.missing_info_option.set_active(self.options_dict['missinginfo'])
# Generations
self.include_generations_option = gtk.CheckButton(_("Generation numbers (recursive only)"))
self.include_generations_option.set_active(self.options_dict['generations'])
# Parental Events
self.include_par_events_option = gtk.CheckButton(_("Parent Events"))
self.include_par_events_option.set_active(self.options_dict['incParEvents'])
# Parental Addresses
self.include_par_addr_option = gtk.CheckButton(_("Parent Addresses"))
self.include_par_addr_option.set_active(self.options_dict['incParAddr'])
# Parental Notes
self.include_par_notes_option = gtk.CheckButton(_("Parent Notes"))
self.include_par_notes_option.set_active(self.options_dict['incParNotes'])
# Parental Names
self.include_par_names_option = gtk.CheckButton(_("Alternate Parent Names"))
self.include_par_names_option.set_active(self.options_dict['incParNames'])
# Relatives Dates
self.include_rel_dates_option = gtk.CheckButton(_("Dates of Relatives (father, mother, spouse)"))
self.include_rel_dates_option.set_active(self.options_dict['incRelDates'])
dialog.add_option(_("Spouse"),self.spouse_menu)
dialog.add_option(_("Recursive"),self.recursive_option)
dialog.add_frame_option(_('Include'),'',self.include_generations_option)
dialog.add_frame_option(_('Include'),'',self.include_par_events_option)
dialog.add_frame_option(_('Include'),'',self.include_par_addr_option)
dialog.add_frame_option(_('Include'),'',self.include_par_notes_option)
dialog.add_frame_option(_('Include'),'',self.include_par_names_option)
dialog.add_frame_option(_('Include'),'',self.include_rel_dates_option)
dialog.add_frame_option(_('Missing Information'),'',self.missing_info_option)
def parse_user_options(self,dialog):
"""
@ -488,6 +657,15 @@ class FamilyGroupOptions(ReportOptions.ReportOptions):
if spouses:
self.options_dict['spouse_id'] = spouses[spouse_index][0]
self.options_dict['recursive'] = int(self.recursive_option.get_active())
self.options_dict['missinginfo'] = int(self.missing_info_option.get_active())
self.options_dict['generations'] = int(self.include_generations_option.get_active())
self.options_dict['incParEvents'] = int(self.include_par_events_option.get_active())
self.options_dict['incParAddr'] = int(self.include_par_addr_option.get_active())
self.options_dict['incParNotes'] = int(self.include_par_notes_option.get_active())
self.options_dict['incParNames'] = int(self.include_par_names_option.get_active())
self.options_dict['incRelDates'] = int(self.include_rel_dates_option.get_active())
def make_default_style(self,default_style):
"""Make default output style for the Family Group Report."""
para = BaseDoc.ParagraphStyle()