kmdi Library: kmdichildview.cpp Source File (kmdi Library)

| # kmdi Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmdichildview.cpp

    00001 //----------------------------------------------------------------------------
    00002 //    filename             : kmdichildview.cpp
    00003 //----------------------------------------------------------------------------
    00004 //    Project              : KDE MDI extension
    00005 //
    00006 //    begin                : 07/1999       by Szymon Stefanek as part of kvirc
    00007 //                                         (an IRC application)
    00008 //    changes              : 09/1999       by Falk Brettschneider to create a
    00009 //                           -06/2000      stand-alone Qt extension set of
    00010 //                                         classes and a Qt-based library
    00011 //                           2000-2003     maintained by the KDevelop project
    00012 //    patches              : 02/2000       by Massimo Morin (mmorin@schedsys.com)
    00013 //                           */2000        by Lars Beikirch (Lars.Beikirch@gmx.net)
    00014 //                           02/2001       by Eva Brucherseifer (eva@rt.e-technik.tu-darmstadt.de)
    00015 //                           01/2003       by Jens Zurheide (jens.zurheide@gmx.de)
    00016 //
    00017 //    copyright            : (C) 1999-2003 by Szymon Stefanek (stefanek@tin.it)
    00018 //                                         and
    00019 //                                         Falk Brettschneider
    00020 //    email                :  falkbr@kdevelop.org (Falk Brettschneider)
    00021 //----------------------------------------------------------------------------
    00022 //
    00023 //----------------------------------------------------------------------------
    00024 //
    00025 //    This program is free software; you can redistribute it and/or modify
    00026 //    it under the terms of the GNU Library General Public License as
    00027 //    published by the Free Software Foundation; either version 2 of the
    00028 //    License, or (at your option) any later version.
    00029 //
    00030 //----------------------------------------------------------------------------
    00031
    00032 #include "kmdichildview.h"
    00033 #include "kmdichildview.moc"
    00034
    00035 #include <qdatetime.h>
    00036 #include <qobjectlist.h>
    00037
    00038 #include "kmdimainfrm.h"
    00039 #include "kmdichildfrm.h"
    00040 #include "kmdidefines.h"
    00041 #include <kdebug.h>
    00042 #include <klocale.h>
    00043 #include <qiconset.h>
    00044
    00045 //============ KMdiChildView ============//
    00046
    00047 KMdiChildView::KMdiChildView( const QString& caption, QWidget* parentWidget, const char* name, WFlags f )
    00048     : QWidget( parentWidget, name, f )
    00049     , m_focusedChildWidget( 0L )
    00050     , m_firstFocusableChildWidget( 0L )
    00051     , m_lastFocusableChildWidget( 0L )
    00052     , m_stateChanged( true )
    00053     , m_bToolView( false )
    00054     , m_bInterruptActivation( false )
    00055     , m_bMainframesActivateViewIsPending( false )
    00056     , m_bFocusInEventIsPending( false )
    00057     , m_trackChanges( 0 )
    00058 {
    00059     setGeometry( 0, 0, 0, 0 );  // reset
    00060     if ( caption != 0L )
    00061         m_szCaption = caption;
    00062     else
    00063         m_szCaption = i18n( "Unnamed" );
    00064
    00065     m_sTabCaption = m_szCaption;
    00066     setFocusPolicy( ClickFocus );
    00067     installEventFilter( this );
    00068
    00069     // store the current time
    00070     updateTimeStamp();
    00071 }
    00072
    00073
    00074 //============ KMdiChildView ============//
    00075
    00076 KMdiChildView::KMdiChildView( QWidget* parentWidget, const char* name, WFlags f )
    00077     : QWidget( parentWidget, name, f )
    00078     , m_focusedChildWidget( 0L )
    00079     , m_firstFocusableChildWidget( 0L )
    00080     , m_lastFocusableChildWidget( 0L )
    00081     , m_stateChanged( true )
    00082     , m_bToolView( false )
    00083     , m_bInterruptActivation( false )
    00084     , m_bMainframesActivateViewIsPending( false )
    00085     , m_bFocusInEventIsPending( false )
    00086     , m_trackChanges( 0 )
    00087 {
    00088     setGeometry( 0, 0, 0, 0 );  // reset
    00089     m_szCaption = i18n( "Unnamed" );
    00090     m_sTabCaption = m_szCaption;
    00091     setFocusPolicy( ClickFocus );
    00092     installEventFilter( this );
    00093
    00094     // store the current time
    00095     updateTimeStamp();
    00096 }
    00097
    00098 //============ ~KMdiChildView ============//
    00099
    00100 KMdiChildView::~KMdiChildView()
    00101 {
    00102     kdDebug( 760 ) << k_funcinfo << endl;
    00103 }
    00104
    00105 void KMdiChildView::trackIconAndCaptionChanges( QWidget *view )
    00106 {
    00107     m_trackChanges = view;
    00108 }
    00109
    00110
    00111 //============== internal geometry ==============//
    00112
    00113 QRect KMdiChildView::internalGeometry() const
    00114 {
    00115     if ( mdiParent() )
    00116     { // is attached
    00117         // get the client area coordinates inside the MDI child frame
    00118         QRect posInFrame = geometry();
    00119         // map these values to the parent of the MDI child frame
    00120         // (this usually is the MDI child area) and return
    00121         QPoint ptTopLeft = mdiParent() ->mapToParent( posInFrame.topLeft() );
    00122         QSize sz = size();
    00123         return QRect( ptTopLeft, sz );
    00124     }
    00125     else
    00126     {
    00127         QRect geo = geometry();
    00128         QRect frameGeo = externalGeometry();
    00129         return QRect( frameGeo.x(), frameGeo.y(), geo.width(), geo.height() );
    00130         //      return geometry();
    00131     }
    00132 }
    00133
    00134 //============== set internal geometry ==============//
    00135
    00136 void KMdiChildView::setInternalGeometry( const QRect& newGeometry )
    00137 {
    00138     if ( mdiParent() )
    00139     { // is attached
    00140         // retrieve the frame size
    00141         QRect geo = internalGeometry();
    00142         QRect frameGeo = externalGeometry();
    00143         int nFrameSizeTop = geo.y() - frameGeo.y();
    00144         int nFrameSizeLeft = geo.x() - frameGeo.x();
    00145
    00146         // create the new geometry that is accepted by the QWidget::setGeometry() method
    00147         QRect newGeoQt;
    00148         newGeoQt.setX( newGeometry.x() - nFrameSizeLeft );
    00149         newGeoQt.setY( newGeometry.y() - nFrameSizeTop );
    00150
    00151         newGeoQt.setWidth( newGeometry.width() + nFrameSizeLeft + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
    00152         newGeoQt.setHeight( newGeometry.height() + nFrameSizeTop + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
    00153         //      newGeoQt.setWidth(newGeometry.width()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);
    00154         //      newGeoQt.setHeight(newGeometry.height()+mdiParent()->captionHeight()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);
    00155
    00156         // set the geometry
    00157         mdiParent()->setGeometry( newGeoQt );
    00158     }
    00159     else
    00160     {
    00161         // retrieve the frame size
    00162         QRect geo = internalGeometry();
    00163         QRect frameGeo = externalGeometry();
    00164         int nFrameSizeTop = geo.y() - frameGeo.y();
    00165         int nFrameSizeLeft = geo.x() - frameGeo.x();
    00166
    00167         // create the new geometry that is accepted by the QWidget::setGeometry() method
    00168         QRect newGeoQt;
    00169
    00170         newGeoQt.setX( newGeometry.x() - nFrameSizeLeft );
    00171         newGeoQt.setY( newGeometry.y() - nFrameSizeTop );
    00172
    00173         newGeoQt.setWidth( newGeometry.width() );
    00174         newGeoQt.setHeight( newGeometry.height() );
    00175
    00176         // set the geometry
    00177         setGeometry( newGeoQt );
    00178     }
    00179 }
    00180
    00181 //============== external geometry ==============//
    00182
    00183 QRect KMdiChildView::externalGeometry() const
    00184 {
    00185     return mdiParent() ? mdiParent()->frameGeometry() : frameGeometry();
    00186 }
    00187
    00188 //============== set external geometry ==============//
    00189
    00190 void KMdiChildView::setExternalGeometry( const QRect& newGeometry )
    00191 {
    00192     if ( mdiParent() )
    00193     { // is attached
    00194         mdiParent() ->setGeometry( newGeometry );
    00195     }
    00196     else
    00197     {
    00198         // retrieve the frame size
    00199         QRect geo = internalGeometry();
    00200         QRect frameGeo = externalGeometry();
    00201         int nTotalFrameWidth = frameGeo.width() - geo.width();
    00202         int nTotalFrameHeight = frameGeo.height() - geo.height();
    00203         int nFrameSizeTop = geo.y() - frameGeo.y();
    00204         int nFrameSizeLeft = geo.x() - frameGeo.x();
    00205
    00206         // create the new geometry that is accepted by the QWidget::setGeometry() method
    00207         // not attached => the window system makes the frame
    00208         QRect newGeoQt;
    00209         newGeoQt.setX( newGeometry.x() + nFrameSizeLeft );
    00210         newGeoQt.setY( newGeometry.y() + nFrameSizeTop );
    00211         newGeoQt.setWidth( newGeometry.width() - nTotalFrameWidth );
    00212         newGeoQt.setHeight( newGeometry.height() - nTotalFrameHeight );
    00213
    00214         // set the geometry
    00215         setGeometry( newGeoQt );
    00216     }
    00217 }
    00218
    00219 //============== minimize ==============//
    00220
    00221 void KMdiChildView::minimize( bool bAnimate )
    00222 {
    00223     if ( mdiParent() )
    00224     {
    00225         if ( !isMinimized() )
    00226         {
    00227             mdiParent() ->setState( KMdiChildFrm::Minimized, bAnimate );
    00228         }
    00229     }
    00230     else
    00231         showMinimized();
    00232 }
    00233
    00234 void KMdiChildView::showMinimized()
    00235 {
    00236     emit isMinimizedNow();
    00237     QWidget::showMinimized();
    00238 }
    00239
    00240 //slot:
    00241 void KMdiChildView::minimize()
    00242 {
    00243     minimize( true );
    00244 }
    00245
    00246 //============= maximize ==============//
    00247
    00248 void KMdiChildView::maximize( bool bAnimate )
    00249 {
    00250     if ( mdiParent() )
    00251     {
    00252         if ( !isMaximized() )
    00253         {
    00254             mdiParent() ->setState( KMdiChildFrm::Maximized, bAnimate );
    00255             emit mdiParentNowMaximized( true );
    00256         }
    00257     }
    00258     else
    00259         showMaximized();
    00260 }
    00261
    00262 void KMdiChildView::showMaximized()
    00263 {
    00264     emit isMaximizedNow();
    00265     QWidget::showMaximized();
    00266 }
    00267
    00268 //slot:
    00269 void KMdiChildView::maximize()
    00270 {
    00271     maximize( true );
    00272 }
    00273
    00274 //============== restoreGeometry ================//
    00275
    00276 QRect KMdiChildView::restoreGeometry()
    00277 {
    00278     if ( mdiParent() )
    00279         return mdiParent() ->restoreGeometry();
    00280     else //FIXME not really supported, may be we must use Windows or X11 funtions
    00281         return geometry();
    00282 }
    00283
    00284 //============== setRestoreGeometry ================//
    00285
    00286 void KMdiChildView::setRestoreGeometry( const QRect& newRestGeo )
    00287 {
    00288     if ( mdiParent() )
    00289         mdiParent()->setRestoreGeometry( newRestGeo );
    00290 }
    00291
    00292 //============== attach ================//
    00293
    00294 void KMdiChildView::attach()
    00295 {
    00296     emit attachWindow( this, true );
    00297 }
    00298
    00299 //============== detach =================//
    00300
    00301 void KMdiChildView::detach()
    00302 {
    00303     emit detachWindow( this, true );
    00304 }
    00305
    00306 //=============== isMinimized ? =================//
    00307
    00308 bool KMdiChildView::isMinimized() const
    00309 {
    00310     if ( mdiParent() )
    00311         return ( mdiParent()->state() == KMdiChildFrm::Minimized );
    00312     else
    00313         return QWidget::isMinimized();
    00314 }
    00315
    00316 //============== isMaximized ? ==================//
    00317
    00318 bool KMdiChildView::isMaximized() const
    00319 {
    00320     if ( mdiParent() )
    00321         return ( mdiParent()->state() == KMdiChildFrm::Maximized );
    00322     else
    00323         return QWidget::isMaximized();
    00324 }
    00325
    00326 //============== restore ================//
    00327
    00328 void KMdiChildView::restore()
    00329 {
    00330     if ( mdiParent() )
    00331     {
    00332         if ( isMaximized() )
    00333             emit mdiParentNowMaximized( false );
    00334
    00335         if ( isMinimized() || isMaximized() )
    00336             mdiParent()->setState( KMdiChildFrm::Normal );
    00337     }
    00338     else
    00339         showNormal();
    00340 }
    00341
    00342 void KMdiChildView::showNormal()
    00343 {
    00344     emit isRestoredNow();
    00345     QWidget::showNormal();
    00346 }
    00347
    00348 //=============== youAreAttached ============//
    00349
    00350 void KMdiChildView::youAreAttached( KMdiChildFrm *lpC )
    00351 {
    00352     lpC->setCaption( m_szCaption );
    00353     emit isAttachedNow();
    00354 }
    00355
    00356 //================ youAreDetached =============//
    00357
    00358 void KMdiChildView::youAreDetached()
    00359 {
    00360     setCaption( m_szCaption );
    00361
    00362     setTabCaption( m_sTabCaption );
    00363     if ( myIconPtr() )
    00364         setIcon( *( myIconPtr() ) );
    00365
    00366     setFocusPolicy( QWidget::StrongFocus );
    00367
    00368     emit isDetachedNow();
    00369 }
    00370
    00371 //================ setCaption ================//
    00372 // this set the caption of only the window
    00373 void KMdiChildView::setCaption( const QString& szCaption )
    00374 {
    00375     // this will work only for window
    00376     m_szCaption = szCaption;
    00377     if ( mdiParent() )
    00378         mdiParent() ->setCaption( m_szCaption );
    00379     else //have to call the parent one
    00380         QWidget::setCaption( m_szCaption );
    00381
    00382     emit windowCaptionChanged( m_szCaption );
    00383 }
    00384
    00385 //============== closeEvent ================//
    00386
    00387 void KMdiChildView::closeEvent( QCloseEvent *e )
    00388 {
    00389     e->ignore(); //we ignore the event , and then close later if needed.
    00390     emit childWindowCloseRequest( this );
    00391 }
    00392
    00393 //================ myIconPtr =================//
    00394
    00395 QPixmap* KMdiChildView::myIconPtr()
    00396 {
    00397     return 0;
    00398 }
    00399
    00400 //============= focusInEvent ===============//
    00401
    00402 void KMdiChildView::focusInEvent( QFocusEvent *e )
    00403 {
    00404     QWidget::focusInEvent( e );
    00405
    00406     // every widget get a focusInEvent when a popup menu is opened!?! -> maybe bug of QT
    00407     if ( e && ( ( e->reason() ) == QFocusEvent::Popup ) )
    00408         return ;
    00409
    00410
    00411     m_bFocusInEventIsPending = true;
    00412     activate();
    00413     m_bFocusInEventIsPending = false;
    00414
    00415     emit gotFocus( this );
    00416 }
    00417
    00418 //============= activate ===============//
    00419
    00420 void KMdiChildView::activate()
    00421 {
    00422     // avoid circularity
    00423     static bool s_bActivateIsPending = false;
    00424     if ( s_bActivateIsPending )
    00425         return ;
    00426
    00427     s_bActivateIsPending = true;
    00428
    00429     // raise the view and push the taskbar button
    00430     if ( !m_bMainframesActivateViewIsPending )
    00431         emit focusInEventOccurs( this );
    00432
    00433     // if this method was called directly, check if the mainframe wants that we interrupt
    00434     if ( m_bInterruptActivation )
    00435         m_bInterruptActivation = false;
    00436     else
    00437     {
    00438         if ( !m_bFocusInEventIsPending )
    00439             setFocus();
    00440
    00441         kdDebug( 760 ) << k_funcinfo << endl;
    00442         emit activated( this );
    00443     }
    00444
    00445     if ( m_focusedChildWidget != 0L )
    00446         m_focusedChildWidget->setFocus();
    00447     else
    00448     {
    00449         if ( m_firstFocusableChildWidget != 0L )
    00450         {
    00451             m_firstFocusableChildWidget->setFocus();
    00452             m_focusedChildWidget = m_firstFocusableChildWidget;
    00453         }
    00454     }
    00455     s_bActivateIsPending = false;
    00456 }
    00457
    00458 //============= focusOutEvent ===============//
    00459
    00460 void KMdiChildView::focusOutEvent( QFocusEvent* e )
    00461 {
    00462     QWidget::focusOutEvent( e );
    00463     emit lostFocus( this );
    00464 }
    00465
    00466 //============= resizeEvent ===============//
    00467
    00468 void KMdiChildView::resizeEvent( QResizeEvent* e )
    00469 {
    00470     QWidget::resizeEvent( e );
    00471
    00472     if ( m_stateChanged )
    00473     {
    00474         m_stateChanged = false;
    00475         if ( isMaximized() )
    00476         { //maximized
    00477             emit isMaximizedNow();
    00478         }
    00479         else if ( isMinimized() )
    00480         { //minimized
    00481             emit isMinimizedNow();
    00482         }
    00483         else
    00484         { //is restored
    00485             emit isRestoredNow();
    00486         }
    00487     }
    00488 }
    00489
    00490 void KMdiChildView::slot_childDestroyed()
    00491 {
    00492     // do what we do if a child is removed
    00493
    00494     // if we lost a child we uninstall ourself as event filter for the lost
    00495     // child and its children
    00496     const QObject * pLostChild = QObject::sender();
    00497     if ( pLostChild && ( pLostChild->isWidgetType() ) )
    00498     {
    00499         QObjectList* list = ( ( QObject* ) ( pLostChild ) ) ->queryList( "QWidget" );
    00500         list->insert( 0, pLostChild );        // add the lost child to the list too, just to save code
    00501         QObjectListIt it( *list );          // iterate over all lost child widgets
    00502         QObject* obj;
    00503         while ( ( obj = it.current() ) != 0 )
    00504         { // for each found object...
    00505             QWidget * widg = ( QWidget* ) obj;
    00506             ++it;
    00507             widg->removeEventFilter( this );
    00508             if ( m_firstFocusableChildWidget == widg )
    00509                 m_firstFocusableChildWidget = 0L;   // reset first widget
    00510
    00511             if ( m_lastFocusableChildWidget == widg )
    00512                 m_lastFocusableChildWidget = 0L;    // reset last widget
    00513
    00514             if ( m_focusedChildWidget == widg )
    00515                 m_focusedChildWidget = 0L;          // reset focused widget
    00516         }
    00517         delete list;                        // delete the list, not the objects
    00518     }
    00519 }
    00520
    00521 //============= eventFilter ===============//
    00522 bool KMdiChildView::eventFilter( QObject *obj, QEvent *e )
    00523 {
    00524     if ( e->type() == QEvent::KeyPress && isAttached() )
    00525     {
    00526         QKeyEvent* ke = ( QKeyEvent* ) e;
    00527         if ( ke->key() == Qt::Key_Tab )
    00528         {
    00529             QWidget* w = ( QWidget* ) obj;
    00530             FocusPolicy wfp = w->focusPolicy();
    00531             if ( wfp == QWidget::StrongFocus || wfp == QWidget::TabFocus || w->focusPolicy() == QWidget::WheelFocus )
    00532             {
    00533                 if ( m_lastFocusableChildWidget != 0 )
    00534                 {
    00535                     if ( w == m_lastFocusableChildWidget )
    00536                     {
    00537                         if ( w != m_firstFocusableChildWidget )
    00538                             m_firstFocusableChildWidget->setFocus();
    00539                     }
    00540                 }
    00541             }
    00542         }
    00543     }
    00544     else if ( e->type() == QEvent::FocusIn )
    00545     {
    00546         if ( obj->isWidgetType() )
    00547         {
    00548             QObjectList * list = queryList( "QWidget" );
    00549             if ( list->find( obj ) != -1 )
    00550                 m_focusedChildWidget = ( QWidget* ) obj;
    00551
    00552             delete list;   // delete the list, not the objects
    00553         }
    00554         if ( !isAttached() )
    00555         {   // is toplevel, for attached views activation is done by main frame event filter
    00556             static bool m_bActivationIsPending = false;
    00557             if ( !m_bActivationIsPending )
    00558             {
    00559                 m_bActivationIsPending = true;
    00560                 activate(); // sets the focus
    00561                 m_bActivationIsPending = false;
    00562             }
    00563         }
    00564     }
    00565     else if ( e->type() == QEvent::ChildRemoved )
    00566     {
    00567         // if we lost a child we uninstall ourself as event filter for the lost
    00568         // child and its children
    00569         QObject * pLostChild = ( ( QChildEvent* ) e ) ->child();
    00570         if ( ( pLostChild != 0L ) && ( pLostChild->isWidgetType() ) )
    00571         {
    00572             QObjectList * list = pLostChild->queryList( "QWidget" );
    00573             list->insert( 0, pLostChild );        // add the lost child to the list too, just to save code
    00574             QObjectListIt it( *list );          // iterate over all lost child widgets
    00575             QObject * o;
    00576             while ( ( o = it.current() ) != 0 )
    00577             { // for each found object...
    00578                 QWidget * widg = ( QWidget* ) o;
    00579                 ++it;
    00580                 widg->removeEventFilter( this );
    00581                 FocusPolicy wfp = widg->focusPolicy();
    00582                 if ( wfp == QWidget::StrongFocus || wfp == QWidget::TabFocus || widg->focusPolicy() == QWidget::WheelFocus )
    00583                 {
    00584                     if ( m_firstFocusableChildWidget == widg )
    00585                         m_firstFocusableChildWidget = 0L;   // reset first widget
    00586
    00587                     if ( m_lastFocusableChildWidget == widg )
    00588                         m_lastFocusableChildWidget = 0L;    // reset last widget
    00589                 }
    00590             }
    00591             delete list;                        // delete the list, not the objects
    00592         }
    00593     }
    00594     else if ( e->type() == QEvent::ChildInserted )
    00595     {
    00596         // if we got a new child and we are attached to the MDI system we
    00597         // install ourself as event filter for the new child and its children
    00598         // (as we did when we were added to the MDI system).
    00599         QObject * pNewChild = ( ( QChildEvent* ) e ) ->child();
    00600         if ( ( pNewChild != 0L ) && ( pNewChild->isWidgetType() ) )
    00601         {
    00602             QWidget * pNewWidget = ( QWidget* ) pNewChild;
    00603             if ( pNewWidget->testWFlags( Qt::WType_Dialog | Qt::WShowModal ) )
    00604                 return false;
    00605             QObjectList *list = pNewWidget->queryList( "QWidget" );
    00606             list->insert( 0, pNewChild );         // add the new child to the list too, just to save code
    00607             QObjectListIt it( *list );          // iterate over all new child widgets
    00608             QObject * o;
    00609             while ( ( o = it.current() ) != 0 )
    00610             { // for each found object...
    00611                 QWidget * widg = ( QWidget* ) o;
    00612                 ++it;
    00613                 widg->installEventFilter( this );
    00614                 connect( widg, SIGNAL( destroyed() ), this, SLOT( slot_childDestroyed() ) );
    00615                 FocusPolicy wfp = widg->focusPolicy();
    00616                 if ( wfp == QWidget::StrongFocus || wfp == QWidget::TabFocus || widg->focusPolicy() == QWidget::WheelFocus )
    00617                 {
    00618                     if ( m_firstFocusableChildWidget == 0 )
    00619                         m_firstFocusableChildWidget = widg;  // first widge
    00620
    00621                     m_lastFocusableChildWidget = widg; // last widget
    00622                 }
    00623             }
    00624             delete list;                        // delete the list, not the objects
    00625         }
    00626     }
    00627     else
    00628     {
    00629         if ( e->type() == QEvent::IconChange )
    00630         {
    00631             //            qDebug("KMDiChildView:: QEvent:IconChange intercepted\n");
    00632             if ( obj == this )
    00633                 iconUpdated( this, icon() ? ( *icon() ) : QPixmap() );
    00634             else if ( obj == m_trackChanges )
    00635                 setIcon( m_trackChanges->icon() ? ( *( m_trackChanges->icon() ) ) : QPixmap() );
    00636         }
    00637         if ( e->type() == QEvent::CaptionChange )
    00638         {
    00639             if ( obj == this )
    00640                 captionUpdated( this, caption() );
    00641         }
    00642     }
    00643
    00644     return false;                           // standard event processing
    00645 }
    00646
    00648 void KMdiChildView::removeEventFilterForAllChildren()
    00649 {
    00650     QObjectList* list = queryList( "QWidget" );
    00651     QObjectListIt it( *list );          // iterate over all child widgets
    00652     QObject* obj;
    00653     while ( ( obj = it.current() ) != 0 )
    00654     { // for each found object...
    00655         QWidget* widg = ( QWidget* ) obj;
    00656         ++it;
    00657         widg->removeEventFilter( this );
    00658     }
    00659     delete list;                        // delete the list, not the objects
    00660 }
    00661
    00662 QWidget* KMdiChildView::focusedChildWidget()
    00663 {
    00664     return m_focusedChildWidget;
    00665 }
    00666
    00667 void KMdiChildView::setFirstFocusableChildWidget( QWidget* firstFocusableChildWidget )
    00668 {
    00669     m_firstFocusableChildWidget = firstFocusableChildWidget;
    00670 }
    00671
    00672 void KMdiChildView::setLastFocusableChildWidget( QWidget* lastFocusableChildWidget )
    00673 {
    00674     m_lastFocusableChildWidget = lastFocusableChildWidget;
    00675 }
    00676
    00678 void KMdiChildView::setTabCaption ( const QString& stbCaption )
    00679 {
    00680     m_sTabCaption = stbCaption;
    00681     emit tabCaptionChanged( m_sTabCaption );
    00682 }
    00683
    00684 void KMdiChildView::setMDICaption ( const QString& caption )
    00685 {
    00686     setCaption( caption );
    00687     setTabCaption( caption );
    00688 }
    00689
    00691 void KMdiChildView::setWindowMenuID( int id )
    00692 {
    00693     m_windowMenuID = id;
    00694 }
    00695
    00696 //============= slot_clickedInWindowMenu ===============//
    00697
    00699 void KMdiChildView::slot_clickedInWindowMenu()
    00700 {
    00701     updateTimeStamp();
    00702     emit clickedInWindowMenu( m_windowMenuID );
    00703 }
    00704
    00705 //============= slot_clickedInDockMenu ===============//
    00706
    00708 void KMdiChildView::slot_clickedInDockMenu()
    00709 {
    00710     emit clickedInDockMenu( m_windowMenuID );
    00711 }
    00712
    00713 //============= setMinimumSize ===============//
    00714
    00715 void KMdiChildView::setMinimumSize( int minw, int minh )
    00716 {
    00717     QWidget::setMinimumSize( minw, minh );
    00718     if ( mdiParent() && mdiParent()->state() != KMdiChildFrm::Minimized )
    00719     {
    00720         mdiParent() ->setMinimumSize( minw + KMDI_CHILDFRM_DOUBLE_BORDER,
    00721                                       minh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight() );
    00722     }
    00723 }
    00724
    00725 //============= setMaximumSize ===============//
    00726
    00727 void KMdiChildView::setMaximumSize( int maxw, int maxh )
    00728 {
    00729     if ( mdiParent() && mdiParent()->state() == KMdiChildFrm::Normal )
    00730     {
    00731         int w = maxw + KMDI_CHILDFRM_DOUBLE_BORDER;
    00732         if ( w > QWIDGETSIZE_MAX )
    00733             w = QWIDGETSIZE_MAX;
    00734
    00735         int h = maxh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight();
    00736         if ( h > QWIDGETSIZE_MAX )
    00737             h = QWIDGETSIZE_MAX;
    00738
    00739         mdiParent()->setMaximumSize( w, h );
    00740     }
    00741     QWidget::setMaximumSize( maxw, maxh );
    00742 }
    00743
    00744 //============= show ===============//
    00745
    00746 void KMdiChildView::show()
    00747 {
    00748     if ( mdiParent() )
    00749         mdiParent()->show();
    00750
    00751     QWidget::show();
    00752 }
    00753
    00754 //============= hide ===============//
    00755
    00756 void KMdiChildView::hide()
    00757 {
    00758     if ( mdiParent() )
    00759         mdiParent()->hide();
    00760
    00761     QWidget::hide();
    00762 }
    00763
    00764 //============= raise ===============//
    00765
    00766 void KMdiChildView::raise()
    00767 {
    00768     if ( mdiParent() )  //TODO Check Z-order
    00769         mdiParent()->raise();
    00770
    00771     QWidget::raise();
    00772 }
    00773
    00774 // kate: space-indent off; replace-tabs off; indent-mode csands; tab-width 4;

This file is part of the documentation for kmdi Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:32:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003