Enhance the Descendant Report and Detailed Descendant Report

This fulfills both feature request 5902 and feature request 8297.

It adds the D'Aboville numbering system and the Henry
numbering system to the Descendant Report, as requested.

It also adds the Modified Henry numbering system to both reports.
This commit is contained in:
Craig J. Anderson 2016-07-19 15:12:33 -07:00 committed by Paul Franklin
parent ac211252bb
commit 72daa89abc
2 changed files with 105 additions and 3 deletions

View File

@ -4,10 +4,10 @@
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007-2012 Brian G. Matherly
# Copyright (C) 2009 Gary Burton
# Copyright (C) 2010 Craig J. Anderson
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Matt Keenan (matt.keenan@gmail.com)
# Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2010,2015 Craig J. Anderson
#
# 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
@ -58,10 +58,74 @@ from gramps.gen.proxy import CacheProxyDb
from gramps.gen.display.place import displayer as _pd
from gramps.gen.display.name import displayer as _nd
#------------------------------------------------------------------------
#
# PrintDAboville
#
#------------------------------------------------------------------------
class PrintDAboville():
""" D'Aboville numbering system """
def __init__(self):
self.num = [0]
def number(self, level):
""" Make the current number based upon the current level """
# Set up the array based on the current level
while len(self.num) > level: # We can go from a level 8 to level 2
self.num.pop()
if len(self.num) < level:
self.num.append(0)
# Increment the current level - initalized with 0
self.num[-1] += 1
# Display
return ".".join(map(str, self.num))
#------------------------------------------------------------------------
#
# PrintHenry
#
#------------------------------------------------------------------------
class PrintHenry():
""" Henry numbering system """
def __init__(self, modified=False):
self.henry = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
self.modified = modified
self.num = [0]
def number(self, level):
""" Make the current number based upon the current level """
# Set up the array based on the current level
while len(self.num) > level: # We can go from a level 8 to level 2
self.num.pop()
if len(self.num) < level:
self.num.append(0)
# Incriment the current level - initalized with 0
self.num[-1] += 1
def strd(inti):
""" no change needed """
return "(" + str(inti) + ")"
# Display
if self.modified is False:
return "".join(map(
lambda x: self.henry[x-1] if x <= len(self.henry) else strd(x)
, self.num))
else:
return "".join(map(
lambda x: str(x) if x < 10 else strd(x)
, self.num))
#------------------------------------------------------------------------
#
# PrintSimple
# Simple numbering system
#
#------------------------------------------------------------------------
class PrintSimple:
@ -373,6 +437,12 @@ class DescendantReport(Report):
numbering = menu.get_option_by_name('numbering').get_value()
if numbering == "Simple":
obj = PrintSimple(self._showdups)
elif numbering == "Henry":
obj = PrintHenry()
elif numbering == "Modified Henry":
obj = PrintHenry(modified=True)
elif numbering == "D'Aboville":
obj = PrintDAboville()
elif numbering == "de Villiers/Pama":
obj = PrintVilliers()
elif numbering == "Meurgey de Tupigny":
@ -439,6 +509,9 @@ class DescendantOptions(MenuReportOptions):
numbering = EnumeratedListOption(_("Numbering system"), "Simple")
numbering.set_items([
("Simple", _("Simple numbering")),
("D'Aboville", _("D'Aboville numbering")),
("Henry", _("Henry numbering")),
("Modified Henry", _("Modified Henry numbering")),
("de Villiers/Pama", _("de Villiers/Pama numbering")),
("Meurgey de Tupigny", _("Meurgey de Tupigny numbering"))])
numbering.set_help(_("The numbering system to be used"))

View File

@ -13,6 +13,7 @@
# Copyright (C) 2011 Matt Keenan <matt.keenan@gmail.com>
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2015 Craig J. Anderson
#
# 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
@ -225,8 +226,33 @@ class DetDescendantReport(Report):
pid+HENRY[index], cur_gen+1)
index += 1
# Filter for d'Aboville numbering
def apply_mhenry_filter(self, person_handle, index, pid, cur_gen=1):
""" Filter for Modified Henry numbering """
def mhenry():
""" convenience finction """
return str(index) if index < 10 else "(" + str(index) + ")"
if (not person_handle) or (cur_gen > self.max_generations):
return
self.dnumber[person_handle] = pid
self.map[index] = person_handle
if len(self.gen_keys) < cur_gen:
self.gen_keys.append([index])
else:
self.gen_keys[cur_gen-1].append(index)
person = self._db.get_person_from_handle(person_handle)
index = 1
for family_handle in person.get_family_handle_list():
family = self._db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
_ix = max(self.map)
self.apply_henry_filter(child_ref.ref, _ix+1,
pid+mhenry(), cur_gen+1)
index += 1
def apply_daboville_filter(self, person_handle, index, pid, cur_gen=1):
""" Filter for d'Aboville numbering """
if (not person_handle) or (cur_gen > self.max_generations):
return
self.dnumber[person_handle] = pid
@ -282,6 +308,8 @@ class DetDescendantReport(Report):
"""
if self.numbering == "Henry":
self.apply_henry_filter(self.center_person.get_handle(), 1, "1")
elif self.numbering == "Modified Henry":
self.apply_mhenry_filter(self.center_person.get_handle(), 1, "1")
elif self.numbering == "d'Aboville":
self.apply_daboville_filter(self.center_person.get_handle(), 1, "1")
elif self.numbering == "Record (Modified Register)":
@ -944,6 +972,7 @@ class DetDescendantOptions(MenuReportOptions):
numbering = EnumeratedListOption(_("Numbering system"), "Henry")
numbering.set_items([
("Henry", _("Henry numbering")),
("Modified Henry", _("Modified Henry numbering")),
("d'Aboville", _("d'Aboville numbering")),
("Record (Modified Register)",
_("Record (Modified Register) numbering"))])