Logo Search packages:      
Sourcecode: kbear version File versions  Download package

bool QextMdiChildView::eventFilter ( QObject *  obj,
QEvent *  e 
) [protected, virtual]

It only catches QEvent::KeyPress events there. If a Qt::Key_Tab is pressed, the internal MDI focus handling is called. That means if the last focusable child widget of this is called, it will jump to the first focusable child widget of this. See QextMdiChildView::setFirstFocusableChildWidget and QextMdiChildView::lastFirstFocusableChildWidget

Definition at line 510 of file qextmdichildview.cpp.

References activate(), isAttached(), m_firstFocusableChildWidget, m_focusedChildWidget, and m_lastFocusableChildWidget.

{
   if(e->type() == QEvent::KeyPress && isAttached()) {
      QKeyEvent* ke = (QKeyEvent*) e;
      if(ke->key() == Qt::Key_Tab) {
         //qDebug("ChildView %i::eventFilter - TAB from %s (%s)", this, obj->name(), obj->className());
         QWidget* w = (QWidget*) obj;
         if((w->focusPolicy() == QWidget::StrongFocus) || 
            (w->focusPolicy() == QWidget::TabFocus   ) || 
            (w->focusPolicy() == QWidget::WheelFocus ))
         {
            //qDebug("  accept TAB as setFocus change");
            if(m_lastFocusableChildWidget != 0) {
               if(w == m_lastFocusableChildWidget) {
                  if(w != m_firstFocusableChildWidget) {
                     //qDebug("  TAB: setFocus to first");
                     m_firstFocusableChildWidget->setFocus();
                     //qDebug("  TAB: focus is set to first");
                  }
               }
            }
         }
      }
   }
   else if(e->type() == QEvent::FocusIn ) {
      if(obj->isWidgetType()) {
         QObjectList *list = queryList( "QWidget" );
         if(list->find(obj) != -1) {
            m_focusedChildWidget = (QWidget*)obj;
         }
         delete list;   // delete the list, not the objects
      }
      if (!isAttached()) {   // is toplevel, for attached views activation is done by main frame event filter
         static bool m_bActivationIsPending = FALSE;
         if(!m_bActivationIsPending) {
            m_bActivationIsPending = TRUE;
            activate(); // sets the focus
            m_bActivationIsPending = FALSE;
         }
      }
   }
   else if (e->type() == QEvent::ChildRemoved) {
      // if we lost a child we uninstall ourself as event filter for the lost
      // child and its children
      QObject* pLostChild = ((QChildEvent*)e)->child();
      if (pLostChild != 0L) {
         QObjectList *list = pLostChild->queryList();
         list->insert(0, pLostChild);        // add the lost child to the list too, just to save code
         QObjectListIt it( *list );          // iterate over all lost child widgets
         QObject * obj;
         while ( (obj=it.current()) != 0 ) { // for each found object...
            QWidget* widg = (QWidget*)obj;
            ++it;
            widg->removeEventFilter(this);
            if((widg->focusPolicy() == QWidget::StrongFocus) ||
               (widg->focusPolicy() == QWidget::TabFocus   ) ||
               (widg->focusPolicy() == QWidget::WheelFocus ))
            {
               if(m_firstFocusableChildWidget == widg) {
                  m_firstFocusableChildWidget = 0L;   // reset first widget
               }
               if(m_lastFocusableChildWidget == widg) {
                  m_lastFocusableChildWidget = 0L;    // reset last widget
               }
            }
         }
         delete list;                        // delete the list, not the objects
      }
   }
   else if (e->type() == QEvent::ChildInserted) {
      // if we got a new child and we are attached to the MDI system we
      // install ourself as event filter for the new child and its children
      // (as we did when we were added to the MDI system).
      QObject* pNewChild = ((QChildEvent*)e)->child();
      if ((pNewChild != 0L) && (pNewChild->isWidgetType()))
      {
         QWidget* pNewWidget = (QWidget*)pNewChild;
#if QT_VERSION < 300
         if (pNewWidget->testWFlags(WType_Modal))
#else
         if (pNewWidget->testWFlags(Qt::WType_Dialog | Qt::WShowModal))
#endif
             return FALSE;
         QObjectList *list = pNewWidget->queryList( "QWidget" );
         list->insert(0, pNewChild);         // add the new child to the list too, just to save code
         QObjectListIt it( *list );          // iterate over all new child widgets
         QObject * obj;
         while ( (obj=it.current()) != 0 ) { // for each found object...
            QWidget* widg = (QWidget*)obj;
            ++it;
            widg->installEventFilter(this);
            connect(widg, SIGNAL(destroyed()), this, SLOT(slot_childDestroyed()));
            if((widg->focusPolicy() == QWidget::StrongFocus) ||
               (widg->focusPolicy() == QWidget::TabFocus   ) ||
               (widg->focusPolicy() == QWidget::WheelFocus ))
            {
               if(m_firstFocusableChildWidget == 0) {
                  m_firstFocusableChildWidget = widg;  // first widge
               }
               m_lastFocusableChildWidget = widg; // last widget
               //qDebug("*** %s (%s)",widg->name(),widg->className());
            }
         }
         delete list;                        // delete the list, not the objects
      }
   }
   return FALSE;                           // standard event processing
}


Generated by  Doxygen 1.6.0   Back to index