mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Replace use of pickle for D'nD in the tag browser
This commit is contained in:
parent
046f43446e
commit
fc61fc88bc
@ -8,7 +8,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import traceback, cPickle, copy, os
|
import traceback, copy, os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from PyQt5.Qt import (QAbstractItemModel, QIcon, QFont, Qt,
|
from PyQt5.Qt import (QAbstractItemModel, QIcon, QFont, Qt,
|
||||||
@ -24,6 +24,8 @@ from calibre.library.field_metadata import category_icon_map
|
|||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.utils.formatter import EvalFormatter
|
from calibre.utils.formatter import EvalFormatter
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from calibre.utils.serialize import json_dumps, json_loads
|
||||||
|
|
||||||
|
|
||||||
TAG_SEARCH_STATES = {'clear': 0, 'mark_plus': 1, 'mark_plusplus': 2,
|
TAG_SEARCH_STATES = {'clear': 0, 'mark_plus': 1, 'mark_plusplus': 2,
|
||||||
'mark_minus': 3, 'mark_minusminus': 4}
|
'mark_minus': 3, 'mark_minusminus': 4}
|
||||||
@ -740,7 +742,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
data.append(d)
|
data.append(d)
|
||||||
else:
|
else:
|
||||||
data.append(None)
|
data.append(None)
|
||||||
raw = bytearray(cPickle.dumps(data, -1))
|
raw = bytearray(json_dumps(data))
|
||||||
ans = QMimeData()
|
ans = QMimeData()
|
||||||
ans.setData('application/calibre+from_tag_browser', raw)
|
ans.setData('application/calibre+from_tag_browser', raw)
|
||||||
return ans
|
return ans
|
||||||
@ -764,8 +766,8 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
return False
|
return False
|
||||||
if not md.hasFormat('application/calibre+from_tag_browser'):
|
if not md.hasFormat('application/calibre+from_tag_browser'):
|
||||||
return False
|
return False
|
||||||
data = str(md.data('application/calibre+from_tag_browser'))
|
data = bytes(md.data('application/calibre+from_tag_browser'))
|
||||||
src = cPickle.loads(data)
|
src = json_loads(data)
|
||||||
for s in src:
|
for s in src:
|
||||||
if s[0] != TagTreeItem.TAG:
|
if s[0] != TagTreeItem.TAG:
|
||||||
return False
|
return False
|
||||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import cPickle, os, re
|
import os, re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
|||||||
TagsModel, DRAG_IMAGE_ROLE, COUNT_ROLE)
|
TagsModel, DRAG_IMAGE_ROLE, COUNT_ROLE)
|
||||||
from calibre.gui2 import config, gprefs, choose_files, pixmap_to_data, rating_font, empty_index
|
from calibre.gui2 import config, gprefs, choose_files, pixmap_to_data, rating_font, empty_index
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.serialize import json_loads
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
|
|
||||||
@ -751,8 +752,8 @@ class TagsView(QTreeView): # {{{
|
|||||||
if fm_dest['kind'] == 'user':
|
if fm_dest['kind'] == 'user':
|
||||||
if src_is_tb:
|
if src_is_tb:
|
||||||
if event.dropAction() == Qt.MoveAction:
|
if event.dropAction() == Qt.MoveAction:
|
||||||
data = str(event.mimeData().data('application/calibre+from_tag_browser'))
|
data = bytes(event.mimeData().data('application/calibre+from_tag_browser'))
|
||||||
src = cPickle.loads(data)
|
src = json_loads(data)
|
||||||
for s in src:
|
for s in src:
|
||||||
if s[0] == TagTreeItem.TAG and \
|
if s[0] == TagTreeItem.TAG and \
|
||||||
(not s[1].startswith('@') or s[2]):
|
(not s[1].startswith('@') or s[2]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user