Changeset 6dbd8bc in OpenModelica
- Timestamp:
- 2016-04-08T15:46:20+02:00 (8 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- 1e8523c
- Parents:
- aef3c2c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditGUI/Editors/MetaModelEditor.cpp
raef3c2c3 r6dbd8bc 459 459 } else { // insert interface point 460 460 QDomElement interfacePoint = mXmlDocument.createElement("InterfacePoint"); 461 interfacePoint.setAttribute("Name", interfaceDataElement.attribute(" name"));461 interfacePoint.setAttribute("Name", interfaceDataElement.attribute("Name")); 462 462 interfacePoint.setAttribute("Position", interfaceDataElement.attribute("Position")); 463 463 interfacePoint.setAttribute("Angle321", interfaceDataElement.attribute("Angle321")); 464 464 subModel.appendChild(interfacePoint); 465 setPlainText(mXmlDocument.toString());466 465 Component *pComponent = mpModelWidget->getDiagramGraphicsView()->getComponentObject(subModel.attribute("Name")); 467 466 if (pComponent) { 468 pComponent->insertInterfacePoint(interfaceDataElement.attribute(" name"));467 pComponent->insertInterfacePoint(interfaceDataElement.attribute("Name")); 469 468 } 470 469 } … … 472 471 interfaceDataElement = interfaceDataElement.nextSiblingElement(); 473 472 } 474 } 473 474 //Now remove all elements in sub model that does not exist in fetched interfaces (i.e. has been externally removed) 475 subModel = subModelList.at(i).toElement(); 476 QDomElement subModelInterfaceDataElement = subModel.firstChildElement("InterfacePoint"); 477 while(!subModelInterfaceDataElement.isNull()) 478 { 479 bool interfaceExists=false; 480 interfaceDataElement = interfaces.firstChildElement(); 481 while(!interfaceDataElement.isNull()) { 482 if(subModelInterfaceDataElement.attribute("Name") == interfaceDataElement.attribute("Name") && 483 subModel.attribute("Name") == interfaceDataElement.attribute("model")) { 484 interfaceExists=true; 485 } 486 interfaceDataElement = interfaceDataElement.nextSiblingElement(); 487 } 488 if(!interfaceExists) { 489 QDomElement elementToRemove = subModelInterfaceDataElement; 490 subModelInterfaceDataElement = subModelInterfaceDataElement.nextSiblingElement("InterfacePoint"); 491 subModel.removeChild(elementToRemove); 492 } 493 else { 494 subModelInterfaceDataElement = subModelInterfaceDataElement.nextSiblingElement("InterfacePoint"); 495 } 496 } 497 } 498 499 //Remove connections between no longer existing elements 500 QDomNodeList connectionsList = mXmlDocument.elementsByTagName("Connection"); 501 for (int i = 0 ; i < connectionsList.size() ; i++) { 502 QDomElement connection = connectionsList.at(i).toElement(); 503 QString from = connection.attribute("From"); 504 QString to = connection.attribute("To"); 505 506 bool fromExists=false; 507 bool toExists=false; 508 for(int i=0; i<subModelList.size(); ++i) { 509 QDomElement subModel = subModelList.at(i).toElement(); 510 QDomElement subModelInterfaceDataElement = subModel.firstChildElement("InterfacePoint"); 511 while(!subModelInterfaceDataElement.isNull()) { 512 if(subModel.attribute("Name") == from.section(".",0,0) && 513 subModelInterfaceDataElement.attribute("Name") == from.section(".",1,1)) { 514 fromExists = true; 515 } 516 else if(subModel.attribute("Name") == to.section(".",0,0) && 517 subModelInterfaceDataElement.attribute("Name") == to.section(".",1,1)) { 518 toExists = true; 519 } 520 subModelInterfaceDataElement = subModelInterfaceDataElement.nextSiblingElement("InterfacePoint"); 521 } 522 } 523 if(!fromExists || !toExists) 524 { 525 connection.parentNode().removeChild(connection); 526 --i; 527 } 528 } 529 530 setPlainText(mXmlDocument.toString()); 475 531 } 476 532
Note: See TracChangeset
for help on using the changeset viewer.