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