]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp
Salome HOME
Error label is added to solver
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetErrorLabel.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetErrorLabel.cpp
4 // Created:     03 Dec 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "ModuleBase_WidgetErrorLabel.h"
8
9 #include <Config_WidgetAPI.h>
10 #include <ModuleBase_Tools.h>
11 #include <ModelAPI_AttributeString.h>
12
13 #include <QLabel>
14
15 ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent,
16                                                const Config_WidgetAPI* theData,
17                                                const std::string& theParentId)
18     : ModuleBase_WidgetLabel(theParent, theData, theParentId)
19 {
20   myDefaultStyle = myLabel->styleSheet();
21 }
22
23 ModuleBase_WidgetErrorLabel::~ModuleBase_WidgetErrorLabel()
24 {
25 }
26
27 bool ModuleBase_WidgetErrorLabel::restoreValueCustom()
28 {
29   DataPtr aData = myFeature->data();
30   AttributeStringPtr aStrAttr = aData->string(attributeID());
31   std::string aMsg;
32   if (aStrAttr.get()) {
33     aMsg = aStrAttr->value();
34   }
35   if (aMsg.empty()) {
36     myLabel->setText("");
37     myLabel->setStyleSheet(myDefaultStyle);
38   } else {
39     myLabel->setText(aMsg.c_str());
40     myLabel->setStyleSheet("QLabel { background-color : red; color : white; }");
41   }
42   return true;
43 }