Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SalomeApp_IntSpinBox.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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 // File: SalomeApp_IntSpinBox.h
21 // Author: Oleg UVAROV
22 //
23 #ifndef SALOMEAPP_INTSPINBOX_H
24 #define SALOMEAPP_INTSPINBOX_H
25 
26 #include "SalomeApp.h"
27 
28 #include <QtxIntSpinBox.h>
29 
30 #include <QValidator>
31 
33 {
34  Q_OBJECT
35 
36  enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
37  enum SearchState { NotFound = 0, IncorrectType, Found };
38 
39 public:
41  SalomeApp_IntSpinBox( int, int, int = 1, QWidget* = 0, bool = true, bool = true );
42  virtual ~SalomeApp_IntSpinBox();
43 
44  virtual void stepBy( int );
45 
46  virtual int valueFromText( const QString& ) const;
47  virtual QString textFromValue( int ) const;
48 
49  virtual QValidator::State validate( QString&, int& ) const;
50 
51  virtual bool isValid( QString& msg, bool = false );
52 
53  virtual void setDefaultValue( const int );
54 
55  virtual void setValue( int );
56 
57  virtual void setText(const QString& );
58 
59  void setAcceptNames( const bool );
60  bool isAcceptNames() const;
61 
62  void setShowTipOnValidate( const bool );
63  bool isShowTipOnValidate() const;
64 
65 signals:
66  void textChanged( const QString& );
67 
68 protected:
69  State isValid( const QString&, int& ) const;
70 
71  int defaultValue() const;
72  bool checkRange( const int ) const;
73 
74  SearchState findVariable( const QString&, int& ) const;
75 
76 protected:
77  virtual void keyPressEvent( QKeyEvent* );
78  virtual void showEvent( QShowEvent* );
79 
80 protected slots:
81  void onEditingFinished();
82  void onTextChanged( const QString& );
83 
84 private:
85  void connectSignalsAndSlots();
86 
87 private:
89 
90  QString myCorrectValue;
91  QString myTextValue;
92 
94  bool myShowTip;
95 };
96 
97 #endif