void BrowserOperation::post_duplicate() { BrowserNode * x_of; void (BrowserOperation::*set_x_of)(BrowserNode *); if (get_of != 0) { x_of = get_of; get_of = 0; set_x_of = &BrowserOperation::set_get_of; } else if (set_of != 0) { x_of = set_of; set_of = 0; set_x_of = &BrowserOperation::set_set_of; } else return; // search for attribute/relation QString s = x_of->get_name(); UmlCode k = x_of->get_type(); BrowserNode * child; for (child = ((BrowserNode *)parent())->firstChild(); child != 0; child = child->nextSibling()) { if ((((BrowserNode *) child)->get_type() == k) && ((BrowserNode *) child)->get_name() == s) { // this one (this->*set_x_of)((BrowserNode *) child); break; } } }
void BrowserArtifact::prepare_update_lib() const { all.memo_id_oid(get_ident(), original_id); for (BrowserNode * child = firstChild(); child != 0; child = child->nextSibling()) ((BrowserNode *) child)->prepare_update_lib(); }
// just check if the inheritance already exist QString BrowserArtifact::check_inherit(const BrowserNode * new_parent) const { BrowserNode * child; for (child = firstChild(); child != 0; child = child->nextSibling()) { BrowserNode * ch = ((BrowserNode *) child); if ((ch->get_type() == UmlInherit) && ((((SimpleRelationData *) ch->get_data())->get_end_node()) == new_parent)) return QObject::tr("already exist"); } return (new_parent != this) ? QString() : QObject::tr("circular inheritance"); }
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); }
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(); }