Salome HOME
Start of the edit should not change the current feature.
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index db4a41f66e0d912ac4d8098d3af523f1cbb380b5..f0d33055320a9a9d21ef2fd36029e063aa75a5e1 100644 (file)
@@ -187,12 +187,12 @@ bool ModuleBase_ModelWidget::storeValue()
   return isDone;
 }
 
-ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ValueState& theState)
+ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ModuleBase_ModelWidget::ValueState& theState)
 {
   ValueState aState = myState;
   if (myState != theState && !myIsValueStateBlocked) {
     myState = theState;
-    emit valueStateChanged();
+    emit valueStateChanged(aState);
   }
   return aState;
 }
@@ -213,14 +213,6 @@ bool ModuleBase_ModelWidget::restoreValue()
   return isDone;
 }
 
-void ModuleBase_ModelWidget::storeValueByApply()
-{
-  // do not emit signal about update the currenty feature object
-  // in order to do not perform additional redisplay in the viewer.
-  // It should happens by finish operation of the apply action
-  storeValueCustom();
-}
-
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj)
 {
   blockUpdateViewer(true);
@@ -259,6 +251,17 @@ bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
       emit focusInWidget(this);
     }
   }
+  else if (theEvent->type() == QEvent::FocusOut) {
+    QFocusEvent* aFocusEvent = dynamic_cast<QFocusEvent*>(theEvent);
+
+    Qt::FocusReason aReason = aFocusEvent->reason();
+    bool aMouseOrKey = aReason == Qt::MouseFocusReason ||
+                        aReason == Qt::TabFocusReason ||
+                        aReason == Qt::BacktabFocusReason ||
+                        aReason == Qt::OtherFocusReason; // to process widget->setFocus()
+    if (aMouseOrKey && getControls().contains(aWidget) && getValueState() == ModifiedInPP)
+      storeValue();
+  }
   // pass the event on to the parent class
 
   return QObject::eventFilter(theObject, theEvent);