Do not use validationChanged and nestedChanged signals for this. Use direct methods updateAction of error manager.
Update application Accept actions by signal of model about feature state change, but not by updated signal of object.
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_REPAIRED));
mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop));
mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop));
foreach(ObjectPtr aObj, aObjects)
aDisplayer->redisplay(aObj, false);
aDisplayer->updateViewer();
- } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_FAILED) ||
- theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)) {
- CompositeFeaturePtr aSketch = sketchMgr()->activeSketch();
- if (aSketch.get()) {
- if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)) {
- // it should be moved out, validating is called to update error string of the sketch feature
- if (sketchMgr()->activeSketch().get()) {
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- bool aValid = aFactory->validate(sketchMgr()->activeSketch());
- }
- }
-
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- aWorkshop->errorMgr()->updateActions(aSketch);
- }
}
}
if (aSketch.get() && aSketch == theFeature) {
AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
anError = aAttributeString->value().c_str();
- if (anError.isEmpty()) {
- if (isNestedCreateOperation(getCurrentOperation()) &&
- aSketch->numberOfSubs() == 1) {
- AttributePtr aFeaturesAttr = aSketch->attribute(SketchPlugin_Sketch::FEATURES_ID());
- anError = std::string("Attribute \"" + aFeaturesAttr->id() + "\" is not initialized.").c_str();
- }
- }
}
else if (myIsResetCurrentValue) { // this flag do not allow commit of the current operation
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
updateActionState(anOkAction, theFeature);
}
- //update AcceptAll action
+}
+
+void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
+{
+ QString anError = myWorkshop->module()->getFeatureError(theFeature);
+
+ XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
if (workshop()->isFeatureOfNested(theFeature)) {
QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
bool anEnabled = anError.isEmpty();
void updateActions(const FeaturePtr& theFeature);
+ /// Update enable state of AcceptAll action if the feature uses it
+ /// \param theFeature a feature
+ void updateAcceptAllAction(const FeaturePtr& theFeature);
+
/// Return true if the feature has no error. If there is an error and the action
/// is not valid, the dialog with the error information is shown.
/// \param theAction an action, which is checked on validity
if (theOperation) {
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
if (aFOperation)
- anErrorMgr->updateActions(aFOperation->feature());
+ anErrorMgr->updateAcceptAllAction(aFOperation->feature());
//emit nestedStateChanged(theOperation->getDescription()->operationId().toStdString(),
// theOperation->isValid());
}