korganizer Library API Documentation

koapp.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 1999 Preston Brown 00005 Copyright (c) 2000,2001,2003 Cornelius Schumacher <schumacher@kde.org> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 As a special exception, permission is given to link this program 00022 with any edition of Qt, and distribute the resulting executable, 00023 without including the source code for Qt in the source distribution. 00024 */ 00025 00026 #include <stdlib.h> 00027 #include <iostream> 00028 00029 #include <kglobal.h> 00030 #include <kcmdlineargs.h> 00031 #include <kconfig.h> 00032 #include <kdebug.h> 00033 #include <klocale.h> 00034 #include <kwin.h> 00035 #include <kurl.h> 00036 00037 #include <libkcal/calformat.h> 00038 00039 #include "korganizer.h" 00040 #include "koprefs.h" 00041 #include "version.h" 00042 #include "alarmclient.h" 00043 #include "koglobals.h" 00044 #include "actionmanager.h" 00045 #include "resourceimportdialog.h" 00046 00047 #include "koapp.h" 00048 #include <kstartupinfo.h> 00049 00050 using namespace std; 00051 00052 KOrganizerApp::KOrganizerApp() : KUniqueApplication() 00053 { 00054 QString prodId = "-//K Desktop Environment//NONSGML KOrganizer %1//EN"; 00055 CalFormat::setApplication( "KOrganizer", prodId.arg( korgVersion ) ); 00056 } 00057 00058 KOrganizerApp::~KOrganizerApp() 00059 { 00060 } 00061 00062 int KOrganizerApp::newInstance() 00063 { 00064 kdDebug(5850) << "KOApp::newInstance()" << endl; 00065 00066 if ( isRestored() ) { 00067 RESTORE( KOrganizer ) 00068 return 0; 00069 } 00070 00071 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 00072 00073 KOGlobals::self()->alarmClient()->startDaemon(); 00074 00075 // If filenames was given as argument load this as calendars, one per window. 00076 if ( args->count() > 0 ) { 00077 int i; 00078 for( i = 0; i < args->count(); ++i ) { 00079 processCalendar( args->url( i ) ); 00080 } 00081 if ( args->isSet( "import" ) ) { 00082 processCalendar( KURL() ); 00083 } 00084 } else { 00085 processCalendar( KURL() ); 00086 } 00087 00088 if ( args->isSet( "import" ) ) { 00089 KOrg::MainWindow *korg = ActionManager::findInstance( KURL() ); 00090 if ( !korg ) { 00091 kdError() << "Unable to find default calendar resources view." << endl; 00092 } else { 00093 QString importUrl = QString::fromLocal8Bit( args->getOption( "import" ) ); 00094 korg->actionManager()->importResource( importUrl ); 00095 } 00096 } 00097 00098 kdDebug(5850) << "KOApp::newInstance() done" << endl; 00099 00100 return 0; 00101 } 00102 00103 00104 void KOrganizerApp::processCalendar( const KURL &url ) 00105 { 00106 KOrg::MainWindow *korg = ActionManager::findInstance( url ); 00107 if ( !korg ) { 00108 bool hasDocument = !url.isEmpty(); 00109 korg = new KOrganizer( "KOrganizer MainWindow" ); 00110 korg->init( hasDocument ); 00111 korg->topLevelWidget()->show(); 00112 00113 kdDebug(5850) << "KOrganizerApp::processCalendar(): '" << url.url() 00114 << "'" << endl; 00115 00116 if ( hasDocument ) korg->openURL( url ); 00117 } 00118 else 00119 korg->topLevelWidget()->show(); 00120 00121 // Handle window activation 00122 #if defined Q_WS_X11 && ! defined K_WS_QTONLY 00123 KStartupInfo::setNewStartupId( korg->topLevelWidget(), startupId() ); 00124 #endif 00125 } 00126 00127 #include "koapp.moc"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003