コード例 #1
0
void DockContainer::removeWidget(KDockWidget *dwdg)
{
    KDockWidget *w = (KDockWidget *)dwdg;
    if(!m_map.contains(w))
        return;
    int id = m_map[w];
    if(m_tb->isTabRaised(id))
    {
        // why do we hide the tab if we're just going
        // to remove it? - mattr 2004-10-26
        m_tb->setTab(id, false);
        m_tabSwitching = false;
        tabClicked(id);
    }
    m_tb->removeTab(id);
    m_ws->removeWidget(w);
    m_map.remove(w);
    m_revMap.remove(id);
    if(m_overlapButtons.contains(w))
    {
        (static_cast< KDockWidgetHeader * >(w->getHeader()->qt_cast("KDockWidgetHeader")))->removeButton(m_overlapButtons[w]);
        m_overlapButtons.remove(w);
    }
    KDockContainer::removeWidget(w);
    itemNames.remove(w->name());
    tabCaptions.remove(w->name());
    tabTooltips.remove(w->name());
    if(!itemNames.count())
        ((KDockWidget *)parentWidget())->undock();
}
コード例 #2
0
void KMdiDockContainer::removeWidget( KDockWidget* dwdg )
{
	KDockWidget * w = dwdg;
	if ( !m_map.contains( w ) )
		return; //we don't have this widget in our container

	kdDebug( 760 ) << k_funcinfo << endl;
	//lower the tab. ( TODO: needed? )
	int id = m_map[ w ];
	if ( m_tb->isTabRaised( id ) )
	{
		m_tb->setTab( id, false );
		tabClicked( id );
	}

	m_tb->removeTab( id );
	m_ws->removeWidget( w );
	m_map.remove( w );
	m_revMap.remove( id );
	if ( m_overlapButtons.contains( w ) )
	{
		( ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() ) )->removeButton( m_overlapButtons[ w ] );
		m_overlapButtons.remove( w );
	}
	KDockContainer::removeWidget( w );
	itemNames.remove( w->name() );
	tabCaptions.remove( w->name() );
	tabTooltips.remove( w->name() );
	hideIfNeeded();
}
コード例 #3
0
KMdiDockContainer::~KMdiDockContainer()
{
	TQMap<KDockWidget*, int>::iterator it;
	while ( m_map.count() )
	{
		it = m_map.begin();
		KDockWidget *w = it.key();
		if ( m_overlapButtons.contains( w ) )
		{
			( ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() ) )->removeButton( m_overlapButtons[w] );
			m_overlapButtons.remove( w );
		}
		m_map.remove( w );
		w->undock();
	}
	deactivated( this );
}
コード例 #4
0
bool KMdiDockContainer::eventFilter( TQObject *obj, TQEvent *event )
{
	switch ( event->type() )
	{
	case TQEvent::MouseButtonPress:
	{
		KMultiTabBarTab* kmtbTab = tqt_dynamic_cast<KMultiTabBarTab*>( obj );
		if ( !kmtbTab )
		{
			kdDebug(760) << k_funcinfo << "Got a mouse button press but we have no tab" << endl;
			break;
		}

		KDockWidget* w = m_revMap[ kmtbTab->id() ];
		if ( !w )
		{
			kdDebug(760) << k_funcinfo << "Got a mouse button press but we have no widget" << endl;
			break;
		}

		if ( !w->getHeader() )
		{
			kdDebug(760) << k_funcinfo << "Got a mouse button press but we have no header" << endl;
			break;
		}

		KDockWidgetHeader *hdr = ::tqqt_cast<KDockWidgetHeader*>( w->getHeader() );
		if ( !hdr )
		{
			kdDebug(760) << "Wrong header type in KMdiDockContainer::eventFilter" << endl;
			break;
		}

		m_dockManager = w->dockManager();
		m_dragPanel = TQT_TQOBJECT(hdr->dragPanel());

		if ( m_dragPanel )
			m_movingState = WaitingForMoveStart;

		delete m_startEvent;
		m_startEvent = new TQMouseEvent( * ( ( TQMouseEvent* ) event ) );
	}
	break;
	case TQEvent::MouseButtonRelease:
		if ( m_movingState == Moving )
		{
			m_movingState = NotMoving;
			TQApplication::postEvent( m_dragPanel, new TQMouseEvent( * ( ( TQMouseEvent* ) event ) ) );
			delete m_startEvent;
			m_startEvent = 0;
		}
	case TQEvent::MouseMove:
		if ( m_movingState == WaitingForMoveStart )
		{
			TQPoint p( ( ( TQMouseEvent* ) event )->pos() - m_startEvent->pos() );
			if ( p.manhattanLength() > TDEGlobalSettings::dndEventDelay() )
			{
				m_dockManager->eventFilter( m_dragPanel, TQT_TQEVENT(m_startEvent) );
				m_dockManager->eventFilter( m_dragPanel, event );
				m_movingState = Moving;
			}
		}
		else if ( m_movingState == Moving )
			m_dockManager->eventFilter( m_dragPanel, event );

		break;
	default:
		break;

	}
	return false;

}
コード例 #5
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);
}
コード例 #6
0
bool DockContainer::eventFilter(QObject *obj, QEvent *event)
{
    if(obj == m_tb)
    {
        if((event->type() == QEvent::Resize) && (m_ws->isHidden()))
        {
            QSize size = ((QResizeEvent *)event)->size();
            if(m_vertical)
                parentDockWidget()->setForcedFixedWidth(size.width());
            else
                parentDockWidget()->setForcedFixedHeight(size.height());
        }
    }
    else
        switch(event->type())
        {
            case QEvent::MouseButtonPress:
            {
                KDockWidget *w = m_revMap[dynamic_cast< KMultiTabBarTab * >(obj)->id()];
                if(!w)
                {
                    kdDebug() << "NoWidget" << endl;
                    break;
                }
                if(!w->getHeader())
                {
                    kdDebug() << "NO HEADER" << endl;
                    break;
                }
                KDockWidgetHeader *hdr = static_cast< KDockWidgetHeader * >(w->getHeader()->qt_cast("KDockWidgetHeader"));
                if(!hdr)
                {
                    kdDebug() << "Wrong header type in DockContainer::eventFilter" << endl;
                    break;
                }
                m_dockManager = w->dockManager();
                m_dragPanel = hdr->dragPanel();
                if(m_dragPanel)
                    m_movingState = WaitingForMoveStart;
                delete m_startEvent;
                m_startEvent = new QMouseEvent(*((QMouseEvent *)event));
            }
            break;
            case QEvent::MouseButtonRelease:
                if(m_movingState == Moving)
                {
                    m_movingState = NotMoving;
                    QApplication::postEvent(m_dragPanel, new QMouseEvent(*((QMouseEvent *)event)));
                    delete m_startEvent;
                    m_startEvent = 0;
                }
                break;
            case QEvent::MouseMove:
                if(m_movingState == WaitingForMoveStart)
                {
                    QPoint p(((QMouseEvent *)event)->pos() - m_startEvent->pos());
                    if(p.manhattanLength() > KGlobalSettings::dndEventDelay())
                    {
                        m_dockManager->eventFilter(m_dragPanel, m_startEvent);
                        m_dockManager->eventFilter(m_dragPanel, event);
                        m_movingState = Moving;
                    }
                }
                else if(m_movingState == Moving)
                {
                    m_dockManager->eventFilter(m_dragPanel, event);
                }
                break;
            default:
                break;
        }
    return false;
}
コード例 #7
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);
}