]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_ModelWidget.cpp
Salome HOME
Result attributes validators created
[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, 
15   const Config_WidgetAPI* theData, 
16   const std::string& theParentId)
17  : QObject(theParent), myHasDefaultValue(false), myParentId(theParentId)
18 {
19   myAttributeID = theData ? theData->widgetId() : "";
20 }
21
22 bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
23 {
24   return theObject->data()->attribute(attributeID())->isInitialized();
25 }
26
27 bool ModuleBase_ModelWidget::focusTo()
28 {
29   QList<QWidget*> aControls = getControls();
30   QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
31   for (; anIt != aLast; anIt++) {
32     QWidget* aWidget = *anIt;
33     if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) {
34       aWidget->setFocus();
35       break;
36     }
37   }
38   return true;
39 }