void CodAddMsgDialog::menu_op() { QPopupMenu m(0); m.insertItem(TR("Choose"), -1); m.insertSeparator(); int index = list.findIndex(edoper->currentText().stripWhiteSpace()); if (index != -1) m.insertItem(TR("Select in browser"), 0); BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp() && (opers.findIndex((OperationData *) bn->get_data()) != -1)) m.insertItem(TR("Choose operation selected in browser"), 1); else bn = 0; if (cl != 0) m.insertItem(TR("Create operation and choose it"), 2); if ((index != -1) || (bn != 0) || (cl != 0)) { switch (m.exec(QCursor::pos())) { case 0: opers[index]->get_browser_node()->select_in_browser(); break; case 2: bn = cl->add_operation(); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { OperationData * od = (OperationData *) bn->get_data(); if ((index = opers.findIndex(od)) == -1) { index = opers.count(); opers.append(od); QString s = od->definition(TRUE, FALSE); list.append(s); edoper->insertItem(s); } } edoper->setCurrentItem(index + 1); } } }
// have marked elements not yet drawn ? static bool marked_not_yet_drawn(Q3PtrDict<DiagramItem> & drawn) { const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes(); Q3PtrListIterator<BrowserNode> it(l); BrowserNode * bn; for (; (bn = it.current()) != 0; ++it) { UmlCode k = bn->get_type(); switch (k) { default: if (!IsaSimpleRelation(k)) break; // no break case UmlComponent: case UmlDeploymentNode: case UmlArtifact: case UmlPackage: if (drawn[bn->get_data()] == 0) return TRUE; } } return FALSE; }
// the relation is not yet drawn, void SimpleRelationCanvas::drop(BrowserNode * bn, UmlCanvas * canvas, Q3PtrDict<DiagramItem> & drawn) { SimpleRelationData * def = (SimpleRelationData *) bn->get_data(); BrowserNode * from = def->get_start_node(); BrowserNode * to = def->get_end_node(); DiagramItem * ccfrom = drawn[from->get_data()]; DiagramItem * ccto = drawn[to->get_data()]; if ((ccfrom != 0) && (ccto != 0)) { SimpleRelationCanvas * rel = new SimpleRelationCanvas(canvas, ccfrom, ccto, from, bn->get_type(), 0, -1.0, -1.0, def); rel->show(); rel->package_modified(); drawn.replace(def, rel); // package set modified by caller } }
// 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"); }
// returns all parents for NON class Q3PtrList<BrowserNode> BrowserNode::parents() const { Q3PtrList<BrowserNode> l; Q3ListViewItem * child; for (child = firstChild(); child != 0; child = child->nextSibling()) { BrowserNode * ch = ((BrowserNode *) child); switch (ch->get_type()) { case UmlInherit: if (!ch->deletedp()) l.append(((SimpleRelationData *) ch->get_data()) ->get_end_node()); default: break; } } return l; }
void BrowserNodeList::search_ddb(BrowserNode * bn, UmlCode k, const QString & s, bool cs, bool even_deleted) { Q3ListViewItem * child; for (child = bn->firstChild(); child != 0; child = child->nextSibling()) { if (even_deleted || !((BrowserNode *) child)->deletedp()) { BrowserNode * ch = (BrowserNode *) child; if (((k == UmlCodeSup) || ((k == UmlRelations) ? IsaRelation(ch->get_type()) : (ch->get_type() == k))) && (s.isEmpty() || ch->get_data()->decldefbody_contain(s, cs, ch))) append(ch); search_ddb(ch, k, s, cs, even_deleted); } } }
void FragmentCanvas::open() { static QStringList dflt; if (dflt.isEmpty()) { dflt.append("alt"); dflt.append("assert"); dflt.append("break"); dflt.append("consider"); dflt.append("critical"); dflt.append("ignore"); dflt.append("loop"); dflt.append("neg"); dflt.append("opt"); dflt.append("par"); dflt.append("ref"); dflt.append("seq"); dflt.append("strict"); } BrowserNode * refered = refer; FragmentDialog d(dflt, name, form, refer); d.raise(); if (d.exec() == QDialog::Accepted) { if (refer != refered) { if (refered != 0) { disconnect(refered->get_data(), SIGNAL(changed()), this, SLOT(modified())); disconnect(refered->get_data(), SIGNAL(deleted()), this, SLOT(modified())); } if (refer != 0) { connect(refer->get_data(), SIGNAL(changed()), this, SLOT(modified())); connect(refer->get_data(), SIGNAL(deleted()), this, SLOT(modified())); } } modified(); } }
void CodChangeMsgDialog::menu_op() { QMenu m(0); MenuFactory::addItem(m, tr("Choose"), -1); m.addSeparator(); int index = list.indexOf(edoper->currentText().trimmed()); if (index != -1) MenuFactory::addItem(m, tr("Select in browser"), 0); BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp() && (opers.indexOf((OperationData *) bn->get_data()) != -1)) MenuFactory::addItem(m, tr("Choose operation selected in browser"), 1); else bn = 0; if (cl != 0) MenuFactory::addItem(m, tr("Create operation and choose it"), 2); if ((index != -1) || (bn != 0) || (cl != 0)) { QAction* retAction = m.exec(QCursor::pos()); if(retAction) { switch (retAction->data().toInt()) { case 0: opers[index]->get_browser_node()->select_in_browser(); break; case 2: bn = cl->add_operation(); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { OperationData * od = (OperationData *) bn->get_data(); if ((index = opers.indexOf(od)) == -1) { index = opers.count(); opers.append(od); QString s = od->definition(TRUE, FALSE); list.append(s); edoper->addItem(s); } } edoper->setCurrentIndex(index + 1); } } } }
void ComponentDiagramView::add_related_elements(DiagramItem * di, QString what, bool inh, bool assoc) { BrowserNodeList l; RelatedElementsDialog dialog(di->get_bn(), what, inh, assoc, l); dialog.raise(); if (dialog.exec() == QDialog::Accepted) { QApplication::setOverrideCursor(Qt::waitCursor); DiagramItemList items(canvas()->allItems()); Q3PtrDict<DiagramItem> drawn; get_drawn(items, drawn); history_save(); history_protected = TRUE; int xmax = canvas()->width() - Diagram_Margin; int ymax = canvas()->height() - Diagram_Margin; QRect re = di->rect(); int x = re.x(); int y = re.bottom() + Diagram_Margin; int future_y = y; Q3PtrListIterator<BrowserNode> it(l); BrowserNode * bn; for (; (bn = it.current()) != 0; ++it) { if (drawn[bn->get_data()] == 0) { DiagramCanvas * dc; switch (bn->get_type()) { case UmlComponent: dc = new ComponentCanvas(bn, the_canvas(), x, y); break; case UmlPackage: dc = new PackageCanvas(bn, the_canvas(), x, y, 0); break; default: continue; } drawn.replace(dc->get_bn()->get_data(), dc); if ((x + dc->width()) > xmax) dc->move(x = Diagram_Margin, y = future_y); if (y + dc->height() > ymax) { dc->move(x = Diagram_Margin, y = Diagram_Margin); future_y = y + dc->height() + Diagram_Margin; } else { int bot = y + dc->height() + Diagram_Margin; if (bot > future_y) future_y = bot; } x = x + dc->width() + Diagram_Margin; dc->show(); dc->upper(); } } canvas()->update(); history_protected = FALSE; window()->package_modified(); QApplication::restoreOverrideCursor(); } }
void ComponentDiagramView::add_marked_elements(const QPoint& p, Q3PtrDict<DiagramItem> & drawn) { QApplication::setOverrideCursor(Qt::waitCursor); history_save(); history_protected = TRUE; int xmax = canvas()->width() - Diagram_Margin; int ymax = canvas()->height() - Diagram_Margin; int x = p.x(); int y = p.y(); int future_y = y; const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes(); Q3PtrListIterator<BrowserNode> it(l); BrowserNode * bn; for (; (bn = it.current()) != 0; ++it) { if (drawn[bn->get_data()] == 0) { DiagramCanvas * dc; switch (bn->get_type()) { case UmlComponent: dc = new ComponentCanvas(bn, the_canvas(), x, y); break; case UmlPackage: dc = new PackageCanvas(bn, the_canvas(), x, y, 0); break; default: continue; } drawn.replace(dc->get_bn()->get_data(), dc); if ((x + dc->width()) > xmax) dc->move(x = Diagram_Margin, y = future_y); if (y + dc->height() > ymax) { dc->move(x = Diagram_Margin, y = Diagram_Margin); future_y = y + dc->height() + Diagram_Margin; } else { int bot = y + dc->height() + Diagram_Margin; if (bot > future_y) future_y = bot; } x = x + dc->width() + Diagram_Margin; dc->show(); dc->upper(); } } UmlCanvas * cnv = (UmlCanvas *) canvas(); if (! cnv->must_draw_all_relations()) { for (it.toFirst(); (bn = it.current()) != 0; ++it) { if ((drawn[bn->get_data()] == 0) && IsaSimpleRelation(bn->get_type())) SimpleRelationCanvas::drop(bn, cnv, drawn); } } canvas()->update(); history_protected = FALSE; window()->package_modified(); QApplication::restoreOverrideCursor(); }
void StateDiagramView::mousePressEvent(QMouseEvent * e) { QPoint diagramPoint(e->x(), e->y()); QPointF scenePoint = mapToScene(diagramPoint); if (!window()->frozen()) { UmlCode action = window()->buttonOn(); switch (action) { case UmlState: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint()); DiagramItem * di; bool specified = ((ci != 0) && ((di = QCanvasItemToDiagramItem(ci)) != 0) && (di->typeUmlCode() == UmlState) && ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action)); BrowserNode * parent; if (specified) { if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0) parent = ((StateCanvas *) di)->get_bn(); } else parent = (BrowserNode *) window()->browser_diagram()->parent(); BrowserNode * b = BrowserState::get_state(parent); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } // may be added in a the state's region rather than the state StateCanvas * c = new StateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y()); c->show(); c->upper(); canvas()->update(); StateCanvas::force_inside(c, TRUE); canvas()->update(); history_protected = FALSE; window()->package_modified(); return; // canvas already updated } } break; case UmlRegion: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint()); DiagramItem * di; if ((ci != 0) && ((di = QCanvasItemToDiagramItem(ci)) != 0) && (di->typeUmlCode() == UmlState) && ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action)) { BrowserRegion::add_region(((StateCanvas *) di)->get_bn()); window()->package_modified(); } } break; case InitialPS: case EntryPointPS: case FinalPS: case TerminatePS: case ExitPointPS: case DeepHistoryPS: case ShallowHistoryPS: case JunctionPS: case ChoicePS: case ForkPS: case JoinPS: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint()); DiagramItem * di; bool specified = ((ci != 0) && ((di = QCanvasItemToDiagramItem(ci)) != 0) && (di->typeUmlCode() == UmlState) && ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(action)); BrowserNode * parent; if (specified) { if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0) parent = ((StateCanvas *) di)->get_bn(); } else parent = (BrowserNode *) window()->browser_diagram()->parent(); BrowserNode * b = BrowserPseudoState::get_pseudostate(parent, action); if (b != 0) { PseudoStateCanvas * c = // may be added in a the state's region rather than the state new PseudoStateCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y()); c->show(); c->upper(); StateCanvas::force_inside(c, FALSE); window()->package_modified(); } } break; case UmlStateAction: case UmlSignalIn: case UmlSignalOut: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); QGraphicsItem * ci = the_canvas()->collision(scenePoint.toPoint()); DiagramItem * di; bool specified = ((ci != 0) && ((di = QCanvasItemToDiagramItem(ci)) != 0) && (di->typeUmlCode() == UmlState) && ((BrowserState *)((StateCanvas *) di)->get_bn())->may_contains(UmlStateAction)); BrowserNode * parent; if (specified) { if ((parent = ((StateCanvas *) di)->pointed_region(scenePoint.toPoint())) == 0) parent = ((StateCanvas *) di)->get_bn(); } else parent = (BrowserNode *) window()->browser_diagram()->parent(); BrowserNode * b = BrowserStateAction::add_stateaction(parent); switch (action) { case UmlSignalIn: ((StateActionData *) b->get_data())->set_stereotype("receive-signal"); break; case UmlSignalOut: ((StateActionData *) b->get_data())->set_stereotype("send-signal"); break; default: // to avoid warning break; } StateActionCanvas * c = // may be added in a the state's region rather than the state new StateActionCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y()); c->show(); c->upper(); StateCanvas::force_inside(c, FALSE); window()->package_modified(); } break; default: DiagramView::mousePressEvent(e); return; } canvas()->update(); history_protected = FALSE; } else DiagramView::mousePressEvent(e); }
UcClassCanvas * UcClassCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "classcanvas_ref")) return ((UcClassCanvas *) dict_get(read_id(st), "classcanvas", canvas)); else if (!strcmp(k, "classcanvas")) { int id = read_id(st); BrowserNode * br = BrowserClass::read_ref(st); UcClassCanvas * result; if (read_file_format() < 52) { read_keyword(st, "xyz"); int x = (int) read_double(st); result = new UcClassCanvas(br, canvas, x, (int) read_double(st), id); result->setZ(read_double(st)); // move the actor in its initial position x = ACTOR_CANVAS_SIZE - result->width(); if (x < 0) result->Q3CanvasRectangle::moveBy(x/2, 0); k = read_keyword(st); read_double(st); read_double(st); if (!strcmp(k, "label_xyz")) // old version read_double(st); else if (strcmp(k, "label_xy")) wrong_keyword(k, "label_xy/label_xyz"); } else { result = new UcClassCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); result->settings.read(st, k); // updates k read_color(st, "color", result->itscolor, k); // updates k if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); read_xyz(st, result); result->compute_size(); if ((read_file_format() < 72) && (result->used_view_mode == asInterface)) { result->settings.class_drawing_mode = asClass; result->compute_size(); } if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); if (strcmp(k, "end")) wrong_keyword(k, "end"); } } result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
void ActivityDiagramView::dropEvent(QDropEvent * e) { BrowserNode * bn; QPoint p = viewportToContents(e->pos()); if ((bn = UmlDrag::decode(e, UmlActivity, TRUE)) != 0) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Choose")); m.insertSeparator(); if (!the_canvas()->already_drawn(bn)) m.insertItem(TR("Draw activity"), 0); m.insertItem(TR("Add a call behavior"), 1); switch (m.exec(QCursor::pos())) { case 0: { history_save(); history_protected = TRUE; ActivityCanvas * c = new ActivityCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); c->upper(); history_protected = TRUE; c->force_sub_inside(TRUE); canvas()->update(); history_protected = FALSE; window()->package_modified(); } break; case 1: { bn = BrowserActivityAction::add_call_behavior(container(p), bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } break; default: break; } } else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) { history_save(); PackageCanvas * pk = new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; pk->show(); pk->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlActivityNode, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); ActivityNodeCanvas * c = new ActivityNodeCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlInterruptibleActivityRegion, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; InterruptibleActivityRegionCanvas * c = new InterruptibleActivityRegionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlExpansionRegion, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ExpansionRegionCanvas * c = new ExpansionRegionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityPartition, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityPartitionCanvas * c = new ActivityPartitionCanvas(bn, the_canvas(), p.x(), p.y()); bool sz; history_protected = TRUE; c->show(); sz = !ActivityContainerCanvas::force_inside(c, TRUE); history_protected = TRUE; c->force_sub_inside(sz); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityAction, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlActivityObject, TRUE)) != 0) { if (the_canvas()->already_drawn(bn)) msg_information("Douml", TR("already drawn")); else { history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlFlow, TRUE)) != 0) { history_save(); history_protected = TRUE; FlowCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if ((bn = UmlDrag::decode(e, UmlSimpleRelations, TRUE)) != 0) { history_save(); history_protected = TRUE; SimpleRelationCanvas::drop(bn, the_canvas()); canvas()->update(); history_protected = FALSE; } else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlColDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) || ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) || ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) { history_save(); IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0); history_protected = TRUE; ic->show(); ic->upper(); canvas()->update(); history_protected = FALSE; window()->package_modified(); } else if ((bn = UmlDrag::decode(e, UmlOperation)) != 0) { bn = BrowserActivityAction::add_call_operation(container(p), (BrowserOperation *) bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if (((bn = UmlDrag::decode(e, UmlAttribute)) != 0) || ((bn = UmlDrag::decode(e, UmlRelations, TRUE)) != 0)) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Choose")); m.insertSeparator(); m.insertItem(TR("Add a read variable value action"), 0); m.insertItem(TR("Add a clear variable value action"), 1); m.insertItem(TR("Add a write variable value action"), 2); m.insertItem(TR("Add a add variable value action"), 3); m.insertItem(TR("Add a remove variable value action"), 4); switch (m.exec(QCursor::pos())) { case 0: bn = BrowserActivityAction::add_read_variable_value(container(p), bn); break; case 1: bn = BrowserActivityAction::add_clear_variable_value(container(p), bn); break; case 2: bn = BrowserActivityAction::add_write_variable_value(container(p), bn); break; case 3: bn = BrowserActivityAction::add_add_variable_value(container(p), bn); break; case 4: bn = BrowserActivityAction::add_remove_variable_value(container(p), bn); break; default: return; } if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlClass)) != 0) { history_protected = FALSE; BrowserActivityObject * obj = BrowserActivityObject::add_activityobject(container(p), 0); if (obj != 0) { ((ActivityObjectData *) obj->get_data())->set_type((BrowserClass *) bn); history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(obj, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlClassInstance)) != 0) { history_protected = FALSE; BrowserActivityObject * obj = BrowserActivityObject::add_activityobject(container(p), bn->get_name()); if (obj != 0) { ((ActivityObjectData *) obj->get_data()) ->set_type(((ClassInstanceData *) bn->get_data())->get_class()); history_save(); history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(obj, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } else if ((bn = UmlDrag::decode(e, UmlState, TRUE)) != 0) { history_protected = FALSE; bn = BrowserActivityAction::add_call_behavior(container(p), bn); if (bn != 0) { history_save(); history_protected = TRUE; ActivityActionCanvas * c = new ActivityActionCanvas(bn, the_canvas(), p.x(), p.y()); history_protected = TRUE; c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; canvas()->update(); history_protected = FALSE; window()->package_modified(); } } }
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(); }