Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit bb9c414

Browse files
committed
Delete functionality for OMSimulator
1 parent 7493133 commit bb9c414

4 files changed

Lines changed: 22 additions & 15 deletions

File tree

OMEdit/OMEditGUI/Modeling/Commands.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,18 +1875,19 @@ void AddSystemCommand::redoInternal()
18751875
*/
18761876
void AddSystemCommand::undo()
18771877
{
1878-
// delete the connector
1879-
/*! @todo Add a function deleteSystem to delete the system from OMSimulator */
1880-
//mpGraphicsView->deleteSystem(mName);
1878+
// delete the system
1879+
LibraryTreeItem *pParentLibraryTreeItem = mpGraphicsView->getModelWidget()->getLibraryTreeItem();
1880+
QString nameStructure = QString("%1.%2").arg(pParentLibraryTreeItem->getNameStructure()).arg(mName);
1881+
OMSProxy::instance()->omsDelete(nameStructure);
18811882
// delete the LibraryTreeItem
1882-
// MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->unloadOMSModel(mpLibraryTreeItem, false);
1883-
// mpLibraryTreeItem = 0;
1884-
// // delete the Component
1885-
// mpGraphicsView->removeItem(mpComponent);
1886-
// mpGraphicsView->removeItem(mpComponent->getOriginItem());
1887-
// mpGraphicsView->deleteComponentFromList(mpComponent);
1888-
// mpComponent->deleteLater();
1889-
// mpComponent = 0;
1883+
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->unloadOMSModel(mpLibraryTreeItem, false);
1884+
mpLibraryTreeItem = 0;
1885+
// delete the Component
1886+
mpGraphicsView->removeItem(mpComponent);
1887+
mpGraphicsView->removeItem(mpComponent->getOriginItem());
1888+
mpGraphicsView->deleteComponentFromList(mpComponent);
1889+
mpComponent->deleteLater();
1890+
mpComponent = 0;
18901891
}
18911892

18921893
/*!

OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,9 @@ void LibraryTreeModel::updateLibraryTreeItemClassText(LibraryTreeItem *pLibraryT
14221422
pParentLibraryTreeItem->getModelWidget()->setWindowTitle(QString(pParentLibraryTreeItem->getName()).append("*"));
14231423
ModelicaEditor *pModelicaEditor = dynamic_cast<ModelicaEditor*>(pParentLibraryTreeItem->getModelWidget()->getEditor());
14241424
if (pModelicaEditor) {
1425+
bool blockSignalsState = pModelicaEditor->getPlainTextEdit()->document()->blockSignals(true);
14251426
pModelicaEditor->setPlainText(contents);
1427+
pModelicaEditor->getPlainTextEdit()->document()->blockSignals(blockSignalsState);
14261428
}
14271429
}
14281430
// if we first updated the parent class then the child classes needs to be updated as well.
@@ -1448,7 +1450,9 @@ void LibraryTreeModel::updateLibraryTreeItemClassText(LibraryTreeItem *pLibraryT
14481450
if (pLibraryTreeItem->getModelWidget() && pLibraryTreeItem->getModelWidget()->getEditor()) {
14491451
OMSimulatorEditor *pOMSimulatorEditor = dynamic_cast<OMSimulatorEditor*>(pLibraryTreeItem->getModelWidget()->getEditor());
14501452
if (pOMSimulatorEditor) {
1453+
bool blockSignalsState = pOMSimulatorEditor->getPlainTextEdit()->document()->blockSignals(true);
14511454
pOMSimulatorEditor->setPlainText(contents);
1455+
pOMSimulatorEditor->getPlainTextEdit()->document()->blockSignals(blockSignalsState);
14521456
}
14531457
}
14541458
}

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,10 +4325,7 @@ void ModelWidget::updateModelicaTextManually(QString contents)
43254325
*/
43264326
void ModelWidget::updateUndoRedoActions()
43274327
{
4328-
if (mpIconGraphicsView && mpIconGraphicsView->isVisible()) {
4329-
MainWindow::instance()->getUndoAction()->setEnabled(mpUndoStack->canUndo());
4330-
MainWindow::instance()->getRedoAction()->setEnabled(mpUndoStack->canRedo());
4331-
} else if (mpDiagramGraphicsView && mpDiagramGraphicsView->isVisible()) {
4328+
if ((mpIconGraphicsView && mpIconGraphicsView->isVisible()) || (mpDiagramGraphicsView && mpDiagramGraphicsView->isVisible())) {
43324329
MainWindow::instance()->getUndoAction()->setEnabled(mpUndoStack->canUndo());
43334330
MainWindow::instance()->getRedoAction()->setEnabled(mpUndoStack->canRedo());
43344331
} else if (mpEditor && mpEditor->isVisible()) {

OMEdit/OMEditGUI/OMS/OMSProxy.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,12 @@ bool OMSProxy::newModel(QString cref)
306306
*/
307307
bool OMSProxy::omsDelete(QString cref)
308308
{
309+
QString command = "oms3_delete";
310+
QStringList args;
311+
args << cref;
312+
LOG_COMMAND(command, args);
309313
oms_status_enu_t status = oms3_delete(cref.toStdString().c_str());
314+
logResponse(command, status, &commandTime);
310315
return statusToBool(status);
311316
}
312317

0 commit comments

Comments
 (0)