From 1b828d5f33700d4755b26a80e5d9dcfd0cdd1830 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Jun 2010 09:45:02 -0600 Subject: [PATCH 1/3] Fix #5146 (/etc/bash_completion.d/calibre has errors) --- src/calibre/linux.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 26bbe0837b..51711b5b0f 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -411,7 +411,8 @@ def options(option_parser): def opts_and_words(name, op, words): opts = '|'.join(options(op)) words = '|'.join([w.replace("'", "\\'") for w in words]) - return ('_'+name+'()'+\ + fname = name.replace('-', '_') + return ('_'+fname+'()'+\ ''' { local cur opts @@ -435,7 +436,7 @@ def opts_and_words(name, op, words): 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): From 80fae845bab7b15ab91544aec4e2a469ede79165 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Jun 2010 09:52:20 -0600 Subject: [PATCH 2/3] ... --- src/calibre/gui2/device.py | 5 ++++- src/calibre/gui2/ui.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 378c585efb..0e18929d81 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -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): rows = self.library_view.selectionModel().selectedRows() diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 29a09d6a1d..9ff30aa768 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -44,7 +44,7 @@ from calibre.gui2.dialogs.scheduler import Scheduler from calibre.gui2.update import CheckForUpdates from calibre.gui2.main_window import 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.dialogs.metadata_single import MetadataSingleDialog 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): 'The main GUI' @@ -228,6 +228,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI, ToolbarMixin, QObject.connect(self.advanced_search_button, SIGNAL('clicked(bool)'), self.do_advanced_search) + DeviceMixin.__init__(self) + ####################### Start spare job server ######################## QTimer.singleShot(1000, self.add_spare_server) From ff6ac7f3529dbccd13d1d98598f842cd4b6639e9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Jun 2010 10:11:13 -0600 Subject: [PATCH 3/3] Add a deleted_after_upload attribute to file paths sent to the device driver from the GUI --- src/calibre/devices/interface.py | 5 ++++- src/calibre/gui2/device.py | 6 ++++-- src/calibre/gui2/library/models.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 2d82bf4563..da8a2cb978 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -289,7 +289,10 @@ class DevicePlugin(Plugin): 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 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 once uploaded to the device. len(names) == len(files) :return: A list of 3-element tuples. The list is meant to be passed diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 0e18929d81..1445b0f36e 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -854,6 +854,7 @@ class DeviceMixin(object): def sync_news(self, send_ids=None, do_auto_convert=True): if self.device_connected: + del_on_upload = config['delete_news_from_library_on_upload'] settings = self.device_manager.device.settings() 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)] @@ -883,6 +884,8 @@ class DeviceMixin(object): 'the device?'), det_msg=autos): self.auto_convert_news(auto, format) 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: dynamic.set('news_to_be_synced', set([])) return @@ -900,8 +903,7 @@ class DeviceMixin(object): 'rb').read()) dynamic.set('news_to_be_synced', set([])) if config['upload_news_to_device'] and files: - remove = ids if \ - config['delete_news_from_library_on_upload'] else [] + remove = ids if del_on_upload else [] space = { self.location_view.model().free[0] : None, self.location_view.model().free[1] : 'carda', self.location_view.model().free[2] : 'cardb' } diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index abd80aaa8f..71f41eab45 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -39,6 +39,7 @@ class FormatPath(unicode): def __new__(cls, path, orig_file_path): ans = unicode.__new__(cls, path) ans.orig_file_path = orig_file_path + ans.deleted_after_upload = False return ans class BooksModel(QAbstractTableModel): # {{{