SHAPER  9.12.0
ModuleBase_DoubleSpinBox.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef MODULEBASE_DOUBLESPINBOX_H_
21 #define MODULEBASE_DOUBLESPINBOX_H_
22 
23 #include "ModuleBase.h"
24 
25 #include <QDoubleSpinBox>
26 #include <QValidator>
27 
28 #include <QColor>
29 
30 class QKeyEvent;
31 
36 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
37 {
38 Q_OBJECT
39 
40  public:
41  explicit ModuleBase_DoubleSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
42  virtual ~ModuleBase_DoubleSpinBox();
43 
45  bool isCleared() const;
46 
48  virtual void setCleared(const bool);
49 
51  int getPrecision() const;
52 
54  void setPrecision(const int);
55 
57  virtual void stepBy(int);
58 
60  virtual double valueFromText(const QString&) const;
61 
63  virtual QString textFromValue(double) const;
64 
66  virtual QValidator::State validate(QString&, int&) const;
67 
70  void setValueEnabled(const bool& theEnable);
71 
72  protected slots:
74  virtual void onTextChanged(const QString&);
75 
76  protected:
78  QString removeTrailingZeroes(const QString&) const;
79 
80  private:
81  // boolen flag whether the key event is emitted. The default value is false
82  bool myIsEmitKeyPressEvent;
83 
85  bool myCleared;
86 
88  int myPrecision;
89 
91  QColor myEnabledBaseColor;
92 };
93 
94 #endif
An extension and customization of QDoubleSpinBox class.
Definition: ModuleBase_DoubleSpinBox.h:37