kowindowlist.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2000,2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <kdebug.h> 00026 00027 #include "actionmanager.h" 00028 #include "kowindowlist.h" 00029 #include "kowindowlist.moc" 00030 00031 KOWindowList::KOWindowList( const char *name ) 00032 : QObject( 0, name ), mDefaultWindow( 0 ) 00033 { 00034 kdDebug(5850) << "KOWindowList::KOWindowList()" << endl; 00035 } 00036 00037 KOWindowList::~KOWindowList() 00038 { 00039 } 00040 00041 void KOWindowList::addWindow( KOrg::MainWindow *korg ) 00042 { 00043 if ( !korg->hasDocument() ) mDefaultWindow = korg; 00044 else mWindowList.append( korg ); 00045 } 00046 00047 void KOWindowList::removeWindow( KOrg::MainWindow *korg ) 00048 { 00049 if ( korg == mDefaultWindow ) mDefaultWindow = 0; 00050 else mWindowList.removeRef( korg ); 00051 } 00052 00053 bool KOWindowList::lastInstance() 00054 { 00055 if ( mWindowList.count() == 1 && !mDefaultWindow ) return true; 00056 if ( mWindowList.count() == 0 && mDefaultWindow ) return true; 00057 else return false; 00058 } 00059 00060 KOrg::MainWindow *KOWindowList::findInstance( const KURL &url ) 00061 { 00062 KOrg::MainWindow *inst; 00063 for( inst = mWindowList.first(); inst; inst = mWindowList.next() ) 00064 if ( inst->getCurrentURL() == url ) 00065 return inst; 00066 return 0; 00067 } 00068 00069 KOrg::MainWindow *KOWindowList::defaultInstance() 00070 { 00071 return mDefaultWindow; 00072 }