32 |
32 |
33 @param parent parent widget (QWidget) |
33 @param parent parent widget (QWidget) |
34 """ |
34 """ |
35 super(CodeMetricsDialog, self).__init__(parent) |
35 super(CodeMetricsDialog, self).__init__(parent) |
36 self.setupUi(self) |
36 self.setupUi(self) |
37 self.setWindowFlags(Qt.Window) |
37 self.setWindowFlags(Qt.WindowType.Window) |
38 |
38 |
39 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
39 self.buttonBox.button( |
40 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
40 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
|
41 self.buttonBox.button( |
|
42 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
41 |
43 |
42 self.summaryList.headerItem().setText( |
44 self.summaryList.headerItem().setText( |
43 self.summaryList.columnCount(), "") |
45 self.summaryList.columnCount(), "") |
44 self.summaryList.header().resizeSection(0, 200) |
46 self.summaryList.header().resizeSection(0, 200) |
45 self.summaryList.header().resizeSection(1, 100) |
47 self.summaryList.header().resizeSection(1, 100) |
50 |
52 |
51 self.__menu = QMenu(self) |
53 self.__menu = QMenu(self) |
52 self.__menu.addAction(self.tr("Collapse All"), |
54 self.__menu.addAction(self.tr("Collapse All"), |
53 self.__resultCollapse) |
55 self.__resultCollapse) |
54 self.__menu.addAction(self.tr("Expand All"), self.__resultExpand) |
56 self.__menu.addAction(self.tr("Expand All"), self.__resultExpand) |
55 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) |
57 self.resultList.setContextMenuPolicy( |
|
58 Qt.ContextMenuPolicy.CustomContextMenu) |
56 self.resultList.customContextMenuRequested.connect( |
59 self.resultList.customContextMenuRequested.connect( |
57 self.__showContextMenu) |
60 self.__showContextMenu) |
58 |
61 |
59 self.__fileList = [] |
62 self.__fileList = [] |
60 self.__project = None |
63 self.__project = None |
62 |
65 |
63 def __resizeResultColumns(self): |
66 def __resizeResultColumns(self): |
64 """ |
67 """ |
65 Private method to resize the list columns. |
68 Private method to resize the list columns. |
66 """ |
69 """ |
67 self.resultList.header().resizeSections(QHeaderView.ResizeToContents) |
70 self.resultList.header().resizeSections( |
|
71 QHeaderView.ResizeMode.ResizeToContents) |
68 self.resultList.header().setStretchLastSection(True) |
72 self.resultList.header().setStretchLastSection(True) |
69 |
73 |
70 def __createResultItem(self, parent, values): |
74 def __createResultItem(self, parent, values): |
71 """ |
75 """ |
72 Private slot to create a new item in the result list. |
76 Private slot to create a new item in the result list. |
81 data.append("{0:5}".format(int(value))) |
85 data.append("{0:5}".format(int(value))) |
82 except ValueError: |
86 except ValueError: |
83 data.append(value) |
87 data.append(value) |
84 itm = QTreeWidgetItem(parent, data) |
88 itm = QTreeWidgetItem(parent, data) |
85 for col in range(1, 7): |
89 for col in range(1, 7): |
86 itm.setTextAlignment(col, Qt.Alignment(Qt.AlignRight)) |
90 itm.setTextAlignment( |
|
91 col, Qt.Alignment(Qt.AlignmentFlag.AlignRight)) |
87 return itm |
92 return itm |
88 |
93 |
89 def __resizeSummaryColumns(self): |
94 def __resizeSummaryColumns(self): |
90 """ |
95 """ |
91 Private method to resize the list columns. |
96 Private method to resize the list columns. |
92 """ |
97 """ |
93 self.summaryList.header().resizeSections(QHeaderView.ResizeToContents) |
98 self.summaryList.header().resizeSections( |
|
99 QHeaderView.ResizeMode.ResizeToContents) |
94 self.summaryList.header().setStretchLastSection(True) |
100 self.summaryList.header().setStretchLastSection(True) |
95 |
101 |
96 def __createSummaryItem(self, col0, col1): |
102 def __createSummaryItem(self, col0, col1): |
97 """ |
103 """ |
98 Private slot to create a new item in the summary list. |
104 Private slot to create a new item in the summary list. |
99 |
105 |
100 @param col0 string for column 0 (string) |
106 @param col0 string for column 0 (string) |
101 @param col1 string for column 1 (string) |
107 @param col1 string for column 1 (string) |
102 """ |
108 """ |
103 itm = QTreeWidgetItem(self.summaryList, [col0, col1]) |
109 itm = QTreeWidgetItem(self.summaryList, [col0, col1]) |
104 itm.setTextAlignment(1, Qt.Alignment(Qt.AlignRight)) |
110 itm.setTextAlignment(1, Qt.Alignment(Qt.AlignmentFlag.AlignRight)) |
105 |
111 |
106 def prepare(self, fileList, project): |
112 def prepare(self, fileList, project): |
107 """ |
113 """ |
108 Public method to prepare the dialog with a list of filenames. |
114 Public method to prepare the dialog with a list of filenames. |
109 |
115 |
111 @param project reference to the project object (Project) |
117 @param project reference to the project object (Project) |
112 """ |
118 """ |
113 self.__fileList = fileList[:] |
119 self.__fileList = fileList[:] |
114 self.__project = project |
120 self.__project = project |
115 |
121 |
116 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
122 self.buttonBox.button( |
117 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
123 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
118 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
124 self.buttonBox.button( |
|
125 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
|
126 self.buttonBox.button( |
|
127 QDialogButtonBox.StandardButton.Close).setDefault(True) |
119 |
128 |
120 self.filterFrame.setVisible(True) |
129 self.filterFrame.setVisible(True) |
121 |
130 |
122 self.__data = self.__project.getData("OTHERTOOLSPARMS", "CodeMetrics") |
131 self.__data = self.__project.getData("OTHERTOOLSPARMS", "CodeMetrics") |
123 if self.__data is None or "ExcludeFiles" not in self.__data: |
132 if self.__data is None or "ExcludeFiles" not in self.__data: |
130 |
139 |
131 @param fn file or list of files or directory to show |
140 @param fn file or list of files or directory to show |
132 the code metrics for (string or list of strings) |
141 the code metrics for (string or list of strings) |
133 """ |
142 """ |
134 self.cancelled = False |
143 self.cancelled = False |
135 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
144 self.buttonBox.button( |
136 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
145 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
137 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
146 self.buttonBox.button( |
|
147 QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
|
148 self.buttonBox.button( |
|
149 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
138 QApplication.processEvents() |
150 QApplication.processEvents() |
139 |
151 |
140 loc = QLocale() |
152 loc = QLocale() |
141 if isinstance(fn, list): |
153 if isinstance(fn, list): |
142 files = fn |
154 files = fn |
229 """ |
241 """ |
230 Private slot called when the action finished or the user pressed the |
242 Private slot called when the action finished or the user pressed the |
231 button. |
243 button. |
232 """ |
244 """ |
233 self.cancelled = True |
245 self.cancelled = True |
234 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
246 self.buttonBox.button( |
235 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
247 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
236 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
248 self.buttonBox.button( |
237 |
249 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
238 self.resultList.header().setSectionResizeMode(QHeaderView.Interactive) |
250 self.buttonBox.button( |
239 self.summaryList.header().setSectionResizeMode(QHeaderView.Interactive) |
251 QDialogButtonBox.StandardButton.Close).setDefault(True) |
|
252 |
|
253 self.resultList.header().setSectionResizeMode( |
|
254 QHeaderView.ResizeMode.Interactive) |
|
255 self.summaryList.header().setSectionResizeMode( |
|
256 QHeaderView.ResizeMode.Interactive) |
240 |
257 |
241 def on_buttonBox_clicked(self, button): |
258 def on_buttonBox_clicked(self, button): |
242 """ |
259 """ |
243 Private slot called by a button of the button box clicked. |
260 Private slot called by a button of the button box clicked. |
244 |
261 |
245 @param button button that was clicked (QAbstractButton) |
262 @param button button that was clicked (QAbstractButton) |
246 """ |
263 """ |
247 if button == self.buttonBox.button(QDialogButtonBox.Close): |
264 if button == self.buttonBox.button( |
|
265 QDialogButtonBox.StandardButton.Close |
|
266 ): |
248 self.close() |
267 self.close() |
249 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
268 elif button == self.buttonBox.button( |
|
269 QDialogButtonBox.StandardButton.Cancel |
|
270 ): |
250 self.__finish() |
271 self.__finish() |
251 |
272 |
252 @pyqtSlot() |
273 @pyqtSlot() |
253 def on_startButton_clicked(self): |
274 def on_startButton_clicked(self): |
254 """ |
275 """ |