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