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

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

Reimplemented from its base class. Additionally it catches

  • the client's mousebutton press events and raises and activates the childframe then
  • the client's resize event and resizes its childframe widget (this) as well

Definition at line 951 of file qextmdichildfrm.cpp.

References QextMdiChildView::activate(), captionHeight(), closePressed(), QextMdiChildFrmCaption::heightHint(), showSystemMenu(), and unsetResizeCursor().

{
   switch (e->type()) {
   case QEvent::Enter:
      {
         // check if the receiver is really a child of this frame
         bool bIsChild = false;
         QObject*    pObj = obj;
         while ( (pObj != 0L) && !bIsChild) {
            bIsChild = (pObj == this);
            pObj = pObj->parent();
         }
         // unset the resize cursor if the cursor moved from the frame into a inner widget
         if (bIsChild) {
            unsetResizeCursor();
         }
      }
      break;
   case QEvent::MouseButtonPress: 
      {
         if ( (QWidget*)obj != m_pClient ) {
            bool bIsSecondClick = FALSE;
            if (m_timeMeasure.elapsed() <= QApplication::doubleClickInterval()) {
               bIsSecondClick = TRUE;  // of a possible double click
            }
            if ( !(((obj == m_pWinIcon) || (obj == m_pUnixIcon)) && bIsSecondClick) ) {
               // in case we didn't click on the icon button
               QFocusEvent* pFE = new QFocusEvent(QFocusEvent::FocusIn);
               QApplication::sendEvent(qApp->mainWidget(), pFE);
               if (m_pClient) {//TEST && !((QWidget*)obj)->hasFocus())
                  m_pClient->activate();
                   }
               QWidget* w = (QWidget*) obj;
               if( (w->parent() != m_pCaption) && (w != m_pCaption)) {
                  if ((w->focusPolicy() == QWidget::ClickFocus) || (w->focusPolicy() == QWidget::StrongFocus)) {
                     w->setFocus();
                  }
               }
            }
            if ((obj == m_pWinIcon) || (obj == m_pUnixIcon)) {
               // in case we clicked on the icon button
               if (m_timeMeasure.elapsed() > QApplication::doubleClickInterval()) {
                  showSystemMenu();
                  m_timeMeasure.start();
               } 
               else {
                  closePressed();   // double click on icon button closes the view
               }
               return TRUE;
            }
         }
      }
      break;
   case QEvent::Resize: 
      {
         if ( ( (QWidget*)obj == m_pClient ) && (m_state == Normal) ) {
            QResizeEvent* re = (QResizeEvent*)e;
            int captionHeight = m_pCaption->heightHint();
            QSize newChildFrmSize( re->size().width() + QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER,
               re->size().height() + captionHeight + QEXTMDI_MDI_CHILDFRM_SEPARATOR + QEXTMDI_MDI_CHILDFRM_DOUBLE_BORDER );
            if( newChildFrmSize != size())
               resize( newChildFrmSize );
         }
      }
      break;
   case 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) /*&& (pLostChild->inherits("QWidget"))*/ ) {
            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);
            }
            delete list;                        // delete the list, not the objects
         }
      }
      break;
   case QEvent::ChildInserted: 
      {
         // if we got a new child we install ourself as event filter for the new 
         // child and its children (as we did when we got our client). 
         // XXX see linkChildren() and focus policy stuff
         QObject* pNewChild = ((QChildEvent*)e)->child();
         if ( (pNewChild != 0L) && (pNewChild->inherits("QWidget")) ) {
            QWidget* pNewWidget = (QWidget*)pNewChild;
            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;
               if (!(widg->inherits("QPopupMenu"))) {
                  widg->installEventFilter(this);
               }
            }
            delete list;                        // delete the list, not the objects
         }
      }
      break;
       default:
                  break;
   }
   return QWidget::eventFilter( obj, e);  // standard event processing
}


Generated by  Doxygen 1.6.0   Back to index