Salome HOME
Splash screen was implemented. Changes in packages SUIT and Session are integrated.
[modules/gui.git] / src / Qtx / QtxDblSpinBox.cxx
index 0d7b22ff4660b48b2f45dde6438370721598cf8f..5c40e9d135c3066cf84e6fec517678419a5013be 100755 (executable)
@@ -82,6 +82,8 @@ myPrecision( 0 )
   setValidator( new Validator( this, "double_spinbox_validator" ) );
   rangeChange();
   updateDisplay();
+
+  connect( editor(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
 }
 
 QtxDblSpinBox::QtxDblSpinBox( double min, double max, double step, QWidget* parent, const char* name )
@@ -97,6 +99,8 @@ myPrecision( 0 )
   setValidator( new Validator( this, "double_spinbox_validator" ) );
   rangeChange();
   updateDisplay();
+
+  connect( editor(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
 }
 
 QtxDblSpinBox::~QtxDblSpinBox()
@@ -173,6 +177,8 @@ void QtxDblSpinBox::setLineStep( double step )
 
 double QtxDblSpinBox::value() const
 {
+  QSpinBox::value();
+
   return myValue;
 }
 
@@ -267,7 +273,10 @@ void QtxDblSpinBox::updateDisplay()
 {
   if ( myBlocked )
     return;
-    
+
+  bool upd = editor()->isUpdatesEnabled();
+  editor()->setUpdatesEnabled( false );
+
   bool isBlock = myBlocked;
   myBlocked = true;
     
@@ -279,11 +288,20 @@ void QtxDblSpinBox::updateDisplay()
     QSpinBox::setValue( QSpinBox::minValue() );
   else
     QSpinBox::setValue( ( QSpinBox::minValue() + QSpinBox::maxValue() ) / 2 );
-    
+  
   QSpinBox::updateDisplay();
-    
+
+  editor()->setUpdatesEnabled( upd );
+
   editor()->setText( myCleared ? QString::null : txt );
-    
+  if ( !myCleared )
+  {
+    if ( editor()->text() == specialValueText() )
+      editor()->selectAll();
+    else
+      editor()->setSelection( prefix().length(), editor()->text().length() - prefix().length() - suffix().length() );
+  }
+
   myBlocked = isBlock;
 }
 
@@ -314,7 +332,7 @@ void QtxDblSpinBox::interpretText()
 void QtxDblSpinBox::valueChange()
 {
   updateDisplay();
-  emit valueChanged( value() );
+  emit valueChanged( myValue );
   emit valueChanged( currentValueText() );
 }
 
@@ -400,3 +418,9 @@ void QtxDblSpinBox::wheelEvent( QWheelEvent* e )
   QSpinBox::wheelEvent( e );
   updateDisplay();
 }
+
+void QtxDblSpinBox::onTextChanged( const QString& str )
+{
+  if ( !myBlocked )
+    myCleared = false;
+}