]> AND Private Git Repository - blast.git/blobdiff - GroupItem.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
added source items
[blast.git] / GroupItem.cpp
index 69b5e0473dc19ca5a5a622883bc49613f4750b1f..c965452a932cbb99fd288e55d70ace9f575a83e4 100644 (file)
@@ -125,7 +125,7 @@ void GroupItem::updateMinimumSize() {
 
   if (getScene() == NULL) return;
 
 
   if (getScene() == NULL) return;
 
-  QList<BoxItem *> blocks = getScene()->getBlockItems();
+  QList<BoxItem *> blocks = getScene()->getBoxItems();
   if(blocks.length() > 0) {
     // first, search for blocks that are at (0,0)
     int xMaxZero = 0;
   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)) {
   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;
 }
 
     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) {
 void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditGroupMove) {
@@ -572,7 +588,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
     if(ifaceItem != NULL)
       dispatcher->renameInterface(ifaceItem);
     else
     if(ifaceItem != NULL)
       dispatcher->renameInterface(ifaceItem);
     else
-      dispatcher->renameBlockOrGroup(this);
+      dispatcher->renameGroupBlock(this);
   }
   else if(selectedAction == showProperties){
     dispatcher->showProperties(ifaceItem);
   }
   else if(selectedAction == showProperties){
     dispatcher->showProperties(ifaceItem);
@@ -636,10 +652,6 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
     QString name = currentInterfaceNode.attribute("name","none");
     if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     QString name = currentInterfaceNode.attribute("name","none");
     if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
-    QString levelStr = currentInterfaceNode.attribute("level","none");
-    int level = AbstractInterface::getIntLevel(levelStr);
-    if(level == -1) throw(Exception(PROJECTFILE_CORRUPTED));
-
     QString directionStr = currentInterfaceNode.attribute("direction","none");
     int direction = AbstractInterface::getIntDirection(directionStr);
     if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));
     QString directionStr = currentInterfaceNode.attribute("direction","none");
     int direction = AbstractInterface::getIntDirection(directionStr);
     if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));
@@ -651,7 +663,7 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
     double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
 
     double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
 
-    GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,level);
+    GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,AbstractInterface::Data);
 
     InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params);
     interfaceItem->setId(id);
 
     InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params);
     interfaceItem->setId(id);
@@ -673,7 +685,7 @@ void GroupItem::save(QXmlStreamWriter &writer) {
   if(parentItem != NULL){
     attrUpperItem = QString::number(parentItem->getId());
   }
   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()));
 
 
   QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
 
 
@@ -691,8 +703,7 @@ void GroupItem::save(QXmlStreamWriter &writer) {
     writer.writeStartElement("group_iface");
 
     writer.writeAttribute("id",QString::number(item->getId()));
     writer.writeStartElement("group_iface");
 
     writer.writeAttribute("id",QString::number(item->getId()));
-    writer.writeAttribute("name",item->getName());
-    writer.writeAttribute("level",QString(item->refInter->getLevelString()));
+    writer.writeAttribute("name",item->getName());    
     writer.writeAttribute("direction",QString(item->refInter->getDirectionString()));
     writer.writeAttribute("orientation",item->getStrOrientation());
     writer.writeAttribute("position",QString::number(item->getPositionRatio()));
     writer.writeAttribute("direction",QString(item->refInter->getDirectionString()));
     writer.writeAttribute("orientation",item->getStrOrientation());
     writer.writeAttribute("position",QString::number(item->getPositionRatio()));