bool BrowserNode::enter_child_name(QString & r, const QString & msg, UmlCode type, BrowserNodeList & nodes, BrowserNode ** old, bool allow_spaces, bool allow_empty, bool existing) { if (existing && nodes.isEmpty()) { msg_warning(TR("Error"), TR("nothing available")); return FALSE; } QStringList list; nodes.full_names(list); list.prepend(QString::null); *old = 0; for (;;) { BooL ok = FALSE; r = (list.count() == 1) ? MyInputDialog::getText("Uml", msg, QString::null, ok) : MyInputDialog::getText("Uml", msg, list, QString::null, existing, ok); if (! ok) return FALSE; if (!r.isEmpty()) { int index = list.findIndex(r); if (index != -1) { *old = nodes.at(index - 1); return TRUE; } } if (wrong_child_name(r, type, allow_spaces, allow_empty)) msg_critical(TR("Error"), r + "\n\n" + TR("illegal name or already used")); else return TRUE; } }
void ClassDiagramView::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) && !l.isEmpty()) { 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 UmlClass: dc = new CdClassCanvas(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(); } }