// Widgets
const static char* WDG_INFO = "label";
+const static char* WDG_ERRORINFO = "error_label";
const static char* WDG_DOUBLEVALUE = "doublevalue";
const static char* WDG_INTEGERVALUE = "integervalue";
const static char* WDG_BOOLVALUE = "boolvalue";
ModuleBase_WidgetToolbox.h
ModuleBase_WidgetValidated.h
ModuleBase_IconFactory.h
+ ModuleBase_WidgetErrorLabel.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetToolbox.cpp
ModuleBase_WidgetValidated.cpp
ModuleBase_IconFactory.cpp
+ ModuleBase_WidgetErrorLabel.cpp
)
SET(PROJECT_LIBRARIES
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetErrorLabel.cpp
+// Created: 03 Dec 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "ModuleBase_WidgetErrorLabel.h"
+
+#include <Config_WidgetAPI.h>
+#include <ModuleBase_Tools.h>
+#include <ModelAPI_AttributeString.h>
+
+#include <QLabel>
+
+ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_WidgetLabel(theParent, theData, theParentId)
+{
+ myDefaultStyle = myLabel->styleSheet();
+}
+
+ModuleBase_WidgetErrorLabel::~ModuleBase_WidgetErrorLabel()
+{
+}
+
+bool ModuleBase_WidgetErrorLabel::restoreValueCustom()
+{
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStrAttr = aData->string(attributeID());
+ std::string aMsg;
+ if (aStrAttr.get()) {
+ aMsg = aStrAttr->value();
+ }
+ if (aMsg.empty()) {
+ myLabel->setText("");
+ myLabel->setStyleSheet(myDefaultStyle);
+ } else {
+ myLabel->setText(aMsg.c_str());
+ myLabel->setStyleSheet("QLabel { background-color : red; color : white; }");
+ }
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetErrorLabel.h
+// Created: 03 Dec 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_WidgetErrorLabel_H
+#define ModuleBase_WidgetErrorLabel_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_WidgetLabel.h"
+
+class QLabel;
+
+/**
+* \ingroup GUI
+* Implementation of model widget for a label with error message
+*/
+class MODULEBASE_EXPORT ModuleBase_WidgetErrorLabel : public ModuleBase_WidgetLabel
+{
+Q_OBJECT
+ public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
+ ModuleBase_WidgetErrorLabel(QWidget* theParent, const Config_WidgetAPI* theData,
+ const std::string& theParentId);
+
+ virtual ~ModuleBase_WidgetErrorLabel();
+
+ virtual bool restoreValueCustom();
+
+private:
+ QString myDefaultStyle;
+};
+
+#endif
#include <ModuleBase_WidgetLineEdit.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetLabel.h>
+#include <ModuleBase_WidgetErrorLabel.h>
#include <ModuleBase_WidgetToolbox.h>
#include <ModuleBase_PageBase.h>
#include <ModuleBase_PageGroupBox.h>
if (theType == WDG_INFO) {
result = new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
+ } else if (theType == WDG_ERRORINFO) {
+ result = new ModuleBase_WidgetErrorLabel(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_DOUBLEVALUE) {
result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_INTEGERVALUE) {
return true;
}
-private:
/// A label control
QLabel* myLabel;
};
<sketch-start-label id="External" title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch">
<validator id="GeomValidators_Face" parameters="plane"/>
</sketch-start-label>
+ <error_label id="SolverError"/>
<validator id="SketchPlugin_SolverErrorValidator"/>
<!--icon=":pictures/x_point.png"-->
</feature>