本文整理汇总了C++中ActionNode::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionNode::addChild方法的具体用法?C++ ActionNode::addChild怎么用?C++ ActionNode::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionNode
的用法示例。
在下文中一共展示了ActionNode::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
ActionChoiceWindow::ActionNode*
ActionChoiceWindow::ActionNode::createActionTree(const ActionVector& actions, ActionGroup* rootGroup)
{
ActionNode* root = new ActionNode(false);
root->setGroup(rootGroup);
set<ActionGroup*> groups;
ActionVector rest;
for (ActionVector::const_iterator iter = actions.begin(); iter != actions.end(); iter++)
{
Action* action = *iter;
ActionGroup* group = action->getGroup();
if (group == NULL || group == rootGroup )
rest.push_back(action);
else if (groups.find(group) == groups.end())
groups.insert(group);
}
if (actions.size() / 1.2 <= rest.size() + groups.size())
{
groups.clear();
rest = actions;
}
for (set<ActionGroup*>::iterator groupIter = groups.begin();
groupIter != groups.end(); groupIter++)
{
ActionVector actionsThisGroup;
ActionGroup* thisGroup = *groupIter;
for (ActionVector::const_iterator actionIter = actions.begin();
actionIter != actions.end(); actionIter++)
{
Action* action = *actionIter;
if (action->getGroup() == thisGroup)
actionsThisGroup.push_back(action);
}
if (actionsThisGroup.size() > 0)
{
ActionNode* actionNodeGroup = createActionTree(actionsThisGroup, thisGroup);
root->addChild(actionNodeGroup);
}
}
for (ActionVector::iterator iter = rest.begin(); iter != rest.end(); iter++)
{
ActionNode* node = new ActionNode(true);
node->setAction(*iter);
root->addChild(node);
}
return root;
}