diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py
index 6a8d3e6da5..14eb674ea3 100644
--- a/src/calibre/ebooks/metadata/book/render.py
+++ b/src/calibre/ebooks/metadata/book/render.py
@@ -89,24 +89,20 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
if val:
ctype = disp.get('interpret_as') or 'html'
val = force_unicode(val)
- if ctype == 'short-text':
- ans.append((field, row % (name, p(val))))
+ if ctype == 'long-text':
+ val = '
%s
' % p(val)
+ elif ctype == 'short-text':
+ val = '%s' % p(val)
+ elif ctype == 'markdown':
+ val = markdown(val)
else:
- if ctype == 'long-text':
- val = '%s
' % p(val)
- elif ctype == 'markdown':
- val = markdown(val)
- else:
- val = comments_to_html(val)
- add_comment = True
- if disp.get('show_heading'):
- if disp.get('heading_on_side'):
- ans.append((field, row % (name, val)))
- add_comment = False
- else:
- val = '%s' % (p(name), val)
- if add_comment:
- comment_fields.append('' % (field.replace('#', '_'), val))
+ val = comments_to_html(val)
+ if disp.get('heading_position', 'hide') == 'side':
+ ans.append((field, row % (name, val)))
+ else:
+ if disp.get('heading_position', 'hide') == 'above':
+ val = '%s' % (p(name), val)
+ comment_fields.append('' % (field.replace('#', '_'), val))
elif metadata['datatype'] == 'rating':
val = getattr(mi, field)
if val:
diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py
index e62a0f5684..a7ef2c41d1 100644
--- a/src/calibre/gui2/preferences/create_custom_column.py
+++ b/src/calibre/gui2/preferences/create_custom_column.py
@@ -164,8 +164,8 @@ class CreateCustomColumn(QDialog):
if c['display'].get('number_format', None):
self.format_box.setText(c['display'].get('number_format', ''))
elif ct == 'comments':
- self.show_comments_heading.setChecked(c['display'].get('show_heading', False))
- self.comments_heading_on_side.setChecked(c['display'].get('heading_on_side', False))
+ idx = max(0, self.comments_heading_position.findData(c['display'].get('heading_position', 'hide')))
+ self.comments_heading_position.setCurrentIndex(idx)
idx = max(0, self.comments_type.findData(c['display'].get('interpret_as', 'html')))
self.comments_type.setCurrentIndex(idx)
self.datatype_changed()
@@ -207,8 +207,7 @@ class CreateCustomColumn(QDialog):
}[which])
self.composite_sort_by.setCurrentIndex(0)
if which == 'text':
- self.show_comments_heading.setChecked(True)
- self.comments_heading_on_side.setChecked(True)
+ self.comments_heading_position.setCurrentIndex(self.comments_heading_position.findData('side'))
self.comments_type.setCurrentIndex(self.comments_type.findData('short-text'))
# }}}
@@ -309,14 +308,17 @@ class CreateCustomColumn(QDialog):
self.composite_label = add_row(_("&Template"), h)
# Comments properties
- self.show_comments_heading = sch = QCheckBox(_('Show heading in the Book Details panel'))
- sch.setToolTip(_(
- 'Choose whether to show the heading for this column in the Book Details panel'))
- add_row(None, sch)
- self.comments_heading_on_side = sch = QCheckBox(_('Show column heading to the side of the text'))
- sch.setToolTip(_(
- 'Choose whether to show the heading above or to the side of the text in the Book Details panel'))
- add_row(None, sch)
+ self.comments_heading_position = ct = QComboBox(self)
+ for k, text in (
+ ('hide', _('No heading')),
+ ('above', _('Show heading above the text')),
+ ('side', _('Show heading to the side of the text'))
+ ):
+ ct.addItem(text, k)
+ ct.setToolTip(_('Choose whether or not the column heading is shown in the Book\n'
+ 'Details panel and, if shown, where'))
+ self.comments_heading_position_label = add_row(_('Column heading'), ct)
+
self.comments_type = ct = QComboBox(self)
for k, text in (
('html', 'HTML'),
@@ -326,7 +328,7 @@ class CreateCustomColumn(QDialog):
):
ct.addItem(text, k)
ct.setToolTip(_('Choose how the data in this column is interpreted.\n'
- 'This control how the data is displayed in the Book Details panel\n'
+ 'This controls how the data is displayed in the Book Details panel\n'
'and how it is edited.'))
self.comments_type_label = add_row(_('Interpret this column as:') + ' ', ct)
@@ -421,10 +423,10 @@ class CreateCustomColumn(QDialog):
self.use_decorations.setVisible(col_type in ['text', 'composite', 'enumeration'])
self.is_names.setVisible(col_type == '*text')
is_comments = col_type == 'comments'
- self.show_comments_heading.setVisible(is_comments)
+ self.comments_heading_position.setVisible(is_comments)
+ self.comments_heading_position_label.setVisible(is_comments)
self.comments_type.setVisible(is_comments)
self.comments_type_label.setVisible(is_comments)
- self.comments_heading_on_side.setVisible(is_comments)
def accept(self):
col = unicode(self.column_name_box.text()).strip()
@@ -520,9 +522,8 @@ class CreateCustomColumn(QDialog):
else:
display_dict = {'number_format': None}
elif col_type == 'comments':
- display_dict['show_heading'] = bool(self.show_comments_heading.isChecked())
+ display_dict['heading_position'] = type(u'')(self.comments_heading_position.currentData())
display_dict['interpret_as'] = type(u'')(self.comments_type.currentData())
- display_dict['heading_on_side'] = bool(self.comments_heading_on_side.isChecked())
if col_type in ['text', 'composite', 'enumeration'] and not is_multiple:
display_dict['use_decorations'] = self.use_decorations.checkState()
diff --git a/src/calibre/srv/metadata.py b/src/calibre/srv/metadata.py
index e1c411a582..027b9865e2 100644
--- a/src/calibre/srv/metadata.py
+++ b/src/calibre/srv/metadata.py
@@ -53,10 +53,10 @@ def add_field(field, db, book_id, ans, field_metadata):
ctype = field_metadata.get('display', {}).get('interpret_as', 'html')
if ctype == 'markdown':
val = markdown(val)
- elif ctype == 'short-text':
- pass
elif ctype == 'long-text':
- val = '%s
' % prepare_string_for_xml(val)
+ val = '%s
' % prepare_string_for_xml(val)
+ elif ctype == 'short-text':
+ val = '%s' % prepare_string_for_xml(val)
else:
val = comments_to_html(val)
elif datatype == 'composite' and field_metadata['display'].get('contains_html'):
diff --git a/src/pyj/book_list/book_details.pyj b/src/pyj/book_list/book_details.pyj
index b987131d66..7296102d3d 100644
--- a/src/pyj/book_list/book_details.pyj
+++ b/src/pyj/book_list/book_details.pyj
@@ -201,8 +201,8 @@ def render_metadata(mi, interface_data, table, field_list=None):
datatype = fm.datatype
val = mi[field]
if field is 'comments' or datatype is 'comments':
- if fm.display?.heading_on_side:
- add_row(name, val, is_html=fm.display?.interpret_as is not 'short-text')
+ if fm.display?.heading_position is 'side':
+ add_row(name, val, is_html=True)
else:
comments[field] = val
return
@@ -256,7 +256,7 @@ def render_metadata(mi, interface_data, table, field_list=None):
comment = comments[field]
div = E.div()
div.innerHTML = comment
- if fm.display?.show_heading:
+ if fm.display?.heading_position is 'above':
name = fm.name or field
div.insertBefore(E.h3(name), div.firstChild or None)
table.parentNode.appendChild(div)