src/eric7/DataViews/CodeMetricsDialog.py

branch
eric7
changeset 10423
299802979277
parent 10076
649f7ca537ea
child 10439
21c28b0f9e41
equal deleted inserted replaced
10422:e28b89693f37 10423:299802979277
36 36
37 def __init__(self, parent=None): 37 def __init__(self, parent=None):
38 """ 38 """
39 Constructor 39 Constructor
40 40
41 @param parent parent widget (QWidget) 41 @param parent parent widget
42 @type QWidget
42 """ 43 """
43 super().__init__(parent) 44 super().__init__(parent)
44 self.setupUi(self) 45 self.setupUi(self)
45 self.setWindowFlags(Qt.WindowType.Window) 46 self.setWindowFlags(Qt.WindowType.Window)
46 47
74 75
75 def __createResultItem(self, parent, values): 76 def __createResultItem(self, parent, values):
76 """ 77 """
77 Private slot to create a new item in the result list. 78 Private slot to create a new item in the result list.
78 79
79 @param parent parent of the new item (QTreeWidget or QTreeWidgetItem) 80 @param parent parent of the new item
80 @param values values to be displayed (list) 81 @type QTreeWidget or QTreeWidgetItem
82 @param values values to be displayed
83 @type list of int
81 @return the generated item 84 @return the generated item
85 @rtype QTreeWidgetItem
82 """ 86 """
83 data = [values[0]] 87 data = [values[0]]
84 for value in values[1:]: 88 for value in values[1:]:
85 try: 89 try:
86 data.append("{0:5}".format(int(value))) 90 data.append("{0:5}".format(int(value)))
102 106
103 def __createSummaryItem(self, col0, col1): 107 def __createSummaryItem(self, col0, col1):
104 """ 108 """
105 Private slot to create a new item in the summary list. 109 Private slot to create a new item in the summary list.
106 110
107 @param col0 string for column 0 (string) 111 @param col0 string for column 0
108 @param col1 string for column 1 (string) 112 @type str
113 @param col1 string for column 1
114 @type str
109 """ 115 """
110 itm = QTreeWidgetItem(self.summaryList, [col0, col1]) 116 itm = QTreeWidgetItem(self.summaryList, [col0, col1])
111 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight) 117 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight)
112 118
113 def prepare(self, fileList): 119 def prepare(self, fileList):
133 def start(self, fn): 139 def start(self, fn):
134 """ 140 """
135 Public slot to start the code metrics determination. 141 Public slot to start the code metrics determination.
136 142
137 @param fn file or list of files or directory to show 143 @param fn file or list of files or directory to show
138 the code metrics for (string or list of strings) 144 the code metrics for
145 @type str or list of str
139 """ 146 """
140 self.cancelled = False 147 self.cancelled = False
141 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) 148 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
142 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True) 149 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
143 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) 150 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
217 224
218 def __getValues(self, loc, stats, identifier): 225 def __getValues(self, loc, stats, identifier):
219 """ 226 """
220 Private method to extract the code metric values. 227 Private method to extract the code metric values.
221 228
222 @param loc reference to the locale object (QLocale) 229 @param loc reference to the locale object
230 @type QLocale
223 @param stats reference to the code metric statistics object 231 @param stats reference to the code metric statistics object
232 @type SourceStat
224 @param identifier identifier to get values for 233 @param identifier identifier to get values for
225 @return list of values suitable for display (list of strings) 234 @type str
235 @return list of values suitable for display
236 @rtype list of str
226 """ 237 """
227 counters = stats.counters.get(identifier, {}) 238 counters = stats.counters.get(identifier, {})
228 v = [] 239 v = []
229 for key in ("start", "end", "lines", "nloc", "commentlines", "empty"): 240 for key in ("start", "end", "lines", "nloc", "commentlines", "empty"):
230 if counters.get(key, 0): 241 if counters.get(key, 0):
262 273
263 def on_buttonBox_clicked(self, button): 274 def on_buttonBox_clicked(self, button):
264 """ 275 """
265 Private slot called by a button of the button box clicked. 276 Private slot called by a button of the button box clicked.
266 277
267 @param button button that was clicked (QAbstractButton) 278 @param button button that was clicked
279 @type QAbstractButton
268 """ 280 """
269 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): 281 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
270 self.close() 282 self.close()
271 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): 283 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
272 self.__finish() 284 self.__finish()
298 310
299 def __showContextMenu(self, coord): 311 def __showContextMenu(self, coord):
300 """ 312 """
301 Private slot to show the context menu of the listview. 313 Private slot to show the context menu of the listview.
302 314
303 @param coord the position of the mouse pointer (QPoint) 315 @param coord the position of the mouse pointer
316 @type QPoint
304 """ 317 """
305 if self.resultList.topLevelItemCount() > 0: 318 if self.resultList.topLevelItemCount() > 0:
306 self.__menu.popup(self.mapToGlobal(coord)) 319 self.__menu.popup(self.mapToGlobal(coord))
307 320
308 def __resultCollapse(self): 321 def __resultCollapse(self):

eric ide

mercurial