void FragmentCanvas::prepare_for_move(bool on_resize) { if (!on_resize) { DiagramCanvas::prepare_for_move(on_resize); QRect r = rect(); Q3CanvasItemList l = collisions(TRUE); Q3CanvasItemList::ConstIterator it; Q3CanvasItemList::ConstIterator end = l.end(); DiagramItem * di; for (it = l.begin(); it != end; ++it) { if ((*it)->visible() && // at least not deleted !(*it)->selected() && ((di = QCanvasItemToDiagramItem(*it)) != 0) && r.contains(di->rect(), TRUE) && di->move_with(UmlFragment)) { the_canvas()->select(*it); di->prepare_for_move(FALSE); } } } }
// resize this to contain its sub elements void ActivityContainerCanvas::resize_to_contain(Q3CanvasItemList & all, BooL & need_sub_upper) { Q3CanvasItemList::Iterator cit; BrowserNode * browser_node = get_bn(); QRect r = rect(); int resize_left = 0; int resize_right = 0; int resize_top = 0; int resize_bottom = 0; for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->visible() && !(*cit)->selected()) { DiagramItem * di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (di->get_bn() != 0) && (((BrowserNode *) di->get_bn())->parent() == browser_node)) { // must look at the type because some canvas items have browser_node // attr equals to the diagram and the parent of the diagram is the activity switch (di->type()) { case UmlActivityObject: case UmlActivityAction: case UmlActivityPartition: case UmlExpansionRegion: case UmlInterruptibleActivityRegion: case InitialAN: case FlowFinalAN: case ActivityFinalAN: case DecisionAN: case MergeAN: case ForkAN: case JoinAN: { QRect di_r = di->rect(); int dx = 0; int dy = 0; if (di_r.left() < r.left()) { dx = r.left() - di_r.left(); if (dx > resize_left) resize_left = dx; } if (di_r.right() > r.right()) { dx = di_r.right() - r.right(); if (dx > resize_right) resize_right = dx; } if (di_r.top() < r.top()) { dy = r.top() - di_r.top(); if (dy > resize_top) resize_top = dy; } if (di_r.bottom() > r.bottom()) { dy = di_r.bottom() - r.bottom(); if (dy > resize_bottom) resize_bottom = dy; } } need_sub_upper |= ((*cit)->z() <= z()); break; default: break; } } } } int dx = 0; int dy = 0; int dw = 0; int dh = 0; if (resize_top != 0) { dy = -resize_top; dh = resize_top; } if (resize_bottom != 0) dh += resize_bottom; if (resize_left != 0) { dx = -resize_left; dw = resize_left; } if (resize_right != 0) dw += resize_right; if ((dx != 0) || (dy != 0)) { moveBy(dx, dy); moveSelfRelsBy(dx, dy); } if ((dw != 0) || (dh != 0)) DiagramCanvas::resize(width() + dw, height() + dh); }