X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetChoice.cpp;h=3bb748f63f6f69f6a2d06a564474ed3e21f3acb4;hb=592b8a38b3c9e2a6a7d3d1d180b1f9b5406c4415;hp=6a1c455d905a2eb46d771bcc4218ddd6216f3d06;hpb=ba737434252ae41c4bee1b792a0f0bb098ffae87;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index 6a1c455d9..3bb748f63 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -1,9 +1,14 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_WidgetChoice.cpp // Created: 03 Sept 2014 // Author: Vitaly Smetannikov #include "ModuleBase_WidgetChoice.h" +#include +#include +#include #include #include @@ -16,18 +21,23 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myContainer = new QWidget(theParent); - QHBoxLayout* aLayout = new QHBoxLayout(myContainer); - aLayout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* aLayout = new QHBoxLayout(this); + 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)); + myLabel = new QLabel(aLabelText, this); + if (!aLabelIcon.isEmpty()) + myLabel->setPixmap(QPixmap(aLabelIcon)); aLayout->addWidget(myLabel); - myCombo = new QComboBox(myContainer); - aLayout->addWidget(myCombo); + myCombo = new QComboBox(this); + 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))); } @@ -35,13 +45,24 @@ ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice() { } -bool ModuleBase_WidgetChoice::storeValue() const +bool ModuleBase_WidgetChoice::storeValueCustom() const { + DataPtr aData = myFeature->data(); + std::shared_ptr aIntAttr = aData->integer(attributeID()); + + aIntAttr->setValue(myCombo->currentIndex()); + updateObject(myFeature); return true; } -bool ModuleBase_WidgetChoice::restoreValue() +bool ModuleBase_WidgetChoice::restoreValueCustom() { + DataPtr aData = myFeature->data(); + std::shared_ptr aIntAttr = aData->integer(attributeID()); + + bool isBlocked = myCombo->blockSignals(true); + myCombo->setCurrentIndex(aIntAttr->value()); + myCombo->blockSignals(isBlocked); return true; } @@ -54,11 +75,13 @@ bool ModuleBase_WidgetChoice::focusTo() QList ModuleBase_WidgetChoice::getControls() const { QList aControls; - aControls.append(myLabel); aControls.append(myCombo); return aControls; } void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex) { -} \ No newline at end of file + emit valuesChanged(); + // Don't transfer focus + // emit focusOutWidget(this); +}