From 09437134bacb7f6e057f1b5cb6f148e51508450c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Oct 2010 14:12:29 -0600 Subject: [PATCH] Drag and drop copies only a single format to OS instead of the whole book dir --- src/calibre/gui2/library/views.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 4411e1fd9f..43a31500c7 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -465,8 +465,25 @@ class BooksView(QTableView): # {{{ ids = ' '.join(map(str, selected)) md = QMimeData() md.setData('application/calibre+from_library', ids) - md.setUrls([QUrl.fromLocalFile(db.abspath(i, index_is_id=True)) - for i in selected]) + fmt = prefs['output_format'] + + def url_for_id(i): + ans = db.format_abspath(i, fmt, index_is_id=True) + if ans is None: + fmts = db.formats(i, index_is_id=True) + if fmts: + fmts = fmts.split(',') + else: + fmts = [] + for f in fmts: + ans = db.format_abspath(i, f, index_is_id=True) + if ans is not None: + break + if ans is None: + ans = db.abspath(i, index_is_id=True) + return QUrl.fromLocalFile(ans) + + md.setUrls([url_for_id(i) for i in selected]) drag = QDrag(self) drag.setMimeData(md) cover = self.drag_icon(m.cover(self.currentIndex().row()),