summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@digia.com>2014-11-04 14:16:22 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2014-12-04 13:52:15 +0100
commit8bb03409353be640a18b58dd80e1bb67f96f13fe (patch)
tree5252f728d987c743747783c82a8d1d4a0464931a
parent87e5cf87e1dce9d46a6ffd9906f6be47f6941fbd (diff)
downloadqt-creator-8bb03409353be640a18b58dd80e1bb67f96f13fe.tar.gz
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.
-rw-r--r--plugins/autotest/testresultmodel.cpp2
-rw-r--r--plugins/autotest/testresultmodel.h2
-rw-r--r--plugins/autotest/testresultspane.cpp10
-rw-r--r--plugins/autotest/testresultspane.h3
4 files changed, 15 insertions, 2 deletions
diff --git a/plugins/autotest/testresultmodel.cpp b/plugins/autotest/testresultmodel.cpp
index 9c7291d2e1..ed03bae173 100644
--- a/plugins/autotest/testresultmodel.cpp
+++ b/plugins/autotest/testresultmodel.cpp
@@ -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
diff --git a/plugins/autotest/testresultmodel.h b/plugins/autotest/testresultmodel.h
index c0a71fe44b..c803d113b6 100644
--- a/plugins/autotest/testresultmodel.h
+++ b/plugins/autotest/testresultmodel.h
@@ -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
diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp
index bb641d264a..eee9fc9340 100644
--- a/plugins/autotest/testresultspane.cpp
+++ b/plugins/autotest/testresultspane.cpp
@@ -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>()));
diff --git a/plugins/autotest/testresultspane.h b/plugins/autotest/testresultspane.h
index af8222e512..58363cbb04 100644
--- a/plugins/autotest/testresultspane.h
+++ b/plugins/autotest/testresultspane.h
@@ -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();