1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetLabel.cpp
4 // Created: 03 Dec 2014
5 // Author: Vitaly SMETANNIKOV
7 // Modified by Clarisse Genrault (CEA) : 17 Nov 2016
9 #include "ModuleBase_WidgetLabel.h"
11 #include <Config_WidgetAPI.h>
12 #include <Config_Keywords.h>
13 #include <ModuleBase_IconFactory.h>
14 #include <ModuleBase_Tools.h>
16 #include <ModelAPI_AttributeString.h>
19 #include <QVBoxLayout>
22 ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
23 const Config_WidgetAPI* theData)
24 : ModuleBase_ModelWidget(theParent, theData)
26 QString aText = translate(theData->getProperty("title"));
27 QString aLabelIcon = QString::fromStdString(theData->getProperty("icon"));
28 myLabel = new QLabel(aText, theParent);
29 if (!aLabelIcon.isEmpty()) {
30 myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon));
31 myLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
33 myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
35 myLabel->setWordWrap(true);
36 myLabel->setIndent(5);
37 myLabel->setContentsMargins(0,0,0,4);
39 QVBoxLayout* aLayout = new QVBoxLayout(this);
40 ModuleBase_Tools::zeroMargins(aLayout);
41 aLayout->addWidget(myLabel);
44 std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET).c_str();
45 if (!aStyleSheet.empty())
46 myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str()));
49 ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
53 QList<QWidget*> ModuleBase_WidgetLabel::getControls() const
55 return QList<QWidget*>();
58 bool ModuleBase_WidgetLabel::restoreValueCustom()
60 DataPtr aData = myFeature->data();
61 AttributeStringPtr aStrAttr = aData->string(attributeID());
65 aMsg = aStrAttr->value();
67 QString aText = ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
68 myLabel->setText(aText);
73 bool ModuleBase_WidgetLabel::focusTo()