Add new columns to person view
This commit is contained in:
parent
a2dfd9013e
commit
703a8d71ae
@ -81,7 +81,7 @@ class SelectPerson(BaseSelector):
|
||||
(_('Death Date'), 150, BaseSelector.MARKUP, 5),
|
||||
(_('Death Place'), 150, BaseSelector.MARKUP, 6),
|
||||
(_('Spouse'), 150, BaseSelector.TEXT, 7),
|
||||
(_('Last Change'), 150, BaseSelector.TEXT, 10)
|
||||
(_('Last Change'), 150, BaseSelector.TEXT, 14)
|
||||
]
|
||||
|
||||
def get_from_handle_func(self):
|
||||
|
@ -56,7 +56,8 @@ _LOG = logging.getLogger(".")
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.lib import Name, EventRef, EventType, EventRoleType
|
||||
from gramps.gen.lib import (Name, EventRef, EventType, EventRoleType,
|
||||
FamilyRelType, ChildRefType, NoteType)
|
||||
from gramps.gen.display.name import displayer as name_displayer
|
||||
from gramps.gen.datehandler import format_time, get_date, get_date_valid
|
||||
from .lru import LRU
|
||||
@ -78,6 +79,8 @@ COLUMN_DEATH = 5
|
||||
COLUMN_BIRTH = 6
|
||||
COLUMN_EVENT = 7
|
||||
COLUMN_FAMILY = 8
|
||||
COLUMN_PARENT = 9
|
||||
COLUMN_NOTES = 16
|
||||
COLUMN_CHANGE = 17
|
||||
COLUMN_TAGS = 18
|
||||
COLUMN_PRIV = 19
|
||||
@ -115,6 +118,10 @@ class PeopleBaseModel(object):
|
||||
self.column_death_day,
|
||||
self.column_death_place,
|
||||
self.column_spouse,
|
||||
self.column_parents,
|
||||
self.column_marriages,
|
||||
self.column_children,
|
||||
self.column_todo,
|
||||
self.column_private,
|
||||
self.column_tags,
|
||||
self.column_change,
|
||||
@ -129,6 +136,10 @@ class PeopleBaseModel(object):
|
||||
self.sort_death_day,
|
||||
self.column_death_place,
|
||||
self.column_spouse,
|
||||
self.sort_parents,
|
||||
self.sort_marriages,
|
||||
self.sort_children,
|
||||
self.sort_todo,
|
||||
self.column_private,
|
||||
self.column_tags,
|
||||
self.sort_change,
|
||||
@ -158,7 +169,7 @@ class PeopleBaseModel(object):
|
||||
"""
|
||||
Return the color column.
|
||||
"""
|
||||
return 11
|
||||
return 15
|
||||
|
||||
def clear_local_cache(self, handle=None):
|
||||
""" Clear the LRU cache """
|
||||
@ -435,6 +446,66 @@ class PeopleBaseModel(object):
|
||||
return "<i>" + cgi.escape(place_title) + "</i>"
|
||||
return ""
|
||||
|
||||
def _get_parents_data(self, data):
|
||||
parents = 0
|
||||
if data[COLUMN_PARENT]:
|
||||
family = self.db.get_family_from_handle(data[COLUMN_PARENT][0])
|
||||
if family.get_father_handle():
|
||||
parents += 1
|
||||
if family.get_mother_handle():
|
||||
parents += 1
|
||||
return parents
|
||||
|
||||
def _get_marriages_data(self, data):
|
||||
marriages = 0
|
||||
for family_handle in data[COLUMN_FAMILY]:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
if int(family.get_relationship()) == FamilyRelType.MARRIED:
|
||||
marriages += 1
|
||||
return marriages
|
||||
|
||||
def _get_children_data(self, data):
|
||||
children = 0
|
||||
for family_handle in data[COLUMN_FAMILY]:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
for child_ref in family.get_child_ref_list():
|
||||
if (child_ref.get_father_relation() == ChildRefType.BIRTH and
|
||||
child_ref.get_mother_relation() == ChildRefType.BIRTH):
|
||||
children += 1
|
||||
return children
|
||||
|
||||
def _get_todo_data(self, data):
|
||||
todo = 0
|
||||
for note_handle in data[COLUMN_NOTES]:
|
||||
note = self.db.get_note_from_handle(note_handle)
|
||||
if int(note.get_type()) == NoteType.TODO:
|
||||
todo += 1
|
||||
return todo
|
||||
|
||||
def column_parents(self, data):
|
||||
return cuni(self._get_parents_data(data))
|
||||
|
||||
def sort_parents(self, data):
|
||||
return '%06d' % self._get_parents_data(data)
|
||||
|
||||
def column_marriages(self, data):
|
||||
return cuni(self._get_marriages_data(data))
|
||||
|
||||
def sort_marriages(self, data):
|
||||
return '%06d' % self._get_marriages_data(data)
|
||||
|
||||
def column_children(self, data):
|
||||
return cuni(self._get_children_data(data))
|
||||
|
||||
def sort_children(self, data):
|
||||
return '%06d' % self._get_children_data(data)
|
||||
|
||||
def column_todo(self, data):
|
||||
return cuni(self._get_todo_data(data))
|
||||
|
||||
def sort_todo(self, data):
|
||||
return '%06d' % self._get_todo_data(data)
|
||||
|
||||
def get_tag_name(self, tag_handle):
|
||||
"""
|
||||
Return the tag name from the given tag handle.
|
||||
|
@ -87,9 +87,13 @@ class BasePersonView(ListView):
|
||||
COL_DDAT = 5
|
||||
COL_DPLAC = 6
|
||||
COL_SPOUSE = 7
|
||||
COL_PRIV = 8
|
||||
COL_TAGS = 9
|
||||
COL_CHAN = 10
|
||||
COL_PARENTS = 8
|
||||
COL_MARRIAGES = 9
|
||||
COL_CHILDREN = 10
|
||||
COL_TODO = 11
|
||||
COL_PRIV = 12
|
||||
COL_TAGS = 13
|
||||
COL_CHAN = 14
|
||||
# column definitions
|
||||
COLUMNS = [
|
||||
(_('Name'), TEXT, None),
|
||||
@ -100,6 +104,10 @@ class BasePersonView(ListView):
|
||||
(_('Death Date'), MARKUP, None),
|
||||
(_('Death Place'), MARKUP, None),
|
||||
(_('Spouse'), TEXT, None),
|
||||
(_('Number of Parents'), TEXT, 'gramps-parents'),
|
||||
(_('Number of Marriages'), TEXT, 'gramps-family'),
|
||||
(_('Number of Children'), TEXT, 'gramps-relation'),
|
||||
(_('Number of To Do Notes'), TEXT, 'gramps-notes'),
|
||||
(_('Private'), ICON, 'gramps-lock'),
|
||||
(_('Tags'), TEXT, None),
|
||||
(_('Last Changed'), TEXT, None),
|
||||
@ -108,9 +116,11 @@ class BasePersonView(ListView):
|
||||
CONFIGSETTINGS = (
|
||||
('columns.visible', [COL_NAME, COL_ID, COL_GEN, COL_BDAT, COL_DDAT]),
|
||||
('columns.rank', [COL_NAME, COL_ID, COL_GEN, COL_BDAT, COL_BPLAC,
|
||||
COL_DDAT, COL_DPLAC, COL_SPOUSE, COL_PRIV, COL_TAGS,
|
||||
COL_CHAN]),
|
||||
('columns.size', [250, 75, 75, 100, 175, 100, 175, 100, 40, 100, 100])
|
||||
COL_DDAT, COL_DPLAC, COL_SPOUSE, COL_PARENTS,
|
||||
COL_MARRIAGES, COL_CHILDREN, COL_TODO, COL_PRIV,
|
||||
COL_TAGS, COL_CHAN]),
|
||||
('columns.size', [250, 75, 75, 100, 175, 100, 175, 100, 30, 30, 30, 30,
|
||||
30, 100, 100])
|
||||
)
|
||||
ADD_MSG = _("Add a new person")
|
||||
EDIT_MSG = _("Edit the selected person")
|
||||
|
Loading…
Reference in New Issue
Block a user