Fix display of names in partition mode

This commit is contained in:
Charles Haley 2010-12-31 06:48:44 +00:00
parent 81900219a2
commit fb76838874
3 changed files with 10 additions and 5 deletions

View File

@ -77,9 +77,9 @@ categories_use_field_for_author_name = 'author'
# sort: the sort value. For authors, this is the author_sort for that author
# category: the category (e.g., authors, series) that the item is in.
categories_collapse_more_than = 50
categories_collapsed_name_template = '{first.name:shorten(4,'',0)}{last.name::shorten(4,'',0)| - |}'
categories_collapsed_rating_template = '{first.avg_rating:4.2f}{last.avg_rating:4.2f| - |}'
categories_collapsed_popularity_template = '{first.count:d}{last.count:d| - |}'
categories_collapsed_name_template = '{first.name:shorten(4,'',0)} - {last.name::shorten(4,'',0)}'
categories_collapsed_rating_template = '{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}'
categories_collapsed_popularity_template = '{first.count:d} - {last.count:d}'
categories_collapse_model = 'first letter'
# Set whether boolean custom columns are two- or three-valued.

View File

@ -674,7 +674,6 @@ class TagsModel(QAbstractItemModel): # {{{
if data is None:
return False
row_index = -1
empty_tag = Tag('')
collapse = tweaks['categories_collapse_more_than']
collapse_model = tweaks['categories_collapse_model']
if sort_by == 'name':
@ -726,7 +725,7 @@ class TagsModel(QAbstractItemModel): # {{{
if cat_len > idx + collapse:
d['last'] = data[r][idx+collapse-1]
else:
d['last'] = empty_tag
d['last'] = data[r][cat_len-1]
name = eval_formatter.safe_format(collapse_template,
d, 'TAG_VIEW', None)
sub_cat = TagTreeItem(parent=category,

View File

@ -371,6 +371,12 @@ class TemplateFormatter(string.Formatter):
raise Exception('get_value must be implemented in the subclass')
def format_field(self, val, fmt):
# ensure we are dealing with a string.
if isinstance(val, (int, float)):
if val:
val = unicode(val)
else:
val = ''
# Handle conditional text
fmt, prefix, suffix = self._explode_format_string(fmt)