X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxWorkstack.cxx;h=2ca7b819ab1edbfa2565d23a6fb8bd3d62c12508;hb=dea6eecafc297c284dfcf6d6ba81680f7a20f17e;hp=96830454f2a69bb99585de8fbb867a68b110990e;hpb=5ebd89d6c37b3e25f8b629b672c81b6eb03a1cab;p=modules%2Fgui.git diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 96830454f..2ca7b819a 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -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 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 ) @@ -1124,7 +1145,11 @@ QRect QtxWorkstackTabBar::tabRect( const int idx ) const int bw = 0; if ( QABS( x2 - x1 ) > width() ) +#if defined QT_VERSION && QT_VERSION >= 0x30300 bw = 2 * style().pixelMetric( QStyle::PM_TabBarScrollButtonWidth, this ); +#else + bw = 2 * 16; +#endif int limit = width() - bw; r.setRight( QMIN( r.right(), limit ) );