//----------------------------------------------------------------------------- int ctkWorkflowWidgetTest2(int argc, char * argv [] ) { QApplication app(argc, argv); int defaultTime = 100; bool hideWidgets = false; ctkWorkflow* workflow = new ctkWorkflow; ctkWorkflowWidget* workflowWidget = new ctkWorkflowWidget; workflowWidget->setWorkflow(workflow); ctkWorkflowGroupBox* groupBox = workflowWidget->workflowGroupBox(); groupBox->setPreText("I am some pre-text"); groupBox->setPostText("I am some post-text"); groupBox->setHideWidgetsOfNonCurrentSteps(hideWidgets); // create and add the first workflow step (depends on workflowWidget // type) ctkWorkflowWidgetStep* step1 = new ctkWorkflowWidgetStep("Step 1"); step1->setName("Step 1"); step1->setDescription("I am in step 1"); if (ctkWorkflowTabWidget* tabWidget = qobject_cast<ctkWorkflowTabWidget*>(workflowWidget)) { tabWidget->associateStepWithLabel(step1, "tab1"); } // step1 is the initial step workflow->setInitialStep(step1); // create and add the second workflow step (depends on // workflowWidget type) ctkWorkflowWidgetStep* step2 = new ctkWorkflowWidgetStep("Step 2"); step2->setName("Step 2"); step2->setDescription("I am in step 2"); if (ctkWorkflowTabWidget* tabWidget = qobject_cast<ctkWorkflowTabWidget*>(workflowWidget)) { tabWidget->associateStepWithLabel(step2, "tab2"); } // add the steps to the workflow workflow->addTransition(step1, step2); // create the qObjects that implement the required functions, and // communicate with the workflow using signals and slots ctkExampleWorkflowWidgetStepUsingSignalsAndSlots* qObject1 = new ctkExampleWorkflowWidgetStepUsingSignalsAndSlots(step1); ctkExampleWorkflowWidgetStepUsingSignalsAndSlots* qObject2 = new ctkExampleWorkflowWidgetStepUsingSignalsAndSlots(step2); // set the widget for each qObject qObject1->setWidget(step1->stepArea()); qObject2->setWidget(step2->stepArea()); // use the qObjects for validation QObject::connect(step1->ctkWorkflowStepQObject(), SIGNAL(invokeValidateCommand(QString)), qObject1, SLOT(validate(QString))); QObject::connect(step2->ctkWorkflowStepQObject(), SIGNAL(invokeValidateCommand(QString)), qObject2, SLOT(validate(QString))); // use the qObjects for entry processing QObject::connect(step1->ctkWorkflowStepQObject(), SIGNAL(invokeOnEntryCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject1, SLOT(onEntry(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); QObject::connect(step2->ctkWorkflowStepQObject(), SIGNAL(invokeOnEntryCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject2, SLOT(onEntry(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); // use the qObjects for exit processing QObject::connect(step1->ctkWorkflowStepQObject(), SIGNAL(invokeOnExitCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject1, SLOT(onExit(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); QObject::connect(step2->ctkWorkflowStepQObject(), SIGNAL(invokeOnExitCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject2, SLOT(onExit(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); // use the qObjects for populating the stepWidgetsList QObject::connect(step1->ctkWorkflowStepQObject(), SIGNAL(invokeCreateUserInterfaceCommand()), qObject1, SLOT(createUserInterface())); QObject::connect(step2->ctkWorkflowStepQObject(), SIGNAL(invokeCreateUserInterfaceCommand()), qObject2, SLOT(createUserInterface())); step1->setHasValidateCommand(1); step2->setHasValidateCommand(1); step1->setHasOnEntryCommand(1); step2->setHasOnEntryCommand(1); step1->setHasOnExitCommand(1); step2->setHasOnExitCommand(1); step1->setHasCreateUserInterfaceCommand(1); step2->setHasCreateUserInterfaceCommand(1); // start the workflow workflow->start(); workflowWidget->show(); // first user interaction test if (userInteractionSimulator1(app, step1, qObject1, step2, qObject2, workflow, workflowWidget, defaultTime) == EXIT_FAILURE) { return EXIT_FAILURE; } // stop the workflow workflow->stop(); QTimer::singleShot(defaultTime, &app, SLOT(quit())); app.exec(); // create and add a third workflow step (depends on workflowWidget // type) ctkWorkflowWidgetStep* step3 = new ctkWorkflowWidgetStep("Step 3"); step3->setName("Step 3"); step3->setDescription("I am in step 3"); if (ctkWorkflowStackedWidget* stackedWidget = qobject_cast<ctkWorkflowStackedWidget*>(workflowWidget)) { stackedWidget->associateStepWithPage(step3, 1); } else if (ctkWorkflowTabWidget* tabWidget = qobject_cast<ctkWorkflowTabWidget*>(workflowWidget)) { tabWidget->associateStepWithPage(step3, 1, "tab2"); } // icon test - add an icon to step3, should show up as a icon on the finish button step3->setIcon(step3->stepArea()->style()->standardIcon(QStyle::SP_ArrowUp)); // add the step to the workflow workflow->addTransition(step2, step3); // create the qObjects that implement the required functions, and // communicate with the workflow using signals and slots ctkExampleWorkflowWidgetStepUsingSignalsAndSlots* qObject3 = new ctkExampleWorkflowWidgetStepUsingSignalsAndSlots(step3); qObject3->setWidget(step3->stepArea()); // use the qObjects for validation QObject::connect(step3->ctkWorkflowStepQObject(), SIGNAL(invokeValidateCommand(QString)), qObject3, SLOT(validate(QString))); // use the qObjects for entry processing QObject::connect(step3->ctkWorkflowStepQObject(), SIGNAL(invokeOnEntryCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject3, SLOT(onEntry(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); // use the qObjects for exit processing QObject::connect(step3->ctkWorkflowStepQObject(), SIGNAL(invokeOnExitCommand(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType)), qObject3, SLOT(onExit(const ctkWorkflowStep*,ctkWorkflowInterstepTransition::InterstepTransitionType))); // use the qObjects for populating the stepWidgetsList QObject::connect(step3->ctkWorkflowStepQObject(), SIGNAL(invokeCreateUserInterfaceCommand()), qObject3, SLOT(createUserInterface())); QObject::connect(qObject3, SIGNAL(createUserInterfaceComplete()), step3->ctkWorkflowStepQObject(), SIGNAL(createUserInterfaceComplete())); step3->setHasValidateCommand(1); step3->setHasOnEntryCommand(1); step3->setHasOnExitCommand(1); step3->setHasCreateUserInterfaceCommand(1); // restart the workflow workflow->start(); // second user interaction test if (userInteractionSimulator2(app, step1, qObject1, step2, qObject2, step3, qObject3, workflow, workflowWidget, defaultTime) == EXIT_FAILURE) { return EXIT_FAILURE; } // stop the workflow workflow->stop(); QTimer::singleShot(defaultTime, &app, SLOT(quit())); app.exec(); // make the second workflow step a finish step as well // TODO put this back once we can add multiple finish steps // finishSteps.push_back(step2); // step1->setFinishStepsToHaveButtonsInStepArea(finishSteps); // step2->setFinishStepsToHaveButtonsInStepArea(finishSteps); // step3->setFinishStepsToHaveButtonsInStepArea(finishSteps); // // workflow->addFinishStep(step2); // // restart the workflow // workflow->start(); // QTimer::singleShot(defaultTime, &app, SLOT(quit())); // app.exec(); // // third user interfaction test // if (userInteractionSimulator3(app, step1, qObject1, step2, qObject2, step3, qObject3, workflow, workflowWidget, defaultTime) == EXIT_FAILURE) // { // return EXIT_FAILURE; // } // // stop the workflow // workflow->stop(); // QTimer::singleShot(defaultTime, &app, SLOT(quit())); // app.exec(); // handles deletion of the workflowWidget, workflow, steps, states // and transitions delete workflowWidget; return EXIT_SUCCESS; }
// -------------------------------------------------------------------------- void ctkWorkflowStepPrivate::invokeValidateCommandInternal(const QString& desiredBranchId)const { emit invokeValidateCommand(desiredBranchId); }