Correction: the operation state(ModifiedInPP) should be used instead of additional internal state in the controls.
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
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;
}
void ModuleBase_DoubleSpinBox::clearModified()
{
myIsModified = false;
-}
+}*/
bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable)
{
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
/// 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
/// Precision value
int myPrecision;
/// Boolean value whether the spin box content is modified
- bool myIsModified;
+ //bool myIsModified;
};
#endif
#include <QKeyEvent>
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;
}
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);
}
+
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
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;
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;
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;
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
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;