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
30 \param thePrecision a precision of values display
32 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
33 virtual ~ModuleBase_ParamIntSpinBox();
35 virtual void stepBy(int);
37 virtual int valueFromText(const QString&) const;
38 virtual QString textFromValue(int value) const;
40 virtual QValidator::State validate(QString&, int&) const;
42 virtual void setValue(int);
44 virtual void setText(const QString&);
46 /// Set a flag about accepted variable
47 void setAcceptVariables(const bool);
49 /// Returns accepted variables flag
50 bool isAcceptVariables() const;
52 /// Returns True if the input value contains variable
53 bool hasVariable() const;
56 /// Returns True if the given text contains variable
57 /// \param theText a text string
58 bool hasVariable(const QString& theText) const;
60 /// Returns state of the control
61 State isValid(const QString&, double&) const;
63 /// Returns True if the given value is within min and max of the control
64 bool checkRange(const double) const;
66 /// Finds a variable by its name. Returns true in success
67 /// \param theName a name of variable
68 /// \param outValue an output value of the variable
69 bool findVariable(const QString& theName, double& outValue) const;
72 virtual void showEvent(QShowEvent*);
75 /// A slot called on text change
76 void onTextChanged(const QString&);
79 void connectSignalsAndSlots();
84 bool myAcceptVariables;