X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FXGUI%2FXGUI_ErrorMgr.cpp;h=249dfe00491ec65e98045a6e586a2cae960b8358;hb=0bada2df7b7948c756effe42fe860cc1b93b77af;hp=9e379850c166e734290e95753d20f16c45c29c18;hpb=2b21081bbbd86d0432cc408a1194df7804143209;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index 9e379850c..249dfe004 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -17,6 +17,9 @@ #include #include +#include +#include + #include #include #include @@ -32,19 +35,22 @@ const QString INVALID_VALUE = "invalid_action"; +//#define DEBUG_ERROR_STATE XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop) : ModuleBase_IErrorMgr(theParent), myErrorDialog(0), myErrorLabel(0), - myWorkshop(theWorkshop) + myWorkshop(theWorkshop), + myAcceptAllToolTip(""), + myAcceptAllStatusTip(""), + myAcceptToolTip(""), + myAcceptStatusTip("") { - } XGUI_ErrorMgr::~XGUI_ErrorMgr() { - } void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) @@ -54,8 +60,6 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) ModuleBase_OperationFeature* aFOperation = dynamic_cast (workshop()->operationMgr()->currentOperation()); if (aFOperation && aFOperation->feature() == theFeature) { - QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); - ModuleBase_ModelWidget* anActiveWidget = activeWidget(); bool isApplyEnabledByActiveWidget = false; if (anActiveWidget) @@ -70,25 +74,45 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) if (anError.isEmpty()) anError = aWidgetError; } - updateActionState(anOkAction, anError); + updateAcceptActionState(anError); updateToolTip(anActiveWidget, aWidgetError); + myWorkshop->setStatusBarMessage(anError); + +#ifdef DEBUG_ERROR_STATE + QString anInfo = ModuleBase_Tools::objectInfo(theFeature); + + QString aResultInfo = QString("valid = %1, anError = %2, aWidgetError = %3") + .arg(anError.isEmpty()).arg(anError).arg(aWidgetError); + qDebug(QString("XGUI_ErrorMgr::updateActions for %1, result: %2").arg(anInfo) + .arg(aResultInfo).toStdString().c_str()); +#endif } } void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature) { - QString anError = myWorkshop->module()->getFeatureError(theFeature); - if (anError.isEmpty()) { - ModuleBase_ModelWidget* anActiveWidget = activeWidget(); - if (anActiveWidget) - anError = anActiveWidget->getError(); + if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty()) + storeInitialActionValues(); + + QString anError = ""; + /// to allow the module have the button always enabled + bool isActionStateEnabled = + myWorkshop->module()->isActionEnableStateFixed(XGUI_ActionsMgr::AcceptAll); + if (!isActionStateEnabled) { + anError = myWorkshop->module()->getFeatureError(theFeature); + if (anError.isEmpty()) { + ModuleBase_ModelWidget* anActiveWidget = activeWidget(); + if (anActiveWidget) + anError = anActiveWidget->getError(); + } } XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); if (workshop()->isFeatureOfNested(theFeature)) { - QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); + QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll); bool anEnabled = anError.isEmpty(); anAcceptAllAction->setEnabled(anEnabled); - anAcceptAllAction->setToolTip(anError); + anAcceptAllAction->setToolTip(!anEnabled ? anError : myAcceptAllToolTip); + anAcceptAllAction->setStatusTip(!anEnabled ? anError : myAcceptAllStatusTip); } } @@ -105,11 +129,31 @@ bool XGUI_ErrorMgr::isApplyEnabled() const return isEnabled; } -void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theError) +void XGUI_ErrorMgr::storeInitialActionValues() { - bool anEnabled = theError.isEmpty(); + ModuleBase_ModelWidget* anActiveWidget = activeWidget(); + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); + QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll); + myAcceptAllToolTip = anAcceptAllAction->toolTip(); + myAcceptAllStatusTip = anAcceptAllAction->statusTip(); - theAction->setEnabled(anEnabled); + QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + myAcceptToolTip = anOkAction->toolTip(); + myAcceptStatusTip = anOkAction->toolTip(); +} + +void XGUI_ErrorMgr::updateAcceptActionState(const QString& theError) +{ + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); + QAction* anAcceptAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + + if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty()) + storeInitialActionValues(); + + bool anEnabled = theError.isEmpty(); + anAcceptAction->setEnabled(anEnabled); + anAcceptAction->setToolTip(anEnabled ? myAcceptToolTip : theError); + anAcceptAction->setStatusTip(anEnabled ? myAcceptStatusTip : theError); // some operations have no property panel, so it is important to check that it is not null if (myPropertyPanel) { // update controls error information