1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef ModuleBase_ParamIntSpinBox_H
4 #define ModuleBase_ParamIntSpinBox_H
6 #include "ModuleBase.h"
8 #include <ModuleBase_IntSpinBox.h>
14 * An extension of a double spin box which let to use parameters and expressions for value definition
16 class MODULEBASE_EXPORT ModuleBase_ParamIntSpinBox : public ModuleBase_IntSpinBox
20 enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
26 Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
27 a step value of 1.0 and a precision of 2 decimal places.
28 The value is initially set to 0.00.
30 \param theParent a parent object
32 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
33 virtual ~ModuleBase_ParamIntSpinBox();
35 virtual void stepBy(int);
37 /// Convert Int value from text string
38 virtual int valueFromText(const QString&) const;
40 /// Convert text string from int value
41 virtual QString textFromValue(int) const;
43 /// Validate the value
44 virtual QValidator::State validate(QString&, int&) const;
46 /// Set current int value
47 virtual void setValue(int);
49 /// Set current text value
50 virtual void setText(const QString&);
52 /// Set a flag about accepted variable
53 void setAcceptVariables(const bool);
55 /// Returns accepted variables flag
56 bool isAcceptVariables() const;
58 /// Returns True if the input value contains variable
59 bool hasVariable() const;
62 /// Returns True if the given text contains variable
63 /// \param theText a text string
64 bool hasVariable(const QString& theText) const;
66 /// Returns state of the control
67 State isValid(const QString&, double&) const;
69 /// Returns True if the given value is within min and max of the control
70 bool checkRange(const double) const;
72 /// Finds a variable by its name. Returns true in success
73 /// \param theName a name of variable
74 /// \param outValue an output value of the variable
75 bool findVariable(const QString& theName, double& outValue) const;
78 virtual void showEvent(QShowEvent*);
81 /// A slot called on text change
82 void onTextChanged(const QString&);
85 void connectSignalsAndSlots();
90 bool myAcceptVariables;