X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetFeature.cpp;h=d1e2ceea66fc30ea0734f2fd7f534ec6167391da;hb=0741a16dede895f053a30112a2f2216650accce0;hp=6007743f5248434f95cb489e300ac6031a98987d;hpb=8ef37902d880bc2e74f2ae46880aaee1b4c19307;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 6007743f5..d1e2ceea6 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -4,6 +4,9 @@ #include +#include +#include + #include #include @@ -16,6 +19,9 @@ #include #include +#include +#include +#include ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData) @@ -23,20 +29,52 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, { QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE)); myFeatureKinds = aKinds.split(" "); + + myContainer = new QWidget(theParent); + QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); + aControlLay->setContentsMargins(0, 0, 0, 0); + + QString aLabelText = QString::fromStdString(theData->widgetLabel()); + myLabel = new QLabel(aLabelText, myContainer); + aControlLay->addWidget(myLabel); + + myEditor = new QLineEdit(myContainer); + QString anObjName = QString::fromStdString(attributeID()); + myEditor->setObjectName(anObjName); + myEditor->setReadOnly(true); + aControlLay->addWidget(myEditor); + + QString aTTip = QString::fromStdString(theData->widgetTooltip()); + myEditor->setToolTip(aTTip); + + aControlLay->addWidget(myEditor); + aControlLay->setStretch(1, 1); } ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature() { } +bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) +{ + bool isDone = false; + + if (theValue) { + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); + if (aFeatureValue) + isDone = setFeature(aFeatureValue->feature()); + } + return isDone; +} + bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature) { if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str())) return false; - //bool isBlocked = this->blockSignals(true); myFeature = theFeature; - //this->blockSignals(isBlocked); + myEditor->setText(theFeature ? theFeature->data()->getName().c_str() : ""); emit valuesChanged(); return true; } @@ -48,11 +86,9 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const boost::dynamic_pointer_cast(aData->attribute(attributeID())); ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; - //bool isBlocked = that->blockSignals(true); aRef->setFeature(myFeature); theFeature->execute(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - //that->blockSignals(isBlocked); return true; } @@ -63,19 +99,20 @@ bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature) boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(attributeID())); - //bool isBlocked = this->blockSignals(true); myFeature = aRef->feature(); - //this->blockSignals(isBlocked); + myEditor->setText(myFeature ? myFeature->data()->getName().c_str() : ""); return true; } QWidget* ModuleBase_WidgetFeature::getControl() const { - return 0; + return myContainer; } QList ModuleBase_WidgetFeature::getControls() const { - QList aControls; - return aControls; + QList aList; + aList.append(myLabel); + aList.append(myEditor); + return aList; }