1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetLineEdit.cpp
6 * Created on: Aug 28, 2014
10 #include <ModuleBase_WidgetLineEdit.h>
11 #include <ModuleBase_Tools.h>
13 #include <ModelAPI_AttributeString.h>
14 #include <ModelAPI_Data.h>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Validator.h>
18 #include <Config_WidgetAPI.h>
20 #include <QFormLayout>
29 ModuleBase_WidgetLineEdit::ModuleBase_WidgetLineEdit(QWidget* theParent,
30 const Config_WidgetAPI* theData,
31 const std::string& theParentId)
32 : ModuleBase_ModelWidget(theParent, theData, theParentId)
34 QFormLayout* aMainLay = new QFormLayout(this);
35 ModuleBase_Tools::adjustMargins(aMainLay);
36 QString aTitle = QString::fromStdString(theData->widgetLabel());
37 myLineEdit = new QLineEdit(this);
38 myLineEdit->setMinimumHeight(20);
39 aMainLay->addRow(aTitle, myLineEdit);
40 this->setLayout(aMainLay);
42 connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
45 ModuleBase_WidgetLineEdit::~ModuleBase_WidgetLineEdit()
49 bool ModuleBase_WidgetLineEdit::storeValueCustom() const
51 // A rare case when plugin was not loaded.
54 DataPtr aData = myFeature->data();
55 AttributeStringPtr aStringAttr = aData->string(attributeID());
56 QString aWidgetValue = myLineEdit->text();
57 aStringAttr->setValue(aWidgetValue.toStdString());
58 updateObject(myFeature);
62 bool ModuleBase_WidgetLineEdit::restoreValue()
64 // A rare case when plugin was not loaded.
67 DataPtr aData = myFeature->data();
68 AttributeStringPtr aStringAttr = aData->string(attributeID());
70 bool isBlocked = myLineEdit->blockSignals(true);
71 myLineEdit->setText(QString::fromStdString(aStringAttr->value()));
72 myLineEdit->blockSignals(isBlocked);
77 QList<QWidget*> ModuleBase_WidgetLineEdit::getControls() const
79 QList<QWidget*> result;
84 void ModuleBase_WidgetLineEdit::onTextChanged()