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;

}
Beispiel #2
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;
}