diff options
author | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-09-04 11:02:14 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-10-02 10:42:32 +0300 |
commit | b4dcfc1d91872fae64466da8b38bdcb9e1fad855 (patch) | |
tree | 8036cfdf62bc9627c2cff287d757d377631fe064 /plugins/autotest/testtreeitem.cpp | |
parent | 0d01a0c7bfe2c80700b64e1b56c1172cc99a6f45 (diff) | |
download | qt-creator-b4dcfc1d91872fae64466da8b38bdcb9e1fad855.tar.gz |
Let TestTreeItem handle its parent
Part of preparing to re-use QC's TreeModel/TreeItem for
TestTreeModel/TestTreeItem.
Change-Id: Ieab26e9061790dd4c3d8dc64ce292727a17977f7
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'plugins/autotest/testtreeitem.cpp')
-rw-r--r-- | plugins/autotest/testtreeitem.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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); } |