Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_DoubleSpinBox.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:      ModuleBase_DoubleSpinBox.h
4 // Author:    Sergey BELASH
5 //
6 #ifndef MODULEBASE_DOUBLESPINBOX_H_
7 #define MODULEBASE_DOUBLESPINBOX_H_
8
9 #include "ModuleBase.h"
10
11 #include <QDoubleSpinBox>
12 #include <QValidator>
13
14
15 /**
16 * \ingroup GUI
17 * An extension and customozation of QDoubleSpinBox class
18 */
19 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
20 {
21 Q_OBJECT
22
23  public:
24   explicit ModuleBase_DoubleSpinBox(QWidget* theParent = 0, int thePrecision = 6);
25   virtual ~ModuleBase_DoubleSpinBox();
26
27   /// Returns true if the control is clear
28   bool isCleared() const;
29
30   /// Set control clear
31   virtual void setCleared(const bool);
32
33   /// Returns current precision
34   int getPrecision() const;
35
36   /// Set precision
37   void setPrecision(const int);
38
39   /// Set step
40   virtual void stepBy(int);
41
42   /// Converts value from string to double
43   virtual double valueFromText(const QString&) const;
44
45   /// Convert value from double to string
46   virtual QString textFromValue(double) const;
47
48   /// Validate current value
49   virtual QValidator::State validate(QString&, int&) const;
50
51  protected slots:
52    /// Called on text changed
53   virtual void onTextChanged(const QString&);
54
55  protected:
56    /// Removes extra trailing zero symbols
57   QString removeTrailingZeroes(const QString&) const;
58
59  private:
60    /// Is clear flag
61   bool myCleared;
62
63   /// Precision value
64   int myPrecision;
65 };
66
67 #endif