23 class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): |
23 class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): |
24 """ |
24 """ |
25 Class implementing a dialog showing statistical data for the last |
25 Class implementing a dialog showing statistical data for the last |
26 code style checker run. |
26 code style checker run. |
27 """ |
27 """ |
|
28 |
28 def __init__(self, statisticData, parent=None): |
29 def __init__(self, statisticData, parent=None): |
29 """ |
30 """ |
30 Constructor |
31 Constructor |
31 |
32 |
32 @param statisticData dictionary with the statistical data |
33 @param statisticData dictionary with the statistical data |
33 @type dict |
34 @type dict |
34 @param parent reference to the parent widget |
35 @param parent reference to the parent widget |
35 @type QWidget |
36 @type QWidget |
36 """ |
37 """ |
37 super().__init__(parent) |
38 super().__init__(parent) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
40 stats = statisticData.copy() |
41 stats = statisticData.copy() |
41 filesCount = stats["_FilesCount"] |
42 filesCount = stats["_FilesCount"] |
42 filesIssues = stats["_FilesIssues"] |
43 filesIssues = stats["_FilesIssues"] |
43 fixesCount = stats["_IssuesFixed"] |
44 fixesCount = stats["_IssuesFixed"] |
44 securityOk = stats["_SecurityOK"] |
45 securityOk = stats["_SecurityOK"] |
45 del stats["_FilesCount"] |
46 del stats["_FilesCount"] |
46 del stats["_FilesIssues"] |
47 del stats["_FilesIssues"] |
47 del stats["_IssuesFixed"] |
48 del stats["_IssuesFixed"] |
48 del stats["_SecurityOK"] |
49 del stats["_SecurityOK"] |
49 |
50 |
50 totalIssues = 0 |
51 totalIssues = 0 |
51 ignoresCount = 0 |
52 ignoresCount = 0 |
52 |
53 |
53 textWrapper = textwrap.TextWrapper(width=80) |
54 textWrapper = textwrap.TextWrapper(width=80) |
54 |
55 |
55 for msgCode in sorted(stats.keys()): |
56 for msgCode in sorted(stats.keys()): |
56 message = getTranslatedMessage(msgCode, [], example=True) |
57 message = getTranslatedMessage(msgCode, [], example=True) |
57 if message is None: |
58 if message is None: |
58 continue |
59 continue |
59 |
60 |
60 self.__createItem(stats[msgCode], msgCode, |
61 self.__createItem( |
61 "\n".join(textWrapper.wrap(message))) |
62 stats[msgCode], msgCode, "\n".join(textWrapper.wrap(message)) |
|
63 ) |
62 totalIssues += stats[msgCode]["total"] |
64 totalIssues += stats[msgCode]["total"] |
63 ignoresCount += stats[msgCode]["ignored"] |
65 ignoresCount += stats[msgCode]["ignored"] |
64 |
66 |
65 self.totalIssues.setText( |
67 self.totalIssues.setText(self.tr("%n issue(s) found", "", totalIssues)) |
66 self.tr("%n issue(s) found", "", totalIssues)) |
68 self.ignoredIssues.setText(self.tr("%n issue(s) ignored", "", ignoresCount)) |
67 self.ignoredIssues.setText( |
69 self.fixedIssues.setText(self.tr("%n issue(s) fixed", "", fixesCount)) |
68 self.tr("%n issue(s) ignored", "", ignoresCount)) |
70 self.filesChecked.setText(self.tr("%n file(s) checked", "", filesCount)) |
69 self.fixedIssues.setText( |
|
70 self.tr("%n issue(s) fixed", "", fixesCount)) |
|
71 self.filesChecked.setText( |
|
72 self.tr("%n file(s) checked", "", filesCount)) |
|
73 self.filesIssues.setText( |
71 self.filesIssues.setText( |
74 self.tr("%n file(s) with issues found", "", filesIssues)) |
72 self.tr("%n file(s) with issues found", "", filesIssues) |
|
73 ) |
75 self.securityOk.setText( |
74 self.securityOk.setText( |
76 self.tr("%n security issue(s) acknowledged", "", securityOk)) |
75 self.tr("%n security issue(s) acknowledged", "", securityOk) |
77 |
76 ) |
|
77 |
78 self.statisticsList.resizeColumnToContents(0) |
78 self.statisticsList.resizeColumnToContents(0) |
79 self.statisticsList.resizeColumnToContents(1) |
79 self.statisticsList.resizeColumnToContents(1) |
80 self.statisticsList.resizeColumnToContents(2) |
80 self.statisticsList.resizeColumnToContents(2) |
81 |
81 |
82 def __createItem(self, counts, msgCode, message): |
82 def __createItem(self, counts, msgCode, message): |
83 """ |
83 """ |
84 Private method to create an entry in the result list. |
84 Private method to create an entry in the result list. |
85 |
85 |
86 @param counts dictionary containing the total and ignored occurrences |
86 @param counts dictionary containing the total and ignored occurrences |
87 of the issue |
87 of the issue |
88 @type dict |
88 @type dict |
89 @param msgCode code of a code style issue message |
89 @param msgCode code of a code style issue message |
90 @type str |
90 @type str |
91 @param message code style issue message to be shown |
91 @param message code style issue message to be shown |
92 @type str |
92 @type str |
93 """ |
93 """ |
94 itm = QTreeWidgetItem(self.statisticsList, [ |
94 itm = QTreeWidgetItem( |
95 msgCode, "{0:6d}".format(counts["total"] - counts["ignored"]), |
95 self.statisticsList, |
96 "{0:6d}".format(counts["ignored"]), message]) |
96 [ |
|
97 msgCode, |
|
98 "{0:6d}".format(counts["total"] - counts["ignored"]), |
|
99 "{0:6d}".format(counts["ignored"]), |
|
100 message, |
|
101 ], |
|
102 ) |
97 CodeStyleCheckerUtilities.setItemIcon(itm, 0, msgCode) |
103 CodeStyleCheckerUtilities.setItemIcon(itm, 0, msgCode) |
98 |
104 |
99 itm.setTextAlignment( |
105 itm.setTextAlignment( |
100 0, Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter) |
106 0, Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter |
|
107 ) |
101 itm.setTextAlignment( |
108 itm.setTextAlignment( |
102 1, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) |
109 1, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter |
|
110 ) |
103 itm.setTextAlignment( |
111 itm.setTextAlignment( |
104 2, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) |
112 2, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter |
|
113 ) |