Salome HOME
The slot "onTextChanged" is disconnect, but value is updated in method value().
[modules/gui.git] / src / Qtx / QtxWorkstack.cxx
index fd3955e4787c4e59b76c40a22017f2d1a14645fd..2ca7b819ab1edbfa2565d23a6fb8bd3d62c12508 100644 (file)
@@ -99,10 +99,25 @@ void QtxWorkstack::split( const int o )
   area->removeWidget( curWid );
   newArea->insertWidget( curWid );
 
+  distributeSpace( trg );
+
   curWid->show();
   curWid->setFocus();
 }
 
+void QtxWorkstack::distributeSpace( QSplitter* split ) const
+{
+  if ( !split )
+    return;
+
+  QIntList szList = split->sizes();
+  int size = ( split->orientation() == Horizontal ?
+               split->width() : split->height() ) / szList.count();
+  for ( QIntList::iterator it = szList.begin(); it != szList.end(); ++it )
+    *it = size;
+  split->setSizes( szList );
+}
+
 void QtxWorkstack::splitVertical()
 {
   split( Qt::Vertical );
@@ -229,9 +244,12 @@ void QtxWorkstack::onDeactivated( QtxWorkstackArea* area )
   if ( idx == -1 )
     return;
 
+  myWin = 0;
+  myArea = 0;
+
   QtxWorkstackArea* newArea = neighbourArea( area );
-  if ( newArea )
-    newArea->setFocus();
+  if ( newArea && newArea->activeWidget() )
+    newArea->activeWidget()->setFocus();
 
   QApplication::postEvent( this, new QCustomEvent( QEvent::User ) );
 }
@@ -476,6 +494,9 @@ void QtxWorkstack::updateState( QSplitter* split )
   if ( split == mySplit )
     return;
 
+  for ( QPtrListIterator<QSplitter> iter( splitList ); iter.current() && !vis; ++iter )
+    vis = iter.current()->isVisibleTo( iter.current()->parentWidget() );
+
   if ( areaList.isEmpty() && splitList.isEmpty() )
     delete split;
   else if ( vis )
@@ -686,7 +707,7 @@ bool QtxWorkstackArea::eventFilter( QObject* o, QEvent* e )
         wid = wid->parentWidget();
       }
       if ( ok )
-        QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)( e->type() == QEvent::FocusIn ? ActivateEvent : FocusEvent ) ) );
+        QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)( e->type() == QEvent::FocusIn ? ActivateWidget : FocusWidget ) ) );
     }
   }
   return false;
@@ -719,14 +740,14 @@ void QtxWorkstackArea::customEvent( QCustomEvent* e )
 {
   switch ( e->type() )
   {
-  case ActivateEvent:
+  case ActivateWidget:
     emit activated( activeWidget() );
     break;
-  case FocusEvent:
-    if ( activeWidget() )
+  case FocusWidget:
+    if ( activeWidget() && !activeWidget()->focusWidget() )
       activeWidget()->setFocus();
     break;
-  case RemoveEvent:
+  case RemoveWidget:
     removeWidget( (QWidget*)e->data() );
     break;
   }
@@ -783,7 +804,7 @@ void QtxWorkstackArea::onChildDestroyed( QObject* obj )
 
   myChild.remove( wid );
 
-  QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)RemoveEvent, wid ) );
+  QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)RemoveWidget, wid ) );
 }
 
 void QtxWorkstackArea::onChildShown( QtxWorkstackChild* c )