当前位置: 首页>>代码示例>>C++>>正文


C++ EventData::addChild方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:slumki,项目名称:Gameka,代码行数:101,代码来源:eventswidget.cpp


注:本文中的EventData::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。