X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_DoubleSpinBox.cpp;h=dba8c5d0f22aec40deef9ddff35ad64c8fd30f56;hb=ced1c42d80f02b1efa749ecdf35e620dcca4d9cc;hp=46f208ee281ea5cb0c45fdeaafc95ab7585bf807;hpb=bc81a3b5bb8b7c51bdec9b32bd8db9c60a73fb88;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 46f208ee2..dba8c5d0f 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -59,7 +59,7 @@ const double PSEUDO_ZERO = 1.e-20; ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePrecision) : QDoubleSpinBox(theParent), myCleared(false), - myIsModified(false) + myIsEmitKeyPressEvent(false) { // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid inconsistency of double-2-string and string-2-double conversion) @@ -77,9 +77,6 @@ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePr connect(lineEdit(), SIGNAL(textChanged( const QString& )), this, SLOT(onTextChanged( const QString& ))); - - connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); - //connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); } /*! @@ -201,13 +198,14 @@ QString ModuleBase_DoubleSpinBox::removeTrailingZeroes(const QString& src) const return res; } -void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent) +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 - return; + if (!myIsEmitKeyPressEvent) + return; } break; default: @@ -216,13 +214,24 @@ void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent) QDoubleSpinBox::keyPressEvent(theEvent); } -bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext) +void ModuleBase_DoubleSpinBox::keyReleaseEvent(QKeyEvent* theEvent) { - myIsModified = false; - - emit valueStored(); - emit focusNextPrev(); - return QDoubleSpinBox::focusNextPrevChild(theIsNext); + 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); } /*! @@ -335,25 +344,12 @@ QValidator::State ModuleBase_DoubleSpinBox::validate(QString& str, int& pos) con void ModuleBase_DoubleSpinBox::onTextChanged(const QString& ) { myCleared = false; - myIsModified = true; } -void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue) +bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable) { - myIsModified = true; -} - -void ModuleBase_DoubleSpinBox::onEditingFinished() -{ - //myIsModified = false; -} + bool aPreviousValue = myIsEmitKeyPressEvent; + myIsEmitKeyPressEvent = theEnable; -bool ModuleBase_DoubleSpinBox::isModified() const -{ - return myIsModified; -} - -void ModuleBase_DoubleSpinBox::clearModified() -{ - myIsModified = false; + return aPreviousValue; }