Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.cpp
1 // File:        ModuleBase_WidgetChoice.cpp
2 // Created:     03 Sept 2014
3 // Author:      Vitaly Smetannikov
4
5 #include "ModuleBase_WidgetChoice.h"
6
7 #include <Config_WidgetAPI.h>
8
9 #include <QWidget>
10 #include <QLayout>
11 #include <QLabel>
12 #include <QComboBox>
13
14 ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, 
15                                                  const Config_WidgetAPI* theData, 
16                                                  const std::string& theParentId)
17     : ModuleBase_ModelWidget(theParent, theData, theParentId)
18 {
19   myContainer = new QWidget(theParent);
20   QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
21   aLayout->setContentsMargins(0, 0, 0, 0);
22
23   QString aLabelText = QString::fromStdString(theData->widgetLabel());
24   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
25   myLabel = new QLabel(aLabelText, myContainer);
26   myLabel->setPixmap(QPixmap(aLabelIcon));
27   aLayout->addWidget(myLabel);
28
29   myCombo = new QComboBox(myContainer);
30   aLayout->addWidget(myCombo);
31   connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
32 }
33
34 ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice()
35 {
36 }
37   
38 bool ModuleBase_WidgetChoice::storeValue() const
39 {
40   return true;
41 }
42
43 bool ModuleBase_WidgetChoice::restoreValue()
44 {
45   return true;
46 }
47
48 bool ModuleBase_WidgetChoice::focusTo()
49 {
50   myCombo->setFocus();
51   return true;
52 }
53
54 QList<QWidget*> ModuleBase_WidgetChoice::getControls() const
55 {
56   QList<QWidget*> aControls;
57   aControls.append(myLabel);
58   aControls.append(myCombo);
59   return aControls;
60 }
61
62 void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex)
63 {
64 }