Esempio n. 1
0
ClassData::ClassData(const ClassData * model, BrowserNode * bn)
    : BasicData(model), constraint(model->constraint)
{
    browser_node = bn;

    if ((nformals = model->nformals) == 0)
        formals = 0;
    else {
        FormalParamData * mformals = model->formals;
        formals = new FormalParamData[nformals];

        for (int index = 0; index != nformals; index += 1)
            formals[index] = mformals[index];
    }

    Q3PtrListIterator<ActualParamData> it(model->actuals);
    BrowserClass * cl = 0;

    for (; it.current(); ++it) {
        ActualParamData * actual = new ActualParamData(*(it.current()));

        if (actual->get_class() != cl) {
            cl = actual->get_class();
            connect(cl->get_data(), SIGNAL(changed()),
                    this, SLOT(update_actuals()));
            connect(cl->get_data(), SIGNAL(deleted()),
                    this, SLOT(update_actuals()));
        }

        actuals.append(actual);
    }

    set_base_type(model->base_type);
    is_deleted = FALSE;
    bodies_read = FALSE;
    bodies_modified = FALSE;
    is_abstract = model->is_abstract;
    is_active = model->is_active;
    cpp_external = model->cpp_external;
    java_external = model->java_external;
    java_final = model->java_final;
    php_external = model->php_external;
    php_final = model->php_final;
    python_2_2 = model->python_2_2;
    python_external = model->python_external;
    idl_external = model->idl_external;
    idl_local = model->idl_local;
    idl_custom = model->idl_custom;
    uml_visibility = model->uml_visibility;
    cpp_visibility = model->cpp_visibility;
    cpp_decl = model->cpp_decl;
    java_decl = model->java_decl;
    java_annotation = model->java_annotation;
    php_decl = model->php_decl;
    python_decl = model->python_decl;
    set_switch_type(model->switch_type);
    idl_decl = model->idl_decl;

    connect(this, SIGNAL(changed()), this, SLOT(update_actuals()));
}
Esempio n. 2
0
void ClassInstanceDialog::type_changed(int i)
{
    // made attribute list
    BrowserClass * cl = (BrowserClass *) nodes.at(i);

    cl->get_attrs(attributes);
    attributes.sort();

    // fill table
    atbl->setRowCount(0);
    atbl->setRowCount(attributes.count());

    QList<SlotAttr> attrs = inst->attributes;

    int index = 0;
    foreach (BrowserNode * at, attributes) {
        atbl->setItem(index, 0, new TableItem(atbl, TableItem::Never, at->get_name(), TableItem::TableItemType));
        atbl->setItem(index, 1, new TableItem(atbl, TableItem::Never, ((BrowserNode *) at->parent())->get_name(), TableItem::TableItemType));

        QList<SlotAttr>::Iterator it_attr;

        for (it_attr = attrs.begin(); it_attr != attrs.end(); ++it_attr) {
            if ((*it_attr).att == at) {
                atbl->setText(index, 2, (*it_attr).value);
                break;
            }
        }

        if (it_attr == attrs.end())
            atbl->setText(index, 2, QString());
        ++index;
    }
Esempio n. 3
0
void ParameterData::on_delete()
{
    BrowserClass * cl = get_type().type;

    if ((cl != 0) && cl->deletedp())
        set_type((BrowserClass *) 0);
}
void BrowserOperation::AddConstructorInitalizer()
{
    ConstructorInitializerDialog ciDialog;
    BrowserClass* container = static_cast<BrowserClass*>(get_container(UmlClass));
    QList<BrowserNode *> parents = container->parents();
    QString initializerDummy(" : ");
    for(BrowserNode* parent : parents)
    {
        BrowserClass* parentClass = static_cast<BrowserClass*>(parent);
        initializerDummy+=parentClass->get_name() + QString("(), ");
    }
    if(initializerDummy != " : ")
        initializerDummy.chop(2);

    QString constructorPrototype = static_cast<OperationData*>(this->get_data())->get_cppdef();

    QString constructorActual = TagManagers::Cpp::updated_def(static_cast<OperationData*>(this->get_data()));

    QString initializer(this->get_value("constructor-initializer"));
    if(initializer.trimmed().isEmpty())
        ciDialog.ui->edInitializer->setText(initializerDummy);
    else
        ciDialog.ui->edInitializer->setText(this->get_value("constructor-initializer"));
    ciDialog.ui->edConstructorPrototype->setText(constructorPrototype);
    ciDialog.ui->edActualConstructor->setText(constructorActual);
    ciDialog.Init(static_cast<OperationData*>(this->get_data()));
    ciDialog.resize(800, 400);
    if(ciDialog.exec() == QDialog::Accepted)
    {
        this->set_value("constructor-initializer", ciDialog.ui->edInitializer->toPlainText());
        this->modified();
        this->get_data()->get_browser_node()->modified();
        this->get_data()->get_browser_node()->package_modified();
    }
}
Esempio n. 5
0
void QuickEdit::AddOperation()
{
    QModelIndex current = ui->tvEditor->selectionModel()->currentIndex();
    if(!current.isValid())
        return;

    current = current.sibling(current.row(), 0);
    TreeItemInterface *itemAsInterface = static_cast<TreeItemInterface*>(current.internalPointer());
    BrowserNode* currentNode = static_cast<BrowserNode*>(itemAsInterface->InternalPointer());

    BrowserClass* classNode;

    int newItemPosition = 0;
    if(currentNode->TypeID()  == TypeIdentifier<BrowserClass>::id())
    {
        classNode = static_cast<BrowserClass*>(currentNode);
        newItemPosition = itemAsInterface->childCount();
    }
    else if(currentNode->TypeID()  == TypeIdentifier<BrowserOperation>::id() && current.parent().isValid())
    {
        itemAsInterface = static_cast<TreeItemInterface*>(current.parent().internalPointer());
        classNode = static_cast<BrowserClass*>(itemAsInterface->InternalPointer());
        newItemPosition = current.row()+1;
        current = current.parent();
    }
    else
        return;

    if(!classNode)
        return;
    BrowserOperation* newOperation = static_cast<BrowserOperation*>(classNode->addOperation());
    classNode->move(newOperation, currentNode);
    classNode->select_in_browser();
    QModelIndex parentIndex;
    TreeItemInterface* parent;
    if(treeModel->parent(current).isValid())
    {
        parentIndex = treeModel->parent(current);
        parentIndex = parentIndex.sibling(parentIndex.row(), 0);
        parent =  static_cast<TreeItemInterface*>(parentIndex.internalPointer());
    }
    else
        parent = treeModel->RootItem();
    int insertIndex = parent->GetIndexOfChild(itemAsInterface);
    QSharedPointer<TreeItemInterface> sharedOfOperation =  parent->GetChildren()[insertIndex];

    if(!treeModel->insertRows(newItemPosition-1, 1, current))
        return;

    if(!current.isValid())
        return;

    QModelIndex newItem = treeModel->index(newItemPosition-1,0,current);
    TreeItemInterface *newItemInterface = static_cast<TreeItemInterface*>(newItem.internalPointer());
    TreeItem<BrowserNode>* newItemAsNode = static_cast<TreeItem<BrowserNode>*>(newItemInterface);
    newItemAsNode->SetController(operationController);
    newItemAsNode->SetParent(sharedOfOperation);
    newItemAsNode->SetInternalData(newOperation);
}
Esempio n. 6
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. 7
0
void ClassData::read(char * & st, char * & k) {
  if (!strcmp(k, "abstract")) {
    is_abstract = TRUE;
    k = read_keyword(st);
  }
  else
    is_abstract = FALSE;
  
  if (!strcmp(k, "active")) {
    is_active = TRUE;
    k = read_keyword(st);
  }
  else
    is_active = FALSE;
  
  if (!strcmp(k, "visibility")) {
    uml_visibility = ::visibility(read_keyword(st));  
    k = read_keyword(st);
  }
  else {
    // old non nested class
    uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "stereotype")) {
    set_stereotype(read_string(st));
    
    if (!strcmp(stereotype, "typedef")) {
      AType t;
      
      t.read(st, "base_type", "explicit_base_type");
      set_base_type(t);
    }
    
    k = read_keyword(st);
  }
  
  unsigned n, i;
  
  if (!strcmp(k, "nformals")) {
    n = read_unsigned(st);
    set_n_formalparams(n);
    
    for (i = 0; i != n; i += 1)
      formals[i].read(st);
    
    k = read_keyword(st);
  }
  else
    set_n_formalparams(0);

  if (!strcmp(k, "nactuals")) {
    n = read_unsigned(st);
    
    BrowserClass * cl = 0;

    for (i = 0; i != n; i += 1) {
      ActualParamData * actual = ActualParamData::read(st);

      actuals.append(actual);
      
      if (actual->get_class() != cl) {
	cl = actual->get_class();
	connect(cl->get_data(), SIGNAL(deleted()),
		this, SLOT(update_actuals()));
	connect(cl->get_data(), SIGNAL(changed()),
		this, SLOT(update_actuals()));
      }
    }

    k = read_keyword(st);
  }
  else {
    n = 0;
    actuals.clear();
  }
  
  if (!strcmp(k, "constraint")) {
    constraint = read_string(st);
    k = read_keyword(st);
  }
  else
    constraint = QString::null;
  
  if (!strcmp(k, "cpp_external")) {
    cpp_external = TRUE;
    k = read_keyword(st);
  }
  else
    cpp_external = FALSE;
  
  if (!strcmp(k, "cpp_visibility")) {
    cpp_visibility = ::visibility(read_keyword(st));
    k = read_keyword(st);
  }
  else
    cpp_visibility = UmlDefaultVisibility;

  if (!strcmp(k, "cpp_decl")) {
    cpp_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "cpp_decl");
  
  if (!strcmp(k, "java_external")) {
    java_external = TRUE;
    k = read_keyword(st);
  }
  else
    java_external = FALSE;
  
  if (read_file_format() <= 33) {
    // old file
    if ((cpp_visibility == UmlDefaultVisibility) &&
	(uml_visibility != UmlPublic) && 
	(uml_visibility != UmlPackageVisibility))
      cpp_visibility = uml_visibility;
    
    if (!strcmp(k, "public")) {
      uml_visibility = UmlPublic;
      k = read_keyword(st);
    }
    else
      uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "final")) {
    java_final = TRUE;
    k = read_keyword(st);
  }
  else
    java_final = FALSE;
  
  if (!strcmp(k, "java_decl")) {
    java_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "java_decl");
  
  if (!strcmp(k, "java_annotation")) {
    java_annotation = read_string(st);
    k = read_keyword(st);
  }
  else
    java_annotation = QString::null;
  
  if (!strcmp(k, "php_external")) {
    php_external = TRUE;
    k = read_keyword(st);
  }
  else
    php_external = FALSE;
  
  if (!strcmp(k, "php_final")) {
    php_final = TRUE;
    k = read_keyword(st);
  }
  else
    php_final = FALSE;
  
  if (!strcmp(k, "php_decl")) {
    php_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 44)
    wrong_keyword(k, "php_decl");
  else
    php_decl = "";
  
  if (!strcmp(k, "python_external")) {
    python_external = TRUE;
    k = read_keyword(st);
  }
  else
    python_external = FALSE;
  
  if (!strcmp(k, "python_2_2")) {
    python_2_2 = TRUE;
    k = read_keyword(st);
  }
  else
    python_2_2 = (read_file_format() < 51);
  
  if (!strcmp(k, "python_decl")) {
    python_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 51)
    wrong_keyword(k, "python_decl");
  else
    python_decl = "";
  
  if (!strcmp(k, "idl_external")) {
    idl_external = TRUE;
    k = read_keyword(st);
  }
  else
    idl_external = FALSE;
  
  if (!strcmp(k, "local")) {
    idl_local = TRUE;
    k = read_keyword(st);
  }
  else
    idl_local = FALSE;
  
  if (!strcmp(k, "custom")) {
    idl_custom = TRUE;
    k = read_keyword(st);
  }
  else
    idl_custom = FALSE;
  
  if (!strcmp(k, "idl_decl")) {
    idl_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "idl_decl");
  
  AType t;
  
  t.read(st, "switch_type", "explicit_switch_type", k);
  set_switch_type(t);
  
  k = read_keyword(st);
}
Esempio n. 8
0
void UcClassCanvas::compute_size() {
  used_settings = settings;
  ((BrowserUseCaseDiagram *) the_canvas()->browser_diagram())
    ->get_simpleclassdiagramsettings(used_settings);

  full_name = browser_node->get_name();
  
  const MyStr & (PackageData::*f)() const = 0;
  const char * sep = 0;	// to avoid warning
  
  switch (used_settings.show_context_mode) {
  case umlContext:
    full_name = browser_node->full_name();
    break;
  case namespaceContext:
    f = &PackageData::get_cpp_namespace;
    sep = "::";
    break;
  case javaPackageContext:
    f = &PackageData::get_java_package;
    sep = ".";
    break;
  case pythonPackageContext:
    f = &PackageData::get_python_package;
    sep = ".";
    break;
  case moduleContext:
    f = &PackageData::get_idl_module;
    sep = "::";
    break;
  default:
    break;
  }
  
  if (f != 0) {
    BrowserClass * cl = (BrowserClass *) browser_node;
    
    while (cl->nestedp())
      cl = (BrowserClass *) cl->parent();
    
    if (((BrowserNode *) cl->parent())->get_type() == UmlClassView) {
      // not under a use case
      BrowserArtifact * cp = cl->get_associated_artifact();
      
      QString context =
	(((PackageData *)
	  ((BrowserNode *)
	   (((cp == 0) ? (BrowserNode *) cl : (BrowserNode *) cp)
	    ->parent()->parent()))->get_data())->*f)();
      
      if (!context.isEmpty())
	full_name = context + sep + full_name;
    }
  }
  
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  QFontMetrics fim(the_canvas()->get_font(UmlNormalItalicFont));
  const ClassData * data = ((ClassData *) browser_node->get_data());
  int wi =
    (data->get_is_abstract()) ? fim.width(full_name) : fm.width(full_name);
  double zoom = the_canvas()->zoom();
  const QPixmap * px = 0;

  if (used_settings.class_drawing_mode == Natural) {
    if ((px = ProfiledStereotypes::diagramPixmap(data->get_stereotype(), zoom)) != 0)
      used_view_mode = Natural;
    else {
      const char * st = data->get_short_stereotype();
      
      if (!strcmp(st, "control"))
	used_view_mode = asControl;
      else if (!strcmp(st, "entity"))
	used_view_mode = asEntity;
      else if (!strcmp(st, "boundary"))
	used_view_mode = asBoundary;
      else if (!strcmp(st, "actor"))
	used_view_mode = asActor;
      else if (!strcmp(st, "interface"))
	used_view_mode = asInterface;
      else
	used_view_mode = asClass;
    }
  }
  else
    used_view_mode = used_settings.class_drawing_mode;

  const int eight = (int) (8 * zoom);

  int he = fm.height() + eight;
  
  bool tmpl = data->get_n_formalparams() != 0;
  
  if (tmpl)
    he += fm.height();
  
  if (used_view_mode == asClass) {
    he += (int) (12 * zoom);
    
    if (data->get_stereotype()[0]) {
      int stw = fm.width(QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      
      if (wi < stw)
	wi = stw;
      
      he += fm.height() + (int) (4 * zoom);
    }
  }
  
  wi += eight;
  
  int min_w;
  
  switch (used_view_mode) {
  case asInterface:
    min_w = (int) (INTERFACE_SIZE * zoom);
    he += min_w;
    break;
  case asControl:
    min_w = (int) (CONTROL_WIDTH * zoom);
    he += (int) (CONTROL_HEIGHT * zoom);
    break;
  case asBoundary:
    min_w = (int) (BOUNDARY_WIDTH * zoom);
    he += (int) (BOUNDARY_HEIGHT * zoom);
    break;
  case asEntity:
    min_w = (int) (ENTITY_SIZE * zoom);
    he += min_w;
    break;
  case asActor:
    min_w = (int) (ACTOR_SIZE * zoom);
    he += (int) (ACTOR_SIZE * zoom);
    break;
  case Natural:
    // pixmap
    min_w = px->width();
    he += px->height();
    break;
  default:	// class
    min_w = (int) (CLASS_CANVAS_MIN_SIZE * zoom);
    break;
  }
  
  if (wi < min_w)
    wi = min_w;
  
  used_color = (itscolor == UmlDefaultColor)
    ? the_canvas()->browser_diagram()->get_color(UmlClass)
    : itscolor;
  
  if ((used_view_mode == asClass) && (used_color != UmlTransparent)) {
    const int shadow = the_canvas()->shadow();
    
    wi += shadow;
    he += shadow;
  }
  
  // force odd width and height for line alignment
  DiagramCanvas::resize(wi | 1, he | 1);
    
  if (tmpl) {
    if (templ == 0) {
      templ = new TemplateCanvas(this);
      templ->show();
    }
    else
      templ->update();
  }
  else if (templ != 0) {
    templ->delete_it();
    templ = 0;
  }
}
Esempio n. 9
0
void OdClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
    QRect r = rect();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    QColor bckgrnd = p.backgroundColor();
    double zoom = the_canvas()->zoom();

    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    FILE * fp = svg();

    if (fp != 0)
      fputs("<g>\n", fp);
    
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
    
    if (used_color != UmlTransparent)
      p.fillRect(r, co);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
    
    BrowserClass * cl = 
      ((ClassInstanceData *) browser_node->get_data())->get_class();
	  
    if (((ClassData *) cl->get_data())->get_is_active()) {
      const int eight = (int) (8 * zoom);
      
      r.setLeft(r.left() + eight);
      r.setRight(r.right() - eight);
      
      p.drawLine(r.topLeft(), r.bottomLeft());
      p.drawLine(r.topRight(), r.bottomRight());

      if (fp != 0)
	fprintf(fp,
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.left(), r.bottom(),
		r.right(), r.top(), r.right(), r.bottom());
    }
    
    const int two = (int) (2 * zoom);
    int he = fm.height() + two;
    
    p.setFont(the_canvas()->get_font(UmlNormalUnderlinedFont));

    r.setTop(r.top() + two);
    if (horiz) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 full_name());
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  full_name(),
		  p.font(), fp);
    }
    else {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 get_name() + ":");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  get_name() + ":",
		  p.font(), fp);
      r.setTop(r.top() + fm.height());
      
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 cl->contextual_name(used_show_context_mode));
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  cl->contextual_name(used_show_context_mode),
		  p.font(), fp);
    }
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));

    const QValueList<SlotAttr> & attributes = 
      ((ClassInstanceData *) browser_node->get_data())->get_attributes();

    if (!attributes.isEmpty()) {
      r.setTop(r.top() + he + two);
      p.drawLine(r.topLeft(), r.topRight());
      if (fp != 0)
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.right(), r.top());

      r.setTop(r.top() + two);
      r.setLeft(r.left() + (int) (4 * zoom));
      
      QValueList<SlotAttr>::ConstIterator it = attributes.begin();
      QString egal = " = ";

      do {
	QString s = (*it).att->get_name() + egal + (*it).value;

	p.drawText(r, ::Qt::AlignTop, s);
	if (fp != 0)
	  draw_text(r, ::Qt::AlignTop, s,
		    p.font(), fp);
	r.setTop(r.top() + he);
	++it;
      } while (it != attributes.end());
    }

    if (fp != 0)
      fputs("</g>\n", fp);
        
    if (selected())
      show_mark(p, rect());
  }
}