Salome HOME
Fix for crash on multi-selection of group-vertices on imported body with Shift-key...
[modules/shaper.git] / src / ModuleBase / ModuleBase_ParamSpinBox.h
1
2 #ifndef ModuleBase_ParamSpinBox_H
3 #define ModuleBase_ParamSpinBox_H
4
5 #include "ModuleBase.h"
6
7 #include <ModuleBase_DoubleSpinBox.h>
8
9 #include <QValidator>
10
11 class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox
12 {
13   Q_OBJECT
14
15   enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
16
17 public:
18   explicit ModuleBase_ParamSpinBox(QWidget* theParent = 0, int thePrecision = 6);
19   virtual ~ModuleBase_ParamSpinBox();
20
21   virtual void stepBy(int);
22
23   virtual double valueFromText(const QString&) const;
24
25   virtual QValidator::State validate(QString&, int&) const;
26
27   virtual void setValue(double);
28
29   virtual void setText(const QString&);
30
31   void setAcceptVariables(const bool);
32   bool isAcceptVariables() const;
33   bool hasVariable() const;
34
35 signals:
36   void textChanged(const QString&);
37
38  protected:
39   bool hasVariable(const QString& theText) const;
40   State isValid(const QString&, double&) const;
41
42   bool checkRange(const double) const;
43
44   bool findVariable(const QString&, double&) const;
45
46  protected:
47   virtual void keyPressEvent(QKeyEvent*);
48   virtual void showEvent(QShowEvent*);
49
50  protected slots:
51   void onEditingFinished();
52   void onTextChanged(const QString&);
53
54  private:
55   void connectSignalsAndSlots();
56
57  private:
58   QString myCorrectValue;
59   QString myTextValue;
60
61   bool myAcceptVariables;
62 };
63
64 #endif