korganizer Library API Documentation

stdcalendar.cpp

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010     
00011     This library 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 GNU
00014     Library General Public License for more details.
00015     
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #include "stdcalendar.h"
00023 
00024 #include <libkcal/resourcecalendar.h>
00025 #include <libkcal/resourcelocal.h>
00026 #include <libkdepim/kpimprefs.h>
00027 
00028 #include <kstaticdeleter.h>
00029 #include <kconfig.h>
00030 #include <kstandarddirs.h>
00031 #include <klocale.h>
00032 
00033 using namespace KOrg;
00034 
00035 static KStaticDeleter<StdCalendar> selfDeleter;
00036 
00037 StdCalendar *StdCalendar::mSelf = 0;
00038 
00039 StdCalendar *StdCalendar::self()
00040 {
00041   if ( !mSelf ) {
00042 #if 0
00043     selfDeleter.setObject( mSelf, new StdCalendar() );
00044 #else
00045     mSelf = new StdCalendar();
00046 #endif
00047   }
00048   return mSelf;
00049 }
00050 
00051 StdCalendar::StdCalendar()
00052   : CalendarResources( KPimPrefs::timezone() )
00053 {
00054   readConfig();
00055 
00056   KCal::CalendarResourceManager *manager = resourceManager();
00057   if ( manager->isEmpty() ) {
00058     KConfig config( "korganizerrc" );
00059     config.setGroup( "General" );
00060     QString fileName = config.readPathEntry( "Active Calendar" );
00061 
00062     QString resourceName;
00063     if ( fileName.isEmpty() ) {
00064       fileName = locateLocal( "data", "korganizer/std.ics" );
00065       resourceName = i18n( "Default Calendar" );
00066     } else {
00067       resourceName = i18n( "Active Calendar" );
00068     }
00069 
00070     KCal::ResourceCalendar *defaultResource =
00071                              new KCal::ResourceLocal( fileName );
00072 
00073     defaultResource->setTimeZoneId( KPimPrefs::timezone() );
00074     defaultResource->setResourceName( resourceName );
00075 
00076     manager->add( defaultResource );
00077     manager->setStandardResource( defaultResource );
00078   }
00079 }
00080 
00081 StdCalendar::~StdCalendar()
00082 {
00083   mSelf = 0;
00084 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 25 11:21:01 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003