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>
18 * An extension and customization of QDoubleSpinBox class
20 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
25 explicit ModuleBase_DoubleSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
26 virtual ~ModuleBase_DoubleSpinBox();
28 /// Returns true if the control is clear
29 bool isCleared() const;
32 virtual void setCleared(const bool);
34 /// Returns current precision
35 int getPrecision() const;
38 void setPrecision(const int);
41 virtual void stepBy(int);
43 /// Converts value from string to double
44 virtual double valueFromText(const QString&) const;
46 /// Convert value from double to string
47 virtual QString textFromValue(double) const;
49 /// Validate current value
50 virtual QValidator::State validate(QString&, int&) const;
52 /// Returns true if the current value is modified by has not been applyed yet
53 virtual bool isModified() const;
55 /// Clears modified state
58 /// Change enable/disable internal state to emit key press event
59 /// \param theEnable if true, the signal is emitted
60 /// \return the previous value
61 bool enableKeyPressEvent(const bool& theEnable);
64 /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed.
69 /// Called on text changed
70 virtual void onTextChanged(const QString&);
71 void onValueChanged(const QString& theValue);
72 void onEditingFinished();
75 /// Removes extra trailing zero symbols
76 QString removeTrailingZeroes(const QString&) const;
77 virtual void keyPressEvent(QKeyEvent* theEvent);
79 /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
80 /// Emits a signal about focus change
81 /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
82 virtual bool focusNextPrevChild(bool theIsNext);
85 // boolen flag whether the key event is emitted. The default value is false
86 bool myIsEmitKeyPressEvent;
93 /// Boolean value whether the spin box content is modified