@@ -2502,29 +2502,14 @@ void ModelWidget::getTLMComponents()
25022502
25032503void ModelWidget::getTLMConnections ()
25042504{
2505- // get the components and thier annotations
2506- QDomDocument doc;
2507- doc.setContent (getEditor ()->getPlainTextEdit ()->toPlainText ());
2508-
2509- // Get the "Root" element
2510- QDomElement docElem = doc.documentElement ();
2511-
2512- QDomElement connections = docElem.firstChildElement ();
2513- while (!connections.isNull ())
2514- {
2515- if (connections.tagName () == " Connections" )
2516- break ;
2517- connections = connections.nextSiblingElement ();
2518- }
2519-
2520- QDomElement connection = connections.firstChildElement (" Connection" );
2521- while (!connection.isNull ())
2522- {
2523- if (connection.tagName () == " Connection" )
2524- {
2525- QDomElement annotation = connection.firstChildElement (" Annotation" );
2526- if (annotation.tagName () == " Annotation" )
2527- {
2505+ TLMEditor *pTLMEditor = dynamic_cast <TLMEditor*>(mpEditor);
2506+ QDomNodeList connections = pTLMEditor->getConnections ();
2507+ for (int i = 0 ; i < connections.size (); i++) {
2508+ QDomElement connection = connections.at (i).toElement ();
2509+ QDomNodeList connectionChildren = connection.childNodes ();
2510+ for (int j = 0 ; j < connectionChildren.size () ; j++) {
2511+ QDomElement annotationElement = connectionChildren.at (j).toElement ();
2512+ if (annotationElement.tagName ().compare (" Annotation" ) == 0 ) {
25282513 // get start component
25292514 Component *pStartComponent = 0 ;
25302515 pStartComponent = mpDiagramGraphicsView->getComponentObject (StringHandler::getSubStringBeforeDots (connection.attribute (" From" )));
@@ -2535,42 +2520,35 @@ void ModelWidget::getTLMConnections()
25352520 Component *pStartConnectorComponent = 0 ;
25362521 Component *pEndConnectorComponent = 0 ;
25372522 if (pStartComponent)
2538- {
25392523 pStartConnectorComponent = pStartComponent;
2540- }
2541- if (pEndComponent)
2542- {
2543- pEndConnectorComponent = pEndComponent;
2544- }
2545- // get the connector annotations
2546- QString connectionAnnotationString;
2547- connectionAnnotationString.append (" {Line(true, {0.0, 0.0}, 0, " ).append (annotation.attribute (" Points" ));
2548- connectionAnnotationString.append (" , {0, 0, 0}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}" );
2549- QStringList shapesList = StringHandler::getStrings (StringHandler::removeFirstLastCurlBrackets (connectionAnnotationString), ' (' , ' )' );
2550- // Now parse the shapes available in list
2551- foreach (QString shape, shapesList)
2552- {
2553- if (shape.startsWith (" Line" ))
2554- {
2555- shape = shape.mid (QString (" Line" ).length ());
2556- shape = StringHandler::removeFirstLastBrackets (shape);
2557- LineAnnotation *pConnectionLineAnnotation = new LineAnnotation (shape, false , pStartConnectorComponent,
2558- pEndConnectorComponent, mpDiagramGraphicsView);
2559- if (pStartConnectorComponent)
2560- pStartConnectorComponent->getRootParentComponent ()->addConnectionDetails (pConnectionLineAnnotation);
2561- pConnectionLineAnnotation->setStartComponentName (StringHandler::getSubStringBeforeDots (connection.attribute (" From" )));
2562- if (pEndConnectorComponent)
2563- pEndConnectorComponent->getRootParentComponent ()->addConnectionDetails (pConnectionLineAnnotation);
2564- pConnectionLineAnnotation->setEndComponentName (StringHandler::getSubStringBeforeDots (connection.attribute (" To" )));
2565- pConnectionLineAnnotation->addPoint (QPointF (0 , 0 ));
2566- pConnectionLineAnnotation->drawCornerItems ();
2567- pConnectionLineAnnotation->setCornerItemsPassive ();
2568- mpDiagramGraphicsView->addConnectionObject (pConnectionLineAnnotation);
2524+ if (pEndComponent)
2525+ pEndConnectorComponent = pEndComponent;
2526+ // get the connector annotations
2527+ QString connectionAnnotationString;
2528+ connectionAnnotationString.append (" {Line(true, {0.0, 0.0}, 0, " ).append (annotationElement.attribute (" Points" ));
2529+ connectionAnnotationString.append (" , {0, 0, 0}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}" );
2530+ QStringList shapesList = StringHandler::getStrings (StringHandler::removeFirstLastCurlBrackets (connectionAnnotationString), ' (' , ' )' );
2531+ // Now parse the shapes available in list
2532+ foreach (QString shape, shapesList) {
2533+ if (shape.startsWith (" Line" )) {
2534+ shape = shape.mid (QString (" Line" ).length ());
2535+ shape = StringHandler::removeFirstLastBrackets (shape);
2536+ LineAnnotation *pConnectionLineAnnotation = new LineAnnotation (shape, false , pStartConnectorComponent,
2537+ pEndConnectorComponent, mpDiagramGraphicsView);
2538+ if (pStartConnectorComponent)
2539+ pStartConnectorComponent->getRootParentComponent ()->addConnectionDetails (pConnectionLineAnnotation);
2540+ pConnectionLineAnnotation->setStartComponentName (StringHandler::getSubStringBeforeDots (connection.attribute (" From" )));
2541+ if (pEndConnectorComponent)
2542+ pEndConnectorComponent->getRootParentComponent ()->addConnectionDetails (pConnectionLineAnnotation);
2543+ pConnectionLineAnnotation->setEndComponentName (StringHandler::getSubStringBeforeDots (connection.attribute (" To" )));
2544+ pConnectionLineAnnotation->addPoint (QPointF (0 , 0 ));
2545+ pConnectionLineAnnotation->drawCornerItems ();
2546+ pConnectionLineAnnotation->setCornerItemsPassive ();
2547+ mpDiagramGraphicsView->addConnectionObject (pConnectionLineAnnotation);
25692548 }
25702549 }
25712550 }
25722551 }
2573- connection = connection.nextSiblingElement ();
25742552 }
25752553}
25762554
0 commit comments