]> SALOME platform Git repositories - modules/gui.git/blob - src/QDS/QDS_CheckBox.cxx
Salome HOME
Retriveing dictionary item without specified component.
[modules/gui.git] / src / QDS / QDS_CheckBox.cxx
1 #include "QDS_CheckBox.h"
2
3 #include <qcheckbox.h>
4
5 /*!
6   Constructor. This method is protected. Object can't be directly constructed.
7   Use static method QDS_CheckBox::Create instead.
8 */
9 QDS_CheckBox::QDS_CheckBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
10 : QDS_Datum( id, parent, flags, comp )
11 {
12 }
13
14 /*!
15   Destructor.
16 */
17 QDS_CheckBox::~QDS_CheckBox()
18 {
19 }
20
21 /*!
22   Returns string from QCheckBox widget.
23 */
24 QString QDS_CheckBox::getString() const
25 {
26   return checkBox() && checkBox()->isChecked() ? "1" : "0";
27 }
28
29 /*!
30   Sets the string into QCheckBox widget.
31 */
32 void QDS_CheckBox::setString( const QString& txt )
33 {
34   bool isOk;
35   int val = (int)txt.toDouble( &isOk );
36   if ( checkBox() )
37     checkBox()->setChecked( isOk && val != 0 );
38 }
39
40 /*!
41   Returns pointer to QCheckBox widget.
42 */
43 QCheckBox* QDS_CheckBox::checkBox() const
44 {
45   return ::qt_cast<QCheckBox*>( controlWidget() );
46 }
47
48 /*!
49   Create QCheckBox widget as control subwidget.
50 */
51 QWidget* QDS_CheckBox::createControl( QWidget* parent )
52 {
53   QCheckBox* cb = new QCheckBox( parent );
54   connect( cb, SIGNAL( stateChanged( int ) ), SLOT( onParamChanged() ) );
55   connect( cb, SIGNAL( toggled( bool ) ), SIGNAL( toggled( bool ) ) );
56   return cb;
57 }
58
59 /*!
60   Notify about shanging of control state
61 */
62 void QDS_CheckBox::onParamChanged()
63 {
64   emit paramChanged();
65 }
66
67 void QDS_CheckBox::setChecked( const bool theState )
68 {
69   if ( checkBox() )
70     checkBox()->setChecked( theState );
71 }
72
73 bool QDS_CheckBox::isChecked() const
74 {
75   return checkBox() ? checkBox()->isChecked() : false;
76 }