void QuickEdit::SetupExtraNodeController()
{

    extraNodeController = QSharedPointer<ItemController<BrowserNode> >( new ItemController<BrowserNode>());
    extraNodeController->SetColumns(columns);
    ADD_GETSET(BrowserExtraMember, extraNodeController, columns.indexOf("name"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString().toLatin1().constData, get_name, set_name);

    ADD_GETSET(BrowserExtraMember, extraNodeController, columns.indexOf("deleted"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toBool, deletedp, set_deleted);

    ADD_PIXMAP_GETTER(BrowserExtraMember, extraNodeController, columns.indexOf("name"), QVector<int>({Qt::DecorationRole}), pixmap);

    extraNodeController->AddFlagsFunctor
            (
                [&](const QModelIndex& index)
    {
        Qt::ItemFlags result;
        result |= Qt::ItemIsSelectable;
        if(!(index.column() *in(columns.indexOf("name"), columns.indexOf("deleted"))))
            return result;

        TreeItemInterface* iface = static_cast<TreeItemInterface*>(index.internalPointer());
        if(!iface)
            return result;
        BrowserNode* pointer = static_cast<BrowserNode*>(iface->InternalPointer());
        if(!pointer)
            return result;
        if(pointer->is_writable())
            result |= Qt::ItemIsEditable;
        result |=  Qt::ItemIsEnabled;
        return result;
    }
    );
}
BrowserNode * DeploymentNodeCanvas::new_type() {
  BrowserNode * container = (BrowserNode *)
    the_canvas()->browser_diagram()->parent();
  
  return (container->is_writable())
    ? BrowserDeploymentNode::add_deploymentnode(container)
    : 0;
}
void QuickEdit::SetupClassController()
{
    classController = QSharedPointer<ItemController<BrowserNode> >( new ItemController<BrowserNode>());
    classController->SetColumns(columns);
    ADD_GETSET(BrowserClass, classController, columns.indexOf("name"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString, get_name, set_name);
    ADD_GETSET(BrowserClass, classController, columns.indexOf("stereotype"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString, get_stereotype, def->set_stereotype);

    ADD_GETSET(BrowserClass, classController, columns.indexOf("deleted"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toBool, deletedp, set_deleted);

    ADD_GETSET_CONVERTED(BrowserClass, classController, columns.indexOf("visibility"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                         toString,BrowserNode::encode_visibility,visibility_as_string, pointer->def->set_uml_visibility);

    ADD_GETSET(BrowserClass, classController, columns.indexOf("abstract"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toBool, def->get_is_abstract, def->set_is_abstract);

    ADD_PIXMAP_GETTER(BrowserClass, classController, columns.indexOf("name"),QVector<int>({Qt::DecorationRole}), pixmap);


    classController->AddFlagsFunctor
            (
                [&](const QModelIndex& index)
    {
        Qt::ItemFlags result;
        result |= Qt::ItemIsSelectable;
        if(!(index.column() *in(columns.indexOf("name"),columns.indexOf("stereotype"),columns.indexOf("visibility"),columns.indexOf("abstract"), columns.indexOf("deleted"))))
            return result;

        TreeItemInterface* iface = static_cast<TreeItemInterface*>(index.internalPointer());
        if(!iface)
            return result;
        BrowserNode* pointer = static_cast<BrowserNode*>(iface->InternalPointer());
        if(!pointer)
            return result;
        if(pointer->is_writable())
            result |= Qt::ItemIsEditable;
        result |=  Qt::ItemIsEnabled;
        return result;
    }
    );
}
ClassInstanceDialog::ClassInstanceDialog(ClassInstanceData * i)
    : TabDialog(0, "class instance dialog", FALSE, Qt::WA_DeleteOnClose),
      inst(i), atbl(0), rtbl(0)
{
    setWindowTitle(tr("Class instance dialog"));

    BrowserNode * bn = inst->get_browser_node();

    bn->edit_start();

    if (bn->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    visit = !hasOkButton();

    GridBox * grid;

    // general tab

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));

    if (visit)
        edname->setReadOnly(TRUE);

    grid->addWidget(new QLabel(tr("stereotype :"), grid));
    grid->addWidget(edstereotype = new QComboBox( grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(bn->get_stereotype()));

    if (! visit) {
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlClassInstance));
        edstereotype->setAutoCompletion(completion());
    }

    SmallPushButton  * b;
    grid->addWidget(b = new SmallPushButton(tr("class :"), grid));

    connect(b, SIGNAL(clicked()), this, SLOT(menu_class()));

    grid->addWidget(edtype = new QComboBox(grid));

    if (visit) {
        edtype->addItem(inst->get_class()->full_name());
        nodes.append(inst->get_class());
    }
    else {
        BrowserClass::instances(nodes);
        nodes.full_names(list);
        edtype->addItems(list);
        edtype->setCurrentIndex(nodes.indexOf(inst->get_class()));
        connect(edtype, SIGNAL(activated(int)), this, SLOT(type_changed(int)));
    }

    if (visit)
        cl_container = 0;
    else {
        cl_container = (BrowserNode *) bn->parent();

        if ((cl_container != 0) && !cl_container->is_writable())
            cl_container = 0;
    }

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));

    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit) {
        connect(b =new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
        vtab->addWidget(b);
    }

    grid->addWidget(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");

    // attributes tab

    atbl = new MyTable(this);
    atbl->setColumnCount(3);
    //atbl->setSortingEnabled(true);
    atbl->setSelectionMode(QTableWidget::NoSelection);	// single does not work
    atbl->verticalHeader()->setSectionsMovable(true);
    atbl->verticalHeader()->setSectionsMovable(true);
    atbl->setHorizontalHeaderLabel(0, tr(" Attribute "));
    atbl->setHorizontalHeaderLabel(1, tr(" Class "));
    atbl->setHorizontalHeaderLabel(2, tr(" Value "));

    addTab(atbl, tr("Attributes"));

    // relation tab

    if (! inst->relations.isEmpty()) {
        rtbl = new RelTable(this, inst, visit);
        addTab(rtbl, tr("Relations"));
    }

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, tr("Properties"));

    type_changed(edtype->currentIndex());

    connect(m_tabWidget, SIGNAL(currentChanged(int)),
            this, SLOT(update_all_tabs(int)));

    open_dialog(this);
}
bool DeploymentNodeCanvas::new_type_available() {
  BrowserNode * container = (BrowserNode *)
    the_canvas()->browser_diagram()->parent();
  
  return container->is_writable();
}
Exemple #6
0
UseCaseDialog::UseCaseDialog(UseCaseData * u)
    : QTabDialog(0, 0, FALSE, WDestructiveClose), uc(u) {
  BrowserNode * bn = u->browser_node;
  
  bn->edit_start();
  
  if (bn->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  setCaption(TR("Use Case dialog"));
  
  bool visit = !hasOkButton();
  
  // general tab
  
  QGrid * grid = new QGrid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);

  new QLabel(TR("name : "), grid);
  edname = new LineEdit(bn->get_name(), grid);
  edname->setReadOnly(visit);

  new QLabel(TR("stereotype : "), grid);
  edstereotype = new QComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(uc->get_stereotype()));
  if (! visit) {
    edstereotype->insertStringList(BrowserUseCase::default_stereotypes());
    edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlUseCase));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  QSizePolicy sp = edstereotype->sizePolicy();
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
  
  new QLabel(TR("extension \npoints : "), grid);
  extension_points = new MultiLineEdit(grid);
  extension_points->setReadOnly(visit);
  extension_points->setText(uc->get_extension_points());
  QFont font = extension_points->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  extension_points->setFont(font);

  QVBox * vtab = new QVBox(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());
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  // USER : list key - value
  
  grid = new QGrid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(bn, grid, visit);
  addTab(grid, TR("Properties"));
  
  open_dialog(this);
}
Exemple #7
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;
}
void QuickEdit::SetupRelationController()
{
    relationController = QSharedPointer<ItemController<BrowserNode> >( new ItemController<BrowserNode>());
    relationController->SetColumns(columns);

    ADD_GETSET(BrowserRelation, relationController, columns.indexOf("name"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString, get_name, set_name);
    ADD_GETSET_DIRECT(BrowserRelation, relationController, columns.indexOf("default"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                      toString, def->a.init_value.operator QString());

    ADD_GETSET(BrowserRelation, relationController, columns.indexOf("deleted"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toBool, deletedp, set_deleted);

    std::function<void(RoleData& , UmlVisibility ) > f = [](RoleData& data, UmlVisibility vis){data.uml_visibility = vis;};

    ADD_PIXMAP_GETTER(BrowserRelation, relationController, columns.indexOf("name"), QVector<int>({Qt::DecorationRole}), pixmap);


    relationController->AddGetter(columns.indexOf("visibility"),QVector<int>({Qt::DisplayRole,Qt::EditRole}),
    [] (const BrowserNode* data, const QModelIndex& index)
{
    Q_UNUSED(index);
        if(!data)
    return QVariant();
    const BrowserRelation* pointer = static_cast<const BrowserRelation*>(data);
    if(pointer)
    return QVariant(pointer->visibility_as_string());
    else
    return QVariant();
    }
    );
    relationController->AddSetter(columns.indexOf("visibility"),QVector<int>({Qt::DisplayRole,Qt::EditRole}),
    [] (BrowserNode* data, QVariant value, const QModelIndex& index)
{
    Q_UNUSED(index);
        if(!data)
    return false;
    BrowserRelation* pointer = static_cast<BrowserRelation*>(data);
    if(pointer)
        pointer->def->a.uml_visibility = BrowserNode::encode_visibility(value.toString());
    pointer->modified();
    return true;
    }
    );


    ADD_GETSET_DIRECT(BrowserRelation, relationController, columns.indexOf("static"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                      toBool, def->a.isa_class_relation);
    ADD_GETSET_DIRECT(BrowserRelation, relationController, columns.indexOf("multiplicity"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                      toString, def->a.multiplicity.operator QString());

    relationController->AddGetter(columns.indexOf("type"),QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                                  [] (const BrowserNode* data, const QModelIndex& )
    {

        if(!data)
            return QVariant();
        const BrowserRelation* pointer = static_cast<const BrowserRelation*>(data);
        if(pointer)
            return QVariant(pointer->def->get_end_class()->get_name());
        else
            return QVariant();
    }
    );
    relationController->AddSetter(1,QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                                  [] (BrowserNode* data, QVariant value, const QModelIndex& )
    {
        if(!data)
            return false;
        BrowserRelation* pointer = static_cast<BrowserRelation*>(data);
        if(pointer)
            pointer->def->get_end_class()->set_name(value.toString());
        pointer->modified();
        return true;
    });


    relationController->AddFlagsFunctor
            (
                [&](const QModelIndex& index)
    {
        Qt::ItemFlags result;
        result |= Qt::ItemIsSelectable;
        if(!(index.column() *in(columns.indexOf("name"),columns.indexOf("type"),columns.indexOf("default"),columns.indexOf("visibility"), columns.indexOf("deleted"))))
            return result;

        TreeItemInterface* iface = static_cast<TreeItemInterface*>(index.internalPointer());
        if(!iface)
            return result;
        BrowserNode* pointer = static_cast<BrowserNode*>(iface->InternalPointer());
        if(!pointer)
            return result;
        if(pointer->is_writable() && (index.column() *in(columns.indexOf("name"),columns.indexOf("default"),columns.indexOf("visibility"))))
            result |= Qt::ItemIsEditable;
        result |=  Qt::ItemIsEnabled ;
        return result;
    }
    );
}
void QuickEdit::SetupAttributeController()
{
    attributeController = QSharedPointer<ItemController<BrowserNode> >( new ItemController<BrowserNode>());
    attributeController->SetColumns(columns);
    ADD_GETSET(BrowserAttribute, attributeController, columns.indexOf("name"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString, get_name, set_name);
    ADD_GETSET_DATA(BrowserAttribute, AttributeData, attributeController, columns.indexOf("type"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                    toString, get_type().get_type, set_type);
    ADD_GETSET_DATA(BrowserAttribute, AttributeData, attributeController, columns.indexOf("default_value"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                    toString, get_init_value, set_init_value);
    ADD_GETSET(BrowserAttribute, attributeController, columns.indexOf("stereotype"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toString, get_stereotype, def->set_stereotype);

    ADD_GETSET(BrowserAttribute, attributeController, columns.indexOf("deleted"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
               toBool, deletedp, set_deleted);

//    ADD_GETSET_DIRECT_ASSIGNMENT(BrowserAttribute, attributeController, columns.indexOf("visibility"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
//                                 visibility_as_string(), BrowserNode::encode_visibility(value.toString()));
    ADD_GETSET_CONVERTED(BrowserAttribute, attributeController, columns.indexOf("visibility"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                         toString,BrowserNode::encode_visibility,visibility_as_string, pointer->def->set_visibility);



    ADD_GETSET_DATA(BrowserAttribute, AttributeData, attributeController, columns.indexOf("static"), QVector<int>({Qt::DisplayRole,Qt::EditRole}),
                    toBool,get_isa_class_attribute, set_isa_class_attribute);





    ADD_PIXMAP_GETTER(BrowserAttribute, attributeController, columns.indexOf("name"), QVector<int>({Qt::DecorationRole}), pixmap);

    attributeController->AddFlagsFunctor
            (
                [&](const QModelIndex& index)
    {
        Qt::ItemFlags result;
        result |= Qt::ItemIsSelectable;
        if(!(index.column() *in(columns.indexOf("name"),columns.indexOf("type"),columns.indexOf("default_value"),columns.indexOf("stereotype"),
                                columns.indexOf("visibility"), columns.indexOf("static"), columns.indexOf("deleted"))))
            return result;

        TreeItemInterface* iface = static_cast<TreeItemInterface*>(index.internalPointer());
        if(!iface)
            return result;
        BrowserNode* pointer = static_cast<BrowserNode*>(iface->InternalPointer());
        if(!pointer)
            return result;
        if(pointer->is_writable())
            result |= Qt::ItemIsEditable;
        result |=  Qt::ItemIsEnabled ;
        return result;
    }
    );

    std::function<void(BrowserNode*,const QModelIndex& index)> f = [](BrowserNode* node ,const QModelIndex& index)
    {
        Q_UNUSED(index);
        BrowserAttribute* attr = static_cast<BrowserAttribute*>(node);
        attr->modified();
        attr->setText(0,attr->get_name() );
        attr->package_modified();
        attr->get_data()->modified();
    };
    attributeController->AddPostProcessors(columns.indexOf("name"), QVector<int>(QVector<int>({Qt::DisplayRole,Qt::EditRole})),f);
}