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.gui2 import dynamic, open_local_file
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
class BookInfo(QDialog, Ui_BookInfo):
|
class BookInfo(QDialog, Ui_BookInfo):
|
||||||
|
|
||||||
@ -130,9 +131,11 @@ class BookInfo(QDialog, Ui_BookInfo):
|
|||||||
for f in formats:
|
for f in formats:
|
||||||
f = f.strip()
|
f = f.strip()
|
||||||
info[_('Formats')] += '<a href="%s">%s</a>, '%(f,f)
|
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
|
if key == 'id': continue
|
||||||
txt = info[key]
|
txt = info[key]
|
||||||
|
if key.endswith(':html'):
|
||||||
|
key = key[:-5]
|
||||||
if key != _('Path'):
|
if key != _('Path'):
|
||||||
txt = u'<br />\n'.join(textwrap.wrap(txt, 120))
|
txt = u'<br />\n'.join(textwrap.wrap(txt, 120))
|
||||||
rows += u'<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt)
|
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.
|
Delegate for comments data.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
QStyledItemDelegate.__init__(self, parent)
|
||||||
|
self.document = QTextDocument()
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
document = QTextDocument()
|
self.document.setHtml(index.data(Qt.DisplayRole).toString())
|
||||||
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);
|
|
||||||
painter.save()
|
painter.save()
|
||||||
|
if option.state & QStyle.State_Selected:
|
||||||
|
painter.fillRect(option.rect, option.palette.highlight())
|
||||||
painter.setClipRect(option.rect)
|
painter.setClipRect(option.rect)
|
||||||
painter.translate(option.rect.topLeft());
|
painter.translate(option.rect.topLeft())
|
||||||
document.drawContents(painter);
|
self.document.drawContents(painter)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
# painter.translate(-option.rect.topLeft());
|
|
||||||
|
|
||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
m = index.model()
|
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, ',',
|
extra.append('%s: %s<br />'%(xml(name), xml(format_tag_string(val, ',',
|
||||||
ignore_max=True,
|
ignore_max=True,
|
||||||
no_tag_count=True))))
|
no_tag_count=True))))
|
||||||
|
elif datatype == 'comments':
|
||||||
|
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))))
|
||||||
comments = item[FM['comments']]
|
comments = item[FM['comments']]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user