* src/plugins/IndivComplete.py: make compatible with BookReport
svn: r1791
This commit is contained in:
parent
d6d4d874a3
commit
64c0e1cd89
@ -48,14 +48,25 @@ from intl import gettext as _
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up sane defaults for the book_item
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_person_id = ""
|
||||
_max_gen = 0
|
||||
_pg_brk = 0
|
||||
_filter = None
|
||||
_options = [ _person_id, _max_gen, _pg_brk, _filter ]
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# IndivComplete
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class IndivComplete:
|
||||
class IndivComplete(Report.Report):
|
||||
|
||||
def __init__(self,database,person,output,document,filter,use_srcs):
|
||||
def __init__(self,database,person,output,document,filter,use_srcs,newpage=0):
|
||||
self.d = document
|
||||
self.use_srcs = use_srcs
|
||||
self.filter = filter
|
||||
@ -65,6 +76,12 @@ class IndivComplete:
|
||||
self.database = database
|
||||
self.person = person
|
||||
self.output = output
|
||||
if output:
|
||||
self.standalone = 1
|
||||
self.d.open(output)
|
||||
else:
|
||||
self.standalone = 0
|
||||
self.newpage = newpage
|
||||
|
||||
def setup(self):
|
||||
tbl = TextDoc.TableStyle()
|
||||
@ -72,31 +89,30 @@ class IndivComplete:
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
self.d.add_table_style("IndTable",tbl)
|
||||
self.d.add_table_style("IDS:IndTable",tbl)
|
||||
|
||||
tbl = TextDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,50)
|
||||
tbl.set_column_width(1,50)
|
||||
self.d.add_table_style("ParentsTable",tbl)
|
||||
self.d.add_table_style("IDS:ParentsTable",tbl)
|
||||
|
||||
cell = TextDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
self.d.add_cell_style("TableHead",cell)
|
||||
self.d.add_cell_style("IDS:TableHead",cell)
|
||||
|
||||
cell = TextDoc.TableCellStyle()
|
||||
self.d.add_cell_style("NormalCell",cell)
|
||||
self.d.add_cell_style("IDS:NormalCell",cell)
|
||||
|
||||
cell = TextDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
self.d.add_cell_style("ListCell",cell)
|
||||
|
||||
self.d.open(self.output)
|
||||
self.d.add_cell_style("IDS:ListCell",cell)
|
||||
|
||||
def end(self):
|
||||
self.d.close()
|
||||
if self.standalone:
|
||||
self.d.close()
|
||||
|
||||
def write_fact(self,event):
|
||||
if event == None:
|
||||
@ -142,26 +158,26 @@ class IndivComplete:
|
||||
note = self.person.getNote()
|
||||
if note == '':
|
||||
return
|
||||
self.d.start_table('note','IndTable')
|
||||
self.d.start_table('note','IDS:IndTable')
|
||||
self.d.start_row()
|
||||
self.d.start_cell('TableHead',2)
|
||||
self.d.start_paragraph('TableTitle')
|
||||
self.d.start_cell('IDS:TableHead',2)
|
||||
self.d.start_paragraph('IDS:TableTitle')
|
||||
self.d.write_text(_('Notes'))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
self.d.end_row()
|
||||
|
||||
self.d.start_row()
|
||||
self.d.start_cell('NormalCell',2)
|
||||
self.d.start_cell('IDS:NormalCell',2)
|
||||
for line in string.split(note,'\n'):
|
||||
self.d.start_paragraph('Normal')
|
||||
self.d.start_paragraph('IDS:Normal')
|
||||
self.d.write_text(line)
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
self.d.end_row()
|
||||
|
||||
self.d.end_table()
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
def write_alt_parents(self):
|
||||
@ -169,10 +185,10 @@ class IndivComplete:
|
||||
if len(self.person.getParentList()) < 2:
|
||||
return
|
||||
|
||||
self.d.start_table("altparents","IndTable")
|
||||
self.d.start_table("altparents","IDS:IndTable")
|
||||
self.d.start_row()
|
||||
self.d.start_cell("TableHead",2)
|
||||
self.d.start_paragraph("TableTitle")
|
||||
self.d.start_cell("IDS:TableHead",2)
|
||||
self.d.start_paragraph("IDS:TableTitle")
|
||||
self.d.write_text(_("Alternate Parents"))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
@ -199,7 +215,7 @@ class IndivComplete:
|
||||
self.write_p_entry(_('Mother'),'','')
|
||||
|
||||
self.d.end_table()
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
def write_alt_names(self):
|
||||
@ -207,10 +223,10 @@ class IndivComplete:
|
||||
if len(self.person.getAlternateNames()) < 1:
|
||||
return
|
||||
|
||||
self.d.start_table("altparents","IndTable")
|
||||
self.d.start_table("altparents","IDS:IndTable")
|
||||
self.d.start_row()
|
||||
self.d.start_cell("TableHead",2)
|
||||
self.d.start_paragraph("TableTitle")
|
||||
self.d.start_cell("IDS:TableHead",2)
|
||||
self.d.start_paragraph("IDS:TableTitle")
|
||||
self.d.write_text(_("Alternate Names"))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
@ -228,7 +244,7 @@ class IndivComplete:
|
||||
self.normal_cell(text)
|
||||
self.d.end_row()
|
||||
self.d.end_table()
|
||||
self.d.start_paragraph('Normal')
|
||||
self.d.start_paragraph('IDS:Normal')
|
||||
self.d.end_paragraph()
|
||||
|
||||
def write_families(self):
|
||||
@ -236,10 +252,10 @@ class IndivComplete:
|
||||
if len(self.person.getFamilyList()) == 0:
|
||||
return
|
||||
|
||||
self.d.start_table("three","IndTable")
|
||||
self.d.start_table("three","IDS:IndTable")
|
||||
self.d.start_row()
|
||||
self.d.start_cell("TableHead",2)
|
||||
self.d.start_paragraph("TableTitle")
|
||||
self.d.start_cell("IDS:TableHead",2)
|
||||
self.d.start_paragraph("IDS:TableTitle")
|
||||
self.d.write_text(_("Marriages/Children"))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
@ -251,8 +267,8 @@ class IndivComplete:
|
||||
else:
|
||||
spouse = family.getFather()
|
||||
self.d.start_row()
|
||||
self.d.start_cell("NormalCell",2)
|
||||
self.d.start_paragraph("Spouse")
|
||||
self.d.start_cell("IDS:NormalCell",2)
|
||||
self.d.start_paragraph("IDS:Spouse")
|
||||
if spouse:
|
||||
text = spouse.getPrimaryName().getRegularName()
|
||||
else:
|
||||
@ -270,8 +286,8 @@ class IndivComplete:
|
||||
self.d.start_row()
|
||||
self.normal_cell(_("Children"))
|
||||
|
||||
self.d.start_cell("ListCell")
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_cell("IDS:ListCell")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
|
||||
first = 1
|
||||
for child in family.getChildList():
|
||||
@ -284,7 +300,7 @@ class IndivComplete:
|
||||
self.d.end_cell()
|
||||
self.d.end_row()
|
||||
self.d.end_table()
|
||||
self.d.start_paragraph('Normal')
|
||||
self.d.start_paragraph('IDS:Normal')
|
||||
self.d.end_paragraph()
|
||||
|
||||
def write_sources(self):
|
||||
@ -292,10 +308,10 @@ class IndivComplete:
|
||||
if len(self.slist) == 0:
|
||||
return
|
||||
|
||||
self.d.start_table("three","IndTable")
|
||||
self.d.start_table("three","IDS:IndTable")
|
||||
self.d.start_row()
|
||||
self.d.start_cell("TableHead",2)
|
||||
self.d.start_paragraph("TableTitle")
|
||||
self.d.start_cell("IDS:TableHead",2)
|
||||
self.d.start_paragraph("IDS:TableTitle")
|
||||
self.d.write_text(_("Sources"))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
@ -310,10 +326,10 @@ class IndivComplete:
|
||||
self.d.end_table()
|
||||
|
||||
def write_facts(self):
|
||||
self.d.start_table("two","IndTable")
|
||||
self.d.start_table("two","IDS:IndTable")
|
||||
self.d.start_row()
|
||||
self.d.start_cell("TableHead",2)
|
||||
self.d.start_paragraph("TableTitle")
|
||||
self.d.start_cell("IDS:TableHead",2)
|
||||
self.d.start_paragraph("IDS:TableTitle")
|
||||
self.d.write_text(_("Individual Facts"))
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
@ -324,18 +340,23 @@ class IndivComplete:
|
||||
for event in event_list:
|
||||
self.write_fact(event)
|
||||
self.d.end_table()
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
def normal_cell(self,text):
|
||||
self.d.start_cell('NormalCell')
|
||||
self.d.start_paragraph('Normal')
|
||||
self.d.start_cell('IDS:NormalCell')
|
||||
self.d.start_paragraph('IDS:Normal')
|
||||
self.d.write_text(text)
|
||||
self.d.end_paragraph()
|
||||
self.d.end_cell()
|
||||
|
||||
def write_report(self):
|
||||
ind_list = self.filter.apply(self.database,self.database.getPersonMap().values())
|
||||
plist = self.database.getPersonMap().values()
|
||||
if self.filter:
|
||||
ind_list = self.filter.apply(self.database,plist)
|
||||
else:
|
||||
ind_list = plist
|
||||
|
||||
count = 0
|
||||
for self.person in ind_list:
|
||||
self.write_person(count)
|
||||
@ -349,22 +370,22 @@ class IndivComplete:
|
||||
|
||||
photo_list = self.person.getPhotoList()
|
||||
name = self.person.getPrimaryName().getRegularName()
|
||||
self.d.start_paragraph("Title")
|
||||
self.d.start_paragraph("IDS:Title")
|
||||
self.d.write_text(_("Summary of %s") % name)
|
||||
self.d.end_paragraph()
|
||||
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
if len(photo_list) > 0:
|
||||
object = photo_list[0].getReference()
|
||||
if object.getMimeType()[0:5] == "image":
|
||||
file = object.getPath()
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.add_photo(file,"row",4.0,4.0)
|
||||
self.d.end_paragraph()
|
||||
|
||||
self.d.start_table("one","IndTable")
|
||||
self.d.start_table("one","IDS:IndTable")
|
||||
|
||||
self.d.start_row()
|
||||
self.normal_cell("%s:" % _("Name"))
|
||||
@ -412,7 +433,7 @@ class IndivComplete:
|
||||
self.d.end_row()
|
||||
self.d.end_table()
|
||||
|
||||
self.d.start_paragraph("Normal")
|
||||
self.d.start_paragraph("IDS:Normal")
|
||||
self.d.end_paragraph()
|
||||
|
||||
self.write_alt_names()
|
||||
@ -427,7 +448,7 @@ class IndivComplete:
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class IndivSummaryDialog(Report.TextReportDialog):
|
||||
class IndivCompleteDialog(Report.TextReportDialog):
|
||||
def __init__(self,database,person):
|
||||
Report.TextReportDialog.__init__(self,database,person)
|
||||
|
||||
@ -491,42 +512,8 @@ class IndivSummaryDialog(Report.TextReportDialog):
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def make_default_style(self):
|
||||
"""Make the default output style for the Individual Summary Report."""
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(16)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_alignment(TextDoc.PARA_ALIGN_CENTER)
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
self.default_style.add_style("Title",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
font.set_italic(1)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for category labels."))
|
||||
self.default_style.add_style("TableTitle",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the spouse's name."))
|
||||
self.default_style.add_style("Spouse",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_size(12)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
self.default_style.add_style("Normal",p)
|
||||
"""Make the default output style for the Individual Complete Report."""
|
||||
_make_default_style(self.default_style)
|
||||
|
||||
def setup_report_options(self):
|
||||
"""The 'Report Options' frame is not used in this dialog."""
|
||||
@ -538,6 +525,7 @@ class IndivSummaryDialog(Report.TextReportDialog):
|
||||
opened."""
|
||||
|
||||
act = self.use_srcs.get_active()
|
||||
|
||||
try:
|
||||
MyReport = IndivComplete(self.db, self.person, self.target_path,
|
||||
self.doc, self.filter, act)
|
||||
@ -566,8 +554,169 @@ class IndivSummaryDialog(Report.TextReportDialog):
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def report(database,person):
|
||||
IndivSummaryDialog(database,person)
|
||||
IndivCompleteDialog(database,person)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Book Item Options dialog
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class IndivCompleteBareReportDialog(Report.BareReportDialog):
|
||||
|
||||
def __init__(self,database,person,opt,stl):
|
||||
|
||||
self.options = opt
|
||||
print self.options
|
||||
self.db = database
|
||||
if self.options[0]:
|
||||
self.person = self.db.getPerson(self.options[0])
|
||||
else:
|
||||
self.person = person
|
||||
Report.BareReportDialog.__init__(self,database,self.person)
|
||||
|
||||
self.max_gen = int(self.options[1])
|
||||
self.pg_brk = int(self.options[2])
|
||||
self.style_name = stl
|
||||
self.new_person = None
|
||||
|
||||
self.generations_spinbox.set_value(self.max_gen)
|
||||
self.pagebreak_checkbox.set_active(self.pg_brk)
|
||||
|
||||
self.window.run()
|
||||
|
||||
def make_default_style(self):
|
||||
_make_default_style(self.default_style)
|
||||
|
||||
def get_report_filters(self):
|
||||
"""Set up the list of possible content filters."""
|
||||
|
||||
name = self.person.getPrimaryName().getName()
|
||||
|
||||
id = GenericFilter.GenericFilter()
|
||||
id.set_name(name)
|
||||
id.add_rule(GenericFilter.HasIdOf([self.person.getId()]))
|
||||
|
||||
des = GenericFilter.GenericFilter()
|
||||
des.set_name(_("Descendants of %s") % name)
|
||||
des.add_rule(GenericFilter.IsDescendantOf([self.person.getId()]))
|
||||
|
||||
ans = GenericFilter.GenericFilter()
|
||||
ans.set_name(_("Ancestors of %s") % name)
|
||||
ans.add_rule(GenericFilter.IsAncestorOf([self.person.getId()]))
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("Entire Database"))
|
||||
all.add_rule(GenericFilter.Everyone([]))
|
||||
|
||||
return [id,des,ans,all]
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Customization hooks
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def get_title(self):
|
||||
"""The window title for this dialog"""
|
||||
return "%s - GRAMPS Book" % (_("Individual Complete"))
|
||||
|
||||
def get_header(self, name):
|
||||
"""The header line at the top of the dialog contents"""
|
||||
return _("Individual Complete Report for GRAMPS Book")
|
||||
|
||||
def get_stylesheet_savefile(self):
|
||||
"""Where to save styles for this report."""
|
||||
return "individual_summary.xml"
|
||||
|
||||
def on_cancel(self, obj):
|
||||
pass
|
||||
|
||||
def on_ok_clicked(self, obj):
|
||||
"""The user is satisfied with the dialog choices. Parse all options
|
||||
and close the window."""
|
||||
|
||||
# Preparation
|
||||
self.parse_style_frame()
|
||||
self.parse_report_options_frame()
|
||||
|
||||
if self.new_person:
|
||||
self.person = self.new_person
|
||||
self.options = [ self.person.getId(), self.max_gen, self.pg_brk ]
|
||||
self.style_name = self.selected_style.get_name()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Function to write Book Item
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def write_book_item(database,person,doc,options,newpage=0):
|
||||
"""Write the FTM Style Descendant Report options set.
|
||||
All user dialog has already been handled and the output file opened."""
|
||||
try:
|
||||
print options
|
||||
if options[0]:
|
||||
person = database.getPerson(options[0])
|
||||
max_gen = int(options[1])
|
||||
pg_brk = int(options[2])
|
||||
filter = options[3]
|
||||
|
||||
# act = self.use_srcs.get_active()
|
||||
|
||||
return IndivComplete(database, person, None, doc, filter, 0, newpage)
|
||||
# return IndivComplete(database, person, None, doc, filter, act, newpage)
|
||||
except Errors.ReportError, msg:
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except Errors.FilterError, msg:
|
||||
(m1,m2) = msg.messages()
|
||||
ErrorDialog(m1,m2)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Makes the default styles
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def _make_default_style(default_style):
|
||||
"""Make the default output style for the Individual Complete Report."""
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(16)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_alignment(TextDoc.PARA_ALIGN_CENTER)
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("IDS:Title",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
font.set_italic(1)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for category labels."))
|
||||
default_style.add_style("IDS:TableTitle",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(TextDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the spouse's name."))
|
||||
default_style.add_style("IDS:Spouse",p)
|
||||
|
||||
font = TextDoc.FontStyle()
|
||||
font.set_size(12)
|
||||
p = TextDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("IDS:Normal",p)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -663,7 +812,7 @@ def get_xpm_image():
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from Plugins import register_report
|
||||
from Plugins import register_report, register_book_item
|
||||
|
||||
register_report(
|
||||
report,
|
||||
@ -673,3 +822,14 @@ register_report(
|
||||
description=_("Produces a complete report on the selected people."),
|
||||
xpm=get_xpm_image()
|
||||
)
|
||||
|
||||
register_book_item(
|
||||
_("Individual Complete"),
|
||||
_("Text"),
|
||||
IndivCompleteBareReportDialog,
|
||||
write_book_item,
|
||||
_options,
|
||||
"default" ,
|
||||
"individual_complete.xml",
|
||||
_make_default_style
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user