src/eric7/CodeFormatting/IsortFormattingDialog.py

branch
eric7
changeset 9460
0d1b5d0fd815
parent 9455
5f138ee215a5
child 9465
8a020c34dce2
diff -r f9c6a8f86195 -r 0d1b5d0fd815 src/eric7/CodeFormatting/IsortFormattingDialog.py
--- a/src/eric7/CodeFormatting/IsortFormattingDialog.py	Tue Nov 01 19:46:49 2022 +0100
+++ b/src/eric7/CodeFormatting/IsortFormattingDialog.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,
@@ -248,8 +250,15 @@
         """
         Private slot handling the selection of the 'Sort Imports' button.
         """
+        files = []
+        for row in range(self.resultsList.topLevelItemCount()):
+            itm = self.resultsList.topLevelItem(row)
+            if itm.data(0, IsortFormattingDialog.StatusRole) == "changed":
+                files.append(itm.data(0, IsortFormattingDialog.FileNameRole))
+        if files:
+            self.__filesList = files
+
         self.__config["__action__"] = IsortFormattingAction.Sort
-
         self.__performAction()
 
     @pyqtSlot(QTreeWidgetItem, int)
@@ -357,7 +366,17 @@
         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, IsortFormattingDialog.StatusRole, status)
+        itm.setData(0, IsortFormattingDialog.FileNameRole, filename)
         if data:
             itm.setData(
                 0, IsortFormattingDialog.DataTypeRole, "error" if isError else "diff"

eric ide

mercurial