X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ModelWidget.cpp;h=feba11647d2650e378e7af013afc71d9075c33ff;hb=71a74e7993bcab222f1bf8deed1d141cab81bdf5;hp=11a884722518389d0db509315038d050f7762423;hpb=fb22ba72114328242bb0bd465abbca43321dcfe4;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 11a884722..feba11647 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -5,11 +5,13 @@ // Author: Natalia ERMOLAEVA #include "ModuleBase_ModelWidget.h" +#include "ModuleBase_Tools.h" #include #include #include #include +#include #include #include @@ -17,8 +19,6 @@ #include #include -#include -#include #include #include @@ -65,10 +65,6 @@ QString ModuleBase_ModelWidget::getValueStateError() const if (anAttr.get()) { QString anAttributeName = anAttr->id().c_str(); switch (aState) { - case ModuleBase_ModelWidget::ModifiedInPP: - anError = "Attribute \"" + anAttributeName + - "\" modification is not applyed. Please click \"Enter\" or \"Tab\"."; - break; case ModuleBase_ModelWidget::ModifiedInViewer: anError = "Attribute \"" + anAttributeName + "\" is locked by modification value in the viewer."; @@ -76,12 +72,44 @@ QString ModuleBase_ModelWidget::getValueStateError() const case ModuleBase_ModelWidget::Reset: anError = "Attribute \"" + anAttributeName + "\" is not initialized."; break; + case ModuleBase_ModelWidget::ModifiedInPP: // Apply should be enabled in this mode + default: + break; } } } return anError; } +QString ModuleBase_ModelWidget::getError() const +{ + QString anError; + + if (!feature().get()) + return anError; + + std::string anAttributeID = attributeID(); + AttributePtr anAttribute = feature()->attribute(anAttributeID); + if (!anAttribute.get()) + return anError; + + std::string aValidatorID; + std::string anErrorMsg; + + static ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators(); + if (!aValidators->validate(anAttribute, aValidatorID, anErrorMsg)) { + if (anErrorMsg.empty()) + anErrorMsg = "unknown error."; + anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg; + } + + anError = QString::fromStdString(anErrorMsg); + if (anError.isEmpty()) + anError = getValueStateError(); + + return anError; +} + void ModuleBase_ModelWidget::enableFocusProcessing() { QList aMyControls = getControls(); @@ -103,21 +131,10 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted) QLabel* aLabel = qobject_cast(aWidget); // We won't set the effect to QLabels - it looks ugly if(aLabel) continue; - if(isHighlighted) { - // If effect is the installed on a different widget, setGraphicsEffect() will - // remove the effect from the widget and install it on this widget. - // That's why we create a new effect for each widget - QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect(); - aGlowEffect->setOffset(.0); - aGlowEffect->setBlurRadius(10.0); - aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF - aWidget->setGraphicsEffect(aGlowEffect); - } else { - QGraphicsEffect* anEffect = aWidget->graphicsEffect(); - if(anEffect) - anEffect->deleteLater(); - aWidget->setGraphicsEffect(NULL); - } + // If effect is the installed on a different widget, setGraphicsEffect() will + // remove the effect from the widget and install it on this widget. + // That's why we create a new effect for each widget + ModuleBase_Tools::setShadowEffect(aWidget, isHighlighted); } } @@ -136,7 +153,7 @@ bool ModuleBase_ModelWidget::focusTo() for (; anIt != aLast && !isFocusAccepted; anIt++) { QWidget* aWidget = *anIt; if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) { - aWidget->setFocus(); + ModuleBase_Tools::setFocus(aWidget, "ModuleBase_ModelWidget::focusTo()"); isFocusAccepted = true; } }