Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index e2b934ee6de130eff7fab5672b876f9a0daf21e6..6a5421549ff74845da9a60dca29fd6257a54761d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ModelWidget.h
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -25,8 +27,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_
     : QObject(theParent),
       myParentId(theParentId)
 {
+  myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty();
   myIsComputedDefault = false;
-  myIsObligatory = theData ? theData->getBooleanAttribute(FEATURE_OBLIGATORY, true) : true;
   myAttributeID = theData ? theData->widgetId() : "";
 }
 
@@ -39,9 +41,8 @@ void ModuleBase_ModelWidget::enableFocusProcessing()
 {
   QList<QWidget*> aMyControls = getControls();
   foreach(QWidget*  eachControl, aMyControls) {
-    if(!myFocusInWidgets.contains(eachControl)) {
-      enableFocusProcessing(eachControl);
-    }
+    eachControl->setFocusPolicy(Qt::StrongFocus);
+    eachControl->installEventFilter(this);
   }
 }
 
@@ -84,7 +85,6 @@ bool ModuleBase_ModelWidget::focusTo()
   return true;
 }
 
-
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
 {
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
@@ -92,20 +92,22 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
 
-void ModuleBase_ModelWidget::enableFocusProcessing(QWidget* theWidget)
+void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) const
 {
-  theWidget->setFocusPolicy(Qt::StrongFocus);
-  theWidget->installEventFilter(this);
-  myFocusInWidgets.append(theWidget);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+  ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+  Events_Loop::loop()->flush(anEvent);
 }
 
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
-  if (theEvent->type() == QEvent::MouseButtonRelease && 
-      myFocusInWidgets.contains(aWidget)) {
-    emit focusInWidget(this);
+  if (theEvent->type() == QEvent::FocusIn) {
+    if (getControls().contains(aWidget)) {
+      emit focusInWidget(this);
+    }
   } 
   // pass the event on to the parent class
+
   return QObject::eventFilter(theObject, theEvent);
 }