+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
// File: ModuleBase_Widgets.h
// Created: 04 June 2014
// Author: Vitaly Smetannikov
#include <ModuleBase_WidgetDoubleValue.h>
+#include <ModuleBase_DoubleSpinBox.h>
+#include <ModuleBase_Tools.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
#include <QWidget>
#include <QLayout>
#include <QLabel>
-#include <QDoubleSpinBox>
#include <QEvent>
-#include <QKeyEvent>
+#include <QTimer>
+
+#include <math.h>
#ifndef DBL_MAX
#define DBL_MAX 1.7976931348623158e+308
#endif
+#ifdef _DEBUG
+#include <iostream>
+#endif
ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
const Config_WidgetAPI* theData,
{
myContainer = new QWidget(theParent);
QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
- aControlLay->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::adjustMargins(aControlLay);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
myLabel->setPixmap(QPixmap(aLabelIcon));
aControlLay->addWidget(myLabel);
- mySpinBox = new QDoubleSpinBox(myContainer);
+ mySpinBox = new ModuleBase_DoubleSpinBox(myContainer);
QString anObjName = QString::fromStdString(attributeID());
mySpinBox->setObjectName(anObjName);
aProp = theData->getProperty(DOUBLE_WDG_STEP);
double aStepVal = QString::fromStdString(aProp).toDouble(&isOk);
if (isOk) {
+ double aMinStep = pow(10, -1. * (double) mySpinBox->decimals());
+ if(aStepVal < aMinStep){
+ aStepVal = aMinStep;
+ }
mySpinBox->setSingleStep(aStepVal);
}
- aProp = theData->getProperty(DOUBLE_WDG_DFLT);
+ aProp = theData->getProperty(ATTR_DEFAULT);
double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
if (isOk) {
mySpinBox->setValue(aDefVal);
+ } else if (aProp == DOUBLE_WDG_DEFAULT_COMPUTED){
+ myIsComputedDefault = true;
}
QString aTTip = QString::fromStdString(theData->widgetTooltip());
aControlLay->setStretch(1, 1);
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
-
- mySpinBox->installEventFilter(this);
}
ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
QList<QWidget*> ModuleBase_WidgetDoubleValue::getControls() const
{
QList<QWidget*> aList;
- aList.append(myLabel);
aList.append(mySpinBox);
return aList;
}
-
-bool ModuleBase_WidgetDoubleValue::eventFilter(QObject *theObject, QEvent *theEvent)
-{
- if (theObject == mySpinBox) {
- if (theEvent->type() == QEvent::KeyRelease) {
- QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
- emit focusOutWidget(this);
- }
- emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
- return true;
- }
- }
- return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
-}