Salome HOME
Issue #1330 correction for attribute ref attr list. Crash of rectangle creation
[modules/shaper.git] / src / ModuleBase / ModuleBase_ModelWidget.cpp
index 939505967552215db2fd1982170c7efe27772e34..e0ac58445270badf66dd16681c699911c1f3f07d 100644 (file)
@@ -22,6 +22,8 @@
 #include <QLabel>
 #include <QFocusEvent>
 
+//#define DEBUG_VALUE_STATE
+
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
                                                const Config_WidgetAPI* theData,
                                                const std::string& theParentId)
@@ -227,11 +229,32 @@ bool ModuleBase_ModelWidget::storeValue()
 
   return isDone;
 }
+#ifdef DEBUG_VALUE_STATE
+std::string getDebugInfo(const ModuleBase_ModelWidget::ValueState& theState)
+{
+  std::string anInfo;
+  switch (theState) {
+    case ModuleBase_ModelWidget::Stored:           anInfo = "Stored          "; break;
+    case ModuleBase_ModelWidget::ModifiedInPP:     anInfo = "ModifiedInPP    "; break;
+    case ModuleBase_ModelWidget::ModifiedInViewer: anInfo = "ModifiedInViewer"; break;
+    case ModuleBase_ModelWidget::Reset:            anInfo = "Reset           "; break;
+    default: break;
+  }
+  return anInfo;
+}
 
-ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ModuleBase_ModelWidget::ValueState& theState)
+#endif
+ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState
+                                         (const ModuleBase_ModelWidget::ValueState& theState)
 {
   ValueState aState = myState;
+
   if (myState != theState && !myIsValueStateBlocked) {
+#ifdef DEBUG_VALUE_STATE
+    qDebug(QString("setValueState: previous state = %1,\t new state = %2")
+           .arg(getDebugInfo(myState).c_str())
+           .arg(getDebugInfo(theState).c_str()).toStdString().c_str());
+#endif
     myState = theState;
     emit valueStateChanged(aState);
   }
@@ -281,7 +304,9 @@ bool ModuleBase_ModelWidget::processEnter()
 
 bool ModuleBase_ModelWidget::processDelete()
 {
-  return false;
+  // we consider that model objects eats delete key in order to
+  // do nothing by for example symbol delete in line edit or spin box
+  return true;
 }
 
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)