Extend markup column definition to a list of columns for listviews.
svn: r14327
This commit is contained in:
parent
77734ed302
commit
4ef3a10161
@ -92,7 +92,7 @@ class ListView(NavigationView):
|
||||
|
||||
def __init__(self, title, dbstate, uistate, columns, handle_col,
|
||||
make_model, signal_map, get_bookmarks, bm_type, nav_group,
|
||||
multiple=False, filter_class=None, markup=False):
|
||||
multiple=False, filter_class=None, markup=None):
|
||||
NavigationView.__init__(self, title, dbstate, uistate,
|
||||
get_bookmarks, bm_type, nav_group)
|
||||
#default is listviews keep themself in sync with database
|
||||
@ -111,7 +111,10 @@ class ListView(NavigationView):
|
||||
self.signal_map = signal_map
|
||||
self.multiple_selection = multiple
|
||||
self.generic_filter = None
|
||||
self.markup_required = markup
|
||||
if markup:
|
||||
self.markup_columns = markup
|
||||
else:
|
||||
self.markup_columns = []
|
||||
dbstate.connect('database-changed', self.change_db)
|
||||
|
||||
def type_list(self):
|
||||
@ -222,7 +225,7 @@ class ListView(NavigationView):
|
||||
mcol = self.model.marker_column()
|
||||
column.add_attribute(self.renderer, 'foreground', mcol)
|
||||
|
||||
if self.markup_required:
|
||||
if pair[1] in self.markup_columns:
|
||||
column.add_attribute(self.renderer, 'markup', pair[1])
|
||||
else:
|
||||
column.add_attribute(self.renderer, 'text', pair[1])
|
||||
|
@ -318,19 +318,22 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
|
||||
self.add_node(node3, handle, sort_key, handle, add_parent=False)
|
||||
|
||||
def column_name(self, data):
|
||||
if data[2]:
|
||||
return unicode(data[2])
|
||||
elif data[5] is not None:
|
||||
name = ''
|
||||
if data[5] is not None:
|
||||
level = [data[5][0][i] for i in range(4,-1,-1)]
|
||||
if not (level[3] or level[4]):
|
||||
return unicode(level[2] or level[1] or level[0])
|
||||
name = unicode(level[2] or level[1] or level[0])
|
||||
elif level[3] and level[4]:
|
||||
return unicode(level[3] + ', ' + level[4])
|
||||
name = unicode(level[3] + ', ' + level[4])
|
||||
elif level[3] or level[4]:
|
||||
return unicode(level[3] or level[4])
|
||||
else:
|
||||
return u"<i>%s<i>" % cgi.escape(_("<no name>"))
|
||||
return unicode(data[2])
|
||||
name = unicode(level[3] or level[4])
|
||||
if not name:
|
||||
name = unicode(data[2])
|
||||
|
||||
if name:
|
||||
return cgi.escape(name)
|
||||
else:
|
||||
return u"<i>%s<i>" % cgi.escape(_("<no name>"))
|
||||
|
||||
def column_header(self, node):
|
||||
"""
|
||||
|
@ -96,6 +96,8 @@ class BasePersonView(ListView):
|
||||
_('Spouse'),
|
||||
_('Last Changed'),
|
||||
]
|
||||
# columns that contain markup
|
||||
MARKUP_COLS = [COL_BDAT, COL_BPLAC, COL_DDAT, COL_DPLAC]
|
||||
# default setting with visible columns, order of the col, and their size
|
||||
CONFIGSETTINGS = (
|
||||
('columns.visible', [COL_NAME, COL_ID, COL_GEN, COL_BDAT, COL_DDAT]),
|
||||
@ -127,7 +129,7 @@ class BasePersonView(ListView):
|
||||
Bookmarks.PersonBookmarks, nav_group,
|
||||
multiple=True,
|
||||
filter_class=PersonSidebarFilter,
|
||||
markup=True)
|
||||
markup=BasePersonView.MARKUP_COLS)
|
||||
|
||||
self.func_list = {
|
||||
'<CONTROL>J' : self.jump,
|
||||
|
@ -99,6 +99,8 @@ class PlaceBaseView(ListView):
|
||||
_('Last Changed'),
|
||||
_('Street'),
|
||||
]
|
||||
# columns that contain markup
|
||||
MARKUP_COLS = [COL_NAME]
|
||||
# default setting with visible columns, order of the col, and their size
|
||||
CONFIGSETTINGS = (
|
||||
('columns.visible', [COL_NAME, COL_ID, COL_STREET, COL_CITY, COL_STATE
|
||||
@ -116,7 +118,7 @@ class PlaceBaseView(ListView):
|
||||
QR_CATEGORY = CATEGORY_QR_PLACE
|
||||
|
||||
def __init__(self, dbstate, uistate, title, model, nav_group,
|
||||
markup=False):
|
||||
markup=None):
|
||||
|
||||
signal_map = {
|
||||
'place-add' : self.row_add,
|
||||
|
@ -55,7 +55,7 @@ class PlaceTreeView(PlaceBaseView):
|
||||
def __init__(self, dbstate, uistate):
|
||||
PlaceBaseView.__init__(self, dbstate, uistate,
|
||||
_('Place Tree View'), PlaceTreeModel,
|
||||
nav_group=0, markup=True)
|
||||
nav_group=0, markup=PlaceBaseView.MARKUP_COLS)
|
||||
|
||||
def type_list(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user