本文整理汇总了C++中TreeNode::GetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::GetElement方法的具体用法?C++ TreeNode::GetElement怎么用?C++ TreeNode::GetElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::GetElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
BST T;
T.InsertBST(8,"龜仙人");
T.InsertBST(1000,"悟空");
T.InsertBST(2,"克林");
T.InsertBST(513,"比克");
cout << "Inorder Traversal:\n";
T.InorderPrint();
cout << endl;
cout << "Level-order Traversal:\n";
T.Levelorder();
cout << endl;
TreeNode *node = T.Search(1000);
if(node != NULL){
cout << "There is " << node->GetElement() << "(" << node->GetKey() << ")" << endl;
}
else {
cout << "no element with Key(1000)" << endl;
}
node = T.Search(73);
if(node != NULL){
cout << "There is " << node->GetElement() << "(" << node->GetKey() << ")" << endl;
}
else {
cout << "no element with Key(73)" << endl;
}
return 0;
}
示例2: 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();
}
示例3:
dbc::ElementGuard model::DbContainerModel::GetElementByIndex(const QModelIndex& index)
{
dbc::ElementGuard element;
TreeNode* node = Index2Node(index);
if (node != nullptr)
{
element = node->GetElement();
}
return element;
}
示例4: dataChanged
void model::DbContainerModel::SetNodeName(const QModelIndex& index, const QString& name)
{
DBC_MODEL_TRY(tr("Set element name"));
TreeNode* node = Index2Node(index);
assert(node != nullptr);
node->GetElement()->Rename(utils::QString2StdString(name));
node->RefreshPath();
emit dataChanged(index, index);
DBC_MODEL_CATCH;
}
示例5: GetDisplayData
QVariant model::DbContainerModel::data(const QModelIndex& index, int role) const
{
TreeNode* node = Index2Node(index);
if (node != nullptr)
{
switch (role)
{
case Qt::DisplayRole:
case ItemNameRole:
return GetDisplayData(node, index.row());
case ItemTypeRole:
return QVariant::fromValue(node->GetElement()->Type());
case ItemSizeRole:
return GetSizeData(node);
default:
return QVariant();
}
}
return QVariant();
}