src/eric7/CodeFormatting/BlackFormattingDialog.py

branch
eric7
changeset 9460
0d1b5d0fd815
parent 9453
e5065dde905d
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9459:f9c6a8f86195 9460:0d1b5d0fd815
40 """ 40 """
41 Class implementing a dialog showing the Black code formatting progress and the 41 Class implementing a dialog showing the Black 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,
251 @pyqtSlot() 253 @pyqtSlot()
252 def __formatButtonClicked(self): 254 def __formatButtonClicked(self):
253 """ 255 """
254 Private slot handling the selection of the 'Format Code' button. 256 Private slot handling the selection of the 'Format Code' button.
255 """ 257 """
258 files = []
259 for row in range(self.resultsList.topLevelItemCount()):
260 itm = self.resultsList.topLevelItem(row)
261 if itm.data(0, BlackFormattingDialog.StatusRole) == "changed":
262 files.append(itm.data(0, BlackFormattingDialog.FileNameRole))
263 if files:
264 self.__filesList = files
265
256 self.__config["__action__"] = BlackFormattingAction.Format 266 self.__config["__action__"] = BlackFormattingAction.Format
257
258 self.__performAction() 267 self.__performAction()
259 268
260 @pyqtSlot(QTreeWidgetItem, int) 269 @pyqtSlot(QTreeWidgetItem, int)
261 def on_resultsList_itemDoubleClicked(self, item, column): 270 def on_resultsList_itemDoubleClicked(self, item, column):
262 """ 271 """
563 isError = True 572 isError = True
564 573
565 if status != "ignored": 574 if status != "ignored":
566 self.__statistics.processedCount += 1 575 self.__statistics.processedCount += 1
567 576
568 if self.__project: 577 itm = QTreeWidgetItem(
569 filename = self.__project.getRelativePath(filename) 578 self.resultsList,
570 579 [
571 itm = QTreeWidgetItem(self.resultsList, [statusMsg, filename]) 580 statusMsg,
581 self.__project.getRelativePath(filename)
582 if self.__project
583 else filename,
584 ],
585 )
586 itm.setData(0, BlackFormattingDialog.StatusRole, status)
587 itm.setData(0, BlackFormattingDialog.FileNameRole, filename)
572 if data: 588 if data:
573 itm.setData( 589 itm.setData(
574 0, BlackFormattingDialog.DataTypeRole, "error" if isError else "diff" 590 0, BlackFormattingDialog.DataTypeRole, "error" if isError else "diff"
575 ) 591 )
576 itm.setData(0, BlackFormattingDialog.DataRole, data) 592 itm.setData(0, BlackFormattingDialog.DataRole, data)

eric ide

mercurial