7836: Limit the number of generations displayed in the ancestor gramplet
This commit is contained in:
parent
9a664acc20
commit
7987e8c1d6
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2013 Nick Hall
|
||||
# Copyright (C) 2013-2014 Nick Hall
|
||||
#
|
||||
# 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
|
||||
@ -18,15 +18,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""Descendant Gramplet"""
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
"""Ancestor Gramplet"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -47,6 +39,10 @@ from gramps.gen.errors import WindowActiveError
|
||||
from gramps.gen.display.name import displayer as name_displayer
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from gramps.gen.config import config
|
||||
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
class Ancestor(Gramplet):
|
||||
|
||||
@ -114,13 +110,16 @@ class Ancestor(Gramplet):
|
||||
active_handle = self.get_active('Person')
|
||||
self.model.clear()
|
||||
if active_handle:
|
||||
self.add_to_tree(None, active_handle)
|
||||
self.add_to_tree(1, None, active_handle)
|
||||
self.view.expand_all()
|
||||
self.set_has_data(self.get_has_data(active_handle))
|
||||
else:
|
||||
self.set_has_data(False)
|
||||
|
||||
def add_to_tree(self, parent_id, person_handle):
|
||||
def add_to_tree(self, depth, parent_id, person_handle):
|
||||
if depth > config.get('behavior.generation-depth'):
|
||||
return
|
||||
|
||||
person = self.dbstate.db.get_person_from_handle(person_handle)
|
||||
name = name_displayer.display(person)
|
||||
|
||||
@ -145,15 +144,16 @@ class Ancestor(Gramplet):
|
||||
|
||||
tooltip = name + '\n' + birth_text + '\n' + death_text
|
||||
|
||||
item_id = self.model.add([name, birth_date, birth_sort,
|
||||
label = _('%(depth)s. %(name)s') % {'depth': depth, 'name': name}
|
||||
item_id = self.model.add([label, birth_date, birth_sort,
|
||||
tooltip, person_handle], node=parent_id)
|
||||
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
if family:
|
||||
if family.get_father_handle():
|
||||
self.add_to_tree(item_id, family.get_father_handle())
|
||||
self.add_to_tree(depth + 1, item_id, family.get_father_handle())
|
||||
if family.get_mother_handle():
|
||||
self.add_to_tree(item_id, family.get_mother_handle())
|
||||
self.add_to_tree(depth + 1, item_id, family.get_mother_handle())
|
||||
|
||||
return item_id
|
||||
|
Loading…
Reference in New Issue
Block a user