mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #7723 (View Specific Format Does Not Allow More Than One Selection)
This commit is contained in:
parent
c63425f0b0
commit
aef657b099
@ -12,7 +12,7 @@ from PyQt4.Qt import Qt, QMenu
|
|||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import isosx
|
||||||
from calibre.gui2 import error_dialog, Dispatcher, question_dialog, config, \
|
from calibre.gui2 import error_dialog, Dispatcher, question_dialog, config, \
|
||||||
open_local_file
|
open_local_file, info_dialog
|
||||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
@ -89,18 +89,34 @@ class ViewAction(InterfaceAction):
|
|||||||
self._launch_viewer(name, viewer, internal)
|
self._launch_viewer(name, viewer, internal)
|
||||||
|
|
||||||
def view_specific_format(self, triggered):
|
def view_specific_format(self, triggered):
|
||||||
rows = self.gui.library_view.selectionModel().selectedRows()
|
rows = list(self.gui.library_view.selectionModel().selectedRows())
|
||||||
if not rows or len(rows) == 0:
|
if not rows or len(rows) == 0:
|
||||||
d = error_dialog(self.gui, _('Cannot view'), _('No book selected'))
|
d = error_dialog(self.gui, _('Cannot view'), _('No book selected'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
return
|
||||||
|
|
||||||
row = rows[0].row()
|
db = self.gui.library_view.model().db
|
||||||
formats = self.gui.library_view.model().db.formats(row).upper().split(',')
|
rows = [r.row() for r in rows]
|
||||||
d = ChooseFormatDialog(self.gui, _('Choose the format to view'), formats)
|
formats = [db.formats(row) for row in rows]
|
||||||
|
formats = [list(f.upper().split(',')) if f else None for f in formats]
|
||||||
|
all_fmts = set([])
|
||||||
|
for x in formats:
|
||||||
|
for f in x: all_fmts.add(f)
|
||||||
|
d = ChooseFormatDialog(self.gui, _('Choose the format to view'),
|
||||||
|
list(sorted(all_fmts)))
|
||||||
if d.exec_() == d.Accepted:
|
if d.exec_() == d.Accepted:
|
||||||
format = d.format()
|
fmt = d.format()
|
||||||
self.view_format(row, format)
|
orig_num = len(rows)
|
||||||
|
rows = [rows[i] for i in range(len(rows)) if formats[i] and fmt in
|
||||||
|
formats[i]]
|
||||||
|
if self._view_check(len(rows)):
|
||||||
|
for row in rows:
|
||||||
|
self.view_format(row, fmt)
|
||||||
|
if len(rows) < orig_num:
|
||||||
|
info_dialog(self.gui, _('Format unavailable'),
|
||||||
|
_('Not all the selected books were available in'
|
||||||
|
' the %s format. You should convert'
|
||||||
|
' them first.')%fmt, show=True)
|
||||||
|
|
||||||
def _view_check(self, num, max_=3):
|
def _view_check(self, num, max_=3):
|
||||||
if num <= max_:
|
if num <= max_:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user