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);
}
//! \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
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;
/// 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.
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)));
}
}
void PartSet_Module::onFeatureTriggered()
{
- QAction* aCmd = dynamic_cast<QAction*>(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<QAction*>(sender());
if (aCmd->isCheckable() && aCmd->isChecked()) {
// 1. check whether the delete should be processed in the module
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
launchOperation(aCmd->data().toString());
}
}
- }
+ }*/
ModuleBase_IModule::onFeatureTriggered();
}
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()
//! \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;
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;
}
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();
/// \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.