From 0b0fa85288c496a5774247f3f336c098160d6aeb Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 11 Nov 2015 15:29:03 +0300 Subject: [PATCH] re-entrant operation: fillet operation should be restarted by the first enter. Correction: the operation state(ModifiedInPP) should be used instead of additional internal state in the controls. --- src/ModuleBase/ModuleBase_DoubleSpinBox.cpp | 8 +++---- src/ModuleBase/ModuleBase_DoubleSpinBox.h | 8 +++---- src/ModuleBase/ModuleBase_IntSpinBox.cpp | 24 +++++++++++++++---- src/ModuleBase/ModuleBase_IntSpinBox.h | 14 +++++++---- .../ModuleBase_WidgetDoubleValue.cpp | 5 ++-- .../ModuleBase_WidgetExprEditor.cpp | 5 ++-- src/ModuleBase/ModuleBase_WidgetIntValue.cpp | 5 ++-- src/PartSet/PartSet_WidgetPoint2d.cpp | 9 +++---- src/PartSet/PartSet_WidgetPoint2dDistance.cpp | 5 ++-- 9 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 081ca65b3..745592709 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), + //myIsModified(false), myIsEmitKeyPressEvent(false) { // VSR 01/07/2010: Disable thousands separator for spin box @@ -327,10 +327,10 @@ QValidator::State ModuleBase_DoubleSpinBox::validate(QString& str, int& pos) con void ModuleBase_DoubleSpinBox::onTextChanged(const QString& ) { myCleared = false; - myIsModified = true; + //myIsModified = true; } -void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue) +/*void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue) { myIsModified = true; } @@ -343,7 +343,7 @@ bool ModuleBase_DoubleSpinBox::isModified() const void ModuleBase_DoubleSpinBox::clearModified() { myIsModified = false; -} +}*/ bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable) { diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index 63e6a7bbe..f827ba264 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -50,10 +50,10 @@ Q_OBJECT virtual QValidator::State validate(QString&, int&) const; /// Returns true if the current value is modified by has not been applyed yet - virtual bool isModified() const; + //virtual bool isModified() const; /// Clears modified state - void clearModified(); + //void clearModified(); /// Change enable/disable internal state to emit key press event /// \param theEnable if true, the signal is emitted @@ -64,7 +64,7 @@ Q_OBJECT /// Called on text changed virtual void onTextChanged(const QString&); /// Called on value changed - void onValueChanged(const QString& theValue); + //void onValueChanged(const QString& theValue); protected: /// Removes extra trailing zero symbols @@ -82,7 +82,7 @@ Q_OBJECT /// Precision value int myPrecision; /// Boolean value whether the spin box content is modified - bool myIsModified; + //bool myIsModified; }; #endif diff --git a/src/ModuleBase/ModuleBase_IntSpinBox.cpp b/src/ModuleBase/ModuleBase_IntSpinBox.cpp index 933cc8455..197bfc22e 100755 --- a/src/ModuleBase/ModuleBase_IntSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_IntSpinBox.cpp @@ -8,13 +8,13 @@ #include ModuleBase_IntSpinBox::ModuleBase_IntSpinBox(QWidget* theParent) -: QSpinBox(theParent), - myIsModified(false) +: QSpinBox(theParent)//, + //myIsModified(false) { - connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); + //connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); } -void ModuleBase_IntSpinBox::onValueChanged(const QString& theValue) +/*void ModuleBase_IntSpinBox::onValueChanged(const QString& theValue) { myIsModified = true; } @@ -27,4 +27,20 @@ bool ModuleBase_IntSpinBox::isModified() const void ModuleBase_IntSpinBox::clearModified() { myIsModified = false; +}*/ + +void ModuleBase_IntSpinBox::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; + } + break; + default: + break; + } + QSpinBox::keyPressEvent(theEvent); } + diff --git a/src/ModuleBase/ModuleBase_IntSpinBox.h b/src/ModuleBase/ModuleBase_IntSpinBox.h index 2e6d959a4..565e43714 100755 --- a/src/ModuleBase/ModuleBase_IntSpinBox.h +++ b/src/ModuleBase/ModuleBase_IntSpinBox.h @@ -27,18 +27,22 @@ public: virtual ~ModuleBase_IntSpinBox() {}; /// Returns true if the current value is modified by has not been applyed yet - virtual bool isModified() const; + //virtual bool isModified() const; /// Clears modified state - void clearModified(); + //void clearModified(); protected slots: /// Called on value changed - void onValueChanged(const QString& theValue); + //void onValueChanged(const QString& theValue); - private: +protected: + /// Called on key press event + virtual void keyPressEvent(QKeyEvent* theEvent); + +private: /// Boolean value whether the spin box content is modified - bool myIsModified; + //bool myIsModified; }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index a43f02cb6..06cfe0c04 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -158,10 +158,11 @@ QList ModuleBase_WidgetDoubleValue::getControls() const bool ModuleBase_WidgetDoubleValue::processEnter() { - bool isModified = mySpinBox->isModified(); + bool isModified = getValueState() == ModifiedInPP; + //bool isModified = mySpinBox->isModified(); if (isModified) { emit valuesChanged(); - mySpinBox->clearModified(); + //mySpinBox->clearModified(); mySpinBox->selectAll(); } return isModified; diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index 4c37116b2..431a387f8 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -314,10 +314,11 @@ QList ModuleBase_WidgetExprEditor::getControls() const bool ModuleBase_WidgetExprEditor::processEnter() { - bool isModified = myEditor->isModified(); + //bool isModified = myEditor->isModified(); + bool isModified = getValueState() == ModifiedInPP; if (isModified) { emit valuesChanged(); - myEditor->clearModified(); + //myEditor->clearModified(); myEditor->selectAll(); } return isModified; diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index b92d5863f..4cae38f12 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -142,10 +142,11 @@ QList ModuleBase_WidgetIntValue::getControls() const bool ModuleBase_WidgetIntValue::processEnter() { - bool isModified = mySpinBox->isModified(); + bool isModified = getValueState() == ModifiedInPP; + //bool isModified = mySpinBox->isModified(); if (isModified) { emit valuesChanged(); - mySpinBox->clearModified(); + //mySpinBox->clearModified(); mySpinBox->selectAll(); } return isModified; diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index ebfe32e00..ccf1a3f14 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -504,13 +504,14 @@ bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature, bool PartSet_WidgetPoint2D::processEnter() { - bool isModified = myXSpin->isModified() || myYSpin->isModified(); + //bool isModified = myXSpin->isModified() || myYSpin->isModified(); + bool isModified = getValueState() == ModifiedInPP; if (isModified) { - bool isXModified = myXSpin->isModified(); + bool isXModified = myXSpin->hasFocus();//myXSpin->isModified(); emit valuesChanged(); //onValuesChanged(); - myXSpin->clearModified(); - myYSpin->clearModified(); + //myXSpin->clearModified(); + //myYSpin->clearModified(); if (isXModified) myXSpin->selectAll(); else diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index ef7bf36c0..829380cef 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -120,10 +120,11 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, bool PartSet_WidgetPoint2dDistance::processEnter() { - bool isModified = mySpinBox->isModified(); + //bool isModified = mySpinBox->isModified(); + bool isModified = getValueState() == ModifiedInPP; if (isModified) { emit valuesChanged(); - mySpinBox->clearModified(); + //mySpinBox->clearModified(); mySpinBox->selectAll(); } return isModified; -- 2.30.2