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
// (to avoid inconsistency of double-2-string and string-2-double conversion)
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:
{
myIsModified = false;
}
+
+bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable)
+{
+ bool aPreviousValue = myIsEmitKeyPressEvent;
+ myIsEmitKeyPressEvent = theEnable;
+
+ return aPreviousValue;
+}
/// Validate current value
virtual QValidator::State validate(QString&, int&) const;
- // Returns true if the current value is modified by has not been applyed yet
+ /// Returns true if the current value is modified by has not been applyed yet
virtual bool isModified() const;
- // Clears modified state
+ /// Clears modified state
void clearModified();
+ /// Change enable/disable internal state to emit key press event
+ /// \param theEnable if true, the signal is emitted
+ /// \return the previous value
+ bool enableKeyPressEvent(const bool& theEnable);
+
signals:
/// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed.
void focusNextPrev();
virtual bool focusNextPrevChild(bool theIsNext);
private:
+ // boolen flag whether the key event is emitted. The default value is false
+ bool myIsEmitKeyPressEvent;
+
/// Is clear flag
bool myCleared;
{
}
-void editedValue(double& outValue, QString& outText)
+void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
{
QDialog aDlg(QApplication::desktop(), Qt::FramelessWindowHint);
QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
aLay->setContentsMargins(2, 2, 2, 2);
- ModuleBase_ParamSpinBox* aEditor = new ModuleBase_ParamSpinBox(&aDlg);
- aEditor->setMinimum(0);
- aEditor->setMaximum(DBL_MAX);
+ ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
+ anEditor->enableKeyPressEvent(true);
+
+ anEditor->setMinimum(0);
+ anEditor->setMaximum(DBL_MAX);
if (outText.isEmpty())
- aEditor->setValue(outValue);
+ anEditor->setValue(outValue);
else
- aEditor->setText(outText);
+ anEditor->setText(outText);
- aLay->addWidget(aEditor);
+ aLay->addWidget(anEditor);
- aEditor->setFocus();
- aEditor->selectAll();
- QObject::connect(aEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
+ anEditor->setFocus();
+ anEditor->selectAll();
+ QObject::connect(anEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
aDlg.move(QCursor::pos());
aDlg.exec();
- outText = aEditor->text();
+ outText = anEditor->text();
bool isDouble;
double aValue = outText.toDouble(&isDouble);
if (isDouble) {
/// Shous popup window under cursor for data editing
void showPopupEditor();
+private:
+ void editedValue(double& outValue, QString& outText);
+
private:
///< the current widget feature
FeaturePtr myFeature;