]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_ModelWidget.cpp
Salome HOME
cd56f06c363d259b3dbbfad4bdaafe1cd2b56da9
[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 <ModelAPI_Data.h>
8 #include <ModelAPI_Attribute.h>
9
10 #include "Config_WidgetAPI.h"
11
12 #include <QWidget>
13
14 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData)
15  : QObject(theParent), myHasDefaultValue(false)
16 {
17   myAttributeID = theData ? theData->widgetId() : "";
18 }
19
20 bool ModuleBase_ModelWidget::isInitialized(FeaturePtr theFeature) const
21 {
22   return theFeature->data()->attribute(attributeID())->isInitialized();
23 }
24
25 bool ModuleBase_ModelWidget::canFocusTo(const std::string& theAttributeName) const
26 {
27   return theAttributeName == attributeID();
28 }
29
30 void ModuleBase_ModelWidget::focusTo()
31 {
32   QList<QWidget*> aControls = getControls();
33   QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
34   for (; anIt != aLast; anIt++) {
35     QWidget* aWidget = *anIt;
36     if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) {
37       aWidget->setFocus();
38       break;
39     }
40   }
41 }
42
43 std::string ModuleBase_ModelWidget::attributeID() const
44 {
45   return myAttributeID;
46 }