Implement Drag&Drop support for dragging files from the operating system to the library

This commit is contained in:
Kovid Goyal 2008-02-27 21:16:14 +00:00
parent 086d4c6d44
commit 1c24785e68
2 changed files with 8 additions and 2 deletions

View File

@ -440,9 +440,11 @@ class BooksView(TableView):
def dragEnterEvent(self, event):
if int(event.possibleActions() & Qt.CopyAction) != 1:
if int(event.possibleActions() & Qt.CopyAction) + \
int(event.possibleActions() & Qt.MoveAction) == 0:
return
paths = self.paths_from_event(event)
if paths:
event.acceptProposedAction()

View File

@ -179,6 +179,8 @@ class Main(MainWindow, Ui_MainWindow):
####################### Library view ########################
self.library_view.set_database(self.database_path)
QObject.connect(self.library_view, SIGNAL('files_dropped(PyQt_PyObject)'),
self.files_dropped)
for func, target in [
('connect_to_search_box', self.search),
('connect_to_book_display', self.status_bar.book_info.show_data),
@ -335,7 +337,9 @@ class Main(MainWindow, Ui_MainWindow):
'''
self.add_recursive(False)
def files_dropped(self, paths):
to_device = self.stack.currentIndex() != 0
self._add_books(paths, to_device)
def add_books(self, checked):