From 5b6e9671d7b2e5b3e867d5285aec625c672e8df4 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 31 Oct 2016 10:32:34 +0100 Subject: [PATCH] AutoTest: Small refactoring of addTestResult() Just some simplifications and restructuring. Change-Id: I2a2a66808f1721e7ce9dc47e20194d544c093092 Reviewed-by: David Schulz --- src/plugins/autotest/testresultmodel.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp index 51dcbca4268..09865b10605 100644 --- a/src/plugins/autotest/testresultmodel.cpp +++ b/src/plugins/autotest/testresultmodel.cpp @@ -135,17 +135,9 @@ TestResultModel::TestResultModel(QObject *parent) void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoExpand) { - const bool isCurrentTestMssg = testResult->result() == Result::MessageCurrentTest; - - QVector topLevelItems = rootItem()->children(); - int lastRow = topLevelItems.size() - 1; - // we'll add the new item, so raising it's counter - if (!isCurrentTestMssg) { - int count = m_testResultCount.value(testResult->result(), 0); - if (testResult->result() == Result::MessageDisabledTests) - m_disabled += testResult->line(); - m_testResultCount.insert(testResult->result(), ++count); - } else { + const QVector &topLevelItems = rootItem()->children(); + const int lastRow = topLevelItems.size() - 1; + if (testResult->result() == Result::MessageCurrentTest) { // MessageCurrentTest should always be the last top level item if (lastRow >= 0) { TestResultItem *current = static_cast(topLevelItems.at(lastRow)); @@ -161,6 +153,10 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx return; } + if (testResult->result() == Result::MessageDisabledTests) + m_disabled += testResult->line(); + m_testResultCount[testResult->result()]++; + TestResultItem *newItem = new TestResultItem(testResult); // FIXME this might be totally wrong... we need some more unique information! if (!testResult->name().isEmpty()) { @@ -188,7 +184,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx return; } } - + // there is no MessageCurrentTest at the last row, but we have a toplevel item - just add it rootItem()->appendChild(newItem); }