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
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()));
}
/*!
return res;
}
-void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent)
+void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent* theEvent)
{
+ bool isEmitKeyRelease = false;
switch (theEvent->key()) {
case Qt::Key_Enter:
case Qt::Key_Return: {
// do not react to the Enter key, the property panel processes it
if (!myIsEmitKeyPressEvent)
return;
+ else
+ isEmitKeyRelease = true;
}
break;
default:
break;
}
QDoubleSpinBox::keyPressEvent(theEvent);
+
+ if (isEmitKeyRelease)
+ emit enterPressed();
}
-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);
}
/*!
void ModuleBase_DoubleSpinBox::onTextChanged(const QString& )
{
myCleared = false;
- myIsModified = true;
-}
-
-void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue)
-{
- myIsModified = true;
-}
-
-void ModuleBase_DoubleSpinBox::onEditingFinished()
-{
- //myIsModified = false;
-}
-
-bool ModuleBase_DoubleSpinBox::isModified() const
-{
- return myIsModified;
-}
-
-void ModuleBase_DoubleSpinBox::clearModified()
-{
- myIsModified = false;
}
bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable)