X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ParamSpinBox.h;h=6f2252ec81bdeb3cdbb6c4ed6b46450e9368a331;hb=1490e92974d2c0bdcdbecd6fa9388e31dccfa363;hp=7d14e951136d1f4cc6065fd650adc5adba00ec82;hpb=7df901531d6c7df50b82058bece27151629c9298;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index 7d14e9511..6f2252ec8 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -8,6 +8,13 @@ #include +class QStringListModel; +class QCompleter; + +/** +* \ingroup GUI +* An extension of a double spin box which let to use parameters and expressions for value definition +*/ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox { Q_OBJECT @@ -15,7 +22,21 @@ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBo enum State { Invalid = 0, NoVariable, Incompatible, Acceptable }; public: + /*! + \brief Constructor. + + Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, + a step value of 1.0 and a precision of 2 decimal places. + The value is initially set to 0.00. + + \param theParent a parent object + \param thePrecision a precision of values display + */ explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 ); + + /// Set list of completion strings + void setCompletionList(QStringList&); + virtual ~ModuleBase_ParamSpinBox(); virtual void stepBy(int); @@ -29,26 +50,36 @@ public: virtual void setText(const QString&); + /// Set a flag about accepted variable void setAcceptVariables(const bool); + + /// Returns accepted variables flag bool isAcceptVariables() const; - bool hasVariable() const; -//signals: - //void textChanged(const QString&); + /// Returns True if the input value contains variable + bool hasVariable() const; - protected: +protected: + /// Returns True if the given text contains variable + /// \param theText a text string bool hasVariable(const QString& theText) const; + + /// Returns state of the control State isValid(const QString&, double&) const; + /// Returns True if the given value is within min and max of the control bool checkRange(const double) const; - bool findVariable(const QString&, double&) const; + /// Finds a variable by its name. Returns true in success + /// \param theName a name of variable + /// \param outValue an output value of the variable + bool findVariable(const QString& theName, double& outValue) const; protected: - //virtual void keyPressEvent(QKeyEvent*); virtual void showEvent(QShowEvent*); protected slots: + /// A slot called on text change void onTextChanged(const QString&); private: @@ -58,6 +89,9 @@ public: QString myTextValue; bool myAcceptVariables; + + QStringListModel* myCompleterModel; + QCompleter* myCompleter; }; #endif