kmdifocuslist.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #include "kmdifocuslist.h"
00020 #include "kmdifocuslist.moc"
00021 #include <qobjectlist.h>
00022 #include <kdebug.h>
00023 
00024 KMdiFocusList::KMdiFocusList(QObject *parent):QObject(parent) {
00025 }
00026     
00027 KMdiFocusList::~KMdiFocusList() {
00028 }
00029 
00030 void KMdiFocusList::addWidgetTree(QWidget* w) {
00031     
00032     m_list.insert(w,w->focusPolicy());
00033     w->setFocusPolicy(QWidget::ClickFocus);
00034     kdDebug(760)<<"KMdiFocusList::addWidgetTree: adding toplevel"<<endl;
00035     connect(w,SIGNAL(destroyed(QObject *)),this,SLOT(objectHasBeenDestroyed(QObject*)));
00036     QObjectList *l=w->queryList("QWidget");
00037     QObjectListIt it( *l );
00038     QObject *obj;
00039         while ( (obj = it.current()) != 0 ) {
00040         QWidget *wid=(QWidget*)obj;
00041         m_list.insert(wid,wid->focusPolicy());  
00042         wid->setFocusPolicy(QWidget::ClickFocus);
00043         kdDebug(760)<<"KMdiFocusList::addWidgetTree: adding widget"<<endl;
00044         connect(wid,SIGNAL(destroyed(QObject *)),this,SLOT(objectHasBeenDestroyed(QObject*)));
00045             ++it;
00046         }
00047         delete l;
00048 }
00049     
00050 void KMdiFocusList::restore() {
00051     for (QMap<QWidget*,QWidget::FocusPolicy>::const_iterator it=m_list.constBegin();it!=m_list.constEnd();++it) {
00052         it.key()->setFocusPolicy(it.data());
00053     }
00054     m_list.clear();
00055 }
00056 
00057 
00058 void KMdiFocusList::objectHasBeenDestroyed(QObject* o) {
00059     if (!o || !o->isWidgetType()) return;
00060     QWidget *w=(QWidget*)o;
00061     m_list.remove(w);
00062 }
 
This file is part of the documentation for kmdi Library Version 3.2.0.