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)
|
val = force_unicode(val)
|
||||||
ans.append((field,
|
ans.append((field,
|
||||||
u'<td class="comments" colspan="2">%s</td>'%comments_to_html(val)))
|
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':
|
elif field == 'path':
|
||||||
if mi.path:
|
if mi.path:
|
||||||
path = force_unicode(mi.path, filesystem_encoding)
|
path = force_unicode(mi.path, filesystem_encoding)
|
||||||
|
@ -127,6 +127,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
self.composite_sort_by.setCurrentIndex(sb)
|
self.composite_sort_by.setCurrentIndex(sb)
|
||||||
self.composite_make_category.setChecked(
|
self.composite_make_category.setChecked(
|
||||||
c['display'].get('make_category', False))
|
c['display'].get('make_category', False))
|
||||||
|
self.composite_make_category.setChecked(
|
||||||
|
c['display'].get('contains_html', False))
|
||||||
elif ct == 'enumeration':
|
elif ct == 'enumeration':
|
||||||
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
|
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
|
||||||
self.enum_colors.setText(','.join(c['display'].get('enum_colors', [])))
|
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, 'date_format_'+x).setVisible(col_type == 'datetime')
|
||||||
getattr(self, 'number_format_'+x).setVisible(col_type in ['int', 'float'])
|
getattr(self, 'number_format_'+x).setVisible(col_type in ['int', 'float'])
|
||||||
for x in ('box', 'default_label', 'label', 'sort_by', 'sort_by_label',
|
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'])
|
getattr(self, 'composite_'+x).setVisible(col_type in ['composite', '*composite'])
|
||||||
for x in ('box', 'default_label', 'label', 'colors', 'colors_label'):
|
for x in ('box', 'default_label', 'label', 'colors', 'colors_label'):
|
||||||
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
||||||
@ -257,6 +259,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
'composite_sort': ['text', 'number', 'date', 'bool']
|
'composite_sort': ['text', 'number', 'date', 'bool']
|
||||||
[self.composite_sort_by.currentIndex()],
|
[self.composite_sort_by.currentIndex()],
|
||||||
'make_category': self.composite_make_category.isChecked(),
|
'make_category': self.composite_make_category.isChecked(),
|
||||||
|
'contains_html': self.composite_contains_html.isChecked(),
|
||||||
}
|
}
|
||||||
elif col_type == 'enumeration':
|
elif col_type == 'enumeration':
|
||||||
if not unicode(self.enum_box.text()).strip():
|
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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer name="horizontalSpacer_24">
|
<spacer name="horizontalSpacer_24">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -795,7 +795,9 @@ class BrowseServer(object):
|
|||||||
list(mi.get_all_user_metadata(False).items()):
|
list(mi.get_all_user_metadata(False).items()):
|
||||||
if m['is_custom'] and field not in displayed_custom_fields:
|
if m['is_custom'] and field not in displayed_custom_fields:
|
||||||
continue
|
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, '')
|
val = mi.get(field, '')
|
||||||
if val and val.strip():
|
if val and val.strip():
|
||||||
comments.append((m['name'], comments_to_html(val)))
|
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'],
|
CFM[key]['is_multiple']['ui_to_list'],
|
||||||
ignore_max=True, no_tag_count=True,
|
ignore_max=True, no_tag_count=True,
|
||||||
joinval=CFM[key]['is_multiple']['list_to_ui']))))
|
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))))
|
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
||||||
else:
|
else:
|
||||||
extra.append('%s: %s<br />'%(xml(name), xml(unicode(val))))
|
extra.append('%s: %s<br />'%(xml(name), xml(unicode(val))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user