mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
ddfc313efd
commit
62cfdc8023
@ -591,8 +591,10 @@ class BooksView(QTableView): # {{{
|
|||||||
fmt = prefs['output_format']
|
fmt = prefs['output_format']
|
||||||
|
|
||||||
def url_for_id(i):
|
def url_for_id(i):
|
||||||
ans = db.format(i, fmt, index_is_id=True, as_path=True,
|
try:
|
||||||
preserve_filename=True)
|
ans = db.format_path(i, fmt, index_is_id=True)
|
||||||
|
except:
|
||||||
|
ans = None
|
||||||
if ans is None:
|
if ans is None:
|
||||||
fmts = db.formats(i, index_is_id=True)
|
fmts = db.formats(i, index_is_id=True)
|
||||||
if fmts:
|
if fmts:
|
||||||
@ -600,13 +602,15 @@ class BooksView(QTableView): # {{{
|
|||||||
else:
|
else:
|
||||||
fmts = []
|
fmts = []
|
||||||
for f in fmts:
|
for f in fmts:
|
||||||
ans = db.format(i, f, index_is_id=True, as_path=True,
|
try:
|
||||||
preserve_filename=True)
|
ans = db.format_path(i, f, index_is_id=True)
|
||||||
|
except:
|
||||||
|
ans = None
|
||||||
if ans is None:
|
if ans is None:
|
||||||
ans = db.abspath(i, index_is_id=True)
|
ans = db.abspath(i, index_is_id=True)
|
||||||
return QUrl.fromLocalFile(ans)
|
return QUrl.fromLocalFile(ans)
|
||||||
|
|
||||||
md.setUrls([url_for_id(i) for i in selected[:25]])
|
md.setUrls([url_for_id(i) for i in selected])
|
||||||
drag = QDrag(self)
|
drag = QDrag(self)
|
||||||
col = self.selectionModel().currentIndex().column()
|
col = self.selectionModel().currentIndex().column()
|
||||||
md.column_name = self.column_map[col]
|
md.column_name = self.column_map[col]
|
||||||
|
@ -1144,6 +1144,20 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
break
|
break
|
||||||
return sha.hexdigest()
|
return sha.hexdigest()
|
||||||
|
|
||||||
|
def format_path(self, index, fmt, index_is_id=False):
|
||||||
|
'''
|
||||||
|
This method is intended to be used only in those rare situations, like
|
||||||
|
Drag'n Drop, when you absolutely need the path to the original file.
|
||||||
|
Otherwise, use format(..., as_path=True).
|
||||||
|
|
||||||
|
Note that a networked backend will always return None.
|
||||||
|
'''
|
||||||
|
path = self.format_abspath(index, fmt, index_is_id=index_is_id)
|
||||||
|
if path is None:
|
||||||
|
id_ = index if index_is_id else self.id(index)
|
||||||
|
raise NoSuchFormat('Record %d has no format: %s'%(id_, fmt))
|
||||||
|
return path
|
||||||
|
|
||||||
def format_abspath(self, index, format, index_is_id=False):
|
def format_abspath(self, index, format, index_is_id=False):
|
||||||
'''
|
'''
|
||||||
Return absolute path to the ebook file of format `format`
|
Return absolute path to the ebook file of format `format`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user