kmdi Library API Documentation

kmdifocuslist.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
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     //this method should never be called twice on the same hierarchy
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 #if (QT_VERSION-0 >= 0x030200)
00052     for (QMap<QWidget*,QWidget::FocusPolicy>::const_iterator it=m_list.constBegin();it!=m_list.constEnd();++it) {
00053 #else
00054     for (QMap<QWidget*,QWidget::FocusPolicy>::iterator it=m_list.begin();it!=m_list.end();++it) {
00055 #endif
00056         it.key()->setFocusPolicy(it.data());
00057     }
00058     m_list.clear();
00059 }
00060 
00061 
00062 void KMdiFocusList::objectHasBeenDestroyed(QObject* o) {
00063     if (!o || !o->isWidgetType()) return;
00064     QWidget *w=(QWidget*)o;
00065     m_list.remove(w);
00066 }
KDE Logo
This file is part of the documentation for kmdi Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:21:51 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003