Salome HOME
Copyright update 2022
[modules/shaper.git] / src / ModuleBase / ModuleBase_DoubleSpinBox.cpp
index 090cf58f313f407e85842105dde7982de2254806..0706dfca6bd5fe7f4d6a6a524a122546ae1f7695 100644 (file)
@@ -1,9 +1,24 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:      ModuleBase_DoubleSpinBox.cxx
-// Author:    Sergey TELKOV
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #include "ModuleBase_DoubleSpinBox.h"
+#include "ModuleBase_Tools.h"
 
 #include <QLineEdit>
 #include <QDoubleValidator>
@@ -58,16 +73,9 @@ const double PSEUDO_ZERO = 1.e-20;
  */
 ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePrecision)
     : QDoubleSpinBox(theParent),
-      myCleared(false),
-      myIsEmitKeyPressEvent(false)
+      myCleared(false)
 {
-  // VSR 01/07/2010: Disable thousands separator for spin box
-  // (to avoid inconsistency of double-2-string and string-2-double conversion)
-  QLocale loc;
-  loc.setNumberOptions(loc.numberOptions() |
-                       QLocale::OmitGroupSeparator |
-                       QLocale::RejectGroupSeparator);
-  setLocale(loc);
+  setLocale(ModuleBase_Tools::doubleLocale());
 
   // MPV 15/09/2014: this must be set before setDecimals;
   // otherwise in release mode setDecimals may crash
@@ -203,42 +211,6 @@ QString ModuleBase_DoubleSpinBox::removeTrailingZeroes(const QString& src) const
   return res;
 }
 
-void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent* theEvent)
-{
-  switch (theEvent->key()) {
-    case Qt::Key_Enter:
-    case Qt::Key_Return: {
-      // do not react to the Enter key, the property panel processes it
-      if (!myIsEmitKeyPressEvent)
-        return;
-    }
-    break;
-    default:
-      break;
-  }
-  QDoubleSpinBox::keyPressEvent(theEvent);
-}
-
-void ModuleBase_DoubleSpinBox::keyReleaseEvent(QKeyEvent* theEvent)
-{
-  switch (theEvent->key()) {
-    case Qt::Key_Enter:
-    case Qt::Key_Return: {
-      // the enter has already been processed when key is pressed,
-      // key release should not be processed in operation manager
-      if (myIsEmitKeyPressEvent) {
-        theEvent->accept();
-        emit enterReleased();
-        return;
-      }
-    }
-    break;
-    default:
-      break;
-  }
-  QDoubleSpinBox::keyReleaseEvent(theEvent);
-}
-
 /*!
  \brief Perform \a steps increment/decrement steps.
 
@@ -353,14 +325,6 @@ void ModuleBase_DoubleSpinBox::onTextChanged(const QString& )
   myCleared = false;
 }
 
-bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable)
-{
-  bool aPreviousValue = myIsEmitKeyPressEvent;
-  myIsEmitKeyPressEvent = theEnable;
-
-  return aPreviousValue;
-}
-
 void ModuleBase_DoubleSpinBox::setValueEnabled(const bool& theEnable)
 {
   setReadOnly(!theEnable);