+ //ModuleBase_Operation* anOperation = currentOperation();
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (currentOperation());
+ if(aFOperation && aFOperation->feature().get()) {
+ //bool aCanCommit = myWorkshop->module()->canCommitOperation();
+ //setApplyEnabled(!myIsValidationLock && aCanCommit && anOperation->isValid());
+ setApplyEnabled(myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty());
+ }
+}
+
+void XGUI_OperationMgr::setLockValidating(bool toLock)
+{
+ myIsValidationLock = toLock;
+ onValidateOperation();
+}
+
+void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
+{
+ myIsApplyEnabled = theEnabled;
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (currentOperation());
+ if (aFOperation) {
+ workshop()->errorMgr()->updateActions(aFOperation->feature());
+ }
+ //emit validationStateChanged(theEnabled);
+}
+
+void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperation)
+{
+ XGUI_ErrorMgr* anErrorMgr = workshop()->errorMgr();
+ if (theOperation) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
+ if (aFOperation)
+ anErrorMgr->updateAcceptAllAction(aFOperation->feature());
+ //emit nestedStateChanged(theOperation->getDescription()->operationId().toStdString(),
+ // theOperation->isValid());
+ }
+ else {
+ foreach(ModuleBase_Operation* anOperation, myOperations) {
+ if (anOperation)
+ updateApplyOfOperations(anOperation);
+ //emit nestedStateChanged(anOperation->getDescription()->operationId().toStdString(),
+ // anOperation->isValid());
+ }
+ }
+}
+
+bool XGUI_OperationMgr::isApplyEnabled() const
+{
+ return myIsApplyEnabled;
+}
+
+bool XGUI_OperationMgr::isParentOperationValid() const
+{
+ bool isValid = false;
+ // 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 = 0;
+ 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;
+ }
+ }
+ return aPrevOp && aPrevOp->isValid();
+}
+
+bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
+{
+ //in case of nested (sketch) operation no confirmation needed
+ if (isGrantedOperation(theOperation))
+ return true;
+ if (theOperation && theOperation->isModified()) {
+ QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
+ int anAnswer = QMessageBox::question(qApp->activeWindow(),
+ tr("Abort operation"),
+ aMessage,
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel);
+ return anAnswer == QMessageBox::Ok;
+ }
+ return true;