AutoTest: Avoid unneeded duplication on rebuild

When the rebuild of the tree model has been triggered
due to switching between grouping by filter or directory
it could happen that some children did not get merged
into others due to (insignificant) differences.
Avoid this visual duplication by finding items similar
to the one to be added and if there is one re-use this
instead.

Change-Id: Ife49593638e0af23ffc7353e305be4ea25eb2180
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-03-13 13:38:43 +01:00
parent db2e962a2f
commit 96ccb95e6f
9 changed files with 108 additions and 1 deletions

View File

@@ -320,6 +320,28 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
}
}
TestTreeItem *QuickTestTreeItem::findChild(const TestTreeItem *other)
{
QTC_ASSERT(other, return nullptr);
const Type otherType = other->type();
switch (type()) {
case Root:
if (otherType == TestCase && other->name().isEmpty())
return unnamedQuickTests();
return findChildByFileAndType(other->filePath(), otherType);
case GroupNode:
return findChildByFileAndType(other->filePath(), otherType);
case TestCase:
if (otherType != TestFunctionOrSet && otherType != TestDataFunction && otherType != TestSpecialFunction)
return nullptr;
return name().isEmpty() ? findChildByNameAndFile(other->name(), other->filePath())
: findChildByName(other->name());
default:
return nullptr;
}
}
bool QuickTestTreeItem::modify(const TestParseResult *result)
{
QTC_ASSERT(result, return false);