From: nds Date: Wed, 22 Jun 2016 06:16:02 +0000 (+0300) Subject: Unpressing the button of the current action must behave like a validation if the... X-Git-Tag: V_2.4.0~73 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c8ab29e531ee03054976a7606076f2c4ee1d9f6b;p=modules%2Fshaper.git Unpressing the button of the current action must behave like a validation if the entity can be created (instead of Cancel, as currently) --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 9442ddc27..942d9ec65 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -201,7 +201,7 @@ void ModuleBase_IModule::onFeatureTriggered() if (aCmd->isCheckable() && !aCmd->isChecked()) { ModuleBase_Operation* anOperation = myWorkshop->findStartedOperation(aCmd->data().toString()); if (myWorkshop->canStopOperation(anOperation)) - myWorkshop->abortOperation(anOperation); + myWorkshop->stopOperation(anOperation); else { aCmd->setChecked(true); } diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index ec8d04906..c7ff4ceee 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -86,9 +86,9 @@ Q_OBJECT //! \return boolean result virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0; - //! Aborts the operation. + //! Commits if possible or aborts the given operation. //! \param theOperation an aborted operation - virtual void abortOperation(ModuleBase_Operation* theOperation) = 0; + virtual void stopOperation(ModuleBase_Operation* theOperation) = 0; //! Returns AIS object by data object //! \param theObject a data object diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 8b19dcd82..af08c48fd 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -142,6 +142,17 @@ void ModuleBase_Operation::onValuesChanged() myIsModified = true; } +void ModuleBase_Operation::onValueStateChanged(int thePreviousState) +{ + if (propertyPanel()) { + ModuleBase_ModelWidget* aWidget = propertyPanel()->activeWidget(); + if (aWidget) { + if (aWidget->getValueState() == ModuleBase_ModelWidget::ModifiedInPP) + myIsModified = true; + } + } +} + void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) { myPropertyPanel = theProp; diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 0fffbc0fd..2e04b5b07 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -148,6 +148,10 @@ signals: /// Changes the modified flag of the operation void onValuesChanged(); + /// Changes the modified flag of the operation if the current state of the widget is modified + /// \param thePreviousState the previous vlaue state of the widget + void onValueStateChanged(int thePreviousState); + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 6066fa00a..9745c5fe0 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -497,6 +497,7 @@ void ModuleBase_OperationFeature::setPropertyPanel(ModuleBase_IPropertyPanel* th for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { ModuleBase_ModelWidget* aWgt = (*aWIt); connect(aWgt, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged())); + connect(aWgt, SIGNAL(valueStateChanged(int)), this, SLOT(onValueStateChanged(int))); } } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index d3eb60aa1..1892f8b0a 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -796,7 +796,9 @@ bool PartSet_Module::deleteObjects() void PartSet_Module::onFeatureTriggered() { - QAction* aCmd = dynamic_cast(sender()); + // is commented for imp: Unpressing the button of the current action must behave like + // a validation if the entity can be created (instead of Cancel, as currently) + /*QAction* aCmd = dynamic_cast(sender()); if (aCmd->isCheckable() && aCmd->isChecked()) { // 1. check whether the delete should be processed in the module ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); @@ -811,7 +813,7 @@ void PartSet_Module::onFeatureTriggered() launchOperation(aCmd->data().toString()); } } - } + }*/ ModuleBase_IModule::onFeatureTriggered(); } diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 5fbeebf5e..a01004ceb 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -139,9 +139,9 @@ bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation) return myWorkshop->operationMgr()->canStopOperation(theOperation); } -void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation) +void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation) { - myWorkshop->operationMgr()->abortOperation(theOperation); + myWorkshop->operationMgr()->stopOperation(theOperation); } void XGUI_ModuleConnector::updateCommandStatus() diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 0afbe49ac..89f5625dd 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -67,9 +67,9 @@ Q_OBJECT //! \return boolean result virtual bool canStopOperation(ModuleBase_Operation* theOperation); - //! Aborts the operation. The operation manager is called. + //! Commits if possible or aborts the given operation. //! \param theOperation an aborted operation - void abortOperation(ModuleBase_Operation* theOperation); + virtual void stopOperation(ModuleBase_Operation* theOperation); //! Returns AIS object by data object virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const; diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index b41264d77..d975519a3 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -368,10 +368,7 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId) else if (canStopOperation(aCurrentOp)) { // the started operation is granted in the parrent operation, // e.g. current - Line in Sketch, started Circle - if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && aCurrentOp->isModified()) - aCurrentOp->commit(); - else - abortOperation(aCurrentOp); + stopOperation(aCurrentOp); } else { aCanStart = false; } @@ -380,6 +377,14 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId) return aCanStart; } +void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation) +{ + if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified()) + theOperation->commit(); + else + abortOperation(theOperation); +} + void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation) { ModuleBase_Operation* aCurrentOperation = currentOperation(); diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 2b3e31069..41d678c59 100755 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -103,6 +103,10 @@ Q_OBJECT /// \param theId id of the operation which is going to start bool canStartOperation(const QString& theId); + /// If Apply is enabled and operation has modification, it is applyed, otherwise aborted + /// \param theOperation the started operation + void stopOperation(ModuleBase_Operation* theOperation); + /// Aborts the parameter operation if it is current, else abort operations from the stack /// of operations until the operation is found. All operations upper the parameter one are /// not aborted.