void BasicData::send_uml_def(ToolCom * com, BrowserNode * bn, const QString & comment) { if (browser_node != 0) { BrowserNode * d = browser_node->get_associated(); if (d != browser_node) { // may have an associated diagram/view if ((d != 0) && !d->deletedp()) d->write_id(com); else com->write_id(0); } } com->write_string(stereotype); ((HaveKeyValueData *) bn)->send_def(com); com->write_string(comment); int api = com->api_format(); if (api > 11) { com->write_bool(bn->markedp()); if (api > 30) com->write_unsigned(bn->get_identifier()); } }
void PseudoStateDialog::menu_reference() { Q3PopupMenu m(0); m.insertItem(TR("Choose"), -1); m.insertSeparator(); int index = reflist.findIndex(edreference->currentText()); if (index != -1) m.insertItem(TR("Select in browser"), 0); BrowserNode * bn = 0; if (! visit) { bn = BrowserView::selected_item(); if ((bn != 0) && !bn->deletedp() && ((BrowserPseudoState *) pst->browser_node)->can_reference(bn)) m.insertItem(TR("Choose pseudo state selected in browser"), 1); else bn = 0; } if ((index != -1) || (bn != 0)) { switch (m.exec(QCursor::pos())) { case 0: pseudostates.at(index)->select_in_browser(); break; case 1: { QString s = bn->full_name(TRUE); if ((index = reflist.findIndex(s)) == -1) { // new state, may be created through an other dialog index = 0; QStringList::Iterator iter = reflist.begin(); QStringList::Iterator iter_end = reflist.end(); while ((iter != iter_end) && (*iter < s)) { ++iter; index += 1; } pseudostates.insert((unsigned) index, bn); reflist.insert(iter, s); edreference->insertItem(s, index + 1); } } edreference->setCurrentItem(index + 1); break; default: break; } } }
void ActivityDialog::menu_specification() { Q3PopupMenu m(0); m.insertItem(TR("Choose"), -1); m.insertSeparator(); int index = list.findIndex(edspecification->currentText().stripWhiteSpace()); if (index != -1) m.insertItem(TR("Select in browser"), 0); BrowserNode * bn = 0; if (! visit) { bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlOperation) && !bn->deletedp()) m.insertItem(TR("Choose operation selected in browser"), 1); else bn = 0; } if ((index != -1) || (bn != 0)) { switch (m.exec(QCursor::pos())) { case 0: opers.at(index)->select_in_browser(); break; case 1: { QString s = bn->full_name(TRUE); if ((index = list.findIndex(s)) == -1) { // new operation, may be created through an other dialog index = 0; QStringList::Iterator iter = list.begin(); QStringList::Iterator iter_end = list.end(); while ((iter != iter_end) && (*iter < s)) { ++iter; index += 1; } opers.insert((unsigned) index, bn); list.insert(iter, s); edspecification->insertItem(s, index + 1); } } edspecification->setCurrentItem(index + 1); break; default: break; } } }
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); } } }
// 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 FragmentDialog::menu_refer() { Q3PopupMenu m(0); bool used = FALSE; m.insertItem(TR("Choose"), -1); m.insertSeparator(); if (diag_cb->currentItem() != 0) { used = TRUE; m.insertItem(TR("Select in browser"), 0); } BrowserNode * bn = BrowserView::selected_item(); if ((bn != 0) && !bn->deletedp() && (dynamic_cast<BrowserDiagram *>(bn) != 0)) { m.insertItem(TR("Choose diagram selected in browser"), 1); used = TRUE; } else bn = 0; if (used) { switch (m.exec(QCursor::pos())) { case 0: nodes.at(diag_cb->currentItem() - 1)->select_in_browser(); break; case 1: diag_cb->setCurrentItem(nodes.findRef(bn) + 1); break; default: break; } } }
bool BrowserNode::save_open_list(Q3TextStream & st) { if (!isOpen()) return FALSE; bool have_open_child = FALSE; for (Q3ListViewItem * child = firstChild(); child != 0; child = child->nextSibling()) { BrowserNode * ch = ((BrowserNode *) child); if (!ch->deletedp()) have_open_child |= ch->save_open_list(st); } if (! have_open_child) { QString warning; st << " "; save(st, TRUE, warning); st << '\n'; } return TRUE; }
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 ParameterDialog::menu_type() { QMenu m(0); MenuFactory::addItem(m, tr("Choose"), -1); m.addSeparator(); int index = list.indexOf(edtype->currentText().trimmed()); if (index != -1) MenuFactory::addItem(m, tr("Select in browser"), 0); BrowserNode * bn = 0; if (! visit) { bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlClass) && !bn->deletedp()) MenuFactory::addItem(m, tr("Choose class selected in browser"), 1); else bn = 0; MenuFactory::addItem(m, tr("Create class and choose it"), 2); } if (!visit || (index != -1) || (bn != 0)) { QAction* retAction = m.exec(QCursor::pos()); if(retAction) { switch (retAction->data().toInt()) { case 0: nodes.at(index)->select_in_browser(); break; case 2: bn = BrowserClass::add_class(FALSE, view); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { QString s = bn->full_name(TRUE); if ((index = list.indexOf(s)) == -1) { // new class, may be created through an other dialog index = 0; QStringList::Iterator iter = list.begin(); QStringList::Iterator iter_end = list.end(); while ((iter != iter_end) && (*iter < s)) { ++iter; index += 1; } nodes.insert((unsigned) index, bn); list.insert(iter, s); edtype->insertItem(index + offset,s); } } edtype->setCurrentIndex(index + offset); break; default: break; } } } }
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(); }
void ActivityObjectDialog::menu_type() { Q3PopupMenu m(0); m.insertItem(TR("Choose"), -1); m.insertSeparator(); int index = list.findIndex(edtype->currentText().stripWhiteSpace()); if (index != -1) m.insertItem(TR("Select in browser"), 0); BrowserNode * bn = 0; if (! visit) { bn = BrowserView::selected_item(); if ((bn != 0) && (bn->get_type() == UmlClass) && !bn->deletedp()) m.insertItem(TR("Choose class selected in browser"), 1); else bn = 0; m.insertItem(TR("Create class and choose it"), 2); } if (!visit || (index != -1) || (bn != 0)) { switch (m.exec(QCursor::pos())) { case 0: nodes.at(index)->select_in_browser(); break; case 2: bn = BrowserClass::add_class(FALSE, view); if (bn == 0) return; bn->select_in_browser(); // no break case 1: { QString s = bn->full_name(TRUE); if ((index = list.findIndex(s)) == -1) { // new class, may be created through an other dialog QStringList::Iterator iter = list.begin(); QStringList::Iterator iter_end = list.end(); index = 0; while ((iter != iter_end) && (*iter < s)) { ++iter; index += 1; } nodes.insert((unsigned) index, bn); list.insert(iter, s); edtype->insertItem(s, index + offset); } } edtype->setCurrentItem(index + offset); break; default: break; } } }