summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/autotest/testcodeparser.cpp4
-rw-r--r--plugins/autotest/testtreeitem.cpp18
-rw-r--r--plugins/autotest/testtreeitem.h3
-rw-r--r--plugins/autotest/testtreemodel.cpp12
4 files changed, 17 insertions, 20 deletions
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index b7a13b4ee8..e0a5ea3226 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -398,7 +398,7 @@ static TestTreeItem constructTestTreeItem(const QString &fileName,
foreach (const QString &functionName, functions.keys()) {
const TestCodeLocationAndType locationAndType = functions.value(functionName);
TestTreeItem *treeItemChild = new TestTreeItem(functionName, locationAndType.m_name,
- locationAndType.m_type, &treeItem);
+ locationAndType.m_type);
treeItemChild->setLine(locationAndType.m_line);
treeItemChild->setColumn(locationAndType.m_column);
// check for data tags and if there are any for this function add them
@@ -408,7 +408,7 @@ static TestTreeItem constructTestTreeItem(const QString &fileName,
foreach (const TestCodeLocationAndType &tagLocation, tags) {
TestTreeItem *tagTreeItem = new TestTreeItem(tagLocation.m_name,
locationAndType.m_name,
- tagLocation.m_type, treeItemChild);
+ tagLocation.m_type);
tagTreeItem->setLine(tagLocation.m_line);
tagTreeItem->setColumn(tagLocation.m_column);
treeItemChild->appendChild(tagTreeItem);
diff --git a/plugins/autotest/testtreeitem.cpp b/plugins/autotest/testtreeitem.cpp
index 5119f4a206..78d91c4490 100644
--- a/plugins/autotest/testtreeitem.cpp
+++ b/plugins/autotest/testtreeitem.cpp
@@ -19,15 +19,17 @@
#include "testtreeitem.h"
+#include <utils/qtcassert.h>
+
namespace Autotest {
namespace Internal {
-TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type, TestTreeItem *parent)
+TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type)
: m_name(name),
m_filePath(filePath),
m_type(type),
m_line(0),
- m_parent(parent)
+ m_parent(0)
{
switch (m_type) {
case TEST_CLASS:
@@ -52,13 +54,10 @@ TestTreeItem::TestTreeItem(const TestTreeItem &other)
m_line(other.m_line),
m_column(other.m_column),
m_mainFile(other.m_mainFile),
- m_parent(other.m_parent)
+ m_parent(0)
{
- foreach (const TestTreeItem *child, other.m_children) {
- TestTreeItem *reparentedChild = new TestTreeItem(*child);
- reparentedChild->m_parent = this;
- m_children.append(reparentedChild);
- }
+ foreach (const TestTreeItem *child, other.m_children)
+ appendChild(new TestTreeItem(*child));
}
TestTreeItem *TestTreeItem::child(int row) const
@@ -73,6 +72,9 @@ TestTreeItem *TestTreeItem::parent() const
void TestTreeItem::appendChild(TestTreeItem *child)
{
+ QTC_ASSERT(child->m_parent == 0, return);
+
+ child->m_parent = this;
m_children.append(child);
}
diff --git a/plugins/autotest/testtreeitem.h b/plugins/autotest/testtreeitem.h
index 8c7bf14307..0d25350eda 100644
--- a/plugins/autotest/testtreeitem.h
+++ b/plugins/autotest/testtreeitem.h
@@ -41,7 +41,7 @@ public:
};
TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
- Type type = ROOT, TestTreeItem *parent = 0);
+ Type type = ROOT);
virtual ~TestTreeItem();
TestTreeItem(const TestTreeItem& other);
@@ -67,7 +67,6 @@ public:
void setChecked(const Qt::CheckState checked);
Qt::CheckState checked() const;
Type type() const { return m_type; }
- void setParent(TestTreeItem *parent) { m_parent = parent; }
QList<QString> getChildNames() const;
private:
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 0b43688982..9f0cf75a27 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -41,8 +41,8 @@ namespace Internal {
TestTreeModel::TestTreeModel(QObject *parent) :
QAbstractItemModel(parent),
m_rootItem(new TestTreeItem(QString(), QString(), TestTreeItem::ROOT)),
- m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
- m_quickTestRootItem(new TestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
+ m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::ROOT)),
+ m_quickTestRootItem(new TestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::ROOT)),
m_parser(new TestCodeParser(this)),
m_connectionsInitialized(false)
{
@@ -664,7 +664,6 @@ void TestTreeModel::addTestTreeItem(const TestTreeItem &item, TestTreeModel::Typ
TestTreeItem *parent = rootItemForType(type);
QModelIndex index = rootIndexForType(type);
TestTreeItem *toBeAdded = new TestTreeItem(item);
- toBeAdded->setParent(parent);
beginInsertRows(index, parent->childCount(), parent->childCount());
parent->appendChild(toBeAdded);
@@ -680,7 +679,6 @@ void TestTreeModel::addTestTreeItems(const QList<TestTreeItem> &itemList, TestTr
beginInsertRows(index, parent->childCount(), parent->childCount() + itemList.size() - 1);
foreach (const TestTreeItem &item, itemList) {
TestTreeItem *toBeAdded = new TestTreeItem(item);
- toBeAdded->setParent(parent);
parent->appendChild(toBeAdded);
}
endInsertRows();
@@ -693,12 +691,12 @@ void TestTreeModel::updateUnnamedQuickTest(const QString &fileName, const QStrin
removeUnnamedQuickTests(fileName);
TestTreeItem unnamed = hasUnnamedQuickTests()
? TestTreeItem(*unnamedQuickTests())
- : TestTreeItem(QString(), QString(), TestTreeItem::TEST_CLASS, rootItemForType(QuickTest));
+ : TestTreeItem(QString(), QString(), TestTreeItem::TEST_CLASS);
foreach (const QString &functionName, functions.keys()) {
const TestCodeLocationAndType locationAndType = functions.value(functionName);
TestTreeItem *testFunction = new TestTreeItem(functionName, locationAndType.m_name,
- locationAndType.m_type, &unnamed);
+ locationAndType.m_type);
testFunction->setLine(locationAndType.m_line);
testFunction->setColumn(locationAndType.m_column);
testFunction->setMainFile(mainFile);
@@ -714,7 +712,6 @@ void TestTreeModel::modifyTestTreeItem(TestTreeItem item, TestTreeModel::Type ty
{
QModelIndex index = rootIndexForType(type);
TestTreeItem *parent = rootItemForType(type);
- item.setParent(parent);
if (file.isEmpty()) {
if (TestTreeItem *unnamed = unnamedQuickTests()) {
index = index.child(unnamed->row(), 0);
@@ -805,7 +802,6 @@ void TestTreeModel::modifyTestSubtree(QModelIndex &toBeModifiedIndex, const Test
for (int row = childCount; row < newChildCount; ++row) {
TestTreeItem *newChild = newItem.child(row);
TestTreeItem *toBeAdded = new TestTreeItem(*newChild);
- toBeAdded->setParent(toBeModifiedItem);
if (checkStates.contains(toBeAdded->name())
&& checkStates.value(toBeAdded->name()) != Qt::Checked)
toBeAdded->setChecked(checkStates.value(toBeAdded->name()));