コード例 #1
0
void KMdiDockContainer::init()
{
	bool overlap = isOverlapMode();
	kdDebug( 760 ) << k_funcinfo << endl;
	if ( !m_horizontal )
	{
		kdDebug( 760 ) << k_funcinfo << "Horizontal tabbar. Setting forced fixed width." << endl;
		parentDockWidget()->setForcedFixedWidth( m_tb->width() );
		activateOverlapMode( m_tb->width() );
	}
	else
	{
		kdDebug( 760 ) << k_funcinfo << "Vertical tabbar. Setting forced fixed height." << endl;
		parentDockWidget()->setForcedFixedHeight( m_tb->height() );
		activateOverlapMode( m_tb->height() );
	}

	if (!overlap) deactivateOverlapMode();

	// try to restore splitter size
	if ( parentDockWidget() && parentDockWidget()->parent() )
	{
		KDockSplitter * sp = ::tqqt_cast<KDockSplitter*>( parentDockWidget()->parent() );
		if ( sp )
			sp->setSeparatorPosX( m_separatorPos );
	}
}
コード例 #2
0
void KMdiDockContainer::changeOverlapMode()
{
	const KDockButton_Private * btn = tqt_dynamic_cast<const KDockButton_Private*>( sender() );

	if ( !btn )
		return ;

	if ( !btn->isOn() )
	{
		kdDebug( 760 ) << k_funcinfo << "Activating overlap mode" << endl;
		if ( !m_horizontal )
			activateOverlapMode( m_tb->width() );
		else
			activateOverlapMode( m_tb->height() );

	}
	else
	{
		kdDebug( 760 ) << k_funcinfo << "Deactivating overlap mode" << endl;
		deactivateOverlapMode();
	}

	TQMap<KDockWidget*, KDockButton_Private*>::iterator it;
	for ( it = m_overlapButtons.begin(); it != m_overlapButtons.end(); ++it )
		it.data()->setOn( !isOverlapMode() );
}
コード例 #3
0
void DockContainer::changeOverlapMode()
{
    const KDockButton_Private *btn = dynamic_cast< const KDockButton_Private * >(sender());

    kdDebug(760) << "DockContainer::changeOverlapMode: button==" << btn << endl;

    if(!btn)
        return;

    if(!btn->isOn())
    {
        kdDebug(760) << "DockContainer::changeOverlapMode: activateOverlapMode" << endl;
        if(m_vertical)
        {
            activateOverlapMode(m_tb->width());
        }
        else
        {
            activateOverlapMode(m_tb->height());
        }
    }
    else
    {
        kdDebug(760) << "DockContainer::changeOverlapMode: deactivateOverlapMode" << endl;
        deactivateOverlapMode();
    }

    for(QMap< KDockWidget *, KDockButton_Private * >::iterator it = m_overlapButtons.begin(); it != m_overlapButtons.end(); ++it)
        it.data()->setOn(!isOverlapMode());
}
コード例 #4
0
void KMdiDockContainer::save( KConfig* cfg, const QString& group_or_prefix )
{
	QString grp = cfg->group();
	cfg->deleteGroup( group_or_prefix + QString( "::%1" ).arg( parent() ->name() ) );
	cfg->setGroup( group_or_prefix + QString( "::%1" ).arg( parent() ->name() ) );

	if ( isOverlapMode() )
		cfg->writeEntry( "overlapMode", "true" );
	else
		cfg->writeEntry( "overlapMode", "false" );

	// try to save the splitter position
	if ( parentDockWidget() && parentDockWidget() ->parent() )
	{
		KDockSplitter * sp = static_cast<KDockSplitter*>( parentDockWidget() ->
		                     parent() ->qt_cast( "KDockSplitter" ) );
		if ( sp )
			cfg->writeEntry( "separatorPosition", m_separatorPos );
	}

	QPtrList<KMultiTabBarTab>* tl = m_tb->tabs();
	QPtrListIterator<KMultiTabBarTab> it( *tl );
	QStringList::Iterator it2 = itemNames.begin();
	int i = 0;
	for ( ;it.current() != 0;++it, ++it2 )
	{
		//    cfg->writeEntry(QString("widget%1").arg(i),m_ws->widget(it.current()->id())->name());
		cfg->writeEntry( QString( "widget%1" ).arg( i ), ( *it2 ) );
		QString s = tabCaptions[ *it2 ];
		if ( !s.isEmpty() )
		{
			cfg->writeEntry( QString( "widget%1-tabCaption" ).arg( i ), s );
		}
		s = tabTooltips[ *it2 ];
		if ( !s.isEmpty() )
		{
			cfg->writeEntry( QString( "widget%1-tabTooltip" ).arg( i ), s );
		}
		//    kdDebug(760)<<"****************************************Saving: "<<m_ws->widget(it.current()->id())->name()<<endl;
		if ( m_tb->isTabRaised( it.current() ->id() ) )
			cfg->writeEntry( m_ws->widget( it.current() ->id() ) ->name(), true );
		++i;
	}
	cfg->sync();
	cfg->setGroup( grp );

}
コード例 #5
0
void DockContainer::collapseOverlapped()
{
    if(m_tabSwitching)
        return;
    if(isOverlapMode())
    {
        QPtrList< KMultiTabBarTab > *tl = m_tb->tabs();
        QPtrListIterator< KMultiTabBarTab > it(*tl);
        for(; it.current(); ++it)
        {
            if(it.current()->isOn())
            {
                kdDebug(760) << "Lowering TAB" << endl;
                it.current()->setState(false);
                tabClicked(it.current()->id());
            }
        }
    }
}
コード例 #6
0
void KMdiDockContainer::save( TQDomElement& dockEl )
{
	TQDomDocument doc = dockEl.ownerDocument();
	TQDomElement el;
	el = doc.createElement( "name" );
	el.appendChild( doc.createTextNode( TQString( "%1" ).arg( parent() ->name() ) ) );
	dockEl.appendChild( el );
	el = doc.createElement( "overlapMode" );
	el.appendChild( doc.createTextNode( isOverlapMode() ? "true" : "false" ) );
	dockEl.appendChild( el );
	TQPtrList<KMultiTabBarTab>* tl = m_tb->tabs();
	TQPtrListIterator<KMultiTabBarTab> it( *tl );
	TQStringList::Iterator it2 = itemNames.begin();
	int i = 0;
	for ( ;it.current() != 0;++it, ++it2 )
	{
		el = doc.createElement( "child" );
		el.setAttribute( "pos", TQString( "%1" ).arg( i ) );
		TQString s = tabCaptions[ *it2 ];
		if ( !s.isEmpty() )
		{
			el.setAttribute( "tabCaption", s );
		}
		s = tabTooltips[ *it2 ];
		if ( !s.isEmpty() )
		{
			el.setAttribute( "tabTooltip", s );
		}
		el.appendChild( doc.createTextNode( *it2 ) );
		dockEl.appendChild( el );
		if ( m_tb->isTabRaised( it.current() ->id() ) )
		{
			TQDomElement el2 = doc.createElement( "raised" );
			el2.appendChild( doc.createTextNode( m_ws->widget( it.current() ->id() ) ->name() ) );
			el.appendChild( el2 );
		}
		++i;
	}


}
コード例 #7
0
void KMdiDockContainer::collapseOverlapped()
{
	//don't collapse if we're switching tabs
	if ( m_tabSwitching )
		return;

	if ( isOverlapMode() )
	{
		TQPtrList<KMultiTabBarTab>* tl = m_tb->tabs();
		TQPtrListIterator<KMultiTabBarTab> it( *tl );
		for ( ;it.current();++it )
		{
			if ( it.current()->isOn() )
			{
				kdDebug( 760 ) << k_funcinfo << "lowering tab with id " << ( *it )->id() << endl;
				it.current()->setState( false );
				tabClicked( ( *it )->id() );
			}
		}
	}
}
コード例 #8
0
void KMdiDockContainer::load( TDEConfig* cfg, const TQString& group_or_prefix )
{
	TQString grp = cfg->group();
	cfg->setGroup( group_or_prefix + TQString( "::%1" ).arg( parent() ->name() ) );

	if ( cfg->readEntry( "overlapMode" ) != "false" )
		activateOverlapMode( m_horizontal?m_tb->height():m_tb->width() );
	else
		deactivateOverlapMode();

	m_separatorPos = cfg->readNumEntry( "separatorPosition", 18000 );

	int i = 0;
	TQString raise;
	while ( true )
	{
		TQString dwn = cfg->readEntry( TQString( "widget%1" ).arg( i ) );
		if ( dwn.isEmpty() )
			break;
		kdDebug( 760 ) << k_funcinfo << "configuring dockwidget :" << dwn << endl;
		KDockWidget *dw = ( ( KDockWidget* ) parent() ) ->dockManager() ->getDockWidgetFromName( dwn );
		if ( dw )
		{
			TQString s = cfg->readEntry( TQString( "widget%1-tabCaption" ).arg( i ) );
			if ( !s.isEmpty() )
			{
				dw->setTabPageLabel( s );
			}
			s = cfg->readEntry( TQString( "widget%1-tabTooltip" ).arg( i ) );
			if ( !s.isEmpty() )
			{
				dw->setToolTipString( s );
			}
			dw->manualDock( ( KDockWidget* ) parent(), KDockWidget::DockCenter );
		}
		if ( cfg->readBoolEntry( dwn, false ) )
			raise = dwn;
		i++;

	}

	TQPtrList<KMultiTabBarTab>* tl = m_tb->tabs();
	TQPtrListIterator<KMultiTabBarTab> it1( *tl );
	m_ws->hide();
	if ( !m_horizontal )
		parentDockWidget() ->setForcedFixedWidth( m_tb->width() );
	else
		parentDockWidget() ->setForcedFixedHeight( m_tb->height() );
	for ( ;it1.current() != 0;++it1 )
	{
		m_tb->setTab( it1.current() ->id(), false );
	}
	kapp->syncX();
	m_delayedRaise = -1;

	for ( TQMap<KDockWidget*, KDockButton_Private*>::iterator it = m_overlapButtons.begin();
	        it != m_overlapButtons.end();++it )
		it.data() ->setOn( !isOverlapMode() );

	if ( !raise.isEmpty() )
	{
		for ( TQMap<KDockWidget*, int>::iterator it = m_map.begin();it != m_map.end();++it )
		{
			if ( it.key() ->name() == raise )
			{
				/*        tabClicked(it.data());
				        m_tb->setTab(it.data(),true);
				        tabClicked(it.data());
				        m_ws->raiseWidget(it.key());
				        kapp->sendPostedEvents();
				        kapp->syncX();*/

				m_delayedRaise = it.data();
				TQTimer::singleShot( 0, this, TQT_SLOT( delayedRaise() ) );
				kdDebug( 760 ) << k_funcinfo << "raising" << it.key() ->name() << endl;
				break;
			}
		}

	}
	if ( m_delayedRaise == -1 )
		TQTimer::singleShot( 0, this, TQT_SLOT( init() ) );
	cfg->setGroup( grp );

}
コード例 #9
0
void KMdiDockContainer::load( TQDomElement& dockEl )
{
	TQString raise;

	for ( TQDomNode n = dockEl.firstChild();!n.isNull();n = n.nextSibling() )
	{
		TQDomElement el = n.toElement();
		if ( el.isNull() )
			continue;
		if ( el.tagName() == "overlapMode" )
		{
			if ( el.attribute( "overlapMode" ) != "false" )
				activateOverlapMode( m_horizontal?m_tb->height():m_tb->width() );
			else
				deactivateOverlapMode();
		}
		else if ( el.tagName() == "child" )
		{
			KDockWidget * dw = ( ( KDockWidget* ) parent() ) ->dockManager() ->getDockWidgetFromName( el.text() );
			if ( dw )
			{
				if ( el.hasAttribute( "tabCaption" ) )
				{
					dw->setTabPageLabel( el.attribute( "tabCaption" ) );
				}
				if ( el.hasAttribute( "tabTooltip" ) )
				{
					dw->setToolTipString( el.attribute( "tabTooltip" ) );
				}
				dw->manualDock( ( KDockWidget* ) parent(), KDockWidget::DockCenter );
			}
		}
	}

	TQPtrList<KMultiTabBarTab>* tl = m_tb->tabs();
	TQPtrListIterator<KMultiTabBarTab> it1( *tl );
	m_ws->hide();
	if ( !m_horizontal )
		parentDockWidget()->setForcedFixedWidth( m_tb->width() );
	else
		parentDockWidget()->setForcedFixedHeight( m_tb->height() );

	for ( ;it1.current() != 0;++it1 )
		m_tb->setTab( it1.current() ->id(), false );

	kapp->syncX();
	m_delayedRaise = -1;

	for ( TQMap<KDockWidget*, KDockButton_Private*>::iterator it = m_overlapButtons.begin();
	        it != m_overlapButtons.end();++it )
		it.data() ->setOn( !isOverlapMode() );

	if ( !raise.isEmpty() )
	{
		for ( TQMap<KDockWidget*, int>::iterator it = m_map.begin();it != m_map.end();++it )
		{
			if ( it.key() ->name() == raise )
			{
				m_delayedRaise = it.data();
				TQTimer::singleShot( 0, this, TQT_SLOT( delayedRaise() ) );
				kdDebug( 760 ) << k_funcinfo << "raising " << it.key()->name() << endl;
				break;
			}
		}

	}
	if ( m_delayedRaise == -1 )
		TQTimer::singleShot( 0, this, TQT_SLOT( init() ) );
}
コード例 #10
0
void KMdiDockContainer::insertWidget ( KDockWidget *dwdg, TQPixmap pixmap, const TQString &text, int & )
{
	kdDebug( 760 ) << k_funcinfo << "Adding a dockwidget to the dock container" << endl;
	KDockWidget* w = dwdg;
	int tab;
	bool alreadyThere = m_map.contains( w );

	if ( alreadyThere )
	{
		tab = m_map[ w ];
		if ( m_ws->addWidget( w, tab ) != tab )
			kdDebug( 760 ) << "ERROR COULDN'T READD WIDGET" << endl;

		kdDebug( 760 ) << k_funcinfo << "Readded widget " << dwdg << endl;
	}
	else
	{
		tab = m_ws->addWidget( w );
		m_map.insert( w, tab );
		m_revMap.insert( tab, w );

		if ( ( ( KDockWidget* ) parentWidget() ) ->mayBeShow() )
			( ( KDockWidget* ) parentWidget() ) ->dockBack();

		if ( ::tqqt_cast<KDockWidgetHeader*>(w->getHeader()) )
		{
			kdDebug( 760 ) << k_funcinfo << "The dockwidget we're adding has a header" << endl;
			kdDebug( 760 ) << k_funcinfo << "Adding our overlap mode button to it" << endl;

			KDockWidgetHeader *hdr = ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() );
			KDockButton_Private *btn = new KDockButton_Private( hdr, "OverlapButton" );

			TQToolTip::add( btn, i18n( "Switch between overlap and side by side mode", "Overlap" ) );

			btn->setToggleButton( true );
			btn->setPixmap( const_cast< const char** >( tdemdi_not_close_xpm ) );
			hdr->addButton( btn );
			m_overlapButtons.insert( w, btn );
			btn->setOn( !isOverlapMode() );

			connect( btn, TQT_SIGNAL( clicked() ), this, TQT_SLOT( changeOverlapMode() ) );
		}

		m_tb->appendTab( pixmap.isNull() ? SmallIcon( "misc" ) : pixmap, tab, w->tabPageLabel() );
		m_tb->tab( tab )->installEventFilter( this );
		kdDebug( 760 ) << k_funcinfo << "Added tab with label " << w->tabPageLabel() <<
			" to the tabbar" << endl;

		connect( m_tb->tab( tab ), TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( tabClicked( int ) ) );

		mTabCnt++;
		m_inserted = tab;
		int dummy = 0;
		KDockContainer::insertWidget( w, pixmap, text, dummy );
		itemNames.append( w->name() );
		tabCaptions.insert( w->name(), w->tabPageLabel() );
		tabTooltips.insert( w->name(), w->toolTipString() );
	}

	//FB  m_ws->raiseWidget(tab);
}
コード例 #11
0
void DockContainer::insertWidget(KDockWidget *dwdg, QPixmap pixmap, const QString &text, int &)
{
    KDockWidget *w = (KDockWidget *)dwdg;
    int tab;
    bool alreadyThere = m_map.contains(w);

    if(alreadyThere)
    {
        tab = m_map[w];
        if(m_ws->addWidget(w, tab) != tab)
            kdDebug(760) << "ERROR COULDN'T READD WIDGET************" << endl;
        kdDebug(760) << "READDED WIDGET***********************************" << endl;
        /*JOWENN    m_tb->setTab(tab,true);
            tabClicked(tab);*/
    }
    else
    {
        tab = m_ws->addWidget(w);
        m_map.insert(w, tab);
        m_revMap.insert(tab, w);


        if(((KDockWidget *)parentWidget())->mayBeShow())
            ((KDockWidget *)parentWidget())->dockBack();

        if(w->getHeader()->qt_cast("KDockWidgetHeader"))
        {
            kdDebug(760) << "*** KDockWidgetHeader has been found" << endl;

            KDockWidgetHeader *hdr = static_cast< KDockWidgetHeader * >(w->getHeader()->qt_cast("KDockWidgetHeader"));

            KDockButton_Private *btn = new KDockButton_Private(hdr, "OverlapButton");

            QToolTip::add(btn, i18n("Switch between overlap and side by side mode", "Overlap"));

            btn->setToggleButton(true);
            btn->setPixmap(const_cast< const char ** >(kmdi_not_close_xpm));
            hdr->addButton(btn);
            m_overlapButtons.insert(w, btn);
            btn->setOn(!isOverlapMode());

            connect(btn, SIGNAL(clicked()), this, SLOT(changeOverlapMode()));
        }

        m_tb->appendTab(pixmap.isNull() ? SmallIcon("misc") : pixmap, tab, w->tabPageLabel());
        m_tb->tab(tab)->installEventFilter(this);
        kdDebug(760) << "NAMENAMENAMENAME:===========================:" << w->tabPageLabel() << endl;

        // FB    m_tb->setTab(tab,true);

        connect(m_tb->tab(tab), SIGNAL(clicked(int)), this, SLOT(tabClicked(int)));

        kdDebug(760) << "DockContainer::insertWidget()" << endl;

        // FB    m_tb->setTab(oldtab,false);

        mTabCnt++;
        m_inserted = tab;
        int dummy = 0;
        // FB    tabClicked(tab);
        KDockContainer::insertWidget(w, pixmap, text, dummy);
        itemNames.append(w->name());
        tabCaptions.insert(w->name(), w->tabPageLabel());
        tabTooltips.insert(w->name(), w->toolTipString());
    }

    // FB  m_ws->raiseWidget(tab);
}