mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More custom comments as html work
This commit is contained in:
parent
c0c4df77ca
commit
092982e057
@ -12,6 +12,7 @@ from calibre.gui2.dialogs.book_info_ui import Ui_BookInfo
|
||||
from calibre.gui2 import dynamic, open_local_file
|
||||
from calibre import fit_image
|
||||
from calibre.library.comments import comments_to_html
|
||||
from calibre.utils.icu import sort_key
|
||||
|
||||
class BookInfo(QDialog, Ui_BookInfo):
|
||||
|
||||
@ -130,9 +131,11 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
for f in formats:
|
||||
f = f.strip()
|
||||
info[_('Formats')] += '<a href="%s">%s</a>, '%(f,f)
|
||||
for key in info.keys():
|
||||
for key in sorted(info.keys(), key=sort_key):
|
||||
if key == 'id': continue
|
||||
txt = info[key]
|
||||
if key.endswith(':html'):
|
||||
key = key[:-5]
|
||||
if key != _('Path'):
|
||||
txt = u'<br />\n'.join(textwrap.wrap(txt, 120))
|
||||
rows += u'<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt)
|
||||
|
@ -296,19 +296,19 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{
|
||||
Delegate for comments data.
|
||||
'''
|
||||
|
||||
def __init__(self, parent):
|
||||
QStyledItemDelegate.__init__(self, parent)
|
||||
self.document = QTextDocument()
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
document = QTextDocument()
|
||||
value = index.data(Qt.DisplayRole)
|
||||
# if value.isValid() and not value.isNull():
|
||||
# QString text("<span style='background-color: lightgreen'>This</span> is highlighted.");
|
||||
text = value.toString()
|
||||
document.setHtml(text);
|
||||
self.document.setHtml(index.data(Qt.DisplayRole).toString())
|
||||
painter.save()
|
||||
if option.state & QStyle.State_Selected:
|
||||
painter.fillRect(option.rect, option.palette.highlight())
|
||||
painter.setClipRect(option.rect)
|
||||
painter.translate(option.rect.topLeft());
|
||||
document.drawContents(painter);
|
||||
painter.translate(option.rect.topLeft())
|
||||
self.document.drawContents(painter)
|
||||
painter.restore()
|
||||
# painter.translate(-option.rect.topLeft());
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
m = index.model()
|
||||
|
@ -173,6 +173,8 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
||||
extra.append('%s: %s<br />'%(xml(name), xml(format_tag_string(val, ',',
|
||||
ignore_max=True,
|
||||
no_tag_count=True))))
|
||||
elif datatype == 'comments':
|
||||
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
||||
else:
|
||||
extra.append('%s: %s<br />'%(xml(name), xml(unicode(val))))
|
||||
comments = item[FM['comments']]
|
||||
|
Loading…
x
Reference in New Issue
Block a user