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 /// Change enable/disable internal state to emit key press event
55 /// \param theEnable if true, the signal is emitted
56 /// \return the previous value
57 bool enableKeyPressEvent(const bool& theEnable);
59 /// Imitation of disable control value. If theEnable is false, the control becomes
60 /// read only and base color is disabled.
61 void setValueEnabled(const bool& theEnable);
64 /// The signal about key release on the control, that corresponds to the attribute
68 /// Called on text changed
69 virtual void onTextChanged(const QString&);
72 /// Removes extra trailing zero symbols
73 QString removeTrailingZeroes(const QString&) const;
74 /// Called on key press event
75 virtual void keyReleaseEvent(QKeyEvent* theEvent);
77 /// Called on key press event
78 virtual void keyPressEvent(QKeyEvent* theEvent);
81 // boolen flag whether the key event is emitted. The default value is false
82 bool myIsEmitKeyPressEvent;
90 /// Cashed color of active base palette
91 QColor myEnabledBaseColor;