本文整理汇总了C++中TreeNode::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::AddChild方法的具体用法?C++ TreeNode::AddChild怎么用?C++ TreeNode::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::AddChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QModelIndex
QModelIndex model::DbContainerModel::AddElement(dbc::ElementType type, const QString& name, const QModelIndex& parent)
{
assert(!name.isEmpty() && type != dbc::ElementTypeUnknown && parent.isValid());
if (name.isEmpty() || type == dbc::ElementTypeUnknown || !parent.isValid())
{
return QModelIndex();
}
TreeNode* parentNode = Index2Node(parent);
dbc::Folder* folder = parentNode->GetElement()->AsFolder();
assert(folder != nullptr);
if (folder == nullptr)
{
return QModelIndex();
}
LoadChildren(parent);
dbc::ElementGuard element = folder->CreateChild(utils::QString2StdString(name), type);
DBC_MODEL_TRY(tr("Element adding"));
int insertedRow = parentNode->GetChildrenCount();
beginInsertRows(parent, insertedRow, insertedRow);
TreeNode* insertedNode = parentNode->AddChild(element);
assert(insertedRow + 1 == parentNode->GetChildrenCount());
endInsertRows();
return createIndex(insertedRow, 0, insertedNode);
DBC_MODEL_CATCH;
element->Remove();
return QModelIndex();
}
示例2: OnSerializeTo
void Decal::OnSerializeTo (TreeNode& root) const
{
if (mShader != 0) root.AddChild("Shader", mShader->GetName());
root.AddChild("Color", mColor);
if (mTextures.IsValid())
{
TreeNode& node = root.AddChild("Textures");
Array<String>& list = node.mValue.ToStringArray();
for (uint i = 0; i < mTextures.GetSize(); ++i)
{
const ITexture* tex = mTextures[i];
if (tex != 0) list.Expand() = tex->GetName();
}
}
}
示例3: rand
void RamAi::GameMonteCarloTree::PerformExpansion(TreeNode &nodeToBeExpanded)
{
std::vector<ButtonSet> allInputCombinations = std::move(ConsoleSettings::GetSpecs().GetAllInputCombinations());
//Select and add one child at random.
while (allInputCombinations.size() > 0)
{
const size_t chosenIndex = rand() % allInputCombinations.size();
//Add the action to the tree if it is unique.
if (!nodeToBeExpanded.ContainsAction(allInputCombinations[chosenIndex]))
{
nodeToBeExpanded.AddChild(allInputCombinations[chosenIndex]);
break;
}
//Otherwise, discard it.
else
{
allInputCombinations.erase(allInputCombinations.begin() + chosenIndex);
}
}
}
示例4: dataChanged
void model::DbContainerModel::LoadChildren(const QModelIndex& parent)
{
TreeNode* node = Index2Node(parent);
assert(node != nullptr);
dbc::ElementGuard element = node->GetElement();
if (!node->wasLoaded && element->Type() == dbc::ElementTypeFolder)
{
dbc::Folder* folder = element->AsFolder();
assert(folder != nullptr);
dbc::DbcElementsIterator iterator = folder->EnumFsEntries();
if (iterator->HasNext())
{
beginInsertRows(parent, 0, iterator->Count() - 1);
int row = 0;
for (; iterator->HasNext(); ++row)
{
node->AddChild(iterator->Next());
}
endInsertRows();
}
}
node->wasLoaded = true;
emit dataChanged(parent, parent);
}
示例5: OnSerializeTo
void OSAttachToBone::OnSerializeTo (TreeNode& node) const
{
node.AddChild("Bone", mName);
}
示例6: OnSerializeTo
void OSRotate::OnSerializeTo (TreeNode& node) const
{
node.AddChild("Axis", mAxis);
node.AddChild("Rate", mRate);
}