24 from E5Gui.E5FileSaveConfirmDialog import confirmOverwrite |
24 from E5Gui.E5FileSaveConfirmDialog import confirmOverwrite |
25 from E5Gui.E5Application import e5App |
25 from E5Gui.E5Application import e5App |
26 |
26 |
27 from .Ui_MicroPythonFileManagerWidget import Ui_MicroPythonFileManagerWidget |
27 from .Ui_MicroPythonFileManagerWidget import Ui_MicroPythonFileManagerWidget |
28 |
28 |
29 from .MicroPythonFileSystem import MicroPythonFileManager |
29 from .MicroPythonFileManager import MicroPythonFileManager |
30 from .MicroPythonFileSystemUtilities import ( |
30 from .MicroPythonFileSystemUtilities import ( |
31 mtime2string, mode2string, decoratedName, listdirStat |
31 mtime2string, mode2string, decoratedName, listdirStat |
32 ) |
32 ) |
33 |
33 |
34 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
34 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
41 |
41 |
42 class MicroPythonFileManagerWidget(QWidget, Ui_MicroPythonFileManagerWidget): |
42 class MicroPythonFileManagerWidget(QWidget, Ui_MicroPythonFileManagerWidget): |
43 """ |
43 """ |
44 Class implementing a file manager for MicroPython devices. |
44 Class implementing a file manager for MicroPython devices. |
45 """ |
45 """ |
46 def __init__(self, port, parent=None): |
46 def __init__(self, commandsInterface, parent=None): |
47 """ |
47 """ |
48 Constructor |
48 Constructor |
49 |
49 |
50 @param port port name of the device |
50 @param commandsInterface reference to the commands interface object |
51 @type str |
51 @type MicroPythonCommandsInterface |
52 @param parent reference to the parent widget |
52 @param parent reference to the parent widget |
53 @type QWidget |
53 @type QWidget |
54 """ |
54 """ |
55 super(MicroPythonFileManagerWidget, self).__init__(parent) |
55 super(MicroPythonFileManagerWidget, self).__init__(parent) |
56 self.setupUi(self) |
56 self.setupUi(self) |
70 0, Qt.AscendingOrder) |
70 0, Qt.AscendingOrder) |
71 self.deviceFileTreeWidget.header().setSortIndicator( |
71 self.deviceFileTreeWidget.header().setSortIndicator( |
72 0, Qt.AscendingOrder) |
72 0, Qt.AscendingOrder) |
73 |
73 |
74 self.__progressInfoDialog = None |
74 self.__progressInfoDialog = None |
75 self.__fileManager = MicroPythonFileManager(port, self) |
75 self.__fileManager = MicroPythonFileManager(commandsInterface, self) |
76 |
76 |
77 self.__fileManager.longListFiles.connect(self.__handleLongListFiles) |
77 self.__fileManager.longListFiles.connect(self.__handleLongListFiles) |
78 self.__fileManager.currentDir.connect(self.__handleCurrentDir) |
78 self.__fileManager.currentDir.connect(self.__handleCurrentDir) |
79 self.__fileManager.currentDirChanged.connect(self.__handleCurrentDir) |
79 self.__fileManager.currentDirChanged.connect(self.__handleCurrentDir) |
80 self.__fileManager.putFileDone.connect(self.__newDeviceList) |
80 self.__fileManager.putFileDone.connect(self.__newDeviceList) |
142 |
142 |
143 def start(self): |
143 def start(self): |
144 """ |
144 """ |
145 Public method to start the widget. |
145 Public method to start the widget. |
146 """ |
146 """ |
147 ui = e5App().getObject("UserInterface") |
147 dirname = "" |
148 vm = e5App().getObject("ViewManager") |
148 vm = e5App().getObject("ViewManager") |
149 |
|
150 ui.preferencesChanged.connect( |
|
151 self.__fileManager.handlePreferencesChanged) |
|
152 |
|
153 self.__fileManager.connectToDevice() |
|
154 |
|
155 dirname = "" |
|
156 aw = vm.activeWindow() |
149 aw = vm.activeWindow() |
157 if aw: |
150 if aw: |
158 dirname = os.path.dirname(aw.getFileName()) |
151 dirname = os.path.dirname(aw.getFileName()) |
159 if not dirname: |
152 if not dirname: |
160 dirname = (Preferences.getMultiProject("Workspace") or |
153 dirname = (Preferences.getMultiProject("Workspace") or |
165 |
158 |
166 def stop(self): |
159 def stop(self): |
167 """ |
160 """ |
168 Public method to stop the widget. |
161 Public method to stop the widget. |
169 """ |
162 """ |
170 ui = e5App().getObject("UserInterface") |
163 pass |
171 ui.preferencesChanged.disconnect( |
|
172 self.__fileManager.handlePreferencesChanged) |
|
173 |
|
174 self.__fileManager.disconnectFromDevice() |
|
175 |
164 |
176 @pyqtSlot(str, str) |
165 @pyqtSlot(str, str) |
177 def __handleError(self, method, error): |
166 def __handleError(self, method, error): |
178 """ |
167 """ |
179 Private slot to handle errors. |
168 Private slot to handle errors. |