ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since 481ff26 was
481ff26,
checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago
|
Modified Data Explorer slightly
|
-
Property mode set to
100755
|
File size:
1.7 KB
|
Line | |
---|
1 | # global |
---|
2 | from PyQt4 import QtCore |
---|
3 | |
---|
4 | # UI |
---|
5 | from UI.DataExplorerUI import DataLoadWidget |
---|
6 | |
---|
7 | class DroppableDataLoadWidget(DataLoadWidget): |
---|
8 | """ |
---|
9 | Overwrite drag and drop methods in the base class |
---|
10 | so users can drop files directly onto the Data Explorer |
---|
11 | """ |
---|
12 | def __init__(self, parent=None, guimanager=None): |
---|
13 | super(DroppableDataLoadWidget, self).__init__(parent) |
---|
14 | |
---|
15 | # Enable file drag-drop on treeView |
---|
16 | self.setAcceptDrops(True) |
---|
17 | self.communicator = guimanager.communicator() |
---|
18 | |
---|
19 | def dragIsOK(self, event): |
---|
20 | """ |
---|
21 | Return True if the event contain URLs |
---|
22 | """ |
---|
23 | # Analyze mime data |
---|
24 | if event.mimeData().hasUrls() and self.currentIndex() == 0: |
---|
25 | return True |
---|
26 | else: |
---|
27 | return False |
---|
28 | |
---|
29 | def dragEnterEvent(self, event): |
---|
30 | """ |
---|
31 | Called automatically on a drag into the treeview |
---|
32 | """ |
---|
33 | if self.dragIsOK(event): |
---|
34 | event.setDropAction(QtCore.Qt.CopyAction) |
---|
35 | event.accept() |
---|
36 | else: |
---|
37 | event.ignore() |
---|
38 | |
---|
39 | def dragMoveEvent(self, event): |
---|
40 | """ |
---|
41 | Called automatically when a drag is |
---|
42 | moved inside the treeview |
---|
43 | """ |
---|
44 | if self.dragIsOK(event): |
---|
45 | event.accept() |
---|
46 | else: |
---|
47 | event.ignore() |
---|
48 | |
---|
49 | def dropEvent(self, event): |
---|
50 | """ |
---|
51 | Called automatically when a drop |
---|
52 | is added to the treeview. |
---|
53 | """ |
---|
54 | if self.dragIsOK(event): |
---|
55 | filenames=[] |
---|
56 | for url in event.mimeData().urls(): |
---|
57 | filenames.append(str(url.toLocalFile())) |
---|
58 | self.communicator.fileReadSignal.emit(filenames) |
---|
59 | event.accept() |
---|
60 | else: |
---|
61 | event.ignore() |
---|
62 | |
---|
Note: See
TracBrowser
for help on using the repository browser.