SHAPER 9.16.0
ModuleBase_ParamIntSpinBox.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModuleBase_ParamIntSpinBox_H
21#define ModuleBase_ParamIntSpinBox_H
22
23#include "ModuleBase.h"
24
25#include <ModuleBase_IntSpinBox.h>
26
27#include <QValidator>
28
33class MODULEBASE_EXPORT ModuleBase_ParamIntSpinBox : public ModuleBase_IntSpinBox
34{
35 Q_OBJECT
36
37 enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
38
39public:
49 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
51
52 virtual void stepBy(int);
53
55 virtual int valueFromText(const QString&) const;
56
58 virtual QString textFromValue(int) const;
59
61 virtual QValidator::State validate(QString&, int&) const;
62
64 virtual void setValue(int);
65
67 virtual void setText(const QString&);
68
70 void setAcceptVariables(const bool);
71
73 bool isAcceptVariables() const;
74
76 bool hasVariable() const;
77
78 protected:
81 bool hasVariable(const QString& theText) const;
82
84 State isValid(const QString&, double&) const;
85
87 bool checkRange(const double) const;
88
92 bool findVariable(const QString& theName, double& outValue) const;
93
94 protected:
95 virtual void showEvent(QShowEvent*);
96
97 protected slots:
99 void onTextChanged(const QString&);
100
101 private:
102 void connectSignalsAndSlots();
103
104 private:
105 QString myTextValue;
106
107 bool myAcceptVariables;
108};
109
110#endif
Enhanced version of the Qt's int spin box.
Definition: ModuleBase_IntSpinBox.h:36
An extension of a double spin box which let to use parameters and expressions for value definition.
Definition: ModuleBase_ParamIntSpinBox.h:34