mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Show full path to the format file in a tooltip when hovering over the
link to open the format in the book details panel
This commit is contained in:
parent
dd7f18eb54
commit
c185e93ea9
@ -5,6 +5,9 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
import os
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import (QPixmap, QSize, QWidget, Qt, pyqtSignal, QUrl, QIcon,
|
from PyQt4.Qt import (QPixmap, QSize, QWidget, Qt, pyqtSignal, QUrl, QIcon,
|
||||||
QPropertyAnimation, QEasingCurve, QApplication, QFontInfo, QAction,
|
QPropertyAnimation, QEasingCurve, QApplication, QFontInfo, QAction,
|
||||||
QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette, QMenu,
|
QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette, QMenu,
|
||||||
@ -164,8 +167,16 @@ def render_data(mi, use_roman_numbers=True, all_fields=False):
|
|||||||
elif field == 'formats':
|
elif field == 'formats':
|
||||||
if isdevice:
|
if isdevice:
|
||||||
continue
|
continue
|
||||||
fmts = [u'<a href="format:%s:%s">%s</a>' % (mi.id, x, x) for x
|
p = partial(prepare_string_for_xml, attribute=True)
|
||||||
in mi.formats]
|
path = ''
|
||||||
|
if mi.path:
|
||||||
|
h, t = os.path.split(mi.path)
|
||||||
|
path = '/'.join((os.path.basename(h), t))
|
||||||
|
data = ({
|
||||||
|
'fmt':x, 'path':p(path or ''), 'fname':p(mi.format_files.get(x, '')),
|
||||||
|
'ext':x.lower(), 'id':mi.id
|
||||||
|
} for x in mi.formats)
|
||||||
|
fmts = [u'<a title="{path}/{fname}.{ext}" href="format:{id}:{fmt}">{fmt}</a>'.format(**x) for x in data]
|
||||||
ans.append((field, row % (name, u', '.join(fmts))))
|
ans.append((field, row % (name, u', '.join(fmts))))
|
||||||
elif field == 'identifiers':
|
elif field == 'identifiers':
|
||||||
urls = urls_from_identifiers(mi.identifiers)
|
urls = urls_from_identifiers(mi.identifiers)
|
||||||
|
@ -493,6 +493,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
mi.id = self.db.id(idx)
|
mi.id = self.db.id(idx)
|
||||||
mi.field_metadata = self.db.field_metadata
|
mi.field_metadata = self.db.field_metadata
|
||||||
mi.path = self.db.abspath(idx, create_dirs=False)
|
mi.path = self.db.abspath(idx, create_dirs=False)
|
||||||
|
mi.format_files = self.db.new_api.format_files(self.db.data.index_to_id(idx))
|
||||||
try:
|
try:
|
||||||
mi.marked = self.db.data.get_marked(idx, index_is_id=False)
|
mi.marked = self.db.data.get_marked(idx, index_is_id=False)
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user