Salome HOME
Simplification of the code: it removes focusNextPrevChild processing.
authornds <nds@opencascade.com>
Fri, 30 Oct 2015 16:02:37 +0000 (19:02 +0300)
committernds <nds@opencascade.com>
Mon, 2 Nov 2015 09:56:35 +0000 (12:56 +0300)
It is not enough to emit signal about focus change here because it can be changed by mouse click in another control. It is not processed in this method.
The same functionality(to store modified value on focus lost) is realized in ::deactivate() of the model widget and processEnter method of the widge.

src/ModuleBase/ModuleBase_DoubleSpinBox.cpp
src/ModuleBase/ModuleBase_DoubleSpinBox.h
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.h
src/ModuleBase/ModuleBase_WidgetIntValue.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h

index 114a27d6ca8f12a539ead1b8250152a8c2141512..081ca65b3fb12dad6800a131d18cda5e0c95a9c1 100644 (file)
@@ -217,15 +217,6 @@ void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent)
   QDoubleSpinBox::keyPressEvent(theEvent);
 }
 
-bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext)
-{
-  //myIsModified = false;
-
-  //emit valueStored();
-  emit focusNextPrev();
-  return QDoubleSpinBox::focusNextPrevChild(theIsNext);
-}
-
 /*!
  \brief Perform \a steps increment/decrement steps.
 
index 51c36cc70257523a909e10cf94a2c9c6977208ec..e1fd8bd61f7341e2cb8419fbdd0b850e576ed73d 100644 (file)
@@ -60,11 +60,6 @@ Q_OBJECT
   /// \return the previous value
   bool enableKeyPressEvent(const bool& theEnable);
 
-signals:
-  /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed.
-  void focusNextPrev();
-  void valueStored();
-
  protected slots:
    /// Called on text changed
   virtual void onTextChanged(const QString&);
@@ -75,11 +70,6 @@ signals:
   QString removeTrailingZeroes(const QString&) const;
   virtual void keyPressEvent(QKeyEvent* theEvent);
 
-  /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
-  /// Emits a signal about focus change
-  /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
-  virtual bool focusNextPrevChild(bool theIsNext);
-
  private:
   // boolen flag whether the key event is emitted. The default value is false
   bool myIsEmitKeyPressEvent;
index 0942fcce77549ef74a33e33570da3ea53f7ec503..dd2c9edd3a1817899a8cddbdeafce020525f1005 100644 (file)
@@ -204,9 +204,6 @@ signals:
   /// The signal about value state modification
   void valueStateChanged(int theState);
 
-  void focusNextPrev();
-  void valueStored();
-
 protected:
   /// Sets default value of widget. Normally, widget should fetch this value
   /// from the xml. However, some widgets derived widgets could define it
index 5f6415893281f14eb741e4ff077ab12ca5085310..4e6ce242c0c41df11844d919760410023e4e83b4 100644 (file)
@@ -86,10 +86,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
   myLabel->setToolTip(aTTip);
 
   aControlLay->addRow(myLabel, mySpinBox);
-  // Apply widget value change by enter/tab event.
-  connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged()));
   connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
-  connect(mySpinBox, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
 }
 
 ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
index 624e047441564ae8cd918e649806cea5c2c8521a..4c37116b2a9fb15487402461c43ca7bdb0d283cf 100644 (file)
@@ -212,13 +212,6 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent )
   }
 }
 
-bool ExpressionEditor::focusNextPrevChild(bool theIsNext)
-{
-  //emit valueStored();
-  //emit focusNextPrev();
-  return QPlainTextEdit::focusNextPrevChild(theIsNext);
-}
-
 void ExpressionEditor::onTextChanged()
 {
   myIsModified = true;
@@ -248,12 +241,7 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
   this->setLayout(aMainLay);
 
   connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified()));
-  //connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged()));
-  //connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
-
   connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
-    /// The signal about key release on the control, that corresponds to the attribute
-  /// \param theEvent key release event
 }
 
 ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor()
index 0e81242bb98b6859c1f0197bc1d71b1f3f984a41..d51f45805992be503d90a6acff9363eefbbb9b2a 100644 (file)
@@ -64,10 +64,8 @@ class ExpressionEditor: public QPlainTextEdit
   void onTextChanged();
 
 signals:
+  /// The signal about text change in the text editor
   void valueModified();
-  /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed.
-  //void valueStored();
-  //void focusNextPrev();
 
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
@@ -89,12 +87,7 @@ signals:
   /// Redefinition of virtual method
   virtual void paintEvent( QPaintEvent* );
 
-  /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
-  /// Emits a signal about focus change
-  /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
-  virtual bool focusNextPrevChild(bool theIsNext);
-
- private:
+private:
   QStringListModel* myCompleterModel;
   QCompleter* myCompleter;
   bool myCompletedAndSelected;
index d9c2a64b23c6f8d45f4c7fb2f2830bd38dd5e340..02c1d6613fb44999865d3ad03d008cb5da622780 100644 (file)
@@ -85,10 +85,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent,
   myLabel->setToolTip(aTTip);
 
   aControlLay->addRow(myLabel, mySpinBox);
-  // Apply widget value change by enter/tab event.
-  connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged()));
   connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesModified()));
-  connect(mySpinBox, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
 }
 
 ModuleBase_WidgetIntValue::~ModuleBase_WidgetIntValue()
index 6cd4fb22afc36dcc77c01609c19e9113d99a2742..66a67efc418a917d2d4085aa1e9ad7452db47f02 100644 (file)
@@ -86,10 +86,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     myXSpin->setToolTip(tr("X"));
     aGroupLay->addWidget(myXSpin, 0, 1);
 
-    // Apply widget value change by enter/tab event.
-    connect(myXSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged()));
     connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
-    connect(myXSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
   }
   {
     QLabel* aLabel = new QLabel(myGroupBox);
@@ -102,10 +99,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     myYSpin->setToolTip(tr("Y"));
     aGroupLay->addWidget(myYSpin, 1, 1);
 
-    // Apply widget value change by enter/tab event.
-    connect(myYSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged()));
     connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
-    connect(myYSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
   }
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -461,17 +455,18 @@ bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature,
   return aPointIsFound;
 }
 
-void PartSet_WidgetPoint2D::onValuesChanged()
+/*void PartSet_WidgetPoint2D::onValuesChanged()
 {
   emit valuesChanged();
-}
+}*/
 
 bool PartSet_WidgetPoint2D::processEnter()
 {
   bool isModified = myXSpin->isModified() || myYSpin->isModified();
   if (isModified) {
     bool isXModified = myXSpin->isModified();
-    onValuesChanged();
+    emit valuesChanged();
+    //onValuesChanged();
     myXSpin->clearModified();
     myYSpin->clearModified();
     if (isXModified)
index b4e45af6713cc048b0e1e4026df594ebedd4c2e4..d5f87eca0b97c05b41ddf95c0d0c3b201c314316 100755 (executable)
@@ -124,9 +124,9 @@ protected:
   /// \return boolean result
   bool isFeatureContainsPoint(const FeaturePtr& theFeature, double theX, double theY);
 
-private slots:
+//private slots:
   /// Process value changed event
-  void onValuesChanged();
+  //void onValuesChanged();
 
  private:
    /// Returns point 2d from selected vertex
index 097d9145d8dd7679b6aa59e3b3f6d9eb09a6b26a..f447f24a20aa9cbdf610048ed72e2b2541ce1d45 100755 (executable)
@@ -118,8 +118,6 @@ 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(focusNextPrev()),
-    //        this, SLOT(onFocusNextPrev()));
   }
 }
 
@@ -170,11 +168,6 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
   activateWidget(NULL);
 }
 
-void XGUI_PropertyPanel::onFocusNextPrev()
-{
-  setActiveWidget(NULL);
-}
-
 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
 {
   // it wraps the Tabs clicking to follow in the chain:
@@ -246,7 +239,7 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
       emit widgetActivated(myActiveWidget);
     } else if (!isEditingMode()) {
       emit noMoreWidgets();
-      setFocusOnOkButton();
+      //setFocusOnOkButton();
     }
   }
 }
index 9e6c38592dc4ff0a591d65b227969cd4abc98b14..374ea5efc1e12b50a47af91bddca079ee9d523ba 100644 (file)
@@ -118,8 +118,6 @@ public slots:
   */
   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
 
-  void onFocusNextPrev();
-
 protected:
   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
   /// \param theWidget a widget