mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add as_html option to composite column
This commit is contained in:
parent
a89729833b
commit
fc93863c58
@ -100,6 +100,14 @@ def render_data(mi, use_roman_numbers=True, all_fields=False):
|
||||
val = force_unicode(val)
|
||||
ans.append((field,
|
||||
u'<td class="comments" colspan="2">%s</td>'%comments_to_html(val)))
|
||||
elif metadata['datatype'] == 'composite' and \
|
||||
metadata['display'].get('contains_html', False):
|
||||
val = getattr(mi, field)
|
||||
if val:
|
||||
val = force_unicode(val)
|
||||
ans.append((field,
|
||||
u'<td class="title">%s</td><td>%s</td>'%
|
||||
(name, comments_to_html(val))))
|
||||
elif field == 'path':
|
||||
if mi.path:
|
||||
path = force_unicode(mi.path, filesystem_encoding)
|
||||
|
@ -127,6 +127,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
||||
self.composite_sort_by.setCurrentIndex(sb)
|
||||
self.composite_make_category.setChecked(
|
||||
c['display'].get('make_category', False))
|
||||
self.composite_make_category.setChecked(
|
||||
c['display'].get('contains_html', False))
|
||||
elif ct == 'enumeration':
|
||||
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
|
||||
self.enum_colors.setText(','.join(c['display'].get('enum_colors', [])))
|
||||
@ -179,7 +181,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
||||
getattr(self, 'date_format_'+x).setVisible(col_type == 'datetime')
|
||||
getattr(self, 'number_format_'+x).setVisible(col_type in ['int', 'float'])
|
||||
for x in ('box', 'default_label', 'label', 'sort_by', 'sort_by_label',
|
||||
'make_category'):
|
||||
'make_category', 'contains_html'):
|
||||
getattr(self, 'composite_'+x).setVisible(col_type in ['composite', '*composite'])
|
||||
for x in ('box', 'default_label', 'label', 'colors', 'colors_label'):
|
||||
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
||||
@ -257,6 +259,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
||||
'composite_sort': ['text', 'number', 'date', 'bool']
|
||||
[self.composite_sort_by.currentIndex()],
|
||||
'make_category': self.composite_make_category.isChecked(),
|
||||
'contains_html': self.composite_contains_html.isChecked(),
|
||||
}
|
||||
elif col_type == 'enumeration':
|
||||
if not unicode(self.enum_box.text()).strip():
|
||||
|
@ -294,6 +294,16 @@ and end with <code>}</code> You can have text before and after the f
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="composite_contains_html">
|
||||
<property name="toolTip">
|
||||
<string>If checked, this column will be displayed as HTML in book details and the content server</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show as HTML in book details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_24">
|
||||
<property name="sizePolicy">
|
||||
|
@ -795,7 +795,9 @@ class BrowseServer(object):
|
||||
list(mi.get_all_user_metadata(False).items()):
|
||||
if m['is_custom'] and field not in displayed_custom_fields:
|
||||
continue
|
||||
if m['datatype'] == 'comments' or field == 'comments':
|
||||
if m['datatype'] == 'comments' or field == 'comments' or (
|
||||
m['datatype'] == 'composite' and \
|
||||
m['display'].get('contains_html', False)):
|
||||
val = mi.get(field, '')
|
||||
if val and val.strip():
|
||||
comments.append((m['name'], comments_to_html(val)))
|
||||
|
@ -186,7 +186,8 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
||||
CFM[key]['is_multiple']['ui_to_list'],
|
||||
ignore_max=True, no_tag_count=True,
|
||||
joinval=CFM[key]['is_multiple']['list_to_ui']))))
|
||||
elif datatype == 'comments':
|
||||
elif datatype == 'comments' or CFM[key]['datatype'] == 'composite' and \
|
||||
CFM[key]['display'].get('contains_html', False):
|
||||
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
||||
else:
|
||||
extra.append('%s: %s<br />'%(xml(name), xml(unicode(val))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user