X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/43fd94117de66d533ef9e58b2de85daa244da309..624231601a0f5daea9b8809993ad3503beafce4f:/GroupItem.cpp diff --git a/GroupItem.cpp b/GroupItem.cpp index 679cc5e..e219f4c 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -125,7 +125,7 @@ void GroupItem::updateMinimumSize() { if (getScene() == NULL) return; - QList blocks = getScene()->getBlockItems(); + QList blocks = getScene()->getBoxItems(); if(blocks.length() > 0) { // first, search for blocks that are at (0,0) int xMaxZero = 0; @@ -259,13 +259,29 @@ bool GroupItem::updateGeometry(ChangeType type) { originPoint.setY(y); if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { - cout << "must change group item shape" << endl; + cout << "GroupItem: must change group item shape" << endl; prepareGeometryChange(); return true; } return false; } +void GroupItem::nameChanged() { + + + QFontMetrics fmId(params->defaultBlockFont); + nameWidth = fmId.width(refBlock->getName()); + nameHeight = fmId.height(); + // changing the BoxItem in the upperscene + if (parentItem != NULL) { + parentItem->nameChanged(); + } + updateGeometry(InterfaceMove); + // force the update in case of the size has not changed + update(); +} + + void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if(params->editState == Parameters::EditGroupMove) { @@ -367,12 +383,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); - /* NOTE : commneted because group interface are normally - created and the connected directly to a block within - the group. Furthermore, there can be a single connection - from a groupe interface. - - if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { + if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceFromCursor(x,y); if (inter != NULL) { @@ -390,9 +401,8 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } } } - } - */ - if (mode == GroupScene::ItemEdition) { + } + else if (mode == GroupScene::ItemEdition) { if (params->cursorState == Parameters::CursorOnInterface) { InterfaceItem *inter = getInterfaceFromCursor(x,y); @@ -417,12 +427,7 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - /* NOTE : commneted because group interface are normally - created and the connected directly to a block within - the group. Furthermore, there can be a single connection - from a groupe interface. - - if (mode == GroupScene::AddConnection) { + if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection)) { if (params->editState == Parameters::EditStartConnection) { params->setEditState(Parameters::EditStartConnection); @@ -440,7 +445,7 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->connect(iface1,iface2); + bool ok = dispatcher->createConnectionItem(iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -449,9 +454,8 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { params->setEditState(Parameters::EditNoOperation); } } - } - */ - if (mode == GroupScene::ItemEdition) { + } + else if (mode == GroupScene::ItemEdition) { currentInterface = NULL; setFlag(ItemIsMovable, true); params->editState = Parameters::EditNoOperation; @@ -572,7 +576,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if(ifaceItem != NULL) dispatcher->renameInterface(ifaceItem); else - dispatcher->renameBlockOrGroup(this); + dispatcher->renameGroupBlock(this); } else if(selectedAction == showProperties){ dispatcher->showProperties(ifaceItem); @@ -647,7 +651,7 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { double position = currentInterfaceNode.attribute("position","none").toDouble(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction); + GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,AbstractInterface::Data); InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params); interfaceItem->setId(id); @@ -669,7 +673,7 @@ void GroupItem::save(QXmlStreamWriter &writer) { if(parentItem != NULL){ attrUpperItem = QString::number(parentItem->getId()); } - QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y())); + QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y()))); QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));