void PseudoStateDialog::accept() { if (!check_edits(edits) || !kvtable->check_unique()) return; QString s = edname->text().stripWhiteSpace(); BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node; if ((s != bn->get_name()) && ((BrowserNode *) bn->parent())->wrong_child_name(s, UmlPseudoState, bn->allow_spaces(), bn->allow_empty())) { msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used")); return; } else bn->set_name(s); bool newst = pst->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace())); bn->set_comment(comment->text()); UmlWindow::update_comment_if_needed(bn); kvtable->updateNodeFromThis(bn); if (edreference != 0) { int index = reflist.findIndex(edreference->currentText()); BrowserPseudoState * ps; if (index != -1) { ps = (BrowserPseudoState *) pseudostates.at(index); if (! bn->can_reference(ps)) ps = 0; } else ps = 0; pst->set_reference(ps); } ProfiledStereotypes::modified(bn, newst); bn->modified(); bn->package_modified(); pst->modified(); Q3TabDialog::accept(); }
PseudoStateDialog::PseudoStateDialog(PseudoStateData * ps) : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), pst(ps) { BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node; BrowserState * refst; switch (bn->get_type()) { case EntryPointPS: case ExitPointPS: if (((BrowserNode *) bn->parent())->get_type() == UmlState) { refst = ((StateData *)((BrowserNode *) bn->parent())->get_data())->get_reference(); break; } // no break default: refst = 0; } bn->edit_start(); if (bn->is_writable()) { setOkButton(TR("OK")); setCancelButton(TR("Cancel")); } else { setOkButton(QString()); setCancelButton(TR("Close")); } QString s = stringify(bn->get_type()); int index = s.find("_"); if (index != -1) s.replace(index, 1, " "); setCaption(TR(s + " dialog")); visit = !hasOkButton(); // general tab Q3Grid * grid = new Q3Grid(2, this); grid->setMargin(5); grid->setSpacing(5); new QLabel(TR("name : "), grid); edname = new LineEdit(bn->get_name(), grid); edname->setReadOnly(visit); new QLabel(TR("stereotype : "), grid); edstereotype = new Q3ComboBox(!visit, grid); edstereotype->insertItem(toUnicode(pst->get_stereotype())); if (! visit) { edstereotype->insertStringList(BrowserPseudoState::default_stereotypes()); edstereotype->insertStringList(ProfiledStereotypes::defaults(bn->get_type())); edstereotype->setAutoCompletion(completion()); } edstereotype->setCurrentItem(0); QSizePolicy sp = edstereotype->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); edstereotype->setSizePolicy(sp); if (refst != 0) { connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()), this, SLOT(menu_reference())); edreference = new Q3ComboBox(FALSE, grid); edreference->setSizePolicy(sp); BrowserNode * ref = ((pst->get_reference() == 0) || !bn->can_reference(pst->get_reference())) ? 0 : pst->get_reference(); if (visit) { if (ref == 0) edreference->insertItem(""); else edreference->insertItem(ref->full_name(TRUE)); } else { edreference->insertItem(""); edreference->setAutoCompletion(completion()); Q3ListViewItem * child; UmlCode k = bn->get_type(); for (child = refst->firstChild(); child != 0; child = child->nextSibling()) { if (!((BrowserNode *) child)->deletedp()) { UmlCode kk = ((BrowserNode *) child)->get_type(); if (kk == k) pseudostates.append((BrowserNode *) child); else if (kk == UmlRegion) { for (Q3ListViewItem * schild = child->firstChild(); schild != 0; schild = schild->nextSibling()) { if (!((BrowserNode *) schild)->deletedp() && (((BrowserNode *) schild)->get_type() == k)) pseudostates.append((BrowserNode *) schild); } } } } pseudostates.sort(); pseudostates.full_names(reflist); edreference->insertStringList(reflist); edreference->setCurrentItem((ref == 0) ? 0 : pseudostates.indexOf(ref) + 1); } } else edreference = 0; Q3VBox * vtab = new Q3VBox(grid); new QLabel(TR("description :"), vtab); if (! visit) connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()), this, SLOT(edit_description())); comment = new MultiLineEdit(grid); comment->setReadOnly(visit); comment->setText(bn->get_comment()); QFont font = comment->font(); if (! hasCodec()) font.setFamily("Courier"); font.setFixedPitch(TRUE); comment->setFont(font); addTab(grid, "Uml"); // USER : list key - value grid = new Q3Grid(2, this); grid->setMargin(5); grid->setSpacing(5); kvtable = new KeyValuesTable(bn, grid, visit); addTab(grid, TR("Properties")); open_dialog(this); }