void Skein::Trim(Node* node, bool running, bool notify) { int i = 0; while (i < node->GetNumChildren()) { Node* child = node->GetChild(i); bool inCurrent = InCurrentThread(child); // Only delete unlocked nodes. If the game is running, only delete // if the node is not in the current thread as well. if (child->GetTemporary() && !(running && inCurrent)) { if (inCurrent) { m_current = m_root; m_played = m_root; } if (RemoveAll(child,false) == false) i++; } else { Trim(child,running,false); i++; } } if (notify) NotifyChange(TreeChanged); }
bool Skein::RemoveSingle(Node* node) { bool removed = false; Node* parent = node->GetParent(); if (parent != NULL) { bool inCurrent = InCurrentThread(node); removed = parent->RemoveSingle(node); if (inCurrent) { m_inst.current = m_inst.root; m_played = m_inst.root; } m_layout = false; NotifyChange(TreeChanged); } if (removed) NotifyEdit(true); return removed; }
void Skein::Trim(Node* node, bool running, bool notify) { // Only delete unlocked nodes. If the game is running, only delete // if the node is not in the current thread as well. bool inCurrent = InCurrentThread(node); if ((node->GetParent() != NULL) && !node->GetLocked() && !(running && inCurrent)) { if (inCurrent) { m_inst.current = m_inst.root; m_played = m_inst.root; } RemoveAll(node,false); } else { // Since this may remove child nodes, run through in reverse for (int i = node->GetNumChildren()-1; i >= 0; i--) Trim(node->GetChild(i),false); } if (notify) NotifyChange(TreeChanged); }