Utils: Introduce TreeItem::{begin,end}

... and use this to reduce the number of explicit uses of m_children.

Despite of being shorter code by itself it is a step towards having
an explicit LeafItem object that doesn't explicitly store a(n empty)
vector of child nodes.

Change-Id: If8db85e2f1134dd1578a78d31235bf57a28f863a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2017-02-07 08:53:00 +01:00
parent af54ab960a
commit 196dbbe0e7
16 changed files with 75 additions and 66 deletions

View File

@@ -104,7 +104,7 @@ void TestResultItem::updateResult()
return;
Result::Type newResult = Result::MessageTestCaseSuccess;
foreach (Utils::TreeItem *child, children()) {
for (Utils::TreeItem *child : *this) {
const TestResult *current = static_cast<TestResultItem *>(child)->testResult();
if (current) {
switch (current->result()) {
@@ -131,7 +131,7 @@ void TestResultItem::updateResult()
void TestResultItem::updateIntermediateChildren()
{
for (Utils::TreeItem *child : children()) {
for (Utils::TreeItem *child : *this) {
TestResultItem *childItem = static_cast<TestResultItem *>(child);
if (childItem->testResult()->result() == Result::MessageIntermediate)
childItem->updateResult();
@@ -225,9 +225,9 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
void TestResultModel::removeCurrentTestMessage()
{
QVector<Utils::TreeItem *> topLevelItems = rootItem()->children();
std::vector<Utils::TreeItem *> topLevelItems(rootItem()->begin(), rootItem()->end());
for (int row = topLevelItems.size() - 1; row >= 0; --row) {
TestResultItem *current = static_cast<TestResultItem *>(topLevelItems.at(row));
TestResultItem *current = static_cast<TestResultItem *>(topLevelItems[row]);
if (current->testResult()->result() == Result::MessageCurrentTest) {
destroyItem(current);
break;