src/eric7/CodeFormatting/IsortFormattingDialog.py

branch
eric7
changeset 9460
0d1b5d0fd815
parent 9455
5f138ee215a5
child 9465
8a020c34dce2
equal deleted inserted replaced
9459:f9c6a8f86195 9460:0d1b5d0fd815
40 """ 40 """
41 Class implementing a dialog showing the isort code formatting progress and the 41 Class implementing a dialog showing the isort code formatting progress and the
42 results. 42 results.
43 """ 43 """
44 44
45 DataTypeRole = Qt.ItemDataRole.UserRole 45 DataRole = Qt.ItemDataRole.UserRole
46 DataRole = Qt.ItemDataRole.UserRole + 1 46 DataTypeRole = Qt.ItemDataRole.UserRole + 1
47 47 FileNameRole = Qt.ItemDataRole.UserRole + 2
48 StatusRole = Qt.ItemDataRole.UserRole + 3
49
50 FileNameColumn = 1
48 StatusColumn = 0 51 StatusColumn = 0
49 FileNameColumn = 1
50 52
51 def __init__( 53 def __init__(
52 self, 54 self,
53 configuration, 55 configuration,
54 filesList, 56 filesList,
246 @pyqtSlot() 248 @pyqtSlot()
247 def __sortImportsButtonClicked(self): 249 def __sortImportsButtonClicked(self):
248 """ 250 """
249 Private slot handling the selection of the 'Sort Imports' button. 251 Private slot handling the selection of the 'Sort Imports' button.
250 """ 252 """
253 files = []
254 for row in range(self.resultsList.topLevelItemCount()):
255 itm = self.resultsList.topLevelItem(row)
256 if itm.data(0, IsortFormattingDialog.StatusRole) == "changed":
257 files.append(itm.data(0, IsortFormattingDialog.FileNameRole))
258 if files:
259 self.__filesList = files
260
251 self.__config["__action__"] = IsortFormattingAction.Sort 261 self.__config["__action__"] = IsortFormattingAction.Sort
252
253 self.__performAction() 262 self.__performAction()
254 263
255 @pyqtSlot(QTreeWidgetItem, int) 264 @pyqtSlot(QTreeWidgetItem, int)
256 def on_resultsList_itemDoubleClicked(self, item, column): 265 def on_resultsList_itemDoubleClicked(self, item, column):
257 """ 266 """
355 self.__statistics.processedCount += 1 364 self.__statistics.processedCount += 1
356 365
357 if self.__project: 366 if self.__project:
358 filename = self.__project.getRelativePath(filename) 367 filename = self.__project.getRelativePath(filename)
359 368
360 itm = QTreeWidgetItem(self.resultsList, [statusMsg, filename]) 369 itm = QTreeWidgetItem(
370 self.resultsList,
371 [
372 statusMsg,
373 self.__project.getRelativePath(filename)
374 if self.__project
375 else filename,
376 ],
377 )
378 itm.setData(0, IsortFormattingDialog.StatusRole, status)
379 itm.setData(0, IsortFormattingDialog.FileNameRole, filename)
361 if data: 380 if data:
362 itm.setData( 381 itm.setData(
363 0, IsortFormattingDialog.DataTypeRole, "error" if isError else "diff" 382 0, IsortFormattingDialog.DataTypeRole, "error" if isError else "diff"
364 ) 383 )
365 itm.setData(0, IsortFormattingDialog.DataRole, data) 384 itm.setData(0, IsortFormattingDialog.DataRole, data)

eric ide

mercurial