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: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-07-03 08:33:09 +02:00
parent 92f4ea3f79
commit 4363e3e9e4
2 changed files with 4 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -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);