mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
c29e881e50
@ -289,7 +289,10 @@ class DevicePlugin(Plugin):
|
|||||||
word "card" if C{on_card} is not None otherwise it must contain the word "memory".
|
word "card" if C{on_card} is not None otherwise it must contain the word "memory".
|
||||||
:files: A list of paths and/or file-like objects. If they are paths and
|
:files: A list of paths and/or file-like objects. If they are paths and
|
||||||
the paths point to temporary files, they may have an additional
|
the paths point to temporary files, they may have an additional
|
||||||
attribute, original_file_path pointing to the originals.
|
attribute, original_file_path pointing to the originals. They may have
|
||||||
|
another optional attribute, deleted_after_upload which if True means
|
||||||
|
that the file pointed to by original_file_path will be deleted after
|
||||||
|
being uploaded to the device.
|
||||||
:names: A list of file names that the books should have
|
:names: A list of file names that the books should have
|
||||||
once uploaded to the device. len(names) == len(files)
|
once uploaded to the device. len(names) == len(files)
|
||||||
:return: A list of 3-element tuples. The list is meant to be passed
|
:return: A list of 3-element tuples. The list is meant to be passed
|
||||||
|
@ -599,7 +599,10 @@ class Emailer(Thread): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class DeviceGUI(object):
|
class DeviceMixin(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.db_book_uuid_cache = set()
|
||||||
|
|
||||||
def dispatch_sync_event(self, dest, delete, specific):
|
def dispatch_sync_event(self, dest, delete, specific):
|
||||||
rows = self.library_view.selectionModel().selectedRows()
|
rows = self.library_view.selectionModel().selectedRows()
|
||||||
@ -851,6 +854,7 @@ class DeviceGUI(object):
|
|||||||
|
|
||||||
def sync_news(self, send_ids=None, do_auto_convert=True):
|
def sync_news(self, send_ids=None, do_auto_convert=True):
|
||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
|
del_on_upload = config['delete_news_from_library_on_upload']
|
||||||
settings = self.device_manager.device.settings()
|
settings = self.device_manager.device.settings()
|
||||||
ids = list(dynamic.get('news_to_be_synced', set([]))) if send_ids is None else send_ids
|
ids = list(dynamic.get('news_to_be_synced', set([]))) if send_ids is None else send_ids
|
||||||
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
||||||
@ -880,6 +884,8 @@ class DeviceGUI(object):
|
|||||||
'the device?'), det_msg=autos):
|
'the device?'), det_msg=autos):
|
||||||
self.auto_convert_news(auto, format)
|
self.auto_convert_news(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
|
for f in files:
|
||||||
|
f.deleted_after_upload = del_on_upload
|
||||||
if not files:
|
if not files:
|
||||||
dynamic.set('news_to_be_synced', set([]))
|
dynamic.set('news_to_be_synced', set([]))
|
||||||
return
|
return
|
||||||
@ -897,8 +903,7 @@ class DeviceGUI(object):
|
|||||||
'rb').read())
|
'rb').read())
|
||||||
dynamic.set('news_to_be_synced', set([]))
|
dynamic.set('news_to_be_synced', set([]))
|
||||||
if config['upload_news_to_device'] and files:
|
if config['upload_news_to_device'] and files:
|
||||||
remove = ids if \
|
remove = ids if del_on_upload else []
|
||||||
config['delete_news_from_library_on_upload'] else []
|
|
||||||
space = { self.location_view.model().free[0] : None,
|
space = { self.location_view.model().free[0] : None,
|
||||||
self.location_view.model().free[1] : 'carda',
|
self.location_view.model().free[1] : 'carda',
|
||||||
self.location_view.model().free[2] : 'cardb' }
|
self.location_view.model().free[2] : 'cardb' }
|
||||||
|
@ -39,6 +39,7 @@ class FormatPath(unicode):
|
|||||||
def __new__(cls, path, orig_file_path):
|
def __new__(cls, path, orig_file_path):
|
||||||
ans = unicode.__new__(cls, path)
|
ans = unicode.__new__(cls, path)
|
||||||
ans.orig_file_path = orig_file_path
|
ans.orig_file_path = orig_file_path
|
||||||
|
ans.deleted_after_upload = False
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
class BooksModel(QAbstractTableModel): # {{{
|
class BooksModel(QAbstractTableModel): # {{{
|
||||||
|
@ -44,7 +44,7 @@ from calibre.gui2.dialogs.scheduler import Scheduler
|
|||||||
from calibre.gui2.update import CheckForUpdates
|
from calibre.gui2.update import CheckForUpdates
|
||||||
from calibre.gui2.main_window import MainWindow
|
from calibre.gui2.main_window import MainWindow
|
||||||
from calibre.gui2.main_ui import Ui_MainWindow
|
from calibre.gui2.main_ui import Ui_MainWindow
|
||||||
from calibre.gui2.device import DeviceManager, DeviceMenu, DeviceGUI, Emailer
|
from calibre.gui2.device import DeviceManager, DeviceMenu, DeviceMixin, Emailer
|
||||||
from calibre.gui2.jobs import JobManager, JobsDialog, JobsButton
|
from calibre.gui2.jobs import JobManager, JobsDialog, JobsButton
|
||||||
from calibre.gui2.dialogs.metadata_single import MetadataSingleDialog
|
from calibre.gui2.dialogs.metadata_single import MetadataSingleDialog
|
||||||
from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
|
from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
|
||||||
@ -105,7 +105,7 @@ class SystemTrayIcon(QSystemTrayIcon): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Main(MainWindow, Ui_MainWindow, DeviceGUI, ToolbarMixin,
|
class Main(MainWindow, Ui_MainWindow, DeviceMixin, ToolbarMixin,
|
||||||
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin):
|
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin):
|
||||||
'The main GUI'
|
'The main GUI'
|
||||||
|
|
||||||
@ -228,6 +228,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI, ToolbarMixin,
|
|||||||
QObject.connect(self.advanced_search_button, SIGNAL('clicked(bool)'),
|
QObject.connect(self.advanced_search_button, SIGNAL('clicked(bool)'),
|
||||||
self.do_advanced_search)
|
self.do_advanced_search)
|
||||||
|
|
||||||
|
DeviceMixin.__init__(self)
|
||||||
|
|
||||||
####################### Start spare job server ########################
|
####################### Start spare job server ########################
|
||||||
QTimer.singleShot(1000, self.add_spare_server)
|
QTimer.singleShot(1000, self.add_spare_server)
|
||||||
|
|
||||||
|
@ -411,7 +411,8 @@ def options(option_parser):
|
|||||||
def opts_and_words(name, op, words):
|
def opts_and_words(name, op, words):
|
||||||
opts = '|'.join(options(op))
|
opts = '|'.join(options(op))
|
||||||
words = '|'.join([w.replace("'", "\\'") for w in words])
|
words = '|'.join([w.replace("'", "\\'") for w in words])
|
||||||
return ('_'+name+'()'+\
|
fname = name.replace('-', '_')
|
||||||
|
return ('_'+fname+'()'+\
|
||||||
'''
|
'''
|
||||||
{
|
{
|
||||||
local cur opts
|
local cur opts
|
||||||
@ -435,7 +436,7 @@ def opts_and_words(name, op, words):
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
complete -F _'''%(opts, words) + name + ' ' + name +"\n\n").encode('utf-8')
|
complete -F _'''%(opts, words) + fname + ' ' + name +"\n\n").encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def opts_and_exts(name, op, exts):
|
def opts_and_exts(name, op, exts):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user