Salome HOME
#1042 Sometimes when setting distance constraints, the input field is not displayed...
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
index d44c7d1d589f78060a93bb8a1dddd7a12be493d8..762bde305e20d92063faad3d91103046076213a0 100755 (executable)
@@ -16,6 +16,9 @@
 #include <ModuleBase_PageBase.h>
 #include <ModuleBase_PageWidget.h>
 
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
 #include <QEvent>
 #include <QFrame>
 #include <QIcon>
@@ -118,6 +121,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
             this,    SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
             this,    SIGNAL(keyReleased(QKeyEvent*)));
+    connect(aWidget, SIGNAL(enterClicked()),
+            this,    SIGNAL(enterClicked()));
+
   }
 }
 
@@ -154,12 +160,19 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
     activateWidget(NULL);
     return;
   }
+  ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
   bool isFoundWidget = false;
-  activateWindow();
+  ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
   for (; anIt != aLast; anIt++) {
+    ModuleBase_ModelWidget* aCurrentWidget = *anIt;
     if (isFoundWidget || !theWidget) {
-      if ((*anIt)->focusTo()) {
+
+      if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
+        continue; // this attribute is not participated in the current case
+
+      if (aCurrentWidget->focusTo()) {
         return;
       }
     }
@@ -182,7 +195,7 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
       for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++)
         aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
       if (aFirstControl)
-        aFirstControl->setFocus();
+        ModuleBase_Tools::setFocus(aFirstControl, "XGUI_PropertyPanel::focusNextPrevChild()");
         isChangedFocus = true;
     }
     else {
@@ -204,7 +217,7 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
       for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--)
         aLastControl = myWidgets[i]->getControlAcceptingFocus(false);
       if (aLastControl)
-        aLastControl->setFocus();
+        ModuleBase_Tools::setFocus(aLastControl, "XGUI_PropertyPanel::focusNextPrevChild()");
         isChangedFocus = true;
     }
     else {
@@ -214,7 +227,7 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
         aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
       if (aFirstControl && aFirstControl->hasFocus()) {
         QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
-        aCancelBtn->setFocus();
+        ModuleBase_Tools::setFocus(aCancelBtn, "XGUI_PropertyPanel::focusNextPrevChild()");
         isChangedFocus = true;
       }
     }
@@ -270,7 +283,7 @@ bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget)
 void XGUI_PropertyPanel::setFocusOnOkButton()
 {
   QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
-  anOkBtn->setFocus();
+  ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
 }
 
 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)