예제 #1
0
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();
}
예제 #2
0
PseudoStateCanvas * PseudoStateCanvas::read(char * & st, UmlCanvas * canvas,
					char * k)
{
  if (!strcmp(k, "pseudostatecanvas_ref"))
    return ((PseudoStateCanvas *) dict_get(read_id(st), "PseudoStateCanvas", canvas));
  else if (!strcmp(k, "pseudostatecanvas")) {
    int id = read_id(st);
    BrowserPseudoState * ps = BrowserPseudoState::read_ref(st);
    PseudoStateCanvas * result = new PseudoStateCanvas(canvas, id);
    
    result->browser_node = ps;
    connect(ps->get_data(), SIGNAL(changed()), result, SLOT(modified()));
    connect(ps->get_data(), SIGNAL(deleted()), result, SLOT(deleted()));
    connect(DrawingSettings::instance(), SIGNAL(changed()), result, SLOT(modified()));

    k = read_keyword(st);
    
    if (!strcmp(k, "horizontal")) {
      result->horiz = TRUE;
      k = read_keyword(st);
    }
    
    if (!strcmp(k, "xyzwh")) {
      read_xyzwh(st, result);
      result->manual_size = TRUE;
    }
    else if (strcmp(k, "xyz"))
      wrong_keyword(k, "xyz");
    else
      read_xyz(st, result);
    
    if (!ps->allow_empty()) {
      result->label = new LabelCanvas(ps->get_name(), canvas, 0, 0);
      read_keyword(st, "label_xy");
      read_xy(st, result->label);
      result->label->setZ(result->z());
      result->label->set_center100();
    }

    if (read_file_format() >= 58) {
      k = read_keyword(st);
      result->read_stereotype_property(st, k);	// updates k
      
      if (strcmp(k, "end"))
	wrong_keyword(k, "end");
    }
    
    result->set_xpm();
    if (result->manual_size) {
      result->width_scale100 = result->width();
      result->height_scale100 = result->height();
    }
    result->set_center100();
    result->show();
    result->check_stereotypeproperties();
    
    if (canvas->paste())
      result->remove_if_already_present();
    
    return result;
  }
  else 
    return 0;
}