+void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
+{
+ QString anError = myWorkshop->module()->getFeatureError(theFeature);
+
+ //update Ok Action and header of property panel if the current operation started for the feature
+ XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (workshop()->operationMgr()->currentOperation());
+ if (aFOperation && aFOperation->feature() == theFeature) {
+ QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
+ updateActionState(anOkAction, theFeature);
+ }
+}
+
+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();
+ anAcceptAllAction->setEnabled(anEnabled);
+ anAcceptAllAction->setToolTip(anError);
+ }
+}
+
+bool XGUI_ErrorMgr::canProcessClick(QAction* theAction, const FeaturePtr& theFeature)
+{
+ QString anError = myWorkshop->module()->getFeatureError(theFeature);
+ bool isActionEnabled = anError.isEmpty();
+ if (!isActionEnabled && !anError.isEmpty()) {
+ if (!myErrorDialog) {
+ myErrorDialog = new QDialog(QApplication::desktop(), Qt::Popup);
+ QHBoxLayout* aLay = new QHBoxLayout(myErrorDialog);
+ aLay->setContentsMargins(0, 0, 0, 0);
+
+ QFrame* aMarginWidget = new QFrame(myErrorDialog);
+ aMarginWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
+
+ aLay->addWidget(aMarginWidget);
+ QHBoxLayout* aMarginLay = new QHBoxLayout(aMarginWidget);
+ aMarginLay->setContentsMargins(4, 4, 4, 4);
+
+ myErrorLabel = new QLabel(aMarginWidget);
+ aMarginLay->addWidget(myErrorLabel);
+ }
+ myErrorLabel->setText(anError);
+ myErrorDialog->move(QCursor::pos());
+ myErrorDialog->show();
+ }
+ return isActionEnabled;
+}
+
+void XGUI_ErrorMgr::updateActionState(QAction* theAction, const FeaturePtr& theFeature/*,
+ const bool theEnabled*/)
+{
+ QString anError = myWorkshop->module()->getFeatureError(theFeature);
+ bool anEnabled = anError.isEmpty();
+
+ bool isActionEnabled = theAction->data() != INVALID_VALUE;
+ if (anEnabled != isActionEnabled) {
+ // update enable state of the button
+ theAction->setIcon(anEnabled ? QIcon(":pictures/button_ok.png"): QIcon(":pictures/button_ok_error.png"));
+ if (anEnabled)
+ theAction->setData("");
+ else
+ theAction->setData(INVALID_VALUE);
+ }
+ // some operations have no property panel, so it is important to check that it is not null
+ if (myPropertyPanel) {
+ // update controls error information
+ QWidget* aWidget = myPropertyPanel->headerWidget();
+ if (aWidget)
+ aWidget->setToolTip(anError);
+ }
+}
+
+/*const char* toString(ModelAPI_ExecState theExecState)