Remove get_report_filters() function. Let reports define the filter options themselves.

svn: r8315
This commit is contained in:
Brian Matherly
2007-03-25 20:35:33 +00:00
parent ec0623d67d
commit 7ee6b12070
12 changed files with 172 additions and 303 deletions

View File

@@ -45,7 +45,6 @@ import BaseDoc
import Utils
import ManagedWindow
from Filters import FilterComboBox,Rules
from _StyleComboBox import StyleComboBox
from _StyleEditor import StyleListDisplay
@@ -106,7 +105,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
#self.output_notebook = None
#self.notebook_page = 1
self.pagecount_menu = None
self.filter_combo = None
self.extra_menu = None
self.extra_textbox = None
self.pagebreak_checkbox = None
@@ -120,10 +118,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
self.style_name = self.options.handler.get_default_stylesheet_name()
(self.max_gen,self.page_breaks) = \
self.options.handler.get_report_generations()
try:
self.local_filters = self.options.get_report_filters(self.person)
except AttributeError:
self.local_filters = []
window = gtk.Dialog('GRAMPS')
self.set_window(window,None,self.get_title())
@@ -200,12 +194,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
created when needed. All subclasses should probably override
this function."""
return "basic_report.xml"
def get_report_filters(self):
"""Return the data used to fill out the 'filter' combo box in
the report options box. The return value is the list of
strings to be inserted into the pulldown."""
return []
def get_report_generations(self):
"""Return the default number of generations to start the
@@ -398,7 +386,7 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
function relies on several report_xxx() customization
functions to determine which of the items should be present in
this box. *All* of these items are optional, although the
generations fields and the filter combo box are used in most
generations fields is used in most
(but not all) dialog boxes."""
(em_label, extra_map, preset, em_tip) = self.get_report_extra_menu_info()
@@ -409,8 +397,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
max_rows = max_rows + 2
#if self.page_breaks:
# max_rows = max_rows + 1
if len(self.local_filters):
max_rows = max_rows + 1
if extra_map:
max_rows = max_rows + 1
@@ -430,19 +416,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
table.set_border_width(6)
self.notebook.append_page(table,label)
row += 1
if len(self.local_filters):
self.filter_combo = FilterComboBox()
label = gtk.Label("%s:" % _("Filter"))
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.filter_combo, 2, 3, row, row+1,
gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL)
self.filter_combo.set(self.local_filters)
self.filter_combo.set_active(self.options.handler.get_filter_number())
row += 1
# Set up the generations spin and page break checkbox
if self.max_gen:
@@ -577,17 +550,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
if self.max_gen or self.pg_brk:
self.options.handler.set_report_generations(self.max_gen,self.pg_brk)
if self.filter_combo:
try:
self.filter = self.filter_combo.get_value()
active = max(0,self.filter_combo.get_active())
self.options.handler.set_filter_number(active)
except:
print "Error setting filter. Proceeding with 'Everyone'"
self.filter = Rules.Person.Everyone([])
else:
self.filter = None
if self.extra_menu:
self.report_menu = self.extra_menu.get_menu().get_active().get_data("d")
else:

View File

@@ -75,7 +75,6 @@ class CommandLineReport:
'papero' : ["=num","Paper orientation number."],
'template' : ["=name","Template name (HTML only)."],
'id' : ["=ID","Gramps ID of a central person. MANDATORY"],
'filter' : ["=num","Filter number."],
'gen' : ["=num","Number of generations to follow."],
'pagebbg' : ["=0/1","Page break between generations."],
}
@@ -115,18 +114,6 @@ class CommandLineReport:
self.options_help['id'].append(id_list)
self.options_help['id'].append(False)
if self.options_dict.has_key('filter'):
filter_num = self.options_dict['filter']
self.filters = self.option_class.get_report_filters(self.person)
self.option_class.handler.set_filter_number(filter_num)
filt_list = [ filt.get_name() for filt in self.filters ]
cust_filt_list = [ filt2.get_name() for filt2 in
CustomFilters.get_filters() ]
filt_list.extend(cust_filt_list)
self.options_help['filter'].append(filt_list)
self.options_help['filter'].append(True)
if self.options_dict.has_key('gen'):
max_gen = self.options_dict['gen']
page_breaks = self.options_dict['pagebbg']

View File

@@ -2451,3 +2451,59 @@ def get_endnotes(sref_map,obj):
str = msg.getvalue()
msg.close()
return str
#-------------------------------------------------------------------------
#
# People Filters
#
#-------------------------------------------------------------------------
def get_person_filters(person,include_single=True):
"""
Returns a list of filters that are relevant for the given person
@param person: the person the filters should apply to.
@type person: L{RelLib.Person}
@param include_single: include a filter to include the single person
@type person: boolean
"""
from Filters import GenericFilter, Rules, CustomFilters
if person:
name = person.get_primary_name().get_name()
gramps_id = person.get_gramps_id()
else:
# Do this in case of command line options query (show=filter)
name = 'PERSON'
gramps_id = ''
if include_single == True:
filt_id = GenericFilter()
filt_id.set_name(name)
filt_id.add_rule(Rules.Person.HasIdOf([gramps_id]))
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
df = GenericFilter()
df.set_name(_("Descendant Families of %s") % name)
df.add_rule(Rules.Person.IsDescendantFamilyOf([gramps_id,1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
if include_single == True:
the_filters = [filt_id,all,des,df,ans,com]
else:
the_filters = [all,des,df,ans,com]
the_filters.extend(CustomFilters.get_filters('Person'))
return the_filters