diff -r 4010cc7e9c0b -r 2c7ccb4484bf eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py --- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Fri Jun 19 13:43:40 2020 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Fri Jun 19 13:46:58 2020 +0200 @@ -141,18 +141,10 @@ self.ecMediumRiskCombo.addItems( CodeStyleCheckerDialog.cryptoBitSelectionsEc) - self.statisticsButton = self.buttonBox.addButton( - self.tr("Statistics..."), QDialogButtonBox.ActionRole) - self.statisticsButton.setToolTip( - self.tr("Press to show some statistics for the last run")) self.statisticsButton.setEnabled(False) - self.showButton = self.buttonBox.addButton( - self.tr("Show"), QDialogButtonBox.ActionRole) - self.showButton.setToolTip( - self.tr("Press to show all files containing an issue")) self.showButton.setEnabled(False) + self.cancelButton.setEnabled(True) self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) self.resultList.headerItem().setText(self.resultList.columnCount(), "") self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) @@ -410,8 +402,8 @@ self.__forProject = True self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.cancelButton.setEnabled(False) self.__data = self.__project.getData("CHECKERSPARMS", "Pep8Checker") if ( @@ -559,6 +551,20 @@ self.__cleanupData() + def __prepareProgress(self): + """ + Private method to prepare the progress tab for the next run. + """ + self.progressList.clear() + if len(self.files) > 0: + self.checkProgress.setMaximum(len(self.files)) + self.checkProgressLabel.setVisible(len(self.files) > 1) + self.checkProgress.setVisible(len(self.files) > 1) + if len(self.files) > 1: + self.progressList.addItems(self.files) + + QApplication.processEvents() + def start(self, fn, save=False, repeat=None): """ Public slot to start the code style check. @@ -573,12 +579,12 @@ if self.__project is None: self.__project = e5App().getObject("Project") - self.mainWidget.setCurrentWidget(self.runTab) + self.mainWidget.setCurrentWidget(self.progressTab) self.cancelled = False self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.cancelButton.setEnabled(True) + self.cancelButton.setDefault(True) self.statisticsButton.setEnabled(False) self.showButton.setEnabled(False) self.fixButton.setEnabled(False) @@ -603,7 +609,7 @@ fn, True, '*{0}'.format(ext), 0)) else: self.files = [fn] - + # filter the list depending on the filter string if self.files: filterString = self.excludeFilesEdit.text() @@ -614,19 +620,16 @@ f for f in self.files if not fnmatch.fnmatch(f, fileFilter.strip()) ] - + self.__errorItem = None self.__resetStatistics() self.__clearErrors(self.files) self.__cleanupData() + self.__prepareProgress() if len(self.files) > 0: self.securityNoteLabel.setVisible( "S" in self.__getCategories(True, asList=True)) - self.checkProgress.setMaximum(len(self.files)) - self.checkProgressLabel.setVisible(len(self.files) > 1) - self.checkProgress.setVisible(len(self.files) > 1) - QApplication.processEvents() # extract the configuration values excludeMessages = self.__assembleExcludeMessages() @@ -715,6 +718,7 @@ self.files.sort() if len(self.files) == 1: self.__batch = False + self.mainWidget.setCurrentWidget(self.resultsTab) self.check() else: self.__batch = True @@ -953,13 +957,29 @@ self.resultList.setSortingEnabled(True) self.resultList.setUpdatesEnabled(True) - self.checkProgress.setValue(self.progress) - self.checkProgressLabel.setPath(fn) - QApplication.processEvents() + self.__updateProgress(fn) if not self.__batch: self.check() + def __updateProgress(self, fn): + """ + Private method to update the progress tab. + + @param fn filename of the just checked file + @type str + """ + self.checkProgress.setValue(self.progress) + self.checkProgressLabel.setPath(fn) + + # remove file from the list of jobs to do + fileItems = self.progressList.findItems(fn, Qt.MatchExactly) + if fileItems: + row = self.progressList.row(fileItems[0]) + self.progressList.takeItem(row) + + QApplication.processEvents() + def __finish(self): """ Private slot called when the code style check finished or the user @@ -970,8 +990,8 @@ self.cancelled = True self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.cancelButton.setEnabled(False) self.statisticsButton.setEnabled(True) self.showButton.setEnabled(True) self.startButton.setEnabled(True) @@ -995,6 +1015,8 @@ self.checkProgress.setVisible(False) self.checkProgressLabel.setVisible(False) + + self.mainWidget.setCurrentWidget(self.resultsTab) def __getEol(self, fn): """ @@ -1548,6 +1570,17 @@ # Update UI with default values self.on_loadDefaultButton_clicked() + @pyqtSlot() + def on_cancelButton_clicked(self): + """ + Private slot to handle the "Cancel" button press. + """ + if self.__batch: + self.styleCheckService.cancelStyleBatchCheck() + QTimer.singleShot(1000, self.__finish) + else: + self.__finish() + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ @@ -1558,16 +1591,6 @@ """ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() - elif button == self.buttonBox.button(QDialogButtonBox.Cancel): - if self.__batch: - self.styleCheckService.cancelStyleBatchCheck() - QTimer.singleShot(1000, self.__finish) - else: - self.__finish() - elif button == self.showButton: - self.on_showButton_clicked() - elif button == self.statisticsButton: - self.on_statisticsButton_clicked() def __clearErrors(self, files): """