本文整理汇总了C++中EventData::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ EventData::addChild方法的具体用法?C++ EventData::addChild怎么用?C++ EventData::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventData
的用法示例。
在下文中一共展示了EventData::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activateNewEventItemMenu
void EventsWidget::activateNewEventItemMenu(QTreeWidgetItem *item) {
EventData *eventData = (EventData*) item->data(0, Qt::UserRole).value<void*>();
QMenu menu;
QAction *newCondition = menu.addAction(QString::fromUtf8(tr("Nova condição").toStdString().c_str()));
QAction *newAction = menu.addAction(QString::fromUtf8(tr("Nova ação").toStdString().c_str()));
QAction *newDialogue = menu.addAction(QString::fromUtf8(tr("Novo diálogo").toStdString().c_str()));
QAction *selectedAction = menu.exec(QCursor::pos());
if(selectedAction == newCondition) {
GameObject *gameObject = (GameObject*)
ui->comboBoxTarget->itemData(ui->comboBoxTarget->currentIndex(), Qt::UserRole).value<void*>();
eventsEditorController->openNewConditionWindow(eventData, gameObject);
QTreeWidgetItem *currentItem = ui->treeWidgetEvents->currentItem();
if(!eventData->newEvent) {
setTreeWidgetItemData(currentItem, eventData);
if(eventData->type == EventData::TYPE_CONDITION) {
EventData *childEventData = new EventData();
EventData *nextEventData = new EventData();
QTreeWidgetItem *child = new QTreeWidgetItem();
QTreeWidgetItem *next = new QTreeWidgetItem();
setTreeWidgetItemData(child, childEventData);
setTreeWidgetItemData(next, nextEventData);
currentItem->addChild(child);
eventData->addChild(childEventData);
if(currentItem->parent() != NULL) {
currentItem->parent()->addChild(next);
eventData->parent->addChild(nextEventData);
} else {
ui->treeWidgetEvents->addTopLevelItem(next);
ProcedureData *currentProcedure =
(ProcedureData*) ui->listWidgetProcedures->currentItem()->data(Qt::UserRole).value<void*>();
currentProcedure->events.push_back(nextEventData);
}
}
}
} else if(selectedAction == newAction) {
GameObject *gameObject = (GameObject*)
ui->comboBoxTarget->itemData(ui->comboBoxTarget->currentIndex(), Qt::UserRole).value<void*>();
eventsEditorController->openNewActionWindow(eventData, gameObject);
QTreeWidgetItem *currentItem = ui->treeWidgetEvents->currentItem();
if(!eventData->newEvent) {
setTreeWidgetItemData(currentItem, eventData);
if(eventData->type == EventData::TYPE_ACTION) {
EventData *nextEventData = new EventData();
QTreeWidgetItem *next = new QTreeWidgetItem();
setTreeWidgetItemData(next, nextEventData);
if(currentItem->parent() != NULL) {
currentItem->parent()->addChild(next);
eventData->parent->addChild(nextEventData);
} else {
ui->treeWidgetEvents->addTopLevelItem(next);
ProcedureData *currentProcedure =
(ProcedureData*) ui->listWidgetProcedures->currentItem()->data(Qt::UserRole).value<void*>();
currentProcedure->events.push_back(nextEventData);
}
}
}
} else if(selectedAction == newDialogue) {
eventsEditorController->openNewDialogueDialog(eventData);
//.........这里部分代码省略.........