Salome HOME
Fix SketcherSetEqual.test_length_equality
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.cpp
index 3a3ed74593529adbb266e78327d359a3717ec81d..3bb748f63f6f69f6a2d06a564474ed3e21f3acb4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetChoice.cpp
 // Created:     03 Sept 2014
 // Author:      Vitaly Smetannikov
@@ -19,18 +21,17 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
                                                  const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+  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 = new QLabel(aLabelText, this);
   if (!aLabelIcon.isEmpty())
     myLabel->setPixmap(QPixmap(aLabelIcon));
   aLayout->addWidget(myLabel);
 
-  myCombo = new QComboBox(myContainer);
+  myCombo = new QComboBox(this);
   aLayout->addWidget(myCombo, 1);
  
   std::string aTypes = theData->getProperty("string_list");
@@ -44,20 +45,20 @@ ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice()
 {
 }
   
-bool ModuleBase_WidgetChoice::storeValue() const
+bool ModuleBase_WidgetChoice::storeValueCustom() const
 {
   DataPtr aData = myFeature->data();
-  boost::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
+  std::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
 
   aIntAttr->setValue(myCombo->currentIndex());
   updateObject(myFeature);
   return true;
 }
 
-bool ModuleBase_WidgetChoice::restoreValue()
+bool ModuleBase_WidgetChoice::restoreValueCustom()
 {
   DataPtr aData = myFeature->data();
-  boost::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
+  std::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
 
   bool isBlocked = myCombo->blockSignals(true);
   myCombo->setCurrentIndex(aIntAttr->value());
@@ -74,7 +75,6 @@ bool ModuleBase_WidgetChoice::focusTo()
 QList<QWidget*> ModuleBase_WidgetChoice::getControls() const
 {
   QList<QWidget*> aControls;
-  aControls.append(myLabel);
   aControls.append(myCombo);
   return aControls;
 }
@@ -82,5 +82,6 @@ QList<QWidget*> ModuleBase_WidgetChoice::getControls() const
 void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex)
 {
   emit valuesChanged();
-  emit focusOutWidget(this);
+  // Don't transfer focus
+  // emit focusOutWidget(this);
 }