1 #include "QDS_SpinBoxDbl.h"
3 #include <DDS_Dictionary.h>
5 #include <qvalidator.h>
7 #include <QtxDblSpinBox.h>
12 QDS_SpinBoxDbl::QDS_SpinBoxDbl( const QString& id, QWidget* parent, const int flags, const QString& comp )
13 : QDS_Datum( id, parent, flags, comp )
20 QDS_SpinBoxDbl::~QDS_SpinBoxDbl()
25 Returns string from QSpinBox widget.
27 QString QDS_SpinBoxDbl::getString() const
30 QtxDblSpinBox* sb = spinBox();
31 if ( sb && !sb->isCleared() )
33 bool hasFocus = sb->hasFocus();
38 if ( !sb->suffix().isEmpty() )
39 res.remove( res.find( sb->suffix() ), sb->suffix().length() );
40 if ( !sb->prefix().isEmpty() )
41 res.remove( res.find( sb->prefix() ), sb->prefix().length() );
51 Sets the string into QSpinBox widget.
53 void QDS_SpinBoxDbl::setString( const QString& txt )
58 spinBox()->setCleared( txt.isEmpty() );
60 spinBox()->setValue( txt.toDouble() );
64 Returns pointer to QtxDblSpinBox widget.
66 QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const
68 return ::qt_cast<QtxDblSpinBox*>( controlWidget() );
72 Create QSpinBox widget as control subwidget.
74 QWidget* QDS_SpinBoxDbl::createControl( QWidget* parent )
76 QtxDblSpinBox* aSpinBox = new QtxDblSpinBox( parent );
77 aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
78 connect( aSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) );
83 Notify about text changing in spin box.
85 void QDS_SpinBoxDbl::onValueChanged( double )
88 QString str = getString();
91 emit paramChanged( str );
95 Returns the increment step.
97 double QDS_SpinBoxDbl::step() const
101 s = spinBox()->lineStep();
106 Sets the increment step.
108 void QDS_SpinBoxDbl::setStep( const double step )
111 spinBox()->setLineStep( step );
114 void QDS_SpinBoxDbl::unitSystemChanged( const QString& system )
116 QDS_Datum::unitSystemChanged( system );
118 QtxDblSpinBox* sb = spinBox();
122 delete sb->validator();
123 QValidator* valid = validator();
124 sb->setValidator( valid );
126 sb->setSuffix( suffix() );
127 sb->setPrefix( prefix() );
129 Standard_Integer aPreci = 1;
130 Handle(DDS_DicItem) aDicItem = dicItem();
131 if ( !aDicItem.IsNull() )
132 aPreci = aDicItem->GetPrecision();
134 sb->setPrecision( aPreci );
136 sb->setLineStep( .1 );
137 sb->setMinValue( minValue().isEmpty() ? -DBL_MAX : minValue().toDouble() );
138 sb->setMaxValue( maxValue().isEmpty() ? DBL_MAX : maxValue().toDouble() );