Skip to content

Commit

Permalink
Prevent model editing from HCOM when editing is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Sep 20, 2024
1 parent 8aa4550 commit 3e7ece4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions HopsanGUI/HcomHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,11 @@ void HcomHandler::executeAddParameterCommand(const QString cmd)
//! @brief Execute function for "chpa" command
void HcomHandler::executeChangeParameterCommand(const QString cmd)
{
if(mpModel->isEditingFullyDisabled()) {
HCOMERR("Model editing is currently disabled");
return;
}

QStringList splitCmd;
splitWithRespectToQuotations(cmd, ' ', splitCmd);

Expand Down Expand Up @@ -4801,6 +4806,11 @@ void HcomHandler::executeRenameComponentCommand(const QString cmd)
return;
}

if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

SystemObject *pContainer = mpModel->getViewContainerObject();
if(pContainer)
{
Expand All @@ -4817,6 +4827,11 @@ void HcomHandler::executeRemoveComponentCommand(const QString cmd)
return;
}

if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

QList<ModelObject*> components;
getComponents(args[0], components);

Expand Down Expand Up @@ -4944,6 +4959,11 @@ void HcomHandler::executeListFilesCommand(const QString cmd)
//! @brief Execute function for "close" command
void HcomHandler::executeCloseModelCommand(const QString cmd)
{
if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

QStringList args = splitCommandArguments(cmd);
if(args.size() > 2)
{
Expand Down Expand Up @@ -5000,6 +5020,12 @@ void HcomHandler::executeAddComponentCommand(const QString cmd)
HCOMERR("Wrong number of arguments");
return;
}

if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

QStringList args = splitCommandArguments(cmd);

QString typeName = args[0];
Expand Down Expand Up @@ -5171,6 +5197,12 @@ void HcomHandler::executeReplaceComponentCommand(const QString cmd)
HCOMERR("Wrong number of arguments");
return;
}

if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

QStringList args = splitCommandArguments(cmd);

QString name = args[0];
Expand All @@ -5190,6 +5222,11 @@ void HcomHandler::executeConnectCommand(const QString cmd)
return;
}

if(mpModel->isEditingLimited()) {
HCOMERR("Model editing is currently disabled");
return;
}

ModelObject *pComponent1, *pComponent2;
pComponent1 = mpModel->getViewContainerObject()->getModelObject(args[0]);
if(pComponent1 == nullptr) {
Expand Down

0 comments on commit 3e7ece4

Please sign in to comment.