From 9e1a5abf94b2dcb5a93bb115669981977f4a791f Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Fri, 27 Jul 2007 04:14:07 +0000 Subject: [PATCH] Add marker report svn: r8776 --- ChangeLog | 5 + po/POTFILES.in | 1 + src/plugins/Makefile.am | 1 + src/plugins/MarkerReport.py | 195 ++++++++++++++++++++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 src/plugins/MarkerReport.py diff --git a/ChangeLog b/ChangeLog index f0ac56fbc..c81cc1fe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-26 Brian Matherly + * src/plugins/MarkerReport.py: Add marker report + * src/plugins/Makefile.in: Add MarkerReport.py + * po/POTFILES.in: Add MarkerReport.py + 2007-07-26 Don Allingham * src/DataViews/_PersonView.py: add siblings quick report * src/plugins/siblings.py: Added diff --git a/po/POTFILES.in b/po/POTFILES.in index 64b8e76f5..fa3c60004 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -311,6 +311,7 @@ src/plugins/ImportvCard.py src/plugins/IndivComplete.py src/plugins/Leak.py src/plugins/FindDupes.py +src/plugins/MarkerReport.py src/plugins/MediaManager.py src/plugins/NarrativeWeb.py src/plugins/OwnerEditor.py diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 73f63d29b..95d158110 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -33,6 +33,7 @@ pkgdata_PYTHON = \ IndivComplete.py\ ImportvCard.py\ FindDupes.py\ + MarkerReport.py\ NarrativeWeb.py\ PatchNames.py\ ReadPkg.py\ diff --git a/src/plugins/MarkerReport.py b/src/plugins/MarkerReport.py new file mode 100644 index 000000000..51825ecc9 --- /dev/null +++ b/src/plugins/MarkerReport.py @@ -0,0 +1,195 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007 Brian G. Matherly +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +"Generate files/Marker Report" + +#------------------------------------------------------------------------ +# +# standard python modules +# +#------------------------------------------------------------------------ +from gettext import gettext as _ + +#------------------------------------------------------------------------ +# +# GRAMPS modules +# +#------------------------------------------------------------------------ +from PluginUtils import register_report +from ReportBase import Report, ReportUtils, ReportOptions, \ + CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI +import BaseDoc +import Sort +from RelLib import MarkerType +from Filters import GenericFilter, Rules +from BasicUtils import name_displayer + +#------------------------------------------------------------------------ +# +# GTK/GNOME modules +# +#------------------------------------------------------------------------ +import gtk + +#------------------------------------------------------------------------ +# +# MarkerReport +# +#------------------------------------------------------------------------ +class MarkerReport(Report): + + def __init__(self,database,person,options_class): + """ + Creates the MarkerReport object that produces the report. + + The arguments are: + + database - the GRAMPS database instance + person - currently selected person + options_class - instance of the Options class for this report + + This report needs the following parameters (class variables) + that come in the options class. + + marker - The marker each object must match to be included. + + """ + + Report.__init__(self,database,person,options_class) + + self.marker = options_class.handler.options_dict['marker'] + self.filter = GenericFilter() + self.filter.add_rule(Rules.Person.HasMarkerOf([self.marker])) + + def write_report(self): + self.doc.start_paragraph("MR-Title") + title = _("Marker Report for %s Items") % self.marker + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) + self.doc.write_text(title,mark) + self.doc.end_paragraph() + + plist = self.database.get_person_handles(sort_handles=False) + ind_list = self.filter.apply(self.database,plist) + + count = 1 + for person_handle in ind_list: + person = self.database.get_person_from_handle(person_handle) + name = name_displayer.display(person) + mark = ReportUtils.get_person_mark(self.database, person) + self.doc.start_paragraph('MR-Normal',str(count)) + self.doc.write_text(name,mark) + self.doc.end_paragraph() + count = count + 1 + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class MarkerOptions(ReportOptions): + + """ + Defines options and provides handling interface. + """ + + def __init__(self,name,person_id=None): + ReportOptions.__init__(self,name,person_id) + + def set_new_options(self): + # Options specific for this report + self.options_dict = { + 'marker' : "", + } + self.options_help = { + 'marker' : ("=str","Marker", + "The marker each item must match to be included", + True), + } + + def add_user_options(self,dialog): + """ + Override the base class add_user_options task to add generations option + """ + self.marker_menu = gtk.combo_box_new_text() + index = 0 + marker_index = 0 + markers = dialog.db.get_marker_types() + markers.append(MarkerType().get_map()[MarkerType.COMPLETE]) + markers.append(MarkerType().get_map()[MarkerType.TODO_TYPE]) + for marker in markers: + self.marker_menu.append_text(marker) + if self.options_dict['marker'] == marker: + marker_index = index + index += 1 + self.marker_menu.set_active(marker_index) + dialog.add_option('Marker',self.marker_menu) + + def parse_user_options(self,dialog): + """ + Parses the custom options that we have added. Set the value in the + options dictionary. + """ + self.options_dict['marker'] = self.marker_menu.get_active_text() + + def make_default_style(self,default_style): + """Make the default output style for the Marker Report.""" + f = BaseDoc.FontStyle() + f.set_size(12) + f.set_type_face(BaseDoc.FONT_SANS_SERIF) + f.set_bold(1) + p = BaseDoc.ParagraphStyle() + p.set_header_level(1) + p.set_bottom_border(1) + p.set_top_margin(ReportUtils.pt2cm(3)) + p.set_bottom_margin(ReportUtils.pt2cm(3)) + p.set_font(f) + p.set_alignment(BaseDoc.PARA_ALIGN_CENTER) + p.set_description(_("The style used for the title of the page.")) + default_style.add_paragraph_style("MR-Title",p) + + font = BaseDoc.FontStyle() + font.set_size(12) + p = BaseDoc.ParagraphStyle() + p.set(first_indent=-0.75,lmargin=.75) + p.set_font(font) + p.set_top_margin(ReportUtils.pt2cm(3)) + p.set_bottom_margin(ReportUtils.pt2cm(3)) + p.set_description(_('The basic style used for the text display.')) + default_style.add_paragraph_style("MR-Normal",p) + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +register_report( + name = 'marker_report', + category = CATEGORY_TEXT, + report_class = MarkerReport, + options_class = MarkerOptions, + modes = MODE_GUI | MODE_BKI | MODE_CLI, + translated_name = _("Marker Report"), + status=(_("Stable")), + description=_("Generates a list of people with a specified marker"), + author_name="Brian G. Matherly", + author_email="pez4brian@gramps-project.org" + )