7342: Update column order in editor event tabs

This commit is contained in:
Nick Hall 2014-02-28 14:00:13 +00:00
parent a0bb7ddfd1
commit ed65d4e7df
3 changed files with 38 additions and 25 deletions

View File

@ -50,14 +50,14 @@ from gui.selectors import SelectorFactory
#-------------------------------------------------------------------------
class EventEmbedList(DbGUIElement, GroupEmbeddedList):
_HANDLE_COL = 7
_HANDLE_COL = 8
_DND_TYPE = DdTargets.EVENTREF
_DND_EXTRA = DdTargets.EVENT
_WORKGROUP = EventRefModel._ROOTINDEX
_WORKNAME = _("Family Events")
_FATHNAME = _("Events father")
_MOTHNAME = _("Events mother")
_WORKNAME = _("Family")
_FATHNAME = _("Father")
_MOTHNAME = _("Mother")
_MSG = {
'add' : _('Add a new family event'),
@ -71,14 +71,15 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Description'), -1, 240, 0, EventRefModel.COL_FONTWEIGHT[0]),
(_('Type'), EventRefModel.COL_TYPE[0], 100, 0,
EventRefModel.COL_FONTWEIGHT[0]),
(_('ID'), EventRefModel.COL_GID[0], 60, 0,
(_('Description'), EventRefModel.COL_DESCR[0], 150, 0, -1),
(_('Type'), EventRefModel.COL_TYPE[0], 120, 0,
EventRefModel.COL_FONTWEIGHT[0]),
(_('ID'), -1, 100, 0, -1),
(_('Date'), EventRefModel.COL_SORTDATE[0], 150, 1, -1),
(_('Place'), EventRefModel.COL_PLACE[0], 140, 0, -1),
(_('Place'), EventRefModel.COL_PLACE[0], 240, 0, -1),
(_('Role'), EventRefModel.COL_ROLE[0], 80, 0, -1),
(_('Main Participants'), EventRefModel.COL_PARTIC[0], 240, 0,
EventRefModel.COL_FONTWEIGHT[0]),
None,
None,
None
@ -150,14 +151,14 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
#family events
if not self._data or self.changed:
self._data = [self.obj.get_event_ref_list()]
self._groups = [(self.obj.get_handle(), self._WORKNAME)]
self._groups = [(self.obj.get_handle(), self._WORKNAME, '')]
#father events
fhandle = self.obj.get_father_handle()
if fhandle:
fdata = self.dbstate.db.get_person_from_handle(fhandle).\
get_event_ref_list()
if fdata:
self._groups.append((fhandle, self._FATHNAME))
self._groups.append((fhandle, self._FATHNAME, ''))
self._data.append(fdata)
#mother events
mhandle = self.obj.get_mother_handle()
@ -165,7 +166,7 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
mdata = self.dbstate.db.get_person_from_handle(mhandle).\
get_event_ref_list()
if mdata:
self._groups.append((mhandle, self._MOTHNAME))
self._groups.append((mhandle, self._MOTHNAME, ''))
self._data.append(mdata)
#we register all events that need to be tracked
for group in self._data:
@ -186,7 +187,7 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
The columns to show as a tuple containing
tuples (show/noshow, model column)
"""
return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5))
return ((1, 1), (1, 6), (1, 3), (1, 4), (1, 0), (1, 5), (1, 2))
def default_types(self):
return [

View File

@ -42,8 +42,10 @@ import cgi
# GRAMPS classes
#
#-------------------------------------------------------------------------
from gen.lib import EventRoleType
import DateHandler
import config
import Utils
#-------------------------------------------------------------------------
#
@ -68,12 +70,13 @@ class EventRefModel(gtk.TreeStore):
COL_DATE = (3, str)
COL_PLACE = (4, str)
COL_ROLE = (5, str)
COL_SORTDATE = (6, str)
COL_EVENTREF = (7, object)
COL_FONTWEIGHT = (8, int)
COL_PARTIC = (6, str)
COL_SORTDATE = (7, str)
COL_EVENTREF = (8, object)
COL_FONTWEIGHT = (9, int)
COLS = (COL_DESCR, COL_TYPE, COL_GID, COL_DATE, COL_PLACE, COL_ROLE,
COL_SORTDATE, COL_EVENTREF, COL_FONTWEIGHT)
COL_PARTIC, COL_SORTDATE, COL_EVENTREF, COL_FONTWEIGHT)
def __init__(self, event_list, db, groups):
"""
@ -96,7 +99,9 @@ class EventRefModel(gtk.TreeStore):
def row_group(self, index, group):
name = self.namegroup(index, len(group))
return [name, '', '', '', '', '', '', (index, None), WEIGHT_BOLD]
spouse = self.groups[index][2]
return ['', name, '', '', '', '', spouse, '', (index, None),
WEIGHT_BOLD]
def namegroup(self, groupindex, length):
return self._GROUPSTRING % {'groupname': self.groups[groupindex][1],
@ -109,6 +114,7 @@ class EventRefModel(gtk.TreeStore):
self.column_date(eventref),
self.column_place(eventref),
self.column_role(eventref),
self.column_participant(eventref),
self.column_sort_date(eventref),
(index, eventref),
self.colweight(index),
@ -144,3 +150,10 @@ class EventRefModel(gtk.TreeStore):
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""
def column_participant(self, event_ref):
if int(event_ref.get_role()) not in (EventRoleType.PRIMARY,
EventRoleType.FAMILY):
return Utils.get_participant_from_event(self.db, event_ref.ref)
else:
return ""

View File

@ -47,8 +47,9 @@ import Errors
#-------------------------------------------------------------------------
class PersonEventEmbedList(EventEmbedList):
_WORKNAME = _("Personal Events")
_FAMNAME = _("With %(namepartner)s (%(famid)s)")
_WORKNAME = _("Personal")
#_FAMNAME = _("With %(namepartner)s (%(famid)s)")
_FAMNAME = _("Family")
_UNKNOWNNAME = _("<Unknown>")
_MSG = {
@ -67,7 +68,7 @@ class PersonEventEmbedList(EventEmbedList):
def get_data(self):
if not self._data or self.changed:
self._data = [self.obj.get_event_ref_list()]
self._groups = [(self.obj.get_handle(), self._WORKNAME)]
self._groups = [(self.obj.get_handle(), self._WORKNAME, '')]
# own family events
family_handle_list = self.obj.get_family_handle_list()
if family_handle_list:
@ -86,10 +87,8 @@ class PersonEventEmbedList(EventEmbedList):
else:
groupname = self._UNKNOWNNAME
self._data.append(family.get_event_ref_list())
self._groups.append((family_handle, self._FAMNAME % {
'namepartner': groupname,
'famid': family.get_gramps_id()
}))
self._groups.append((family_handle, self._FAMNAME,
groupname))
self.changed = False
return self._data