1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_DoubleSpinBox.h
4 // Author: Sergey BELASH
6 #ifndef MODULEBASE_DOUBLESPINBOX_H_
7 #define MODULEBASE_DOUBLESPINBOX_H_
9 #include "ModuleBase.h"
11 #include <QDoubleSpinBox>
20 * An extension and customization of QDoubleSpinBox class
22 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
27 explicit ModuleBase_DoubleSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
28 virtual ~ModuleBase_DoubleSpinBox();
30 /// Returns true if the control is clear
31 bool isCleared() const;
34 virtual void setCleared(const bool);
36 /// Returns current precision
37 int getPrecision() const;
40 void setPrecision(const int);
43 virtual void stepBy(int);
45 /// Converts value from string to double
46 virtual double valueFromText(const QString&) const;
48 /// Convert value from double to string
49 virtual QString textFromValue(double) const;
51 /// Validate current value
52 virtual QValidator::State validate(QString&, int&) const;
54 /// Imitation of disable control value. If theEnable is false, the control becomes
55 /// read only and base color is disabled.
56 void setValueEnabled(const bool& theEnable);
59 /// Called on text changed
60 virtual void onTextChanged(const QString&);
63 /// Removes extra trailing zero symbols
64 QString removeTrailingZeroes(const QString&) const;
67 // boolen flag whether the key event is emitted. The default value is false
68 bool myIsEmitKeyPressEvent;
76 /// Cashed color of active base palette
77 QColor myEnabledBaseColor;