--- a/eric6/MicroPython/MicroPythonFileManagerWidget.py Mon Jul 22 19:19:06 2019 +0200 +++ b/eric6/MicroPython/MicroPythonFileManagerWidget.py Mon Jul 22 20:17:33 2019 +0200 @@ -25,6 +25,7 @@ import UI.PixmapCache import Preferences +import Utilities class MicroPythonFileManagerWidget(QWidget, Ui_MicroPythonFileManagerWidget): @@ -45,6 +46,8 @@ self.putButton.setIcon(UI.PixmapCache.getIcon("1rightarrow")) self.getButton.setIcon(UI.PixmapCache.getIcon("1leftarrow")) + self.localUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) + self.deviceUpButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) self.putButton.setEnabled(False) self.getButton.setEnabled(False) @@ -161,11 +164,13 @@ if not dirname: dirname = os.getcwd() + if dirname.endswith(os.sep): + dirname = dirname[:-1] self.localCwd.setText(dirname) filesStatList = listdir_stat(dirname) filesList = [( - decoratedName(f, s[0]), + decoratedName(f, s[0], os.path.isdir(os.path.join(dirname, f))), mode2string(s[0]), str(s[6]), mtime2string(s[8])) for f, s in filesStatList] @@ -180,22 +185,43 @@ @pyqtSlot(QTreeWidgetItem, int) def on_localFileTreeWidget_itemActivated(self, item, column): """ - Slot documentation goes here. + Private slot to handle the activation of a local item. - @param item DESCRIPTION + If the item is a directory, the list will be re-populated for this + directory. + + @param item reference to the activated item @type QTreeWidgetItem - @param column DESCRIPTION + @param column column of the activation @type int """ - # TODO: not implemented yet - # show listing of activated directory + name = os.path.join(self.localCwd.text(), item.text(0)) + if name.endswith("/"): + # directory names end with a '/' + self.__listLocalFiles(name) + elif Utilities.MimeTypes.isTextFile(name): + e5App().getObject("ViewManager").getEditor(name) @pyqtSlot() def on_localFileTreeWidget_itemSelectionChanged(self): """ - Slot documentation goes here. + Private slot handling a change of selection in the local pane. """ - # TODO: not implemented yet + enable = bool(len(self.localFileTreeWidget.selectedItems())) + if enable: + enable &= not ( + self.localFileTreeWidget.selectedItems()[0].text(0) + .endswith("/")) + self.putButton.setEnabled(enable) + + @pyqtSlot() + def on_localUpButton_clicked(self): + """ + Private slot to go up one directory level. + """ + cwd = self.localCwd.text() + dirname = os.path.dirname(cwd) + self.__listLocalFiles(dirname) @pyqtSlot(QTreeWidgetItem, int) def on_deviceFileTreeWidget_itemActivated(self, item, column): @@ -218,6 +244,14 @@ # TODO: not implemented yet @pyqtSlot() + def on_deviceUpButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() def on_putButton_clicked(self): """ Slot documentation goes here.