X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetChoice.cpp;h=3a3ed74593529adbb266e78327d359a3717ec81d;hb=43780ffac779af7f061513b0f6243f2edb73602c;hp=6a1c455d905a2eb46d771bcc4218ddd6216f3d06;hpb=b801d5f85aa3dc5786510acf87c8003f1d59eadd;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index 6a1c455d9..3a3ed7459 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -3,7 +3,10 @@ // Author: Vitaly Smetannikov #include "ModuleBase_WidgetChoice.h" +#include +#include +#include #include #include @@ -18,16 +21,22 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, { myContainer = new QWidget(theParent); QHBoxLayout* aLayout = new QHBoxLayout(myContainer); - aLayout->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::adjustMargins(aLayout); QString aLabelText = QString::fromStdString(theData->widgetLabel()); QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); myLabel = new QLabel(aLabelText, myContainer); - myLabel->setPixmap(QPixmap(aLabelIcon)); + if (!aLabelIcon.isEmpty()) + myLabel->setPixmap(QPixmap(aLabelIcon)); aLayout->addWidget(myLabel); myCombo = new QComboBox(myContainer); - aLayout->addWidget(myCombo); + aLayout->addWidget(myCombo, 1); + + std::string aTypes = theData->getProperty("string_list"); + QStringList aList = QString(aTypes.c_str()).split(' '); + myCombo->addItems(aList); + connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); } @@ -37,11 +46,22 @@ ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice() bool ModuleBase_WidgetChoice::storeValue() const { + DataPtr aData = myFeature->data(); + boost::shared_ptr aIntAttr = aData->integer(attributeID()); + + aIntAttr->setValue(myCombo->currentIndex()); + updateObject(myFeature); return true; } bool ModuleBase_WidgetChoice::restoreValue() { + DataPtr aData = myFeature->data(); + boost::shared_ptr aIntAttr = aData->integer(attributeID()); + + bool isBlocked = myCombo->blockSignals(true); + myCombo->setCurrentIndex(aIntAttr->value()); + myCombo->blockSignals(isBlocked); return true; } @@ -61,4 +81,6 @@ QList ModuleBase_WidgetChoice::getControls() const void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex) { -} \ No newline at end of file + emit valuesChanged(); + emit focusOutWidget(this); +}