aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest/quick
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-03-13 13:38:43 +0100
committerChristian Stenger <christian.stenger@qt.io>2018-04-16 07:47:36 +0000
commit96ccb95e6fd8d198aa962e96320dbdeb942f158e (patch)
treeb3541a644049eac15fd9073b6ef04236b7273a63 /src/plugins/autotest/quick
parentdb2e962a2fdd4ff71a7395245999b667c02da6f8 (diff)
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>
Diffstat (limited to 'src/plugins/autotest/quick')
-rw-r--r--src/plugins/autotest/quick/quicktesttreeitem.cpp22
-rw-r--r--src/plugins/autotest/quick/quicktesttreeitem.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp
index 68a844fbbca..69f3cdc8447 100644
--- a/src/plugins/autotest/quick/quicktesttreeitem.cpp
+++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp
@@ -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);
diff --git a/src/plugins/autotest/quick/quicktesttreeitem.h b/src/plugins/autotest/quick/quicktesttreeitem.h
index 88d21bf637c..48c2467de98 100644
--- a/src/plugins/autotest/quick/quicktesttreeitem.h
+++ b/src/plugins/autotest/quick/quicktesttreeitem.h
@@ -46,6 +46,7 @@ public:
QList<TestConfiguration *> getAllTestConfigurations() const override;
QList<TestConfiguration *> getSelectedTestConfigurations() const override;
TestTreeItem *find(const TestParseResult *result) override;
+ TestTreeItem *findChild(const TestTreeItem *other) override;
bool modify(const TestParseResult *result) override;
bool lessThan(const TestTreeItem *other, SortMode mode) const override;
bool isGroupNodeFor(const TestTreeItem *other) const override;