Refactoring the report system. Decouple MenuOptions from the code that displays them. (Book Report is broken and needs to be fixed.)
svn: r9875
This commit is contained in:
@@ -454,14 +454,11 @@ class AncestorChartOptions(MenuReportOptions):
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name,"pid",pid)
|
||||
|
||||
max_gen = NumberOption(_("Generations"),10,1,15)
|
||||
max_gen.set_help(_("The number of generations to include in the report"))
|
||||
|
||||
@@ -232,15 +232,12 @@ class AncestorOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the ancestor report.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name,"pid",pid)
|
||||
|
||||
maxgen = NumberOption(_("Generations"),10,1,15)
|
||||
maxgen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"maxgen",maxgen)
|
||||
|
||||
@@ -83,6 +83,8 @@ from ReportBase._DocReportDialog import DocReportDialog
|
||||
from ReportBase._CommandLineReport import CommandLineReport
|
||||
from ReportBase._ReportOptions import ReportOptions
|
||||
|
||||
from BasicUtils import name_displayer as _nd
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Private Functions
|
||||
@@ -103,13 +105,13 @@ def _get_subject(options,db):
|
||||
option_names = menu.get_all_option_names()
|
||||
for name in option_names:
|
||||
option = menu.get_option_by_name(name)
|
||||
if isinstance(option,PersonOption):
|
||||
from BasicUtils import name_displayer as _nd
|
||||
if isinstance(option, PersonFilterOption):
|
||||
return option.get_filter().get_name()
|
||||
elif isinstance(option, PersonOption):
|
||||
gid = option.get_value()
|
||||
person = db.get_person_from_gramps_id(gid)
|
||||
return _nd.display(person)
|
||||
elif isinstance(option,PersonFilterOption):
|
||||
return option.get_filter().get_name()
|
||||
|
||||
return _("Not Applicable")
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Donald N. Allingham
|
||||
# Copyright (C) 2008 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
|
||||
@@ -37,11 +38,12 @@ import time
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import Tool, register_tool, PluginWindows, \
|
||||
MenuToolOptions, BooleanOption, PersonFilterOption, StringOption, \
|
||||
NumberOption
|
||||
NumberOption, PersonOption
|
||||
import gen.lib
|
||||
import Config
|
||||
from BasicUtils import name_displayer
|
||||
import Errors
|
||||
from ReportBase import ReportUtils
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@@ -52,12 +54,21 @@ class CalcEstDateOptions(MenuToolOptions):
|
||||
""" Calculate Estimated Date options """
|
||||
|
||||
def add_menu_options(self, menu, dbstate):
|
||||
self.__db = dbstate.get_database()
|
||||
|
||||
""" Adds the options """
|
||||
category_name = _("Options")
|
||||
|
||||
filter = PersonFilterOption(_("Filter"), dbstate, 0, False)
|
||||
filter.set_help(_("Select filter to restrict people"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(_("Select filter to restrict people"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
source_text = StringOption(_("Source text"),
|
||||
_("Calculated Date Estimates"))
|
||||
@@ -105,6 +116,28 @@ class CalcEstDateOptions(MenuToolOptions):
|
||||
0, 200)
|
||||
num.set_help(_("Average years between two generations"))
|
||||
menu.add_option(category_name, "AVG_GENERATION_GAP", num)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
gid = self.__pid.get_value()
|
||||
person = self.__db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 0, 2, 3, 4 and 5 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
|
||||
class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
|
||||
|
||||
+48
-7
@@ -1,6 +1,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2008 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
|
||||
@@ -45,7 +46,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_DRAW, CATEGORY_TEXT, \
|
||||
MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from PluginUtils import NumberOption, BooleanOption, StringOption, \
|
||||
PersonFilterOption, EnumeratedListOption
|
||||
PersonFilterOption, EnumeratedListOption, PersonOption
|
||||
import GrampsLocale
|
||||
import gen.lib
|
||||
from Utils import probably_alive, ProgressMeter
|
||||
@@ -144,6 +145,7 @@ class Calendar(Report):
|
||||
self.text3 = options_class.handler.options_dict['text3']
|
||||
self.filter_option = options_class.menu.get_option_by_name('filter')
|
||||
self.filter = self.filter_option.get_filter()
|
||||
self.pid = options_class.handler.options_dict['pid']
|
||||
|
||||
self.title = _("Calendar Report") #% name
|
||||
|
||||
@@ -313,7 +315,7 @@ class Calendar(Report):
|
||||
self.progress.set_pass(_('Filtering data...'), 0)
|
||||
people = self.filter.apply(self.database,
|
||||
self.database.get_person_handles(sort_handles=False))
|
||||
center_person = self.filter_option.get_center_person()
|
||||
center_person = self.database.get_person_from_gramps_id(self.pid)
|
||||
rel_calc = relationship_class()
|
||||
self.progress.set_pass(_('Filtering data...'), len(people))
|
||||
for person_handle in people:
|
||||
@@ -471,18 +473,32 @@ class CalendarReport(Calendar):
|
||||
|
||||
class CalendarOptions(MenuReportOptions):
|
||||
""" Calendar options for graphic calendar """
|
||||
def __init__(self, name, dbstate=None):
|
||||
self.__dbstate = dbstate
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
MenuReportOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self, menu,dbstate):
|
||||
def add_menu_options(self, menu, dbstate):
|
||||
""" Adds the options for the graphical calendar """
|
||||
category_name = _("Report Options")
|
||||
|
||||
year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000)
|
||||
year = NumberOption(_("Year of calendar"), time.localtime()[0],
|
||||
1000, 3000)
|
||||
year.set_help(_("Year of calendar"))
|
||||
menu.add_option(category_name,"year", year)
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
|
||||
filter.set_help(_("Select filter to restrict people that appear on calendar"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Select filter to restrict people that appear on calendar"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
name_format = EnumeratedListOption(_("Name format"), -1)
|
||||
for num, name, fmt_str, act in name_displayer.get_name_format():
|
||||
@@ -537,6 +553,29 @@ class CalendarOptions(MenuReportOptions):
|
||||
text3 = StringOption(_("Text Area 3"), "http://gramps-project.org/",)
|
||||
text3.set_help(_("Third line of text at bottom of calendar"))
|
||||
menu.add_option(category_name,"text3", text3)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 1, 2, 3 and 4 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def make_my_style(self, default_style, name, description,
|
||||
size=9, font=BaseDoc.FONT_SERIF, justified ="left",
|
||||
@@ -603,6 +642,8 @@ class CalendarOptions(MenuReportOptions):
|
||||
|
||||
class CalendarReportOptions(CalendarOptions):
|
||||
""" Options for the calendar (birthday and anniversary) report """
|
||||
def __init__(self, name, dbstate=None):
|
||||
CalendarOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self, menu,dbstate):
|
||||
""" Adds the options for the graphical calendar """
|
||||
|
||||
@@ -410,15 +410,12 @@ class DescendChartOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the descendant report.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
max_gen = NumberOption(_("Generations"),10,1,50)
|
||||
max_gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"maxgen",max_gen)
|
||||
|
||||
@@ -201,15 +201,12 @@ class DescendantOptions(MenuReportOptions):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
gen = NumberOption(_("Generations"),10,1,15)
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"gen",gen)
|
||||
|
||||
@@ -674,15 +674,12 @@ class DetAncestorOptions(MenuReportOptions):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
gen = NumberOption(_("Generations"),10,1,100)
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"gen",gen)
|
||||
|
||||
@@ -635,15 +635,12 @@ class DetDescendantOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the detailed descendant report.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
gen = NumberOption(_("Generations"),10,1,100)
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"gen",gen)
|
||||
|
||||
@@ -225,12 +225,11 @@ class EndOfLineOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the End of Line report.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the End of Line Report."""
|
||||
|
||||
@@ -23,25 +23,17 @@
|
||||
|
||||
"""Generate files/Family Group Report"""
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Gnome/GTK modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from PluginUtils import register_report, BooleanOption, EnumeratedListOption
|
||||
from PluginUtils import register_report, BooleanOption, FamilyOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
import BaseDoc
|
||||
import DateHandler
|
||||
import Utils
|
||||
from TransUtils import sgettext as _
|
||||
from BasicUtils import name_displayer as _nd
|
||||
|
||||
@@ -73,14 +65,8 @@ class FamilyGroup(Report):
|
||||
self.family_handle = None
|
||||
|
||||
family_id = options_class.handler.options_dict['family_id']
|
||||
if family_id:
|
||||
family_list = person.get_family_handle_list()
|
||||
for family_handle in family_list:
|
||||
family = database.get_family_from_handle(family_handle)
|
||||
this_family_id = family.get_gramps_id()
|
||||
if this_family_id == family_id:
|
||||
self.family_handle = family_handle
|
||||
break
|
||||
family = database.get_family_from_gramps_id(family_id)
|
||||
self.family_handle = family.get_handle()
|
||||
|
||||
self.recursive = options_class.handler.options_dict['recursive']
|
||||
self.missingInfo = options_class.handler.options_dict['missinginfo']
|
||||
@@ -596,19 +582,9 @@ class FamilyGroupOptions(MenuReportOptions):
|
||||
category_name = _("Report Options")
|
||||
##########################
|
||||
|
||||
if dbstate:
|
||||
db = dbstate.get_database()
|
||||
person = dbstate.get_active_person()
|
||||
else:
|
||||
db = None
|
||||
person = None
|
||||
families = self.get_families(db, person)
|
||||
|
||||
family_id = EnumeratedListOption(_("Spouse"), "")
|
||||
for item in families:
|
||||
family_id.add_item(item[0], item[1])
|
||||
family_id.set_help(_("Gramps ID of the person's family."))
|
||||
menu.add_option(category_name,"family_id",family_id)
|
||||
family_id = FamilyOption(_("Center Family"))
|
||||
family_id.set_help(_("The center family for the report"))
|
||||
menu.add_option(category_name, "family_id", family_id)
|
||||
|
||||
recursive = BooleanOption(_('Recursive'),False)
|
||||
recursive.set_help(_("Create reports for all decendants "
|
||||
@@ -671,32 +647,6 @@ class FamilyGroupOptions(MenuReportOptions):
|
||||
"information."))
|
||||
menu.add_option(category_name,"missinginfo",missinginfo)
|
||||
|
||||
def get_families(self,database,person):
|
||||
"""
|
||||
Create a mapping of all spouse names:families to be put
|
||||
into the 'extra' option menu in the report options box. If
|
||||
the selected person has never been married then this routine
|
||||
will return a placebo label and disable the OK button.
|
||||
"""
|
||||
families = []
|
||||
family_id = None
|
||||
family_list = person.get_family_handle_list()
|
||||
for family_handle in family_list:
|
||||
family = database.get_family_from_handle(family_handle)
|
||||
family_id = family.get_gramps_id()
|
||||
if person.get_handle() == family.get_father_handle():
|
||||
spouse_handle = family.get_mother_handle()
|
||||
else:
|
||||
spouse_handle = family.get_father_handle()
|
||||
if spouse_handle:
|
||||
spouse = database.get_person_from_handle(spouse_handle)
|
||||
name = spouse.get_primary_name().get_name()
|
||||
else:
|
||||
name = _("unknown")
|
||||
name = "%s (%s)" % (name,family_id)
|
||||
families.append((family_id,name))
|
||||
return families
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make default output style for the Family Group Report."""
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
|
||||
@@ -326,15 +326,12 @@ class FanChartOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the fan chart.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
max_gen = NumberOption(_("Generations"),5,1,self.MAX_GENERATIONS)
|
||||
max_gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"maxgen",max_gen)
|
||||
|
||||
@@ -49,8 +49,10 @@ import gen.lib
|
||||
import Utils
|
||||
import ThumbNails
|
||||
from DateHandler import displayer as _dd
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_GRAPHVIZ, MODE_GUI
|
||||
from PluginUtils import register_report, EnumeratedListOption, BooleanOption, NumberOption, ColourButtonOption, PersonListOption, SurnameColourOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_GRAPHVIZ, MODE_GUI
|
||||
from PluginUtils import register_report, EnumeratedListOption, BooleanOption, \
|
||||
NumberOption, ColourOption, PersonListOption, SurnameColourOption
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -87,7 +89,7 @@ class FamilyLinesOptions(MenuReportOptions):
|
||||
category = _('People of Interest')
|
||||
# --------------------------------
|
||||
|
||||
personList = PersonListOption( _('People of interest'), '', dbstate)
|
||||
personList = PersonListOption( _('People of interest'))
|
||||
personList.set_help( _('People of interest are used as a starting point when determining \"family lines\".'))
|
||||
menu.add_option(category, 'FLgidlist', personList)
|
||||
|
||||
@@ -107,7 +109,7 @@ class FamilyLinesOptions(MenuReportOptions):
|
||||
category = _('Family Colours')
|
||||
# ----------------------------
|
||||
|
||||
surnameColour = SurnameColourOption(_('Family colours'), '', dbstate)
|
||||
surnameColour = SurnameColourOption(_('Family colours'))
|
||||
surnameColour.set_help( _('Colours to use for various family lines.'))
|
||||
menu.add_option(category, 'FLsurnameColours', surnameColour)
|
||||
|
||||
@@ -115,19 +117,19 @@ class FamilyLinesOptions(MenuReportOptions):
|
||||
category = _('Individuals')
|
||||
# -------------------------
|
||||
|
||||
colourMales = ColourButtonOption( _('Males'), '#e0e0ff')
|
||||
colourMales = ColourOption( _('Males'), '#e0e0ff')
|
||||
colourMales.set_help( _('The colour to use to display men.'))
|
||||
menu.add_option(category, 'FLcolourMales', colourMales)
|
||||
|
||||
colourFemales = ColourButtonOption( _('Females'), '#ffe0e0')
|
||||
colourFemales = ColourOption( _('Females'), '#ffe0e0')
|
||||
colourFemales.set_help( _('The colour to use to display women.'))
|
||||
menu.add_option(category, 'FLcolourFemales', colourFemales)
|
||||
|
||||
colourUnknown = ColourButtonOption( _('Unknown'), '#e0e0e0')
|
||||
colourUnknown = ColourOption( _('Unknown'), '#e0e0e0')
|
||||
colourUnknown.set_help( _('The colour to use when the gender is unknown.'))
|
||||
menu.add_option(category, 'FLcolourUnknown', colourUnknown)
|
||||
|
||||
colourFamily = ColourButtonOption( _('Families'), '#ffffe0')
|
||||
colourFamily = ColourOption( _('Families'), '#ffffe0')
|
||||
colourFamily.set_help( _('The colour to use to display families.'))
|
||||
menu.add_option(category, 'FLcolourFamilies', colourFamily)
|
||||
|
||||
|
||||
@@ -169,15 +169,12 @@ class HourGlassOptions(MenuReportOptions):
|
||||
"""
|
||||
Create all the menu options for this report.
|
||||
"""
|
||||
gid = ""
|
||||
if dbstate:
|
||||
gid = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"), gid, dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("", "pid", pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
max_gen = NumberOption(_('Max Descendant Generations'), 10, 1, 15)
|
||||
max_gen.set_help(_("The number of generations of descendants to " \
|
||||
"include in the report"))
|
||||
|
||||
+80
-37
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
#
|
||||
# Adapted from GraphViz.py (now deprecated)
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
@@ -29,14 +29,21 @@
|
||||
Create a relationship graph using Graphviz
|
||||
"""
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from TransUtils import sgettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import register_report, PersonFilterOption, \
|
||||
EnumeratedListOption, BooleanOption
|
||||
from ReportBase import Report, MenuReportOptions, \
|
||||
EnumeratedListOption, BooleanOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
|
||||
from BasicUtils import name_displayer
|
||||
import DateHandler
|
||||
@@ -408,35 +415,48 @@ class RelGraphOptions(MenuReportOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
def __init__(self,name,dbstate=None):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
def __init__(self, name, dbstate=None):
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
self.__include_images = None
|
||||
self.__image_on_side = None
|
||||
self.__dbstate = dbstate
|
||||
MenuReportOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
def add_menu_options(self, menu, dbstate):
|
||||
################################
|
||||
category_name = _("Report Options")
|
||||
################################
|
||||
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
|
||||
filter.set_help(_("Select the filter to be applied to the report"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Determines what people are included in the graph"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
incdate = BooleanOption(
|
||||
_("Include Birth, Marriage and Death dates"), True)
|
||||
incdate.set_help(_("Include the dates that the individual was born, "
|
||||
"got married and/or died in the graph labels."))
|
||||
menu.add_option(category_name,"incdate", incdate)
|
||||
menu.add_option(category_name, "incdate", incdate)
|
||||
|
||||
justyears = BooleanOption(_("Limit dates to years only"), False)
|
||||
justyears.set_help(_("Prints just dates' year, neither "
|
||||
"month or day nor date approximation "
|
||||
"or interval are shown."))
|
||||
menu.add_option(category_name,"justyears", justyears)
|
||||
menu.add_option(category_name, "justyears", justyears)
|
||||
|
||||
placecause = BooleanOption(_("Place/cause when no date"), True)
|
||||
placecause.set_help(_("When no birth, marriage, or death date is "
|
||||
"available, the correspondent place field (or "
|
||||
"cause field when blank place) will be used."))
|
||||
menu.add_option(category_name,"placecause", placecause)
|
||||
menu.add_option(category_name, "placecause", placecause)
|
||||
|
||||
url = BooleanOption(_("Include URLs"), False)
|
||||
url.set_help(_("Include a URL in each graph node so "
|
||||
@@ -444,23 +464,26 @@ class RelGraphOptions(MenuReportOptions):
|
||||
"generated that contain active links "
|
||||
"to the files generated by the 'Narrated "
|
||||
"Web Site' report."))
|
||||
menu.add_option(category_name,"url", url)
|
||||
menu.add_option(category_name, "url", url)
|
||||
|
||||
incid = BooleanOption(_("Include IDs"), False)
|
||||
incid.set_help(_("Include individual and family IDs."))
|
||||
menu.add_option(category_name,"incid", incid)
|
||||
menu.add_option(category_name, "incid", incid)
|
||||
|
||||
self.includeImages = BooleanOption(
|
||||
self.__include_images = BooleanOption(
|
||||
_('Include thumbnail images of people'), False)
|
||||
self.includeImages.set_help(_("Whether to include thumbnails of people."))
|
||||
menu.add_option(category_name,"includeImages", self.includeImages)
|
||||
self.__include_images.set_help(
|
||||
_("Whether to include thumbnails of people."))
|
||||
menu.add_option(category_name, "includeImages", self.__include_images)
|
||||
self.__include_images.connect('value-changed', self.__image_changed)
|
||||
|
||||
self.imageOnTheSide = EnumeratedListOption(_("Thumbnail Location"), 0)
|
||||
self.imageOnTheSide.add_item(0, _('Above the name'))
|
||||
self.imageOnTheSide.add_item(1, _('Beside the name'))
|
||||
self.imageOnTheSide.set_help(_("Where the thumbnail image should appear "
|
||||
"relative to the name"))
|
||||
menu.add_option(category_name,"imageOnTheSide",self.imageOnTheSide)
|
||||
self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0)
|
||||
self.__image_on_side.add_item(0, _('Above the name'))
|
||||
self.__image_on_side.add_item(1, _('Beside the name'))
|
||||
self.__image_on_side.set_help(
|
||||
_("Where the thumbnail image should appear "
|
||||
"relative to the name"))
|
||||
menu.add_option(category_name, "imageOnTheSide", self.__image_on_side)
|
||||
|
||||
################################
|
||||
category_name = _("Graph Style")
|
||||
@@ -472,35 +495,55 @@ class RelGraphOptions(MenuReportOptions):
|
||||
color.set_help(_("Males will be shown with blue, females "
|
||||
"with red. If the sex of an individual "
|
||||
"is unknown it will be shown with gray."))
|
||||
menu.add_option(category_name,"color",color)
|
||||
menu.add_option(category_name, "color", color)
|
||||
|
||||
arrow = EnumeratedListOption(_("Arrowhead direction"), 'd')
|
||||
for i in range( 0, len(_ARROWS) ):
|
||||
arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"])
|
||||
arrow.set_help(_("Choose the direction that the arrows point."))
|
||||
menu.add_option(category_name,"arrow",arrow)
|
||||
menu.add_option(category_name, "arrow", arrow)
|
||||
|
||||
dashed = BooleanOption(
|
||||
_("Indicate non-birth relationships with dotted lines"), True)
|
||||
dashed.set_help(_("Non-birth relationships will show up "
|
||||
"as dotted lines in the graph."))
|
||||
menu.add_option(category_name,"dashed", dashed)
|
||||
menu.add_option(category_name, "dashed", dashed)
|
||||
|
||||
showfamily = BooleanOption(_("Show family nodes"), True)
|
||||
showfamily.set_help(_("Families will show up as ellipses, linked "
|
||||
"to parents and children."))
|
||||
menu.add_option(category_name,"showfamily", showfamily)
|
||||
|
||||
|
||||
def imageChanged(self, button):
|
||||
self.imageOnTheSide.gobj.set_sensitive(self.includeImages.gobj.get_active())
|
||||
|
||||
|
||||
def post_init(self, dialog):
|
||||
self.includeImages.gobj.connect('toggled', self.imageChanged)
|
||||
self.imageChanged(self.includeImages.gobj)
|
||||
|
||||
menu.add_option(category_name, "showfamily", showfamily)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 1, 2, 3 and 4 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def __image_changed(self):
|
||||
"""
|
||||
Handle thumbnail change. If the image is not to be included, make the
|
||||
image location option unavailable.
|
||||
"""
|
||||
self.__image_on_side.set_available(self.__include_images.get_value())
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
||||
@@ -35,12 +35,10 @@ from gettext import gettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
import const
|
||||
import Utils
|
||||
import BaseDoc
|
||||
from Filters import GenericFilter, Rules
|
||||
import DateHandler
|
||||
from PluginUtils import register_report, PersonFilterOption, BooleanOption
|
||||
from PluginUtils import register_report, PersonFilterOption, BooleanOption, \
|
||||
PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
@@ -531,21 +529,55 @@ class IndivCompleteOptions(MenuReportOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
def __init__(self,name,dbstate=None):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
def __init__(self, name, dbstate=None):
|
||||
self.__dbstate = dbstate
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
MenuReportOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
def add_menu_options(self, menu, dbstate):
|
||||
################################
|
||||
category_name = _("Report Options")
|
||||
################################
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,True)
|
||||
filter.set_help(_("Select the filter to be applied to the report"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Select the filter to be applied to the report"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
cites = BooleanOption(_("Include Source Information"), True)
|
||||
cites.set_help(_("Whether to cite sources."))
|
||||
menu.add_option(category_name,"cites", cites)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, True)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [0, 2, 3, 4, 5]:
|
||||
# Filters 0, 2, 3, 4 and 5 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Individual Complete Report."""
|
||||
|
||||
@@ -330,15 +330,12 @@ class KinshipOptions(MenuReportOptions):
|
||||
"""
|
||||
Add options to the menu for the kinship report.
|
||||
"""
|
||||
id = ""
|
||||
if dbstate:
|
||||
id = dbstate.get_active_person().get_gramps_id()
|
||||
pid = PersonOption(_("Center Person"),id,dbstate)
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option("","pid",pid)
|
||||
|
||||
category_name = _("Report Options")
|
||||
|
||||
pid = PersonOption(_("Center Person"))
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
maxdescend = NumberOption(_("Max Descendant Generations"),2,1,20)
|
||||
maxdescend.set_help(_("The maximum number of descendant generations"))
|
||||
menu.add_option(category_name,"maxdescend",maxdescend)
|
||||
|
||||
@@ -39,7 +39,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
import BaseDoc
|
||||
from gen.lib import MarkerType, FamilyRelType
|
||||
from Filters import GenericFilter, GenericFilterFactory, Rules
|
||||
from Filters import GenericFilterFactory, Rules
|
||||
from BasicUtils import name_displayer
|
||||
import DateHandler
|
||||
|
||||
@@ -433,7 +433,8 @@ class MarkerOptions(MenuReportOptions):
|
||||
"""
|
||||
category_name = _("Report Options")
|
||||
|
||||
marker = EnumeratedListOption(_('Marker'),0)
|
||||
marker = EnumeratedListOption(_('Marker'),
|
||||
MarkerType._I2EMAP[MarkerType.COMPLETE])
|
||||
# Add built-in marker types
|
||||
for mtype in MarkerType._I2SMAP:
|
||||
if mtype != MarkerType.NONE and mtype != MarkerType.CUSTOM:
|
||||
|
||||
@@ -48,11 +48,10 @@ from gen.lib import Person, FamilyRelType, EventType
|
||||
# gender and report type names
|
||||
import BaseDoc
|
||||
from PluginUtils import register_report
|
||||
from PluginUtils import BooleanOption, PersonFilterOption, EnumeratedListOption, \
|
||||
NumberOption
|
||||
from PluginUtils import BooleanOption, PersonFilterOption, PersonOption, \
|
||||
EnumeratedListOption, NumberOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from Filters import GenericFilter, Rules
|
||||
import DateHandler
|
||||
from Utils import ProgressMeter
|
||||
|
||||
@@ -660,7 +659,10 @@ class StatisticsChart(Report):
|
||||
class StatisticsChartOptions(MenuReportOptions):
|
||||
|
||||
def __init__(self,name,dbstate=None):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
self.__dbstate = dbstate
|
||||
MenuReportOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
"""
|
||||
@@ -668,9 +670,17 @@ class StatisticsChartOptions(MenuReportOptions):
|
||||
"""
|
||||
category_name = _("Report Options")
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
|
||||
filter.set_help(_("Determines what people are included in the report"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Determines what people are included in the report"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
sortby = EnumeratedListOption(_('Sort chart items by'),
|
||||
_options.SORT_VALUE )
|
||||
@@ -735,6 +745,29 @@ class StatisticsChartOptions(MenuReportOptions):
|
||||
menu.get_option_by_name("data_gender").set_value(True)
|
||||
menu.get_option_by_name("data_ccount").set_value(True)
|
||||
menu.get_option_by_name("data_bmonth").set_value(True)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 1, 2, 3 and 4 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the Statistics report."""
|
||||
|
||||
+39
-5
@@ -38,7 +38,8 @@ from TransUtils import sgettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import register_report
|
||||
from PluginUtils import PersonFilterOption, EnumeratedListOption
|
||||
from PluginUtils import PersonFilterOption, EnumeratedListOption, \
|
||||
PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
pt2cm = ReportUtils.pt2cm
|
||||
@@ -296,15 +297,25 @@ class TimeLine(Report):
|
||||
class TimeLineOptions(MenuReportOptions):
|
||||
|
||||
def __init__(self,name,dbstate=None):
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
self.__dbstate = dbstate
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
category_name = _("Report Options")
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
|
||||
filter.set_help(_("Determine what people will be included in "
|
||||
"the report"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Determines what people are included in the report"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
sortby = EnumeratedListOption(_('Sort by'), 0 )
|
||||
idx = 0
|
||||
@@ -314,6 +325,29 @@ class TimeLineOptions(MenuReportOptions):
|
||||
sortby.set_help( _("Sorting method to use"))
|
||||
menu.add_option(category_name,"sortby",sortby)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 1, 2, 3 and 4 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Timeline report."""
|
||||
# Paragraph Styles
|
||||
|
||||
Reference in New Issue
Block a user