Exemple #1
0
void BrowserNodeList::search(BrowserNode * bn, UmlCode k, const QString & s,
			     bool cs, bool even_deleted, bool for_name,
			     bool for_stereotype)
{
  Q3ListViewItem * child;
    
  for (child = bn->firstChild(); child != 0; child = child->nextSibling()) {
    if (even_deleted || !((BrowserNode *) child)->deletedp()) {
      BrowserNode * ch = (BrowserNode *) child;
      
      if (((k == UmlCodeSup) ||
	   ((k == UmlRelations)
	    ? IsaRelation(ch->get_type())
	    : (ch->get_type() == k))) &&
	  (s.isEmpty() ||
	   (QString((for_name)
		    ? ch->get_name()
		    : ((for_stereotype) ? ch->get_stereotype()
					: ch->get_comment()))
	    .find(s, 0, cs) != -1)))
	append((BrowserNode *) child);
      
      search((BrowserNode *) child, k, s, cs, even_deleted,
	     for_name, for_stereotype);
    }
  }
}
Exemple #2
0
void PackageCanvas::prepare_for_move(bool on_resize) {
  if (! on_resize) {
    DiagramCanvas::prepare_for_move(on_resize);
    
    Q3CanvasItemList l = collisions(TRUE);
    Q3CanvasItemList::ConstIterator it;
    Q3CanvasItemList::ConstIterator end = l.end();
    DiagramItem * di;
    BrowserNode * p = get_bn();
  
    for (it = l.begin(); it != end; ++it) {
      if ((*it)->visible() && // at least not deleted
	  !(*it)->selected() &&
	  ((di = QCanvasItemToDiagramItem(*it)) != 0) &&
	  di->move_with_its_package()) {
	BrowserNode * bn = di->get_bn();
	
	do
	  bn = (BrowserNode *) bn->parent();
	while (bn->get_type() != UmlPackage);
	
	if (bn == p) {
	  the_canvas()->select(*it);
	  di->prepare_for_move(FALSE);
	}
      }
    }
  }
}
Exemple #3
0
void BasicDialog::accept() {
  if (!check_edits(edits) || !kvtable->check_unique())
    return;
    
  BrowserNode * bn = data->get_browser_node();

  if (edname != 0) {
    QString s = edname->text().stripWhiteSpace();

    if ((s != bn->get_name()) &&
	((BrowserNode *) bn->parent())->wrong_child_name(s, bn->get_type(),
							 bn->allow_spaces(),
							 bn->allow_empty())) {
      msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
      return;
    }
    else
      bn->set_name(s);
  }

  bool newst = data->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));
  
  bn->set_comment(comment->text());
  UmlWindow::update_comment_if_needed(bn);
    
  kvtable->update(bn);
  
  ProfiledStereotypes::modified(bn, newst);
  
  bn->package_modified();
  data->modified();
    
  Q3TabDialog::accept();
}
Exemple #4
0
// have marked elements not yet drawn ?
static bool marked_not_yet_drawn(Q3PtrDict<DiagramItem> & drawn)
{
  const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes();
  Q3PtrListIterator<BrowserNode> it(l);
  BrowserNode * bn;
      
  for (; (bn = it.current()) != 0; ++it) {
    UmlCode k = bn->get_type();
    
    switch (k) {
    default:
      if (!IsaSimpleRelation(k))
	break;
      // no break
    case UmlComponent:
    case UmlDeploymentNode:
    case UmlArtifact:
    case UmlPackage:
      if (drawn[bn->get_data()] == 0)
	return TRUE;
    }
  }
  
  return FALSE;
}
Exemple #5
0
BrowserNode * BrowserNode::get_container(UmlCode k) const {
  BrowserNode * p  = (BrowserNode *) this;
  
  while ((p != 0) && (p->get_type() != k))
    p = (BrowserNode *) p->parent();
  
  return p;
}
Exemple #6
0
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;
        }
    }
}
Exemple #7
0
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);
    }
  }
}
Exemple #8
0
void BrowserNodeList::search_ddb(BrowserNode * bn, UmlCode k, const QString & s,
				 bool cs, bool even_deleted)
{
  Q3ListViewItem * child;
    
  for (child = bn->firstChild(); child != 0; child = child->nextSibling()) {
    if (even_deleted || !((BrowserNode *) child)->deletedp()) {
      BrowserNode * ch = (BrowserNode *) child;
      
      if (((k == UmlCodeSup) ||
	   ((k == UmlRelations)
	    ? IsaRelation(ch->get_type())
	    : (ch->get_type() == k))) &&
	  (s.isEmpty() || 
	   ch->get_data()->decldefbody_contain(s, cs, ch)))
	append(ch);
      
      search_ddb(ch, k, s, cs, even_deleted);
    }
  }
}
Exemple #9
0
void BrowserNode::unconsistent_fixed(const char * what, BrowserNode * newone) {  
  UnconsistencyFixedMsg += QString("<li>") + what + QString(" <i>") +
    quote(full_name()) + QString("</i> and <i>") + 
      quote(newone->full_name()) + QString("</i></li>\n");

  BrowserNode * bn = this;

  while (bn->get_type() != UmlPackage)
    bn = (BrowserNode *) bn->parent();

  if (ModifiedPackages.findRef(bn) == -1)
    ModifiedPackages.append(bn);
}
Exemple #10
0
// just check if the inheritance already exist
QString BrowserArtifact::check_inherit(const BrowserNode * new_parent) const
{
    BrowserNode * child;

    for (child = firstChild(); child != 0; child = child->nextSibling()) {
        BrowserNode * ch = ((BrowserNode *) child);

        if ((ch->get_type() == UmlInherit) &&
                ((((SimpleRelationData *) ch->get_data())->get_end_node())
                 == new_parent))
            return QObject::tr("already exist");
    }
    return (new_parent != this) ? QString() : QObject::tr("circular inheritance");
}
Exemple #11
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);
}
Exemple #12
0
// 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;
}
Exemple #13
0
ActivityPartitionCanvas::ActivityPartitionCanvas(BrowserNode * bn, UmlCanvas * canvas,
						 int x, int y)
    : ActivityContainerCanvas(0, canvas, x, y, 
			      ACTIVITY_PARTITION_CANVAS_MIN_SIZE,
			      ACTIVITY_PARTITION_CANVAS_MIN_SIZE, 0) {
  browser_node = bn;
  itscolor = UmlDefaultColor;
  
  BrowserNode * parent = (BrowserNode *) browser_node->parent();
  
  if (parent->get_type() == UmlActivityPartition) {
    Q3CanvasItemList all = the_canvas()->allItems();
    Q3CanvasItemList::Iterator cit;

    for (cit = all.begin(); cit != all.end(); ++cit) {
      if ((*cit)->visible()) {
	DiagramItem * di = QCanvasItemToDiagramItem(*cit);
	
	if ((di != 0) && (di->get_bn() == parent)) {
	  horiz = ((ActivityPartitionCanvas *) di)->horiz;
	  break;
	}
      }
    }
    
    if (cit == all.end())
      horiz = FALSE;
  }
  else
    horiz = FALSE;

  check_size();
  check_stereotypeproperties();
  
  ActivityPartitionData * data =
    (ActivityPartitionData *) browser_node->get_data();
  
  connect(data, SIGNAL(changed()), this, SLOT(modified()));
  connect(data, SIGNAL(deleted()), this, SLOT(deleted()));
  connect(DrawingSettings::instance(), SIGNAL(changed()), this, SLOT(modified()));
}
void ExpansionRegionDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    BrowserNode * bn = data->get_browser_node();

    if (edname != 0) {
        QString s = edname->text().trimmed();

        if ((s != bn->get_name()) &&
                ((BrowserNode *) bn->parent())->wrong_child_name(s, bn->get_type(),
                        bn->allow_spaces(),
                        bn->allow_empty())) {
            msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
            return;
        }
        else
            bn->set_name(s);
    }

    data->must_isolate = must_isolate_cb->isChecked();
    data->mode = expansion_mode_kind(edmode->currentText().toLatin1().constData());

    bool newst = data->set_stereotype(fromUnicode(edstereotype->currentText().trimmed()));

    bn->set_comment(comment->text());
    UmlWindow::update_comment_if_needed(bn);

    kvtable->updateNodeFromThis(bn);

    ProfiledStereotypes::modified(bn, newst);

    bn->package_modified();
    data->modified();

    TabDialog::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;
        }
    }
}
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);
        }
        }
    }
}
Exemple #17
0
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();
  }
}
Exemple #18
0
void ComponentDiagramView::add_marked_elements(const QPoint& p,
					       Q3PtrDict<DiagramItem> & drawn) {
  QApplication::setOverrideCursor(Qt::waitCursor);
  
  history_save();
  history_protected = TRUE;
  
  int xmax = canvas()->width() - Diagram_Margin;
  int ymax = canvas()->height() - Diagram_Margin;
  int x = p.x();
  int y = p.y();
  int future_y = y;
  const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes();
  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();
    }
  }
  
  UmlCanvas * cnv = (UmlCanvas *) canvas();
  
  if (! cnv->must_draw_all_relations()) {
    for (it.toFirst(); (bn = it.current()) != 0; ++it) {
      if ((drawn[bn->get_data()] == 0) &&
	  IsaSimpleRelation(bn->get_type()))
	SimpleRelationCanvas::drop(bn, cnv, drawn);
    }
  }
  
  canvas()->update();
  history_protected = FALSE;
  window()->package_modified();
  
  QApplication::restoreOverrideCursor();
}
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 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;
            }
        }
    }
}
Exemple #21
0
BasicDialog::BasicDialog(BasicData * nd, QString s,
			 const QStringList & default_stereotypes,
			 QSize & sz, bool unnamed)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), data(nd), previous_size(sz) {
  nd->get_browser_node()->edit_start();
  
  if (nd->get_browser_node()->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  setCaption(TR(s + " dialog"));
  
  bool visit = !hasOkButton();
  
  // general tab
  
  BrowserNode * bn = data->get_browser_node();
  Q3Grid * grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);

  if (unnamed)
    edname = 0;
  else {
    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);
  }    
  new QLabel(TR("stereotype : "), grid);
  edstereotype = new Q3ComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(data->get_stereotype()));
  if (! visit) {
    edstereotype->insertStringList(default_stereotypes);
    edstereotype->insertStringList(ProfiledStereotypes::defaults(bn->get_type()));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  QSizePolicy sp = edstereotype->sizePolicy();
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
  
  Q3VBox * vtab = new Q3VBox(grid);
  new QLabel(TR("description :"), vtab);
  if (! visit)
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(bn->get_comment());
  QFont font = comment->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  // USER : list key - value
  
  grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(bn, grid, visit);
  addTab(grid, TR("Properties"));
  
  open_dialog(this);
}
Exemple #22
0
bool BrowserNode::delete_internal(QString & warning) {
  if (deletedp())
    return TRUE;
  
  if (!is_writable() && !root_permission() && !is_from_lib()) {
    warning += "\n    " + TR("%1 is read-only", full_name());
    return FALSE;
  }
  
  static Q3PtrList<BrowserNode> targetof;
  static bool made = FALSE;
  bool made_here;
  
  if (!made) {
    made = TRUE;
    made_here = TRUE;
    referenced_by(targetof, TRUE);
  }
  else
    made_here = FALSE;
    
  bool ro = FALSE;
  
  if (!root_permission()) {
    Q3PtrListIterator<BrowserNode> it(targetof);
    BrowserNode * r;
    
    while ((r = it.current()) != 0) {
      if (!r->is_writable() && !r->is_from_lib()) {
	ro = TRUE;
	warning += "\n    ";
	switch (r->get_type()) {
	case UmlComponent:
	  warning += TR("%1 referenced by the read-only component %2", full_name(), r->full_name());
	  break;
	case UmlArtifact:
	  warning += TR("%1 referenced by the read-only artifact %2", full_name(), r->full_name());
	  break;
	default:
	  warning += TR("%1 is the target of the read-only relation %2", full_name(), r->full_name());
	  break;
	}
      }
      
      ++it;
    }
  }
  
  if (made_here) {
    made = FALSE;
    targetof.clear();
  }
  
  if (ro)
    return FALSE;
  
  // sub elts
  Q3ListViewItem * child;
  bool ok = TRUE;
  
  for (child = firstChild(); child != 0; child = child->nextSibling())
    ok &= ((BrowserNode *) child)->delete_internal(warning);
  
  if (ok) {
    is_deleted = TRUE;
    if (is_marked) {
      marked_list.removeRef(this);
      is_marked = FALSE;
    }
    get_data()->delete_it();
    repaint();
    package_modified();
  }

  return ok;
}
Exemple #23
0
void ActivityActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  QBrush brsh = p.brush();
  QColor bckgrnd = p.backgroundColor();
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  p.setBackgroundColor(co);
  
  const ActivityActionData * data =
    (ActivityActionData *) browser_node->get_data();
  const int shadow = the_canvas()->shadow();
  int margin;
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  switch (data->get_action_kind()) {
  case UmlAcceptEventAction:
    if (((AcceptEventAction *) data->get_action())->timeevent) {
      // don't draw shadow
      margin = (int) (21 * the_canvas()->zoom());
      
      int t = (r.y() + r.bottom() - margin)/2;
      
      p.setPen(::Qt::SolidLine);
      p.setBackgroundMode(::Qt::TransparentMode);
      p.drawLine(r.right() - margin, t, r.right() - 1, t);
      p.lineTo(r.right() - margin - 1, t + margin);
      p.lineTo(r.right() - 1, t + margin);
      p.lineTo(r.right() - margin - 1, t);

      if (fp != 0) {
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin, t, r.right() - 1, t);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t, r.right() - margin - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin - 1, t + margin, r.right() - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t + margin, r.right() - margin - 1, t);
      }

      r.setWidth(r.width() - margin - 1);
      margin = (int) (3 * the_canvas()->zoom());
    }
    else {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right(), r.y());
      a.setPoint(2, r.right(), r.bottom());
      a.setPoint(3, r.x(), r.bottom());
      a.setPoint(4, r.x() + margin, (r.y() + r.bottom())/2);
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);

	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(3, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + margin + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setLeft(r.left() + margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  case UmlSendSignalAction:
  case UmlBroadcastSignalAction:
    {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right() - margin, r.y());
      a.setPoint(2, r.right(), (r.y() + r.bottom())/2);
      a.setPoint(3, r.right() - margin, r.bottom());
      a.setPoint(4, r.x(), r.bottom());
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() - margin + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(3, r.right() - margin + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
      
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setWidth(r.width() - margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  default:      
    margin = (int) (9 * the_canvas()->zoom());
      
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
      p.setPen(::Qt::NoPen);
      p.setBrush(::Qt::darkGray);
      p.drawRoundRect(r.left() + shadow, r.top() + shadow, r.width(), r.height());
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
		::Qt::darkGray.rgb()&0xffffff,
		r.left() + shadow, r.top() + shadow, r.width() - 1, r.height() - 1);

      p.setPen(::Qt::SolidLine);
    }
    
    p.setBrush(co);
    p.drawRoundRect(r);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
	      svg_color(used_color),
	      r.left(), r.top(), r.width() - 1, r.height() - 1);
    
    if (data->get_action_kind() == UmlCallBehaviorAction) {
      BrowserNode * behavior =
	((CallBehaviorAction *) data->get_action())->behavior;
      
      if ((behavior != 0) && (behavior->get_type() == UmlActivity)) {
	int l = (int) (6 * the_canvas()->zoom());
	int lx = r.right() - margin - l;
	int ty = r.bottom() - margin - l;
	int mx = lx + l;
	int my = ty + l;
	int rx = mx + l;
	int by = my + l;
	
	p.drawLine(lx, my, rx, my);
	p.drawLine(mx, ty, mx, by);
	p.drawLine(lx, my, lx, by);
	p.drawLine(rx, my, rx, by);

	if (fp != 0) {
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, rx, my);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  mx, ty, mx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, lx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  rx, my, rx, by);
	}
      }
    }
    break;
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  p.drawText(r.x() + margin,
	     r.y() + margin,
	     r.width() - margin - margin,
	     r.height() - margin - margin,
	     align, s);
  
  if (fp != 0) {
    fputs("</g>\n", fp);
    draw_text(r.x() + margin,
	      r.y() + margin,
	      r.width() - margin - margin,
	      r.height() - margin - margin,
	      align, s, p.font(), fp);
  }
  
  p.setBackgroundColor(bckgrnd);
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, rect());
}