Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Fri, 17 Apr 2015 12:01:19 +0000 (15:01 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 17 Apr 2015 12:01:19 +0000 (15:01 +0300)
src/ModuleBase/ModuleBase_ParamSpinBox.cpp
src/ModuleBase/ModuleBase_ParamSpinBox.h

index 925b1cc94c8508545041d6b63677ae962331aa76..1fdad51d3682ff889c22d401bd96be370ce285e5 100644 (file)
@@ -12,6 +12,7 @@
 #include <QRegExp>
 
 #include <string>
+#include <iostream>
 
 /*!
  \class ModuleBase_ParamSpinBox
@@ -62,28 +63,8 @@ void ModuleBase_ParamSpinBox::stepBy(int steps)
  */
 void ModuleBase_ParamSpinBox::connectSignalsAndSlots()
 {
-  connect(this, SIGNAL(editingFinished()),
-          this, SLOT(onEditingFinished()));
-
   connect(this, SIGNAL(valueChanged(const QString&)),
           this, SLOT(onTextChanged(const QString&)));
-
-  //connect(lineEdit(), SIGNAL(textChanged(const QString&)),
-  //        this,       SLOT(onTextChanged(const QString&)));
-
-  //connect(lineEdit(), SIGNAL(textChanged(const QString&)),
-  //        this,       SIGNAL(textChanged(const QString&)));
-}
-
-/*!
- \brief This function is called when editing is finished.
- */
-void ModuleBase_ParamSpinBox::onEditingFinished()
-{
-  if (myTextValue.isNull())
-    myTextValue = text();
-
-  setText(myTextValue);
 }
 
 /*!
@@ -92,11 +73,6 @@ void ModuleBase_ParamSpinBox::onEditingFinished()
 void ModuleBase_ParamSpinBox::onTextChanged(const QString& text)
 {
   myTextValue = text;
-
-  double value = 0;
-  if (isValid(text, value) == Acceptable) {
-    myCorrectValue = text;
-  }
 }
 
 /*!
@@ -115,6 +91,14 @@ double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const
   return aValue;
 }
 
+QString ModuleBase_ParamSpinBox::textFromValue (double theValue) const
+{
+  if (hasVariable(myTextValue)){
+    return myTextValue;
+  }
+  return ModuleBase_DoubleSpinBox::textFromValue(theValue);
+}
+
 /*!
  \brief This function is used to determine whether input is valid.
  \param str currently entered value
@@ -155,8 +139,7 @@ void ModuleBase_ParamSpinBox::setValue(const double value)
 {
   ModuleBase_DoubleSpinBox::setValue(value);
 
-  myCorrectValue = ModuleBase_DoubleSpinBox::textFromValue(value);
-  myTextValue = myCorrectValue;
+  myTextValue = ModuleBase_DoubleSpinBox::textFromValue(value);
 }
 
 /*!
@@ -188,7 +171,7 @@ bool ModuleBase_ParamSpinBox::isAcceptVariables() const
 
 bool ModuleBase_ParamSpinBox::hasVariable() const
 {
-  return hasVariable(text());
+  return hasVariable(myTextValue);
 }
 
 bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const
index 8d9811db054de42f0c70aea73fa73725c418cf73..403fc7a2983d00c185f71f589d2d79014417b562 100644 (file)
@@ -21,6 +21,7 @@ public:
   virtual void stepBy(int);
 
   virtual double valueFromText(const QString&) const;
+  virtual QString textFromValue (double value) const;
 
   virtual QValidator::State validate(QString&, int&) const;
 
@@ -48,14 +49,12 @@ signals:
   virtual void showEvent(QShowEvent*);
 
  protected slots:
-  void onEditingFinished();
   void onTextChanged(const QString&);
 
  private:
   void connectSignalsAndSlots();
 
  private:
-  QString myCorrectValue;
   QString myTextValue;
 
   bool myAcceptVariables;