Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[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 TELKOV
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 * An extension and customozation of QDoubleSpinBox class
17 */
18 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
19 {
20 Q_OBJECT
21
22  public:
23   ModuleBase_DoubleSpinBox(QWidget* theParent = 0, int thePrecision = 6);
24   virtual ~ModuleBase_DoubleSpinBox();
25
26   /// Returns true if the control is clear
27   bool isCleared() const;
28
29   /// Set control clear
30   virtual void setCleared(const bool);
31
32   /// Returns current precision
33   int getPrecision() const;
34
35   /// Set precision
36   void setPrecision(const int);
37
38   /// Set step
39   virtual void stepBy(int);
40
41   /// Converts value from string to double
42   virtual double valueFromText(const QString&) const;
43
44   /// Convert value from double to string
45   virtual QString textFromValue(double) const;
46
47   /// Validate current value
48   virtual QValidator::State validate(QString&, int&) const;
49
50  protected slots:
51    /// Called on text changed
52   virtual void onTextChanged(const QString&);
53
54  protected:
55    /// Removes extra trailing zero symbols
56   QString removeTrailingZeroes(const QString&) const;
57
58  private:
59    /// Is clear flag
60   bool myCleared;
61
62   /// Precision value
63   int myPrecision;
64 };
65
66 #endif