korganizer

kowindowlist.cpp
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000,2003 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 
25 #include <kdebug.h>
26 
27 #include "actionmanager.h"
28 #include "kowindowlist.h"
29 #include "kowindowlist.moc"
30 
31 KOWindowList::KOWindowList( const char *name )
32  : TQObject( 0, name ), mDefaultWindow( 0 )
33 {
34 // kdDebug(5850) << "KOWindowList::KOWindowList()" << endl;
35 }
36 
37 KOWindowList::~KOWindowList()
38 {
39 }
40 
42 {
43  if ( !korg->hasDocument() ) mDefaultWindow = korg;
44  else mWindowList.append( korg );
45 }
46 
48 {
49  if ( korg == mDefaultWindow ) mDefaultWindow = 0;
50  else mWindowList.removeRef( korg );
51 }
52 
54 {
55  if ( mWindowList.count() == 1 && !mDefaultWindow ) return true;
56  if ( mWindowList.count() == 0 && mDefaultWindow ) return true;
57  else return false;
58 }
59 
61 {
62  KOrg::MainWindow *inst;
63  for( inst = mWindowList.first(); inst; inst = mWindowList.next() )
64  if ( inst->getCurrentURL() == url )
65  return inst;
66  return 0;
67 }
68 
70 {
71  return mDefaultWindow;
72 }
KOrg::MainWindow * findInstance(const KURL &url)
Is there a instance with this URL?
bool lastInstance()
Is there only one instance left?
KOWindowList(const char *name=0)
Constructs a new list of KOrganizer windows.
void addWindow(KOrg::MainWindow *)
Register a main window.
void removeWindow(KOrg::MainWindow *)
Unregister a main window.
KOrg::MainWindow * defaultInstance()
Return default instance.
interface for korganizer main window
Definition: mainwindow.h:41
virtual KURL getCurrentURL() const =0
Get current URL.