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();
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 )
56 spinBox()->setValue( txt.toDouble() );
60 Returns pointer to XMLGUI_SpinBoxDbl widget.
62 QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const
64 return ::qt_cast<QtxDblSpinBox*>( controlWidget() );
68 Create QSpinBox widget as control subwidget.
70 QWidget* QDS_SpinBoxDbl::createControl( QWidget* parent )
72 QtxDblSpinBox* aSpinBox = new QtxDblSpinBox( parent );
73 aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
74 connect( aSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) );
79 Notify about text changing in spin box.
81 void QDS_SpinBoxDbl::onValueChanged( double )
84 QString str = getString();
87 emit paramChanged( str );
91 Returns the increment step.
93 double QDS_SpinBoxDbl::step() const
97 s = spinBox()->lineStep();
102 Sets the increment step.
104 void QDS_SpinBoxDbl::setStep( const double step )
107 spinBox()->setLineStep( step );
110 void QDS_SpinBoxDbl::unitSystemChanged( const QString& system )
112 QDS_Datum::unitSystemChanged( system );
114 QtxDblSpinBox* sb = spinBox();
118 delete sb->validator();
119 QValidator* valid = validator();
120 sb->setValidator( valid );
122 sb->setSuffix( suffix() );
123 sb->setPrefix( prefix() );
125 Standard_Integer aPreci = 1;
126 Handle(DDS_DicItem) aDicItem = dicItem();
127 if ( !aDicItem.IsNull() )
128 aPreci = aDicItem->GetPrecision();
130 sb->setPrecision( aPreci );
132 sb->setLineStep( .1 );
133 sb->setMinValue( minValue().toDouble() );
134 sb->setMaxValue( maxValue().toDouble() );