Commit 8bb03409 authored by Christian Stenger's avatar Christian Stenger Committed by Christian Stenger
Browse files

Enable filter items on availability

If there are items inside the results pane that match the filter
item filtering for these kind of results will be enabled.
parent 87e5cf87
......@@ -109,6 +109,7 @@ void TestResultModel::addTestResult(const TestResult &testResult)
beginInsertRows(QModelIndex(), m_testResults.size(), m_testResults.size());
m_testResults.append(testResult);
endInsertRows();
m_availableResultTypes.insert(testResult.result());
}
void TestResultModel::clearTestResults()
......@@ -121,6 +122,7 @@ void TestResultModel::clearTestResults()
m_maxWidthOfFileName = 0;
m_widthOfLineNumber = 0;
endRemoveRows();
m_availableResultTypes.clear();
}
TestResult TestResultModel::testResult(const QModelIndex &index) const
......
......@@ -52,6 +52,7 @@ public:
void enableAllResultTypes();
void toggleTestResultType(ResultType type);
bool hasResultType(ResultType type) { return m_availableResultTypes.contains(type); }
signals:
......@@ -63,6 +64,7 @@ private:
int m_maxWidthOfFileName;
int m_lastMaxWidthIndex;
QFont m_measurementFont;
QSet<ResultType> m_availableResultTypes;
};
class TestResultFilterModel : public QSortFilterProxyModel
......
......@@ -86,6 +86,7 @@ void TestResultsPane::createToolButtons()
m_filterButton->setPopupMode(QToolButton::InstantPopup);
m_filterMenu = new QMenu(m_filterButton);
initializeFilterMenu();
connect(m_filterMenu, &QMenu::aboutToShow, this, &TestResultsPane::updateFilterMenu);
connect(m_filterMenu, &QMenu::triggered, this, &TestResultsPane::filterMenuTriggered);
m_filterButton->setMenu(m_filterMenu);
}
......@@ -241,7 +242,6 @@ void TestResultsPane::onRunSelectedTriggered()
void TestResultsPane::initializeFilterMenu()
{
QMap<ResultType, QString> textAndType;
textAndType.clear();
textAndType.insert(ResultType::PASS, QLatin1String("Pass"));
textAndType.insert(ResultType::FAIL, QLatin1String("Fail"));
textAndType.insert(ResultType::EXPECTED_FAIL, QLatin1String("Expected Fail"));
......@@ -260,6 +260,14 @@ void TestResultsPane::initializeFilterMenu()
}
}
void TestResultsPane::updateFilterMenu()
{
foreach (QAction *action, m_filterMenu->actions()) {
action->setEnabled(m_model->hasResultType(
static_cast<ResultType>(action->data().value<int>())));
}
}
void TestResultsPane::filterMenuTriggered(QAction *action)
{
m_filterModel->toggleTestResultType(static_cast<ResultType>(action->data().value<int>()));
......
......@@ -76,11 +76,12 @@ private slots:
void onItemActivated(const QModelIndex &index);
void onRunAllTriggered();
void onRunSelectedTriggered();
void initializeFilterMenu();
void updateFilterMenu();
void filterMenuTriggered(QAction *action);
private:
explicit TestResultsPane(QObject *parent = 0);
void initializeFilterMenu();
void createToolButtons();
void onTestRunStarted();
void onTestRunFinished();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment