mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Changes to device editable columns to give fine-grain control over what columns can be edited.
This commit is contained in:
parent
02e9160f37
commit
c67a9d8487
@ -38,7 +38,7 @@ class FOLDER_DEVICE(USBMS):
|
|||||||
|
|
||||||
THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
|
THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
|
||||||
|
|
||||||
CAN_SET_METADATA = True
|
CAN_SET_METADATA = ['title', 'authors']
|
||||||
SUPPORTS_SUB_DIRS = True
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
#: Icon for this device
|
#: Icon for this device
|
||||||
|
@ -37,7 +37,7 @@ class DevicePlugin(Plugin):
|
|||||||
THUMBNAIL_HEIGHT = 68
|
THUMBNAIL_HEIGHT = 68
|
||||||
|
|
||||||
#: Whether the metadata on books can be set via the GUI.
|
#: Whether the metadata on books can be set via the GUI.
|
||||||
CAN_SET_METADATA = True
|
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
||||||
|
|
||||||
#: Path separator for paths to books on device
|
#: Path separator for paths to books on device
|
||||||
path_sep = os.sep
|
path_sep = os.sep
|
||||||
|
@ -30,7 +30,7 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
# Ordered list of supported formats
|
# Ordered list of supported formats
|
||||||
FORMATS = ['epub', 'pdf']
|
FORMATS = ['epub', 'pdf']
|
||||||
CAN_SET_METADATA = True
|
CAN_SET_METADATA = ['collections']
|
||||||
|
|
||||||
VENDOR_ID = [0x2237]
|
VENDOR_ID = [0x2237]
|
||||||
PRODUCT_ID = [0x4161]
|
PRODUCT_ID = [0x4161]
|
||||||
@ -126,7 +126,7 @@ class KOBO(USBMS):
|
|||||||
book = self.book_from_path(prefix, lpath, title, authors, mime, date, ContentType, ImageID)
|
book = self.book_from_path(prefix, lpath, title, authors, mime, date, ContentType, ImageID)
|
||||||
# print 'Update booklist'
|
# print 'Update booklist'
|
||||||
book.device_collections = [playlist_map[lpath]] if lpath in playlist_map else []
|
book.device_collections = [playlist_map[lpath]] if lpath in playlist_map else []
|
||||||
|
|
||||||
if bl.add_book(book, replace_metadata=False):
|
if bl.add_book(book, replace_metadata=False):
|
||||||
changed = True
|
changed = True
|
||||||
except: # Probably a path encoding error
|
except: # Probably a path encoding error
|
||||||
@ -250,7 +250,7 @@ class KOBO(USBMS):
|
|||||||
# print "Delete file normalized path: " + path
|
# print "Delete file normalized path: " + path
|
||||||
extension = os.path.splitext(path)[1]
|
extension = os.path.splitext(path)[1]
|
||||||
ContentType = self.get_content_type_from_extension(extension)
|
ContentType = self.get_content_type_from_extension(extension)
|
||||||
|
|
||||||
ContentID = self.contentid_from_path(path, ContentType)
|
ContentID = self.contentid_from_path(path, ContentType)
|
||||||
|
|
||||||
ImageID = self.delete_via_sql(ContentID, ContentType)
|
ImageID = self.delete_via_sql(ContentID, ContentType)
|
||||||
@ -453,7 +453,7 @@ class KOBO(USBMS):
|
|||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 1 and ContentID like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 1 and ContentID like \'file:///mnt/sd/%\''
|
||||||
elif oncard != 'carda' and oncard != 'cardb':
|
elif oncard != 'carda' and oncard != 'cardb':
|
||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 1 and ContentID not like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 1 and ContentID not like \'file:///mnt/sd/%\''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except:
|
except:
|
||||||
@ -489,7 +489,7 @@ class KOBO(USBMS):
|
|||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 2 and ContentID like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 2 and ContentID like \'file:///mnt/sd/%\''
|
||||||
elif oncard != 'carda' and oncard != 'cardb':
|
elif oncard != 'carda' and oncard != 'cardb':
|
||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 2 and ContentID not like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ReadStatus = 2 and ContentID not like \'file:///mnt/sd/%\''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except:
|
except:
|
||||||
@ -519,7 +519,7 @@ class KOBO(USBMS):
|
|||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
# debug_print('Database: Commit set ReadStatus as Finished')
|
# debug_print('Database: Commit set ReadStatus as Finished')
|
||||||
else: # No collections
|
else: # No collections
|
||||||
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
||||||
print "Reseting ReadStatus to 0"
|
print "Reseting ReadStatus to 0"
|
||||||
# Reset Im_Reading list in the database
|
# Reset Im_Reading list in the database
|
||||||
@ -527,7 +527,7 @@ class KOBO(USBMS):
|
|||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID like \'file:///mnt/sd/%\''
|
||||||
elif oncard != 'carda' and oncard != 'cardb':
|
elif oncard != 'carda' and oncard != 'cardb':
|
||||||
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID not like \'file:///mnt/sd/%\''
|
query= 'update content set ReadStatus=0, FirstTimeReading = \'true\' where BookID is Null and ContentID not like \'file:///mnt/sd/%\''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except:
|
except:
|
||||||
@ -541,7 +541,7 @@ class KOBO(USBMS):
|
|||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
# debug_print('Finished update_device_database_collections', collections_attributes)
|
# debug_print('Finished update_device_database_collections', collections_attributes)
|
||||||
|
|
||||||
def sync_booklists(self, booklists, end_session=True):
|
def sync_booklists(self, booklists, end_session=True):
|
||||||
# debug_print('KOBO: started sync_booklists')
|
# debug_print('KOBO: started sync_booklists')
|
||||||
paths = self.get_device_paths()
|
paths = self.get_device_paths()
|
||||||
|
@ -27,7 +27,7 @@ class PRS505(USBMS):
|
|||||||
|
|
||||||
|
|
||||||
FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt']
|
FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt']
|
||||||
CAN_SET_METADATA = True
|
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
||||||
|
|
||||||
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
||||||
PRODUCT_ID = [0x031e]
|
PRODUCT_ID = [0x031e]
|
||||||
|
@ -50,7 +50,7 @@ class USBMS(CLI, Device):
|
|||||||
book_class = Book
|
book_class = Book
|
||||||
|
|
||||||
FORMATS = []
|
FORMATS = []
|
||||||
CAN_SET_METADATA = False
|
CAN_SET_METADATA = []
|
||||||
METADATA_CACHE = 'metadata.calibre'
|
METADATA_CACHE = 'metadata.calibre'
|
||||||
|
|
||||||
def get_device_information(self, end_session=True):
|
def get_device_information(self, end_session=True):
|
||||||
|
@ -907,7 +907,7 @@ class DeviceBooksModel(BooksModel): # {{{
|
|||||||
}
|
}
|
||||||
self.marked_for_deletion = {}
|
self.marked_for_deletion = {}
|
||||||
self.search_engine = OnDeviceSearch(self)
|
self.search_engine = OnDeviceSearch(self)
|
||||||
self.editable = True
|
self.editable = ['title', 'authors', 'collections']
|
||||||
self.book_in_library = None
|
self.book_in_library = None
|
||||||
|
|
||||||
def mark_for_deletion(self, job, rows, rows_are_ids=False):
|
def mark_for_deletion(self, job, rows, rows_are_ids=False):
|
||||||
@ -953,13 +953,13 @@ class DeviceBooksModel(BooksModel): # {{{
|
|||||||
if self.map[index.row()] in self.indices_to_be_deleted():
|
if self.map[index.row()] in self.indices_to_be_deleted():
|
||||||
return Qt.ItemIsUserCheckable # Can't figure out how to get the disabled flag in python
|
return Qt.ItemIsUserCheckable # Can't figure out how to get the disabled flag in python
|
||||||
flags = QAbstractTableModel.flags(self, index)
|
flags = QAbstractTableModel.flags(self, index)
|
||||||
if index.isValid() and self.editable:
|
if index.isValid():
|
||||||
cname = self.column_map[index.column()]
|
cname = self.column_map[index.column()]
|
||||||
if cname in ('title', 'authors') or \
|
if cname in self.editable and \
|
||||||
(cname == 'collections' and \
|
cname != 'collections' or \
|
||||||
callable(getattr(self.db, 'supports_collections', None)) and \
|
(callable(getattr(self.db, 'supports_collections', None)) and \
|
||||||
self.db.supports_collections() and \
|
self.db.supports_collections() and \
|
||||||
prefs['manage_device_metadata']=='manual'):
|
prefs['manage_device_metadata']=='manual'):
|
||||||
flags |= Qt.ItemIsEditable
|
flags |= Qt.ItemIsEditable
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
@ -1243,7 +1243,14 @@ class DeviceBooksModel(BooksModel): # {{{
|
|||||||
def set_editable(self, editable):
|
def set_editable(self, editable):
|
||||||
# Cannot edit if metadata is sent on connect. Reason: changes will
|
# Cannot edit if metadata is sent on connect. Reason: changes will
|
||||||
# revert to what is in the library on next connect.
|
# revert to what is in the library on next connect.
|
||||||
self.editable = editable and prefs['manage_device_metadata']!='on_connect'
|
if isinstance(editable, list):
|
||||||
|
self.editable = editable
|
||||||
|
elif editable:
|
||||||
|
self.editable = ['title', 'authors', 'collections']
|
||||||
|
else:
|
||||||
|
self.editable = []
|
||||||
|
if prefs['manage_device_metadata']=='on_connect':
|
||||||
|
self.editable = []
|
||||||
|
|
||||||
def set_search_restriction(self, s):
|
def set_search_restriction(self, s):
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user