- // the enable state of the parent operation of the nested one is defined by the rules that
- // firstly there are nested operations and secondly the parent operation is valid
- ModuleBase_Operation* aPrevOp;
- Operations::const_iterator anIt = myOperations.end();
- if (anIt != myOperations.begin()) { // there are items in the operations list
- --anIt;
- aPrevOp = *anIt; // the last top operation, the operation which is started
- if (anIt != myOperations.begin()) { // find the operation where the started operation is nested
- --anIt;
- aPrevOp = *anIt;
- }
- }
- bool isNestedOk = (myOperations.count() >= 1) && aPrevOp->isValid();
- emit nestedStateChanged(isNestedOk);
+ bool aParentValid = isParentOperationValid();
+ // in order to apply is enabled only if there are modifications in the model
+ // e.g. sketch can be applyed only if at least one nested element modification is finished
+ bool aCanUndo = ModelAPI_Session::get()->canUndo();
+ emit nestedStateChanged(aParentValid && aCanUndo);
+