From: sbh Date: Fri, 17 Apr 2015 12:01:07 +0000 (+0300) Subject: Issue #475 #451 correct detection of variables in the ParamSpinBox X-Git-Tag: V_1.1.0~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c93898acb58bc77dbfef4f5cba260885d31379fe;p=modules%2Fshaper.git Issue #475 #451 correct detection of variables in the ParamSpinBox --- diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 64e340fc0..1fdad51d3 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -65,12 +65,6 @@ void ModuleBase_ParamSpinBox::connectSignalsAndSlots() { 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&))); } /*! @@ -79,11 +73,6 @@ void ModuleBase_ParamSpinBox::connectSignalsAndSlots() void ModuleBase_ParamSpinBox::onTextChanged(const QString& text) { myTextValue = text; - - double value = 0; - if (isValid(text, value) == Acceptable) { - myCorrectValue = text; - } } /*! @@ -102,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 @@ -142,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); } /*! @@ -175,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 diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index acdfadf1a..403fc7a29 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -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; @@ -54,7 +55,6 @@ signals: void connectSignalsAndSlots(); private: - QString myCorrectValue; QString myTextValue; bool myAcceptVariables;