@@ -117,7 +117,7 @@ void GraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
117117 // ! @todo Grid Lines changes when resize the window. Update it.
118118 if (mpParentProjectTab->mpParentProjectTabWidget ->mShowLines )
119119 {
120- painter->scale (1.0 , -1.0 );
120+ // painter->scale(1.0, -1.0);
121121 painter->setBrush (Qt::NoBrush);
122122 painter->setPen (Qt::gray);
123123
@@ -781,7 +781,7 @@ void GraphicsView::contextMenuEvent(QContextMenuEvent *event)
781781 QMenu menu (mpParentProjectTab->mpParentProjectTabWidget ->mpParentMainWindow );
782782 mpCancelConnectionAction->setText (" Context Menu" );
783783 menu.addAction (mpParentProjectTab->mpParentProjectTabWidget ->mpParentMainWindow ->exportAsImage );
784- menu.addAction (mpParentProjectTab->mpParentProjectTabWidget ->mpParentMainWindow ->exportToOMNotebookAction );
784+ // menu.addAction(mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow->exportToOMNotebookAction);
785785 menu.exec (event->globalPos ());
786786 return ; // return from it because at a time we only want one context menu.
787787 }
@@ -1918,7 +1918,7 @@ ProjectTabWidget::ProjectTabWidget(MainWindow *parent)
19181918 mShowLines = false ;
19191919 mToolBarEnabled = true ;
19201920
1921- connect (mpParentMainWindow->openAction , SIGNAL (triggered ()), this ,SLOT (openModel ()));
1921+ connect (mpParentMainWindow->openAction , SIGNAL (triggered ()), this ,SLOT (openFile ()));
19221922 connect (mpParentMainWindow->saveAction , SIGNAL (triggered ()), this ,SLOT (saveProjectTab ()));
19231923 connect (mpParentMainWindow->saveAsAction , SIGNAL (triggered ()), this ,SLOT (saveProjectTabAs ()));
19241924 connect (this ,SIGNAL (tabCloseRequested (int )),SLOT (closeProjectTab (int )));
@@ -2381,7 +2381,7 @@ bool ProjectTabWidget::closeAllProjectTabs()
23812381
23822382// ! Loads a model from a file and opens it in a new project tab.
23832383// ! @see saveModel(bool saveAs)
2384- void ProjectTabWidget::openModel (QString fileName)
2384+ void ProjectTabWidget::openFile (QString fileName)
23852385{
23862386 if (fileName.isEmpty ())
23872387 {
@@ -2394,7 +2394,6 @@ void ProjectTabWidget::openModel(QString fileName)
23942394 fileName = name;
23952395 }
23962396
2397-
23982397 // create new OMC instance and load the file in it
23992398 OMCProxy *omc = new OMCProxy (mpParentMainWindow, false );
24002399 // if error in loading file
@@ -2423,7 +2422,57 @@ void ProjectTabWidget::openModel(QString fileName)
24232422 if (existModel)
24242423 {
24252424 QMessageBox *msgBox = new QMessageBox (mpParentMainWindow);
2426- msgBox->setWindowTitle (QString (Helper::applicationName).append (" - Question" ));
2425+ msgBox->setWindowTitle (QString (Helper::applicationName).append (" - Information" ));
2426+ msgBox->setIcon (QMessageBox::Information);
2427+ msgBox->setText (QString (GUIMessages::getMessage (GUIMessages::UNABLE_TO_LOAD_FILE)));
2428+ msgBox->setInformativeText (QString (GUIMessages::getMessage (GUIMessages::REDEFING_EXISTING_MODELS))
2429+ .arg (existingmodelsList.join (" ," )).append (" \n " )
2430+ .append (GUIMessages::getMessage (GUIMessages::DELETE_AND_LOAD)));
2431+ msgBox->setStandardButtons (QMessageBox::Ok);
2432+ msgBox->exec ();
2433+ }
2434+ // if no conflicting model found then just load the file simply
2435+ else
2436+ {
2437+ mpParentMainWindow->mpLibrary ->loadFile (fileName, modelsList);
2438+ }
2439+ // quit the temporary OMC
2440+ omc->stopServer ();
2441+ }
2442+
2443+ // ! Loads a model and opens it in a new project tab.
2444+ // ! @see saveModel(bool saveAs)
2445+ void ProjectTabWidget::openModel (QString modelText)
2446+ {
2447+ // create new OMC instance and load the file in it
2448+ OMCProxy *omc = new OMCProxy (mpParentMainWindow, false );
2449+ // if error in loading file
2450+ if (!omc->saveModifiedModel (modelText))
2451+ {
2452+ QString message = QString (GUIMessages::getMessage (GUIMessages::UNABLE_TO_LOAD_FILE))
2453+ .append (omc->getErrorString ());
2454+ mpParentMainWindow->mpMessageWidget ->printGUIErrorMessage (message);
2455+ return ;
2456+ }
2457+ // get the class names now to check if they are already loaded or not
2458+ QStringList existingmodelsList;
2459+ QStringList modelsList = omc->getClassNames ();
2460+ bool existModel = false ;
2461+ // check if the model already exists in OMEdit OMC instance
2462+ foreach (QString model, modelsList)
2463+ {
2464+ if (mpParentMainWindow->mpOMCProxy ->existClass (model))
2465+ {
2466+ existingmodelsList.append (model);
2467+ existModel = true ;
2468+ }
2469+ }
2470+
2471+ // check if existModel is true
2472+ if (existModel)
2473+ {
2474+ QMessageBox *msgBox = new QMessageBox (mpParentMainWindow);
2475+ msgBox->setWindowTitle (QString (Helper::applicationName).append (" - Information" ));
24272476 msgBox->setIcon (QMessageBox::Information);
24282477 msgBox->setText (QString (GUIMessages::getMessage (GUIMessages::UNABLE_TO_LOAD_FILE)));
24292478 msgBox->setInformativeText (QString (GUIMessages::getMessage (GUIMessages::REDEFING_EXISTING_MODELS))
@@ -2435,7 +2484,7 @@ void ProjectTabWidget::openModel(QString fileName)
24352484 // if no conflicting model found then just load the file simply
24362485 else
24372486 {
2438- mpParentMainWindow->mpLibrary ->loadModel (fileName , modelsList);
2487+ mpParentMainWindow->mpLibrary ->loadModel (modelText , modelsList);
24392488 }
24402489 // quit the temporary OMC
24412490 omc->stopServer ();
0 commit comments