From 4a6b730259935ee8e828ac5fdc43c9c618cdf51a Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 27 Mar 2007 11:50:26 +0000 Subject: [PATCH] Remove "get_generations()" from the report options base classes. It was forcing some reports to have the "page break between generations" options even though they weren't using it. All reports now define all of their own options. svn: r8323 --- ChangeLog | 13 +++++++ src/ReportBase/_BareReportDialog.py | 55 +--------------------------- src/ReportBase/_CommandLineReport.py | 13 +------ src/ReportBase/_ReportOptions.py | 22 ----------- src/plugins/AncestorReport.py | 29 ++++++++++----- src/plugins/DescendReport.py | 34 +++++++++++++---- src/plugins/DetAncestralReport.py | 32 ++++++++++------ src/plugins/DetDescendantReport.py | 32 ++++++++++------ 8 files changed, 101 insertions(+), 129 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1232da78..2a7e088d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-03-27 Brian Matherly + * src/ReportBase/_CommandLineReport.py + * src/ReportBase/_BareReportDialog.py + * src/ReportBase/_ReportOptions.py + * src/plugins/DescendReport.py + * src/plugins/DetDescendantReport.py + * src/plugins/AncestorReport.py + * src/plugins/DetAncestralReport.py + Remove "get_generations()" from the report options base classes. It was + forcing some reports to have the "page break between generations" options + even though they weren't using it. All reports now define all of their own + options. + 2007-03-26 Brian Matherly * src/plugins/DetDescendantReport.py: fix for multiple notes. diff --git a/src/ReportBase/_BareReportDialog.py b/src/ReportBase/_BareReportDialog.py index 538bd8973..fb5b04d62 100644 --- a/src/ReportBase/_BareReportDialog.py +++ b/src/ReportBase/_BareReportDialog.py @@ -107,8 +107,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): self.pagecount_menu = None self.extra_menu = None self.extra_textbox = None - self.pagebreak_checkbox = None - self.generations_spinbox = None self.widgets = [] self.frame_names = [] self.frames = {} @@ -116,8 +114,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): self.style_button = None self.style_name = self.options.handler.get_default_stylesheet_name() - (self.max_gen,self.page_breaks) = \ - self.options.handler.get_report_generations() window = gtk.Dialog('GRAMPS') self.set_window(window,None,self.get_title()) @@ -195,12 +191,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): this function.""" return "basic_report.xml" - def get_report_generations(self): - """Return the default number of generations to start the - spinbox (zero to disable) and whether or not to include the - 'page break between generations' check box""" - return (10, 1) - #------------------------------------------------------------------------ # # Functions related to extending the options @@ -379,13 +369,7 @@ class BareReportDialog(ManagedWindow.ManagedWindow): (but not all) dialog boxes.""" row = 0 - max_rows = 0 - if self.max_gen: - max_rows = max_rows + 2 - #if self.page_breaks: - # max_rows = max_rows + 1 - - max_rows = max_rows + len(self.widgets) + max_rows = len(self.widgets) if max_rows == 0: return @@ -401,29 +385,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): table.set_border_width(6) self.notebook.append_page(table,label) row += 1 - - # Set up the generations spin and page break checkbox - if self.max_gen: - self.generations_spinbox = gtk.SpinButton(digits=0) - self.generations_spinbox.set_numeric(1) - adjustment = gtk.Adjustment(self.max_gen,1,999,1,0) - self.generations_spinbox.set_adjustment(adjustment) - adjustment.value_changed() - label = gtk.Label("%s:" % _("Generations")) - label.set_alignment(0.0,0.5) - table.attach(label, 1, 2, row, row+1, - gtk.SHRINK|gtk.FILL, gtk.SHRINK|gtk.FILL) - table.attach(self.generations_spinbox, 2, 3, row, row+1, - gtk.EXPAND|gtk.FILL,gtk.SHRINK|gtk.FILL) - row += 1 - - #if self.page_breaks: - msg = _("Page break between generations") - self.pagebreak_checkbox = gtk.CheckButton(msg) - self.pagebreak_checkbox.set_active(self.page_breaks) - table.attach(self.pagebreak_checkbox,2,3,row,row+1, - yoptions=gtk.SHRINK) - row += 1 # Setup requested widgets for (text,widget) in self.widgets: @@ -506,20 +467,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): whether or not they are displayed on the screen. The subclass will know which ones it has enabled. This is for simplicity of programming.""" - - if self.generations_spinbox: - self.max_gen = self.generations_spinbox.get_value_as_int() - else: - self.max_gen = 0 - - if self.pagebreak_checkbox and self.pagebreak_checkbox.get_active(): - self.pg_brk = 1 - else: - self.pg_brk = 0 - - if self.max_gen or self.pg_brk: - self.options.handler.set_report_generations(self.max_gen,self.pg_brk) - if self.extra_menu: self.report_menu = self.extra_menu.get_menu().get_active().get_data("d") else: diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index 62c90dcad..61af2c042 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -114,21 +114,10 @@ class CommandLineReport: self.options_help['id'].append(id_list) self.options_help['id'].append(False) - if self.options_dict.has_key('gen'): - max_gen = self.options_dict['gen'] - page_breaks = self.options_dict['pagebbg'] - self.option_class.handler.set_report_generations(max_gen, - page_breaks) - - self.options_help['gen'].append("Whatever Number You Wish") - self.options_help['pagebbg'].append([ - "No page break","Page break"]) - self.options_help['pagebbg'].append(True) - self.option_class.handler.output = self.options_dict['of'] self.options_help['of'].append(os.path.join(const.user_home, "whatever_name")) - + if self.category == CATEGORY_TEXT: for item in PluginUtils.textdoc_list: if item[7] == self.options_dict['off']: diff --git a/src/ReportBase/_ReportOptions.py b/src/ReportBase/_ReportOptions.py index caf34ba8b..905eda7f0 100644 --- a/src/ReportBase/_ReportOptions.py +++ b/src/ReportBase/_ReportOptions.py @@ -408,20 +408,6 @@ class OptionHandler(_Options.OptionHandler): self.option_list_collection.set_last_paper_name(self.paper_name) self.option_list_collection.set_last_format_name(self.format_name) - def get_report_generations(self): - if self.default_options_dict.has_key('gen'): - max_gen = self.options_dict.get('gen', - self.default_options_dict['gen']) - page_breaks = self.options_dict.get('pagebbg', - self.default_options_dict['pagebbg']) - return (max_gen,page_breaks) - else: - return (0,0) - - def set_report_generations(self,max_gen,page_breaks): - self.options_dict['gen'] = max_gen - self.options_dict['pagebbg'] = page_breaks - def get_stylesheet_savefile(self): """Where to save user defined styles for this report.""" return "%s.xml" % self.module_name @@ -574,11 +560,3 @@ class ReportOptions(_Options.Options): This method MUST NOT be overridden by subclasses. """ self.handler.newpage = val - - def get_report_generations(self): - """ - Return (max_generations,page_breaks) tuple. - - This method MUST NOT be overridden by subclasses. - """ - return self.handler.get_report_generations() diff --git a/src/plugins/AncestorReport.py b/src/plugins/AncestorReport.py index d1c8ef38e..08acbef07 100644 --- a/src/plugins/AncestorReport.py +++ b/src/plugins/AncestorReport.py @@ -75,8 +75,8 @@ class AncestorReport(Report): Report.__init__(self,database,person,options_class) self.map = {} - (self.max_generations,self.pgbrk) \ - = options_class.get_report_generations() + self.max_generations = options_class.handler.options_dict['gen'] + self.pgbrk = options_class.handler.options_dict['pagebbg'] self.opt_namebrk = options_class.handler.options_dict['namebrk'] def apply_filter(self,person_handle,index,generation=1): @@ -218,19 +218,20 @@ class AncestorOptions(ReportOptions): def __init__(self,name,person_id=None): ReportOptions.__init__(self,name,person_id) - def enable_options(self): - # Semi-common options that should be enabled for this report - self.enable_dict = { - 'gen' : 10, - 'pagebbg' : 0, - } - def set_new_options(self): # Options specific for this report self.options_dict = { + 'gen' : 10, + 'pagebbg' : 0, 'namebrk' : 0, } self.options_help = { + 'gen' : ("=int","Generations", + "The number of generations to include in the report", + True), + 'pagebbg' : ("=0/1","Page Break Between Generations", + ["No line break", "Insert line break"], + False), 'namebrk' : ("=0/1","Indicates if a line break should follow the name.", ["No line break", "Insert line break"], False), @@ -308,6 +309,14 @@ class AncestorOptions(ReportOptions): Override the base class add_user_options task to add a check box to the dialog that for the LineBreak option. """ + self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1)) + self.max_gen.set_value(self.options_dict['gen']) + dialog.add_option(_('Generations'),self.max_gen) + + self.cb_pagebreak = gtk.CheckButton (_("Page break between generations")) + self.cb_pagebreak.set_active (self.options_dict['pagebbg']) + dialog.add_option ('', self.cb_pagebreak) + self.cb_break = gtk.CheckButton (_("Add linebreak after each name")) self.cb_break.set_active (self.options_dict['namebrk']) dialog.add_option ('', self.cb_break) @@ -317,6 +326,8 @@ class AncestorOptions(ReportOptions): Parses the custom options that we have added. Set the value in the options dictionary. """ + self.options_dict['gen'] = self.max_gen.get_value_as_int() + self.options_dict['pagebbg'] = int(self.cb_pagebreak.get_active ()) self.options_dict['namebrk'] = int(self.cb_break.get_active ()) #------------------------------------------------------------------------ diff --git a/src/plugins/DescendReport.py b/src/plugins/DescendReport.py index 69758179d..8f85787b7 100644 --- a/src/plugins/DescendReport.py +++ b/src/plugins/DescendReport.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# (C) 2007 Brian 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 @@ -76,14 +77,12 @@ class DescendantReport(Report): that come in the options class. gen - Maximum number of generations to include. - pagebbg - Whether to include page breaks between generations. """ Report.__init__(self,database,person,options_class) - (self.max_generations,self.pgbrk) \ - = options_class.get_report_generations() + self.max_generations = options_class.handler.options_dict['gen'] sort = Sort.Sort(self.database) self.by_birthdate = sort.by_birthdate @@ -199,12 +198,31 @@ class DescendantOptions(ReportOptions): def __init__(self,name,person_id=None): ReportOptions.__init__(self,name,person_id) - def enable_options(self): - # Semi-common options that should be enabled for this report - self.enable_dict = { - 'gen' : 10, - 'pagebbg' : 0, + def set_new_options(self): + # Options specific for this report + self.options_dict = { + 'gen' : 10, } + self.options_help = { + 'gen' : ("=int","Generations", + "The number of generations to include in the report", + True), + } + + def add_user_options(self,dialog): + """ + Override the base class add_user_options task to add generations option + """ + self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1)) + self.max_gen.set_value(self.options_dict['gen']) + dialog.add_option(_('Generations'),self.max_gen) + + def parse_user_options(self,dialog): + """ + Parses the custom options that we have added. Set the value in the + options dictionary. + """ + self.options_dict['gen'] = self.max_gen.get_value_as_int() def make_default_style(self,default_style): """Make the default output style for the Descendant Report.""" diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index f96a6d789..301155d95 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2007 Brian 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 @@ -98,9 +99,8 @@ class DetAncestorReport(Report): self.map = {} - (self.max_generations,self.pgbrk) \ - = options_class.get_report_generations() - + self.max_generations = options_class.handler.options_dict['gen'] + self.pgbrk = options_class.handler.options_dict['pagebbg'] self.fullDate = options_class.handler.options_dict['fulldates'] self.listChildren = options_class.handler.options_dict['listc'] self.includeNotes = options_class.handler.options_dict['incnotes'] @@ -689,6 +689,8 @@ class DetAncestorOptions(ReportOptions): def set_new_options(self): # Options specific for this report self.options_dict = { + 'gen' : 10, + 'pagebbg' : 0, 'fulldates' : 1, 'listc' : 1, 'incnotes' : 1, @@ -705,6 +707,12 @@ class DetAncestorOptions(ReportOptions): 'incsources' : 0, } self.options_help = { + 'gen' : ("=int","Generations", + "The number of generations to include in the report", + True), + 'pagebbg' : ("=0/1","Page Break Between Generations", + ["No line break", "Insert line break"], + False), 'fulldates' : ("=0/1","Whether to use full dates instead of just year.", ["Do not use full dates","Use full dates"], True), @@ -749,13 +757,6 @@ class DetAncestorOptions(ReportOptions): True), } - def enable_options(self): - # Semi-common options that should be enabled for this report - self.enable_dict = { - 'gen' : 10, - 'pagebbg' : 0, - } - def make_default_style(self,default_style): """Make the default output style for the Detailed Ancestral Report""" font = BaseDoc.FontStyle() @@ -864,6 +865,11 @@ class DetAncestorOptions(ReportOptions): Override the base class add_user_options task to add a menu that allows the user to select the sort method. """ + self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1)) + self.max_gen.set_value(self.options_dict['gen']) + + self.cb_pagebreak = gtk.CheckButton (_("Page break between generations")) + self.cb_pagebreak.set_active (self.options_dict['pagebbg']) # Full date usage self.full_date_option = gtk.CheckButton(_("Use full dates instead of only the year")) @@ -924,7 +930,8 @@ class DetAncestorOptions(ReportOptions): # Add new options. The first argument is the tab name for grouping options. # if you want to put everyting in the generic "Options" category, use # self.add_option(text,widget) instead of self.add_frame_option(category,text,widget) - + dialog.add_option(_('Generations'),self.max_gen) + dialog.add_option ('', self.cb_pagebreak) dialog.add_frame_option(_('Content'),'',self.usecall) dialog.add_frame_option(_('Content'),'',self.full_date_option) dialog.add_frame_option(_('Content'),'',self.list_children_option) @@ -944,7 +951,8 @@ class DetAncestorOptions(ReportOptions): """ Parses the custom options that we have added. """ - + self.options_dict['gen'] = self.max_gen.get_value_as_int() + self.options_dict['pagebbg'] = int(self.cb_pagebreak.get_active ()) self.options_dict['fulldates'] = int(self.full_date_option.get_active()) self.options_dict['listc'] = int(self.list_children_option.get_active()) self.options_dict['incnotes'] = int(self.include_notes_option.get_active()) diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index f4e659194..5179fcd01 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2007 Brian 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 @@ -101,9 +102,8 @@ class DetDescendantReport(Report): self.map = {} - (self.max_generations,self.pgbrk) \ - = options_class.get_report_generations() - + self.max_generations = options_class.handler.options_dict['gen'] + self.pgbrk = options_class.handler.options_dict['pagebbg'] self.fullDate = options_class.handler.options_dict['fulldates'] self.listChildren = options_class.handler.options_dict['listc'] self.includeNotes = options_class.handler.options_dict['incnotes'] @@ -715,6 +715,8 @@ class DetDescendantOptions(ReportOptions): def set_new_options(self): # Options specific for this report self.options_dict = { + 'gen' : 10, + 'pagebbg' : 0, 'fulldates' : 1, 'listc' : 1, 'incnotes' : 1, @@ -732,6 +734,12 @@ class DetDescendantOptions(ReportOptions): 'incmates' : 1, } self.options_help = { + 'gen' : ("=int","Generations", + "The number of generations to include in the report", + True), + 'pagebbg' : ("=0/1","Page Break Between Generations", + ["No line break", "Insert line break"], + False), 'fulldates' : ("=0/1","Whether to use full dates instead of just year.", ["Do not use full dates","Use full dates"], True), @@ -779,13 +787,6 @@ class DetDescendantOptions(ReportOptions): True), } - def enable_options(self): - # Semi-common options that should be enabled for this report - self.enable_dict = { - 'gen' : 10, - 'pagebbg' : 0, - } - def make_default_style(self,default_style): """Make the default output style for the Detailed Ancestral Report""" font = BaseDoc.FontStyle() @@ -894,6 +895,11 @@ class DetDescendantOptions(ReportOptions): Override the base class add_user_options task to add a menu that allows the user to select the sort method. """ + self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1)) + self.max_gen.set_value(self.options_dict['gen']) + + self.cb_pagebreak = gtk.CheckButton (_("Page break between generations")) + self.cb_pagebreak.set_active (self.options_dict['pagebbg']) # Full date usage self.full_date_option = gtk.CheckButton(_("Use full dates instead of only the year")) @@ -958,7 +964,8 @@ class DetDescendantOptions(ReportOptions): # Add new options. The first argument is the tab name for grouping options. # if you want to put everyting in the generic "Options" category, use # self.add_option(text,widget) instead of self.add_frame_option(category,text,widget) - + dialog.add_option(_('Generations'),self.max_gen) + dialog.add_option ('', self.cb_pagebreak) dialog.add_frame_option(_('Content'),'',self.usecall) dialog.add_frame_option(_('Content'),'',self.full_date_option) dialog.add_frame_option(_('Content'),'',self.list_children_option) @@ -979,7 +986,8 @@ class DetDescendantOptions(ReportOptions): """ Parses the custom options that we have added. """ - + self.options_dict['gen'] = self.max_gen.get_value_as_int() + self.options_dict['pagebbg'] = int(self.cb_pagebreak.get_active ()) self.options_dict['fulldates'] = int(self.full_date_option.get_active()) self.options_dict['listc'] = int(self.list_children_option.get_active()) self.options_dict['usecall'] = int(self.usecall.get_active())