Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
1 // File:        ModuleBase_ModelWidget.h
2 // Created:     25 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include "ModuleBase_ModelWidget.h"
6
7 #include "Config_WidgetAPI.h"
8
9 #include <QWidget>
10
11 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData)
12  : QObject(theParent), myHasDefaultValue(false)
13 {
14   myAttributeID = theData ? theData->widgetId() : "";
15 }
16
17 bool ModuleBase_ModelWidget::canFocusTo(const std::string& theAttributeName) const
18 {
19   return theAttributeName == attributeID();
20 }
21
22 void ModuleBase_ModelWidget::focusTo()
23 {
24   QList<QWidget*> aControls = getControls();
25   QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
26   for (; anIt != aLast; anIt++) {
27     QWidget* aWidget = *anIt;
28     if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) {
29       aWidget->setFocus();
30       break;
31     }
32   }
33 }
34
35 std::string ModuleBase_ModelWidget::attributeID() const
36 {
37   return myAttributeID;
38 }