diff -r f9c6a8f86195 -r 0d1b5d0fd815 src/eric7/CodeFormatting/BlackFormattingDialog.py --- a/src/eric7/CodeFormatting/BlackFormattingDialog.py Tue Nov 01 19:46:49 2022 +0100 +++ b/src/eric7/CodeFormatting/BlackFormattingDialog.py Wed Nov 02 10:11:18 2022 +0100 @@ -42,11 +42,13 @@ results. """ - DataTypeRole = Qt.ItemDataRole.UserRole - DataRole = Qt.ItemDataRole.UserRole + 1 + DataRole = Qt.ItemDataRole.UserRole + DataTypeRole = Qt.ItemDataRole.UserRole + 1 + FileNameRole = Qt.ItemDataRole.UserRole + 2 + StatusRole = Qt.ItemDataRole.UserRole + 3 + FileNameColumn = 1 StatusColumn = 0 - FileNameColumn = 1 def __init__( self, @@ -253,8 +255,15 @@ """ Private slot handling the selection of the 'Format Code' button. """ + files = [] + for row in range(self.resultsList.topLevelItemCount()): + itm = self.resultsList.topLevelItem(row) + if itm.data(0, BlackFormattingDialog.StatusRole) == "changed": + files.append(itm.data(0, BlackFormattingDialog.FileNameRole)) + if files: + self.__filesList = files + self.__config["__action__"] = BlackFormattingAction.Format - self.__performAction() @pyqtSlot(QTreeWidgetItem, int) @@ -565,10 +574,17 @@ if status != "ignored": self.__statistics.processedCount += 1 - if self.__project: - filename = self.__project.getRelativePath(filename) - - itm = QTreeWidgetItem(self.resultsList, [statusMsg, filename]) + itm = QTreeWidgetItem( + self.resultsList, + [ + statusMsg, + self.__project.getRelativePath(filename) + if self.__project + else filename, + ], + ) + itm.setData(0, BlackFormattingDialog.StatusRole, status) + itm.setData(0, BlackFormattingDialog.FileNameRole, filename) if data: itm.setData( 0, BlackFormattingDialog.DataTypeRole, "error" if isError else "diff"