-ProfileNode* ProfileNode::traverseNextNodePreOrder(bool processChildren) const
-{
- if (processChildren && m_children.size())
- return m_children[0].get();
-
- if (m_nextSibling)
- return m_nextSibling;
-
- ProfileNode* nextParent = m_parent;
- if (!nextParent)
- return 0;
-
- ProfileNode* next;
- for (next = m_parent->nextSibling(); !next; next = nextParent->nextSibling()) {
- nextParent = nextParent->parent();
- if (!nextParent)
- return 0;
- }
-
- return next;
-}
-
-void ProfileNode::setTreeVisible(ProfileNode* node, bool visible)
-{
- ProfileNode* nodeParent = node->parent();
- ProfileNode* nodeSibling = node->nextSibling();
- node->setParent(0);
- node->setNextSibling(0);
-
- for (ProfileNode* currentNode = node; currentNode; currentNode = currentNode->traverseNextNodePreOrder())
- currentNode->setVisible(visible);
-
- node->setParent(nodeParent);
- node->setNextSibling(nodeSibling);
-}
-
-void ProfileNode::calculateVisibleTotalTime()
-{
- double sumOfVisibleChildrensTime = 0.0;
-
- for (unsigned i = 0; i < m_children.size(); ++i) {
- if (m_children[i]->visible())
- sumOfVisibleChildrensTime += m_children[i]->totalTime();
- }
-
- m_visibleTotalTime = m_visibleSelfTime + sumOfVisibleChildrensTime;
-}
-
-bool ProfileNode::focus(const CallIdentifier& callIdentifier)
-{
- if (!m_visible)
- return false;
-
- if (m_callIdentifier != callIdentifier) {
- m_visible = false;
- return true;
- }
-
- for (ProfileNode* currentParent = m_parent; currentParent; currentParent = currentParent->parent())
- currentParent->setVisible(true);
-
- return false;
-}
-
-void ProfileNode::exclude(const CallIdentifier& callIdentifier)
-{
- if (m_visible && m_callIdentifier == callIdentifier) {
- setTreeVisible(this, false);
-
- m_parent->setVisibleSelfTime(m_parent->selfTime() + m_visibleTotalTime);
- }
-}
-
-void ProfileNode::restore()
-{
- m_visibleTotalTime = m_actualTotalTime;
- m_visibleSelfTime = m_actualSelfTime;
- m_visible = true;
-}
-