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 );
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 ) );
}
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 )
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;
{
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;
}
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 )
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 ) );