I currently have a problem in my DB Tree.
First of all I create a directory, so I test if it exists or not and I do:
Code: Select all
if (!CVisee_group)
{
CVisee_group = new ccHObject(type);
m_app->dbRootObject()->addChild(CVisee_group);
m_app->addToDB(CVisee_group, false, true, false, false);
}
Code: Select all
m_pParentFolderVisee->addChild(pVisee);
m_app->addToDB(pVisee, false, true, false, false);
I can delete my CustomHObject like that:
Code: Select all
ccHObject* root = m_app->dbRootObject();
ccHObject* pChildren = NULL;
for (int i =0; i < root->getChildrenNumber(); i++)
{
pChildren = root->getChild(i);
if (pChildren && pChildren->isKindOf(CC_TYPES::HIERARCHY_OBJECT))
{
ccHObject* pChildren2 = NULL;
for (int j = 0;j < pChildren->getChildrenNumber(); j++)
{
pChildren2 = pChildren->getChild(j);
if (ident == (pChildren2->getMetaData("ident").toInt()))
{
m_app->removeFromDB(pChildren2);
}
}
}
}
Code: Select all
int ccHObject::getIndex() const
{
return (m_parent ? m_parent->getChildIndex(this) : -1);
}
If I delete my CustomHObject in another way like this:
Code: Select all
pChildren2->getParent()->removeChild(pChildren2);
Would you have a correct method to better manage the addition and deletion of Objects in the dbtree
cheers