void KMdiDockContainer::tabClicked( int t )
{
	bool call_makeVisible = !m_tabSwitching;
	m_tabSwitching = true;
	if ( m_tb->isTabRaised( t ) )
	{
		kdDebug( 760 ) << k_funcinfo << "Tab " << t << " was just activated" << endl;
		if ( m_ws->isHidden() )
		{
			kdDebug( 760 ) << k_funcinfo << "Showing widgetstack for tab just clicked" << endl;
			m_ws->show();
			parentDockWidget()->restoreFromForcedFixedSize();
		}

		if ( !m_ws->widget( t ) )
		{
			kdDebug( 760 ) << k_funcinfo << "Widget tab was clicked for is not in our stack" << endl;
			kdDebug( 760 ) << k_funcinfo << "Docking it back in" << endl;
			m_revMap[t]->manualDock( parentDockWidget(), KDockWidget::DockCenter, 20 );
			if ( call_makeVisible )
				m_revMap[t]->makeDockVisible();
			m_tabSwitching = false;
			emit activated( this );
			return ;
		}

		if ( m_ws->widget( t ) )
		{
			m_ws->raiseWidget( t );
			KDockWidget * tmpDw = ::tqqt_cast<KDockWidget*>( m_ws->widget( t ) );
			if ( tmpDw )
			{
				if ( tmpDw->getWidget() )
					tmpDw->getWidget()->setFocus();
			}
			else
				kdDebug( 760 ) << k_funcinfo << "Something really weird is going on" << endl;
		}
		else
			kdDebug( 760 ) << k_funcinfo << "We have no widget to handle in our stack." << endl;

		if ( oldtab != t )
			m_tb->setTab( oldtab, false );

		m_tabSwitching = true;
		oldtab = t;
		emit activated( this );
	}
	else
	{
		kdDebug( 760 ) << k_funcinfo << "Tab " << t << " was just deactiviated" << endl;
		// try save splitter position
		if ( parentDockWidget() && parentDockWidget()->parent() )
		{
			KDockSplitter * sp = ::tqqt_cast<KDockSplitter*>( parentDockWidget()->parent() );
			if ( sp )
				m_separatorPos = sp->separatorPos();
		}
		m_previousTab = t;
		//    oldtab=-1;
		if ( m_block )
			return ;
		emit deactivated( this );
		m_block = true;
		if ( m_ws->widget( t ) )
		{
			//    ((KDockWidget*)m_ws->widget(t))->undock();
		}
		m_block = false;
		m_ws->hide ();


		kdDebug( 760 ) << k_funcinfo << "Fixed Width:" << m_tb->width() << endl;
		if ( !m_horizontal )
			parentDockWidget()->setForcedFixedWidth( m_tb->width() ); // strange why it worked before at all
		else
			parentDockWidget()->setForcedFixedHeight( m_tb->height() ); // strange why it worked before at all
	}
	m_tabSwitching = false;
}
Beispiel #2
0
void DockContainer::tabClicked(int t)
{
    kdDebug(760) << "DockContainer::tabClicked()" << endl;
    bool call_makeVisible = !m_tabSwitching;
    m_tabSwitching = true;
    if((t != -1) && m_tb->isTabRaised(t))
    {
        if(m_ws->isHidden())
        {
            m_ws->show();
            parentDockWidget()->restoreFromForcedFixedSize();
        }
        if(!m_ws->widget(t))
        {
            m_revMap[t]->manualDock(parentDockWidget(), KDockWidget::DockCenter, 20);
            if(call_makeVisible)
                m_revMap[t]->makeDockVisible(); // manualDock(parentDockWidget(),KDockWidget::DockCenter,20);
            m_tabSwitching = false;
            emit activated(this);
            return;
        }
        m_ws->raiseWidget(t);
        if(m_ws->widget(t))
        {
            KDockWidget *tmpDw = static_cast< KDockWidget * >(m_ws->widget(t)->qt_cast("KDockWidget"));
            if(tmpDw)
            {
                if(tmpDw->getWidget())
                    tmpDw->getWidget()->setFocus();
            }
            else
                kdDebug(760) << "Something really weird is going on" << endl;
        }
        else
            kdDebug(760) << "DockContainer::tabClicked(int): m_ws->widget(t)==0 " << endl;

        if(oldtab != t)
            m_tb->setTab(oldtab, false);
        m_tabSwitching = true;
        oldtab = t;
        emit activated(this);
    }
    else
    {
        // try save splitter position
        if(parentDockWidget() && parentDockWidget()->parent())
        {
            KDockSplitter *sp = static_cast< KDockSplitter * >(parentDockWidget()->parent()->qt_cast("KDockSplitter"));
            if(sp)
                m_separatorPos = sp->separatorPos();
        }
        m_previousTab = t;
        //    oldtab=-1;
        if(m_block)
            return;
        emit deactivated(this);
        m_block = true;
        if(m_ws->widget(t))
        {
            //    ((KDockWidget*)m_ws->widget(t))->undock();
        }
        m_block = false;
        m_ws->hide();


        kdDebug(760) << "Fixed Width:" << m_tb->width() << endl;
        if(m_vertical)
            parentDockWidget()->setForcedFixedWidth(m_tb->width()); // strange why it worked before at all
        else
            parentDockWidget()->setForcedFixedHeight(m_tb->height()); // strange why it worked before at all
    }
    m_tabSwitching = false;
}