Salome HOME
178eb5d6316cf0db2bb2cf77c712614f498f7a0c
[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(ObjectPtr theObject) const
21 {
22   return theObject->data()->attribute(attributeID())->isInitialized();
23 }
24
25 bool ModuleBase_ModelWidget::focusTo()
26 {
27   QList<QWidget*> aControls = getControls();
28   QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
29   for (; anIt != aLast; anIt++) {
30     QWidget* aWidget = *anIt;
31     if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) {
32       aWidget->setFocus();
33       break;
34     }
35   }
36   return true;
37 }
38
39 std::string ModuleBase_ModelWidget::attributeID() const
40 {
41   return myAttributeID;
42 }