When adding books via the add books button to the device, restrict to formats supported by device

This commit is contained in:
Kovid Goyal 2009-12-21 21:12:04 -07:00
parent 205cdd7a61
commit 2508202262
3 changed files with 10 additions and 28 deletions

View File

@ -926,8 +926,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
'''
Add books from the local filesystem to either the library or the device.
'''
books = choose_files(self, 'add books dialog dir', 'Select books',
filters=[
filters = [
(_('Books'), BOOK_EXTENSIONS),
(_('EPUB Books'), ['epub']),
(_('LRF Books'), ['lrf']),
@ -938,10 +937,15 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
(_('PDF Books'), ['pdf']),
(_('Comics'), ['cbz', 'cbr', 'cbc']),
(_('Archives'), ['zip', 'rar']),
])
]
to_device = self.stack.currentIndex() != 0
if to_device:
filters = [(_('Supported books'), self.device_manager.device.FORMATS)]
books = choose_files(self, 'add books dialog dir', 'Select books',
filters=filters)
if not books:
return
to_device = self.stack.currentIndex() != 0
self._add_books(books, to_device)

View File

@ -473,7 +473,7 @@ class LibraryDatabase2(LibraryDatabase):
def upgrade_version_2(self):
''' Fix Foreign key constraints for deleting from link tables. '''
script = textwrap.dedent('''\
DROP TRIGGER fkc_delete_books_%(ltable)s_link;
DROP TRIGGER IF EXISTS fkc_delete_books_%(ltable)s_link;
CREATE TRIGGER fkc_delete_on_%(table)s
BEFORE DELETE ON %(table)s
BEGIN

View File

@ -11,7 +11,6 @@ from copy import deepcopy
from functools import partial
from optparse import OptionParser as _OptionParser
from optparse import IndentedHelpFormatter
from PyQt4.QtCore import QString
from calibre.constants import terminal_controller, iswindows, isosx, \
__appname__, __version__, __author__, plugins
from calibre.utils.lock import LockError, ExclusiveFile
@ -365,6 +364,7 @@ class OptionSet(object):
if val is val is True or val is False or val is None or \
isinstance(val, (int, float, long, basestring)):
return repr(val)
from PyQt4.QtCore import QString
if isinstance(val, QString):
return repr(unicode(val))
pickle = cPickle.dumps(val, -1)
@ -722,26 +722,4 @@ def migrate():
p.set('migrated', True)
if __name__ == '__main__':
import subprocess
from PyQt4.Qt import QByteArray
c = Config('test', 'test config')
c.add_opt('one', ['-1', '--one'], help="This is option #1")
c.set('one', u'345')
c.add_opt('two', help="This is option #2")
c.set('two', 345)
c.add_opt('three', help="This is option #3")
c.set('three', QString(u'aflatoon'))
c.add_opt('four', help="This is option #4")
c.set('four', QByteArray('binary aflatoon'))
subprocess.call(['pygmentize', os.path.expanduser('~/.config/calibre/test.py')])
opts = c.parse()
for i in ('one', 'two', 'three', 'four'):
print i, repr(getattr(opts, i))