Commit 4363e3e9 authored by hjk's avatar hjk

TreeModel: Remove TreeItem::setModel from interface

This should not be accessible to client code, as the
property is effectively managed by the owning model
and manually changing it on an item breaks that.

Change-Id: Ie04451be3c0e51e7c796dcd64d400600f035fa08
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 92f4ea3f
......@@ -770,15 +770,6 @@ QModelIndex TreeItem::index() const
return m_model->indexForItem(this);
}
void TreeItem::setModel(TreeModel *model)
{
if (m_model == model)
return;
m_model = model;
foreach (TreeItem *item, m_children)
item->setModel(model);
}
void TreeItem::walkTree(TreeItemVisitor *visitor)
{
if (visitor->preVisit(this)) {
......@@ -972,6 +963,9 @@ int TreeModel::topLevelItemCount() const
void TreeModel::setRootItem(TreeItem *item)
{
QTC_ASSERT(item, return);
QTC_ASSERT(item->m_model == 0, return);
QTC_ASSERT(item->m_parent == 0, return);
QTC_CHECK(m_root);
if (m_root) {
QTC_CHECK(m_root->m_parent == 0);
......@@ -980,7 +974,7 @@ void TreeModel::setRootItem(TreeItem *item)
delete m_root;
}
m_root = item;
item->setModel(this);
item->propagateModel(this);
emit layoutChanged();
}
......
......@@ -101,7 +101,6 @@ public:
QModelIndex index() const;
TreeModel *model() const { return m_model; }
void setModel(TreeModel *model);
void walkTree(TreeItemVisitor *visitor);
void walkTree(std::function<void(TreeItem *)> f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment