15 from PyQt6.QtCore import pyqtSlot, Qt, QLocale |
15 from PyQt6.QtCore import pyqtSlot, Qt, QLocale |
16 from PyQt6.QtWidgets import ( |
16 from PyQt6.QtWidgets import ( |
17 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
17 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
18 QApplication |
18 QApplication |
19 ) |
19 ) |
|
20 |
|
21 from EricWidgets.EricApplication import ericApp |
20 |
22 |
21 from .Ui_CodeMetricsDialog import Ui_CodeMetricsDialog |
23 from .Ui_CodeMetricsDialog import Ui_CodeMetricsDialog |
22 from . import CodeMetrics |
24 from . import CodeMetrics |
23 |
25 |
24 import Utilities |
26 import Utilities |
60 Qt.ContextMenuPolicy.CustomContextMenu) |
62 Qt.ContextMenuPolicy.CustomContextMenu) |
61 self.resultList.customContextMenuRequested.connect( |
63 self.resultList.customContextMenuRequested.connect( |
62 self.__showContextMenu) |
64 self.__showContextMenu) |
63 |
65 |
64 self.__fileList = [] |
66 self.__fileList = [] |
65 self.__project = None |
67 self.__project = ericApp().getObject("Project") |
66 self.filterFrame.setVisible(False) |
68 self.filterFrame.setVisible(False) |
67 |
69 |
68 def __resizeResultColumns(self): |
70 def __resizeResultColumns(self): |
69 """ |
71 """ |
70 Private method to resize the list columns. |
72 Private method to resize the list columns. |
109 @param col1 string for column 1 (string) |
111 @param col1 string for column 1 (string) |
110 """ |
112 """ |
111 itm = QTreeWidgetItem(self.summaryList, [col0, col1]) |
113 itm = QTreeWidgetItem(self.summaryList, [col0, col1]) |
112 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight) |
114 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight) |
113 |
115 |
114 def prepare(self, fileList, project): |
116 def prepare(self, fileList): |
115 """ |
117 """ |
116 Public method to prepare the dialog with a list of filenames. |
118 Public method to prepare the dialog with a list of filenames. |
117 |
119 |
118 @param fileList list of filenames (list of strings) |
120 @param fileList list of filenames |
119 @param project reference to the project object (Project) |
121 @type list of str |
120 """ |
122 """ |
121 self.__fileList = fileList[:] |
123 self.__fileList = fileList[:] |
122 self.__project = project |
|
123 |
124 |
124 self.buttonBox.button( |
125 self.buttonBox.button( |
125 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
126 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
126 self.buttonBox.button( |
127 self.buttonBox.button( |
127 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
128 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
182 return |
183 return |
183 |
184 |
184 stats = CodeMetrics.analyze(file, total) |
185 stats = CodeMetrics.analyze(file, total) |
185 |
186 |
186 v = self.__getValues(loc, stats, 'TOTAL ') |
187 v = self.__getValues(loc, stats, 'TOTAL ') |
187 fitm = self.__createResultItem(self.resultList, [file] + v) |
188 # make the file name project relative |
|
189 fitm = self.__createResultItem( |
|
190 self.resultList, |
|
191 [self.__project.getRelativePath(file)] + v |
|
192 ) |
188 |
193 |
189 identifiers = stats.identifiers |
194 identifiers = stats.identifiers |
190 for identifier in identifiers: |
195 for identifier in identifiers: |
191 v = self.__getValues(loc, stats, identifier) |
196 v = self.__getValues(loc, stats, identifier) |
192 |
197 |