本文整理汇总了C++中BrowserNode::TypeID方法的典型用法代码示例。如果您正苦于以下问题:C++ BrowserNode::TypeID方法的具体用法?C++ BrowserNode::TypeID怎么用?C++ BrowserNode::TypeID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BrowserNode
的用法示例。
在下文中一共展示了BrowserNode::TypeID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddOperation
void QuickEdit::AddOperation()
{
QModelIndex current = ui->tvEditor->selectionModel()->currentIndex();
if(!current.isValid())
return;
current = current.sibling(current.row(), 0);
TreeItemInterface *itemAsInterface = static_cast<TreeItemInterface*>(current.internalPointer());
BrowserNode* currentNode = static_cast<BrowserNode*>(itemAsInterface->InternalPointer());
BrowserClass* classNode;
int newItemPosition = 0;
if(currentNode->TypeID() == TypeIdentifier<BrowserClass>::id())
{
classNode = static_cast<BrowserClass*>(currentNode);
newItemPosition = itemAsInterface->childCount();
}
else if(currentNode->TypeID() == TypeIdentifier<BrowserOperation>::id() && current.parent().isValid())
{
itemAsInterface = static_cast<TreeItemInterface*>(current.parent().internalPointer());
classNode = static_cast<BrowserClass*>(itemAsInterface->InternalPointer());
newItemPosition = current.row()+1;
current = current.parent();
}
else
return;
if(!classNode)
return;
BrowserOperation* newOperation = static_cast<BrowserOperation*>(classNode->addOperation());
classNode->move(newOperation, currentNode);
classNode->select_in_browser();
QModelIndex parentIndex;
TreeItemInterface* parent;
if(treeModel->parent(current).isValid())
{
parentIndex = treeModel->parent(current);
parentIndex = parentIndex.sibling(parentIndex.row(), 0);
parent = static_cast<TreeItemInterface*>(parentIndex.internalPointer());
}
else
parent = treeModel->RootItem();
int insertIndex = parent->GetIndexOfChild(itemAsInterface);
QSharedPointer<TreeItemInterface> sharedOfOperation = parent->GetChildren()[insertIndex];
if(!treeModel->insertRows(newItemPosition-1, 1, current))
return;
if(!current.isValid())
return;
QModelIndex newItem = treeModel->index(newItemPosition-1,0,current);
TreeItemInterface *newItemInterface = static_cast<TreeItemInterface*>(newItem.internalPointer());
TreeItem<BrowserNode>* newItemAsNode = static_cast<TreeItem<BrowserNode>*>(newItemInterface);
newItemAsNode->SetController(operationController);
newItemAsNode->SetParent(sharedOfOperation);
newItemAsNode->SetInternalData(newOperation);
}
示例2: AddParameter
void QuickEdit::AddParameter()
{
QModelIndex current = ui->tvEditor->selectionModel()->currentIndex();
if (!current.isValid())
return;
current = current.sibling(current.row(), 0);
TreeItemInterface* itemAsInterface = static_cast<TreeItemInterface*>(current.internalPointer());
BrowserNode* currentNode = static_cast<BrowserNode*>(itemAsInterface->InternalPointer());
BrowserOperation* operationNode;
if (currentNode->TypeID() == TypeIdentifier<BrowserOperation>::id())
{
operationNode = static_cast<BrowserOperation*>(currentNode);
}
else if (currentNode->TypeID() == TypeIdentifier<BrowserOperationAttribute>::id())
{
operationNode = static_cast<BrowserOperationAttribute*>(currentNode)->get_operation();
itemAsInterface = itemAsInterface->parent();
current = current.parent();
}
else
return;
OperationData* currentData = static_cast<OperationData*>(operationNode->get_data());
int originalParamCount = currentData->nparams;
currentData->set_n_params(originalParamCount + 1);
QModelIndex parentIndex = current.parent();
parentIndex = parentIndex.sibling(parentIndex.row(), 0);
TreeItemInterface* parent = static_cast<TreeItemInterface*>(parentIndex.internalPointer());
if (!parent)
parent = treeModel->RootItem();
int insertIndex = parent->GetIndexOfChild(itemAsInterface);
auto sharedOfOperation = parent->GetChildren()[insertIndex];
int newItemPosition = currentData->nparams;
if (!treeModel->insertRows(sharedOfOperation->childCount(), 1, current))
return;
QSharedPointer<BrowserNode> param(new BrowserOperationAttribute(dummyView,
static_cast<BrowserOperation*>(operationNode),
currentData->params.last()));
localNodeHolder.push_back(param);
if (!current.isValid())
return;
QModelIndex newItem = treeModel->index(sharedOfOperation->childCount() - 1, 0, current);
TreeItemInterface *newItemInterface = static_cast<TreeItemInterface*>(newItem.internalPointer());
TreeItem<BrowserNode>* newItemAsNode = static_cast<TreeItem<BrowserNode>*>(newItemInterface);
newItemAsNode->SetController(operationAttributeController);
newItemAsNode->SetParent(sharedOfOperation);
newItemAsNode->SetInternalData(param.data());
operationNode->modified();
OperationFuncs::recompute_param(operationNode, newItemPosition - 1, true);
}
示例3: OnContextMenu
void QuickEdit::OnContextMenu(QPoint point)
{
QModelIndex current = ui->tvEditor->selectionModel()->currentIndex();
if(!current.isValid())
return;
current = current.sibling(current.row(), 0);
TreeItemInterface *itemAsInterface = static_cast<TreeItemInterface*>(current.internalPointer());
BrowserNode* currentNode = static_cast<BrowserNode*>(itemAsInterface->InternalPointer());
if(!itemAsInterface)
return;
CreateMenu();
SetupMenu(itemAsInterface);
if(currentNode->TypeID() != TypeIdentifier<BrowserOperationAttribute>::id())
{
contextMenu->removeAction(actBefore);
contextMenu->removeAction(actAfter);
}
contextMenu->popup(ui->tvEditor->mapToGlobal(point));
}