diff -r 411df92e881f -r 3b34efa2857c src/eric7/Testing/TestResultsTree.py --- a/src/eric7/Testing/TestResultsTree.py Sun Dec 03 14:54:00 2023 +0100 +++ b/src/eric7/Testing/TestResultsTree.py Mon Jan 01 11:10:45 2024 +0100 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2022 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> +# Copyright (c) 2022 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> # """ @@ -20,6 +20,7 @@ QCoreApplication, QModelIndex, QPoint, + QSortFilterProxyModel, Qt, pyqtSignal, pyqtSlot, @@ -422,6 +423,62 @@ counts[TestResultCategory.PENDING], ) + def getStatusFilterList(self): + """ + Public method to get a list of the unique test result status. + + @return test result status + @rtype set of str + """ + return {t.status for t in self.__testResults} + + +class TestResultsFilterModel(QSortFilterProxyModel): + """ + Class implementing a filter model to filter the test results by status. + """ + + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent object + @type QObject + """ + super().__init__(parent) + + self.__statusFilterString = "" + + def filterAcceptsRow(self, sourceRow, sourceParent): + """ + Public method to determine, if the row is acceptable. + + @param sourceRow row number in the source model + @type int + @param sourceParent index of the source item + @type QModelIndex + @return flag indicating acceptance + @rtype bool + """ + sm = self.sourceModel() + idx = sm.index(sourceRow, 0, sourceParent) + status = sm.data(idx, Qt.ItemDataRole.DisplayRole) + return ( + sourceParent.isValid() + or self.__statusFilterString == "" + or status == self.__statusFilterString + ) + + def setStatusFilterString(self, filterString): + """ + Public method to set the status filter string. + + @param filterString status filter string + @type str + """ + self.__statusFilterString = filterString + self.invalidateRowsFilter() + class TestResultsTreeView(QTreeView): """ @@ -452,7 +509,7 @@ self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) # connect signals and slots - self.doubleClicked.connect(self.__gotoTestDefinition) + self.activated.connect(self.__gotoTestDefinition) self.customContextMenuRequested.connect(self.__showContextMenu) self.header().sortIndicatorChanged.connect(self.sortByColumn) @@ -559,7 +616,7 @@ """ cindex = self.__canonicalIndex(index) filename, lineno = self.model().data(cindex, Qt.ItemDataRole.UserRole) - if filename is not None: + if filename: if lineno is None: lineno = 1 self.goto.emit(filename, lineno) @@ -603,7 +660,9 @@ act = menu.addAction( self.tr("Show Source"), lambda: self.__gotoTestDefinition(index) ) - act.setEnabled(self.model().data(index, Qt.ItemDataRole.UserRole) is not None) + act.setEnabled( + self.model().data(index, Qt.ItemDataRole.UserRole)[0] is not None + ) menu.addSeparator() menu.addAction(self.tr("Collapse All"), self.collapseAll)