mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
D'nD fixes
Fix dragging a single book in the book list using the multi-book icon. Also use a class decorator for the API, looks nicer :)
This commit is contained in:
parent
85ef13a6ff
commit
fb0410b04c
@ -73,7 +73,7 @@ def drag_data(self):
|
||||
m = self.model()
|
||||
db = m.db
|
||||
rows = self.selectionModel().selectedIndexes()
|
||||
selected = list(map(m.id, rows))
|
||||
selected = list(set(map(m.id, rows)))
|
||||
ids = ' '.join(map(str, selected))
|
||||
md = QMimeData()
|
||||
md.setData('application/calibre+from_library', ids)
|
||||
@ -174,6 +174,7 @@ def setup_dnd_interface(cls_or_self):
|
||||
if x in {'mouseMoveEvent', 'mousePressEvent'}:
|
||||
func = partial(func, base_class)
|
||||
setattr(cls, x, MethodType(func, None, cls))
|
||||
return cls
|
||||
else:
|
||||
self = cls_or_self
|
||||
self.drag_allowed = True
|
||||
@ -417,6 +418,7 @@ def join_with_timeout(q, timeout=2):
|
||||
q.all_tasks_done.release()
|
||||
# }}}
|
||||
|
||||
@setup_dnd_interface
|
||||
class GridView(QListView):
|
||||
|
||||
update_item = pyqtSignal(object)
|
||||
@ -606,4 +608,3 @@ class GridView(QListView):
|
||||
def restore_hpos(self, hpos):
|
||||
pass
|
||||
|
||||
setup_dnd_interface(GridView)
|
||||
|
@ -144,6 +144,7 @@ class PreserveViewState(object): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
@setup_dnd_interface
|
||||
class BooksView(QTableView): # {{{
|
||||
|
||||
files_dropped = pyqtSignal(object)
|
||||
@ -923,8 +924,6 @@ class BooksView(QTableView): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
setup_dnd_interface(BooksView)
|
||||
|
||||
class DeviceBooksView(BooksView): # {{{
|
||||
|
||||
def __init__(self, parent):
|
||||
|
Loading…
x
Reference in New Issue
Block a user