Ejemplo n.º 1
0
void AnnotationDialog::add_annotation()
{
    const int ndefault =
        sizeof(DefaultAnnotations) / sizeof(*DefaultAnnotations);
    int added_index = cb->currentItem();
    QString added;

    if (added_index < ndefault)
        added = DefaultAnnotations[added_index];
    else {
        BrowserNode * cl = annotations.at(added_index - ndefault);
        added = cl->get_name();

        // have member ?
        int n = 0;
        QString first_name;
        Q3ListViewItem * child;

        for (child = cl->firstChild(); child != 0; child = child->nextSibling()) {
            if (!((BrowserNode *) child)->deletedp()) {
                switch (((BrowserNode *) child)->get_type()) {
                case UmlClass:
                case UmlExtraMember:
                    break;

                default:
                    switch (++n) {
                    case 1:
                        first_name = ((BrowserNode *) child)->get_name();
                        break;

                    case 2:
                        added += "(" + first_name + QString("=, ")
                                 + ((BrowserNode *) child)->get_name() + "=";
                        break;

                    default:
                        added += QString(", ") + ((BrowserNode *) child)->get_name() + QString("=");
                    }
                }
            }
        }

        switch (n) {
        case 0:
            break;

        case 1:
            added += "()";
            break;

        default:
            added += ")";
        }
    }

    e->insert("@" + added + "\n");
    e->setFocus();
}
Ejemplo n.º 2
0
StateDialog::StateDialog(StateData * d)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox( grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(state->get_stereotype()));

    if (!visit) {
        edstereotype->addItems(BrowserState::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);
    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    grid->addWidget(sButton);
    grid->addWidget(edspecification = new QComboBox(grid));
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->addItem("");
        else
            edspecification->addItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->addItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->addItems(speclist);
        edspecification->setCurrentIndex((state->get_specification() == 0)
                                         ? 0
                                         : opers.indexOf(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(sButton = new SmallPushButton(tr("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            grid->addWidget(sButton);
            grid->addWidget(edreference = new QComboBox(grid));
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->addItem("");
                else
                    edreference->addItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->addItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    QMutableListIterator<BrowserNode *> it(states);

                    while (it.hasNext()) {
                        BrowserState *state = (BrowserState *)it.next();
                        if (!((BrowserState *) bn)->can_reference(state) ||
                                state->is_ref()) {
                            it.remove();
                        }
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->addItems(reflist);
                edreference->setCurrentIndex((state->get_reference() == 0)
                                             ? 0
                                             : states.indexOf(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
Ejemplo n.º 3
0
StateDialog::StateDialog(StateData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    Q3Grid * grid;

    //
    // general tab
    //

    grid = new Q3Grid(2, this);
    umltab = grid;
    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(state->get_stereotype()));

    if (!visit) {
        edstereotype->insertStringList(BrowserState::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    connect(new SmallPushButton(TR("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    edspecification = new Q3ComboBox(FALSE, grid);
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->insertItem("");
        else
            edspecification->insertItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->insertItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->insertStringList(speclist);
        edspecification->setCurrentItem((state->get_specification() == 0)
                                        ? 0
                                        : opers.findRef(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            edreference = new Q3ComboBox(FALSE, grid);
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->insertItem("");
                else
                    edreference->insertItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->insertItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    BrowserNode * st = states.first();

                    while (st != 0) {
                        if (!((BrowserState *) bn)->can_reference((BrowserState *) st) ||
                            ((BrowserState *) st)->is_ref()) {
                            states.remove();
                            st = states.current();
                        }
                        else
                            st = states.next();
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->insertStringList(reflist);
                edreference->setCurrentItem((state->get_reference() == 0)
                                            ? 0
                                            : states.findRef(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
Ejemplo n.º 4
0
PseudoStateDialog::PseudoStateDialog(PseudoStateData * ps)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), pst(ps)
{
    BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node;
    BrowserState * refst;
    SmallPushButton* sButton;

    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.indexOf("_");

    if (index != -1)
        s.replace(index, 1, " ");

    setCaption((s + " dialog"));

    visit = !hasOkButton();

    // general tab

    GridBox * grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(TR("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(TR("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(pst->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(BrowserPseudoState::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(bn->get_type()));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    if (refst != 0) {
        connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                this, SLOT(menu_reference()));
        grid->addWidget(edreference = new QComboBox(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->addItem("");
            else
                edreference->addItem(ref->full_name(TRUE));
        }
        else {
            edreference->addItem("");
            edreference->setAutoCompletion(completion());

            BrowserNode * 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 (BrowserNode * 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->addItems(reflist);
            edreference->setCurrentIndex((ref == 0)
                                        ? 0
                                        : pseudostates.indexOf(ref) + 1);
        }
    }
    else
        edreference = 0;

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(TR("description :"), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(sButton);
    }

    grid->addWidget(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 GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, TR("Properties"));

    open_dialog(this);
}
Ejemplo n.º 5
0
void RelatedElementsDialog::accept() {
  bool inh = (inh_rb != 0) && inh_rb->isChecked();
  bool dep = dep_rb->isChecked();
  bool assoc = (assoc_rb != 0) && assoc_rb->isChecked();
  
  if (!inh && !dep && !assoc)
    return;

  bool sametype = sametype_rb->isChecked();
  UmlCode k = elt->get_type();
  
  elts.clear();

  Q3PtrDict<BrowserNode> d(71);
  BrowserNodeList added;
  int lvl = sb_level->value();
    
  added.append(elt);
  d.insert(elt, elt);
    
  do {
    BrowserNodeList newones;
    Q3PtrListIterator<BrowserNode> it(added);
    
    for (; it.current() != 0; ++it) {
      BrowserNode * e = (BrowserNode *) it.current();
      BrowserNode * bn;
      
      if (referenced_rb->isChecked()) {
	for (bn = (BrowserNode *) e->firstChild();
	     bn != 0;
	     bn = (BrowserNode *) bn->nextSibling()) {
	  if (! bn->deletedp()) {
	    BrowserNode * target;
	    
	    switch (bn->get_type()) {
	    case UmlAssociation:
	    case UmlDirectionalAssociation:
	    case UmlAggregation:
	    case UmlAggregationByValue:
	    case UmlDirectionalAggregation:
	    case UmlDirectionalAggregationByValue:
	      if (! assoc) continue;
	      target = ((RelationData *) bn->get_data())->get_end_class();
	      break;
	    case UmlDependency:
	      if (! dep) continue;
	      target = ((RelationData *) bn->get_data())->get_end_class();
	      break;
	    case UmlGeneralisation:
	    case UmlRealize:
	      if (! inh) continue;
	      target = ((RelationData *) bn->get_data())->get_end_class();
	      break;
	    case UmlDependOn:
	      if (! dep) continue;
	      target = ((SimpleRelationData *) bn->get_data())->get_end_node();
	      break;
	    case UmlInherit:
	      if (! inh) continue;
	      target = ((SimpleRelationData *) bn->get_data())->get_end_node();
	      break;
	    default:
	      continue;
	    }
	    
	    if ((sametype && (target->get_type() != k)) ||
		(d[target] != 0))
	      continue;
	    d.insert(target, target);
	    newones.append(target);
	  }
	}
      }
      
      if (referencing_rb->isChecked()) {
	if (e->get_type() == UmlClass)
	  BrowserRelation::get_relating(e, d, newones, inh, dep, assoc);
	BrowserSimpleRelation::get_relating(e, d, newones, inh, dep, sametype, k);
      }
    }
    
    added = newones;
  } while (--lvl != 0);
  
  d.remove(elt);
  
  Q3PtrDictIterator<BrowserNode> it(d);
  
  while (it.current()) {
    elts.append(it.current());
    ++it;
  }
  
  QDialog::accept();
}