Esempio n. 1
0
RelationData::RelationData(const BrowserRelation * model,
                           BrowserRelation * r)
    : ClassMemberData((ClassMemberData *) model->get_data()),
      Labeled<RelationData>(all, 0), is_deleted(FALSE), is_unconsistent(FALSE)
{
    RelationData * md = (RelationData *) model->get_data();

    type = md->type;
    name = md->name;
    a = md->a;
    b = md->b;
    set_association(md->association);
    original_id = 0;

    if (md->start == model) {
        start = r;

        if (md->end_removed_from == 0) {
            // bi dir, self to model became self to r
            end = new BrowserRelation((md->get_end_class() == (BrowserClass *) model->parent())
                                      ? (BrowserClass *) r->parent() : md->get_end_class(),
                                      this);
            end_removed_from = 0;
        }
        else {
            // uni dir
            end = 0;
            end_removed_from = (md->end_removed_from == (BrowserClass *) model->parent())
                               ? (BrowserClass *) r->parent() : md->end_removed_from;
            connect(end_removed_from->get_data(), SIGNAL(deleted()),
                    this, SLOT(end_deleted()));
        }
    }
    else {
        // bi dir, self to model became self to r
        end = r;
        start = new BrowserRelation((md->get_start_class() == (BrowserClass *) model->parent())
                                    ? (BrowserClass *) r->parent() : md->get_start_class(),
                                    this);
        end_removed_from = 0;
    }

    if (get_start_class() == md->get_start_class())
        // to not have two times the same role name
        a.role = 0;

    if ((end != 0) && (get_end_class() == md->get_end_class()))
        // to not have two times the same role name
        b.role = 0;
}
Esempio n. 2
0
void ClassInstanceData::check_rels()
{
    bool modif = FALSE;
    Q3ValueList<SlotRel>::Iterator it_rel = relations.begin();

    while (it_rel != relations.end()) {
        const SlotRel & slot_rel = *it_rel;
        BasicData * d = slot_rel.value->get_data();
        bool remove = slot_rel.value->deletedp();

        if (!remove) {
            RelationData * rd = (RelationData *) slot_rel.rel;
            BrowserClass * other = (slot_rel.is_a)
                                   ? rd->get_end_class() : rd->get_start_class();
            BrowserClass * cl = ((ClassInstanceData *) d)->get_class();

            if (cl == 0) {
                // instance doesn't exist
                // note : its brower_node will be deleted
                remove = TRUE;
            }
            else if (cl != other) {
                QList<BrowserClass *> l;

                cl->get_all_parents(l);
                remove |= (! l.contains(other));
            }
        }

        if (remove) {
            it_rel = relations.remove(it_rel);
            modif = TRUE;
        }
        else
            ++it_rel;
    }

    if (modif)
        modified();
}
Esempio n. 3
0
void UcClassCanvas::draw_all_depend_gene(UcClassCanvas * end) {
  Q3ListViewItem * child;
  Q3CanvasItemList all = canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  
  for (child = browser_node->firstChild(); child; child = child->nextSibling()) {
    if (dependencyOrGeneralization(((BrowserNode *) child)->get_type()) &&
	!((BrowserNode *) child)->deletedp()) {
      RelationData * def =
	((RelationData *) ((BrowserNode *) child)->get_data());

      if ((def->get_start_class() == browser_node) && 	// rel begins by this
	  ((end == 0) || (def->get_end_class() == end->browser_node)) &&
	  !has_relation(def)) {
	// adds it in case the other class is drawn
	BrowserClass * end_class = 
	  ((BrowserClass *) def->get_end_class());
	DiagramItem * di;
	
	if (end_class == browser_node)
	  di = this;
	else {	
	  di = 0;
	  for (cit = all.begin(); cit != all.end(); ++cit) {
	    DiagramItem * adi = QCanvasItemToDiagramItem(*cit);
	    
	    if ((adi != 0) &&		// an uml canvas item
		(adi->type() == UmlClass) &&
		(((UcClassCanvas *) adi)->browser_node == end_class) &&
		((((UcClassCanvas *) adi) == end) || (*cit)->visible())) {
	      // other class canvas find
	      di = adi;
	      break;
	    }
	  }
	}
	
	if (di != 0)
	  (new RelationCanvas(the_canvas(), this, di,
			      ((BrowserClass *) browser_node), 
			      def->get_type(), 0, -1.0, -1.0, def))
	    ->show();
      }
    }
  }
  
  if ((end == 0) &&
      !DrawingSettings::just_modified() &&
      !on_load_diagram()) {
    for (cit = all.begin(); cit != all.end(); ++cit) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
      
      if ((di != 0) &&	// an uml canvas item
	  (di->type() == UmlClass) &&
	  (((UcClassCanvas *) di) != this) &&
	  !((UcClassCanvas *) di)->browser_node->deletedp() &&
	  ((UcClassCanvas *) di)->visible())
	((UcClassCanvas *) di)->draw_all_depend_gene(this);
    }
  }
}