mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: use QByteArray().data() to get bytestring instead of str()
b'1' can be mapped into an int, but 'b"1"' cannot. Also rename one instance -- the QMimeData class requires using the data() method to retrieve content, and QByteArray uses data() to retrieve the raw bytes, but once we get to data.data().data() it's a bit ridiculous. So make the first one be called md, as is used in other mime handling code too.
This commit is contained in:
parent
6ce8e01801
commit
074e3ff829
@ -40,7 +40,7 @@ class ConvertAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -106,7 +106,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -51,7 +51,7 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -37,7 +37,7 @@ class EmbedAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -39,7 +39,7 @@ class MarkBooksAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -420,7 +420,7 @@ class PolishAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -87,7 +87,7 @@ class ToCEditAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -74,7 +74,7 @@ class TweakEpubAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -308,7 +308,7 @@ class UnpackBookAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -286,10 +286,10 @@ class ToolBar(QToolBar): # {{{
|
|||||||
event.ignore()
|
event.ignore()
|
||||||
|
|
||||||
def dropEvent(self, event):
|
def dropEvent(self, event):
|
||||||
data = event.mimeData()
|
md = event.mimeData()
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if data.hasFormat(mime):
|
if md.hasFormat(mime):
|
||||||
ids = list(map(int, str(data.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
tgt = None
|
tgt = None
|
||||||
for ac in self.location_manager.available_actions:
|
for ac in self.location_manager.available_actions:
|
||||||
w = self.widgetForAction(ac)
|
w = self.widgetForAction(ac)
|
||||||
@ -303,8 +303,8 @@ class ToolBar(QToolBar): # {{{
|
|||||||
return
|
return
|
||||||
|
|
||||||
mime = 'application/calibre+from_device'
|
mime = 'application/calibre+from_device'
|
||||||
if data.hasFormat(mime):
|
if md.hasFormat(mime):
|
||||||
paths = [unicode_type(u.toLocalFile()) for u in data.urls()]
|
paths = [unicode_type(u.toLocalFile()) for u in md.urls()]
|
||||||
if paths:
|
if paths:
|
||||||
self.gui.iactions['Add Books'].add_books_from_device(
|
self.gui.iactions['Add Books'].add_books_from_device(
|
||||||
self.gui.current_view(), paths=paths)
|
self.gui.current_view(), paths=paths)
|
||||||
@ -312,7 +312,7 @@ class ToolBar(QToolBar): # {{{
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Give added_actions an opportunity to process the drag&drop event
|
# Give added_actions an opportunity to process the drag&drop event
|
||||||
if self.check_iactions_for_drag(event, data, 'drop_event'):
|
if self.check_iactions_for_drag(event, md, 'drop_event'):
|
||||||
event.accept()
|
event.accept()
|
||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
|
@ -857,7 +857,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
fm['datatype'] == 'composite' and
|
fm['datatype'] == 'composite' and
|
||||||
fm['display'].get('make_category', False)))):
|
fm['display'].get('make_category', False)))):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
ids = list(map(int, str(md.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
self.handle_drop(node, ids)
|
self.handle_drop(node, ids)
|
||||||
return True
|
return True
|
||||||
elif node.type == TagTreeItem.CATEGORY:
|
elif node.type == TagTreeItem.CATEGORY:
|
||||||
@ -871,7 +871,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
(fm_src['datatype'] == 'composite' and
|
(fm_src['datatype'] == 'composite' and
|
||||||
fm_src['display'].get('make_category', False))):
|
fm_src['display'].get('make_category', False))):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
ids = list(map(int, str(md.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
self.handle_user_category_drop(node, ids, md.column_name)
|
self.handle_user_category_drop(node, ids, md.column_name)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user