コード例 #1
0
ファイル: ComponentDiagramView.cpp プロジェクト: kralf/bouml
void ComponentDiagramView::menu(const QPoint& p) {
  Q3PopupMenu m(0);
  
  m.insertItem(new MenuTitle(TR("Component diagram menu"), m.font()), -1);
 
  if ((((UmlCanvas *) canvas())->browser_diagram())->is_writable()) {
    DiagramItemList items(canvas()->allItems());
    Q3PtrDict<DiagramItem> drawn;
    
    get_drawn(items, drawn);
    
    if (marked_not_yet_drawn(drawn))
      m.insertItem(TR("Add marked elements"), 28);
    
    switch (default_menu(m, 30)) {
    case EDIT_DRAWING_SETTING_CMD:
      ((BrowserComponentDiagram *) the_canvas()->browser_diagram())->edit_settings();
      break;
    case RELOAD_CMD:
      // pure drawing modifications are lost
      // mark the diagram modified because the undid modifications
      // may be saved in the file are not saved in memory
      load("Component");
      window()->package_modified();
      break;
    case 28:
      add_marked_elements(p, drawn);
      break;
    }
  }
  else
    (void) default_menu(m, 30);
}
コード例 #2
0
void ClassDiagramView::menu(const QPoint& p) {
  Q3PopupMenu m(0);
  
  MenuFactory::createTitle(m, TR("Class diagram menu"));

  if ((((UmlCanvas *) canvas())->browser_diagram())->is_writable()) {
    BrowserNode * bn = BrowserView::selected_item();
    DiagramItemList items(canvas()->allItems());
    Q3PtrDict<DiagramItem> drawn;
    
    get_drawn(items, drawn);
    
    if ((bn != 0) && (bn->get_type() == UmlClassView)) {      
      if (not_yet_drawn(bn, drawn)) {
	m.insertItem(TR("Add classes of the selected class view"), 29);
	if (marked_not_yet_drawn(drawn))
	  m.insertItem(TR("Add marked elements"), 28);
	m.insertSeparator();
      }
    }
    else if (marked_not_yet_drawn(drawn)) {
      m.insertItem(TR("Add marked elements"), 28);
      m.insertSeparator();
    }
    
    switch (default_menu(m, 30)) {
    case EDIT_DRAWING_SETTING_CMD:
      ((BrowserClassDiagram *) ((UmlCanvas *) canvas())->browser_diagram())->edit_settings();
      break;
    case RELOAD_CMD:
      // pure drawing modifications are lost
      // mark the diagram modified because the undid modifications
      // may be saved in the file are not saved in memory
      load("Class");
      window()->package_modified();
      break;
    case 28:
      add_marked_elements(p, drawn);
      break;
    case 29:
      add_classview_classes(bn, p, drawn);
      break;
    }
  }
  else
    (void) default_menu(m, 30);
}
コード例 #3
0
ファイル: ComponentDiagramView.cpp プロジェクト: kralf/bouml
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();
  }
}