2 #ifndef ModuleBase_ParamIntSpinBox_H
3 #define ModuleBase_ParamIntSpinBox_H
5 #include "ModuleBase.h"
7 #include <ModuleBase_IntSpinBox.h>
13 * An extension of a double spin box which let to use parameters and expressions for value definition
15 class MODULEBASE_EXPORT ModuleBase_ParamIntSpinBox : public ModuleBase_IntSpinBox
19 enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
25 Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
26 a step value of 1.0 and a precision of 2 decimal places.
27 The value is initially set to 0.00.
29 \param theParent a parent object
31 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
32 virtual ~ModuleBase_ParamIntSpinBox();
34 virtual void stepBy(int);
36 /// Convert Int value from text string
37 virtual int valueFromText(const QString&) const;
39 /// Convert text string from int value
40 virtual QString textFromValue(int) const;
42 /// Validate the value
43 virtual QValidator::State validate(QString&, int&) const;
45 /// Set current int value
46 virtual void setValue(int);
48 /// Set current text value
49 virtual void setText(const QString&);
51 /// Set a flag about accepted variable
52 void setAcceptVariables(const bool);
54 /// Returns accepted variables flag
55 bool isAcceptVariables() const;
57 /// Returns True if the input value contains variable
58 bool hasVariable() const;
61 /// Returns True if the given text contains variable
62 /// \param theText a text string
63 bool hasVariable(const QString& theText) const;
65 /// Returns state of the control
66 State isValid(const QString&, double&) const;
68 /// Returns True if the given value is within min and max of the control
69 bool checkRange(const double) const;
71 /// Finds a variable by its name. Returns true in success
72 /// \param theName a name of variable
73 /// \param outValue an output value of the variable
74 bool findVariable(const QString& theName, double& outValue) const;
77 virtual void showEvent(QShowEvent*);
80 /// A slot called on text change
81 void onTextChanged(const QString&);
84 void connectSignalsAndSlots();
89 bool myAcceptVariables;