mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Make heading-on-side for comments columns configurable
This commit is contained in:
parent
b49b1e81a9
commit
0b0f6e6b9d
@ -98,9 +98,15 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
val = markdown(val)
|
||||
else:
|
||||
val = comments_to_html(val)
|
||||
add_comment = True
|
||||
if disp.get('show_heading'):
|
||||
val = '<h3 class="comments-heading">%s</h3>%s' % (p(name), val)
|
||||
comment_fields.append('<div id="%s" class="comments">%s</div>' % (field.replace('#', '_'), val))
|
||||
if disp.get('heading_on_side'):
|
||||
ans.append((field, row % (name, val)))
|
||||
add_comment = False
|
||||
else:
|
||||
val = '<h3 class="comments-heading">%s</h3>%s' % (p(name), val)
|
||||
if add_comment:
|
||||
comment_fields.append('<div id="%s" class="comments">%s</div>' % (field.replace('#', '_'), val))
|
||||
elif metadata['datatype'] == 'rating':
|
||||
val = getattr(mi, field)
|
||||
if val:
|
||||
|
@ -165,6 +165,7 @@ class CreateCustomColumn(QDialog):
|
||||
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_type.findData(c['display'].get('interpret_as', 'html')))
|
||||
self.comments_type.setCurrentIndex(idx)
|
||||
self.datatype_changed()
|
||||
@ -207,6 +208,7 @@ class CreateCustomColumn(QDialog):
|
||||
self.composite_sort_by.setCurrentIndex(0)
|
||||
if which == 'text':
|
||||
self.show_comments_heading.setChecked(True)
|
||||
self.comments_heading_on_side.setChecked(True)
|
||||
self.comments_type.setCurrentIndex(self.comments_type.findData('short-text'))
|
||||
# }}}
|
||||
|
||||
@ -307,9 +309,13 @@ class CreateCustomColumn(QDialog):
|
||||
self.composite_label = add_row(_("&Template"), h)
|
||||
|
||||
# Comments properties
|
||||
self.show_comments_heading = sch = QCheckBox(_('Show heading in book details panel'))
|
||||
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'))
|
||||
'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_type = ct = QComboBox(self)
|
||||
for k, text in (
|
||||
@ -418,6 +424,7 @@ class CreateCustomColumn(QDialog):
|
||||
self.show_comments_heading.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()
|
||||
@ -515,6 +522,7 @@ class CreateCustomColumn(QDialog):
|
||||
elif col_type == 'comments':
|
||||
display_dict['show_heading'] = bool(self.show_comments_heading.isChecked())
|
||||
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()
|
||||
|
@ -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?.interpret_as is 'short-text':
|
||||
add_row(name, val)
|
||||
if fm.display?.heading_on_side:
|
||||
add_row(name, val, is_html=fm.display?.interpret_as is not 'short-text')
|
||||
else:
|
||||
comments[field] = val
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user