5 |
5 |
6 """ |
6 """ |
7 Module implementing a code metrics dialog. |
7 Module implementing a code metrics dialog. |
8 """ |
8 """ |
9 |
9 |
|
10 import collections |
|
11 import fnmatch |
10 import os |
12 import os |
11 import fnmatch |
13 import time |
12 import collections |
|
13 |
14 |
14 from PyQt6.QtCore import pyqtSlot, Qt, QLocale |
15 from PyQt6.QtCore import pyqtSlot, Qt, QLocale |
15 from PyQt6.QtWidgets import ( |
16 from PyQt6.QtWidgets import ( |
16 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
17 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
17 QApplication |
18 QApplication |
173 # disable updates of the list for speed |
174 # disable updates of the list for speed |
174 self.resultList.setUpdatesEnabled(False) |
175 self.resultList.setUpdatesEnabled(False) |
175 self.resultList.setSortingEnabled(False) |
176 self.resultList.setSortingEnabled(False) |
176 |
177 |
177 # now go through all the files |
178 # now go through all the files |
|
179 now = time.monotonic() |
178 for progress, file in enumerate(files, start=1): |
180 for progress, file in enumerate(files, start=1): |
179 if self.cancelled: |
181 if self.cancelled: |
180 return |
182 return |
181 |
183 |
182 stats = CodeMetrics.analyze(file, total) |
184 stats = CodeMetrics.analyze(file, total) |
190 |
192 |
191 self.__createResultItem(fitm, [identifier] + v) |
193 self.__createResultItem(fitm, [identifier] + v) |
192 self.resultList.expandItem(fitm) |
194 self.resultList.expandItem(fitm) |
193 |
195 |
194 self.checkProgress.setValue(progress) |
196 self.checkProgress.setValue(progress) |
195 QApplication.processEvents() |
197 if time.monotonic() - now > 0.01: |
|
198 QApplication.processEvents() |
|
199 now = time.monotonic() |
196 finally: |
200 finally: |
197 # reenable updates of the list |
201 # reenable updates of the list |
198 self.resultList.setSortingEnabled(True) |
202 self.resultList.setSortingEnabled(True) |
199 self.resultList.setUpdatesEnabled(True) |
203 self.resultList.setUpdatesEnabled(True) |
200 self.__resizeResultColumns() |
204 self.__resizeResultColumns() |