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 ActivityDiagramView::contentsMousePressEvent(QMouseEvent * e) { if (!window()->frozen()) { UmlCode action = window()->buttonOn(); switch (action) { case UmlActivity: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * b = BrowserActivity::get_activity((BrowserNode *) window()->browser_diagram()->parent()->parent()); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } ActivityCanvas * c = new ActivityCanvas(b, the_canvas(), e->x(), e->y()); c->show(); c->upper(); history_protected = TRUE; c->force_sub_inside(TRUE); window()->package_modified(); } } break; case UmlInterruptibleActivityRegion: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos()); BrowserNode * b = BrowserInterruptibleActivityRegion::get_interruptibleactivityregion(parent); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } InterruptibleActivityRegionCanvas * c = new InterruptibleActivityRegionCanvas(b, the_canvas(), e->x(), e->y()); bool rz; c->show(); history_protected = TRUE; rz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(rz); window()->package_modified(); } } break; case UmlExpansionRegion: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos()); BrowserNode * b = BrowserExpansionRegion::get_expansionregion(parent); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } ExpansionRegionCanvas * c = new ExpansionRegionCanvas(b, the_canvas(), e->x(), e->y()); bool rz; c->show(); history_protected = TRUE; rz = !ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->force_sub_inside(rz); window()->package_modified(); } } break; case InitialAN: case ActivityFinalAN: case FlowFinalAN: case DecisionAN: case MergeAN: case ForkAN: case JoinAN: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos()); BrowserNode * b = BrowserActivityNode::get_activitynode(parent, action); if (b != 0) { // a new element, don't check already drawn ActivityNodeCanvas * c = new ActivityNodeCanvas(b, the_canvas(), e->x(), e->y()); c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; window()->package_modified(); } } break; case UmlActivityAction: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos()); BrowserNode * b = BrowserActivityAction::get_activityaction(parent); if (b != 0) { history_protected = TRUE; if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } ActivityActionCanvas * c = new ActivityActionCanvas(b, the_canvas(), e->x(), e->y()); c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->upper(); window()->package_modified(); } } break; case UmlActivityObject: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos()); BrowserNode * b = BrowserActivityObject::get_activityobject(parent); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } history_protected = TRUE; ActivityObjectCanvas * c = new ActivityObjectCanvas(b, the_canvas(), e->x(), e->y()); c->show(); (void) ActivityContainerCanvas::force_inside(c, FALSE); history_protected = TRUE; c->upper(); window()->package_modified(); } } break; case UmlActivityPartition: { history_protected = TRUE; unselect_all(); window()->selectOn(); history_save(); BrowserNode * parent = container(e->pos(), TRUE); BrowserNode * b = BrowserActivityPartition::get_activitypartition(parent); if (b != 0) { if (the_canvas()->already_drawn(b)) { msg_information("Douml", TR("already drawn")); history_protected = FALSE; return; } ActivityPartitionCanvas * c = new ActivityPartitionCanvas(b, the_canvas(), e->x(), e->y()); bool rz; c->show(); history_protected = TRUE; rz = !ActivityContainerCanvas::force_inside(c, TRUE); history_protected = TRUE; c->force_sub_inside(rz); window()->package_modified(); } } break; default: DiagramView::contentsMousePressEvent(e); return; } canvas()->update(); history_protected = FALSE; } else DiagramView::contentsMousePressEvent(e); }