void UmlTransition::generate(QList<UmlTransition> trs, UmlClass * machine, UmlClass * anystate, UmlState * state, QCString & body, QCString indent, bool completion) { UmlTransition * tr; bool guard = FALSE; for (tr = trs.first(); tr != 0; tr = trs.next()) { body += indent; if (!tr->cppGuard().isEmpty()) { // manage guard body += ((tr == trs.getFirst()) ? "if (" : "else if (") + tr->cppGuard() + ") {\n"; guard = TRUE; } else // no gard : it is the last transition, may be the first body += ((tr == trs.getFirst()) ? "{\n" : "else {\n"); // the target state UmlItem * tg = tr->target(); bool self_external = (state == tg) && tr->isExternal(); while (tg->kind() != aState) tg = tg->parent(); // the parent common to the current and the target state UmlState * common = state; if (self_external) { // execute exit behavior if (!state->cppExitBehavior().isEmpty()) body += indent + " _doexit(stm);\n"; } else { bool fromExit = // the exit behavior is made entering in the exit point (tr->parent()->kind() == anExitPointPseudoState); // compute common parent and manage exit behavior if (tr->target()->kind() != aTerminatePseudoState) { while (! ((UmlState *) tg)->inside(common)) { if (!fromExit && !common->cppExitBehavior().isEmpty()) body += indent + " stm" + common->path() + "._doexit(stm);\n"; fromExit = FALSE; switch (common->parent()->kind()) { case aState: common = (UmlState *) common->parent(); break; case aRegion: common = (UmlState *) common->parent()->parent(); break; default: UmlCom::trace("Error : transition from '" + state->name() + "' goes outside the state machine"); throw 0; } } } } // manage transition activity if (!tr->cppActivity().isEmpty()) body += "#ifdef VERBOSE_STATE_MACHINE\n" + indent + " puts(\"DEBUG : execute activity of transition " + tr->name() + "\");\n#endif\n" + tr->cppActivity(); // manage entry behavior if (self_external) { if (state->needCreate()) body += indent + " create(stm);\n"; } else if (tr->target()->kind() != aTerminatePseudoState) { if (tg != common) { QCString enter; UmlState * tg_parent; // the enter behavior of the target state will be managed // generating a call to create for (tg_parent = (UmlState *) tg->parent(); tg_parent != common; tg_parent = (UmlState *) tg_parent->parent()) if (!tg_parent->cppEntryBehavior().isEmpty()) enter.insert(0, indent + " stm" + tg_parent->path() + "._doentry(stm);\n"); if (!enter.isEmpty()) body += enter; } // set the current state if needed if (tg != state) body += indent + " stm._set_currentState(stm" + ((UmlState *) tg)->path() + ");\n#ifdef VERBOSE_STATE_MACHINE\n" + indent + " puts(\"DEBUG : current state is now " + ((UmlState *) tg)->prettyPath() + "\");\n#endif\n"; } // do the transition if (tr->target()->kind() == aState) { if ((tg != state) && ((UmlState *) tg)->needCreate()) body += indent + " stm" + ((UmlState *) tg)->path() + ".create(stm);\n"; } else tr->target()->generate(machine, anystate, ((UmlState *) tg), body, indent + " "); if (completion) body += indent + " return (bool) 1;\n"; body += indent + "}\n"; } if (completion && guard) body += indent + "return (bool) 0;\n"; }
//===================================== // XKeyboard virtual slots... //------------------------------------- bool XKeyboard::slotRun (int index) { if (XTemplate::slotRun (index)) { // log(L_INFO,"XKeyboard::slotRun() called: %d\n",index); // ... // this function is called if the keyboard page is activated. // use this function to init the dialog with the current // setup of the keyboard // --- XWrapPointer< QDict<char> > mText (mTextPtr); mStatus -> message (mText["RunXKeyboard"]); mFrame -> nextButton() -> setText (mText["finish"]); // ... // get the mFiles pointer wrapper from the Intro // object which has read all the data files. Than // lookup the keyboard XData object // --- QDict<XFile>* mFilePtr = mIntro->getFiles(); XWrapFile < QDict<XFile> > mFiles (mFilePtr); XData* sysData = mFiles["sys_KEYBOARD"] -> getDevice(0); if (! sysData) { return (FALSE); } QDict<char> keyboardInfo = sysData -> getData(); QString XKBLayouts = keyboardInfo["XkbLayout"]; QString XKBVariants = keyboardInfo["XkbVariant"]; QString XKBModel = keyboardInfo["XkbModel"]; //===================================== // clean QListView data fields //------------------------------------- mAddView -> clearSelection(); QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); item -> setOn ( false ); item -> setText ( 3 , "" ); } //===================================== // select base keyboard model //------------------------------------- QDictIterator<char> itModel (mModelHash); for (; itModel.current(); ++itModel) { if (itModel.currentKey() == XKBModel) { mType -> setCurrentText (QString::fromLocal8Bit (itModel.current())); } } //===================================== // get layout/variant lists //------------------------------------- XStringList completeLayout (XKBLayouts); completeLayout.setSeperator (","); QList<char> layoutList = completeLayout.getList(); QString baseLayout = layoutList.getFirst(); layoutList.removeFirst(); QStringList completeVariant = QStringList::split (",", XKBVariants,True); QList<char> variantList; QStringList::Iterator in; for (in = completeVariant.begin(); in != completeVariant.end(); ++in) { if (QString (*in).isEmpty()) { variantList.append ("!"); } else { variantList.append (*in); } } QString baseVariant = variantList.getFirst(); variantList.removeFirst(); int varCount = 0; //===================================== // select base/secondary layout(s) //------------------------------------- // 1) QDictIterator<char> itLayout (mLayoutHash); for (; itLayout.current(); ++itLayout) { if (itLayout.currentKey() == baseLayout) { mLayout -> setCurrentText (QString::fromLocal8Bit (itLayout.current())); } } // 2) QListIterator<char> it (layoutList); for (; it.current(); ++it) { QListViewItemIterator itAdd (mAddView); for ( ; itAdd.current(); ++itAdd ) { QCheckListItem* item = (QCheckListItem*)itAdd.current(); QString layout = itAdd.current()->text(2); if (layout == it.current()) { item -> setOn (true); if (QString(variantList.at(varCount)) != "!") { item -> setText ( 3 , variantList.at(varCount) ); } mAddView -> setSelected (itAdd.current(), true); mAddView -> ensureItemVisible (item); varCount++; } } } updateVariants(); //===================================== // select base/secondary variant(s) //------------------------------------- for (int n=0;n<mVariant->count();n++) { QString item = mVariant->text (n); if (item == baseVariant) { mVariant -> setCurrentText (baseVariant); } } } return (TRUE); }