libkcal Library API Documentation

resourcecalendar.cpp

00001 /*
00002     This file is part of libkdepim.
00003     Copyright (c) 1998 Preston Brown
00004     Copyright (c) 2001-2004 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library 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 GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020     Boston, MA 02111-1307, USA.
00021 */
00022 
00023 #include <kconfig.h>
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 
00027 #include "calendar.h"
00028 
00029 #include "resourcecalendar.h"
00030 
00031 using namespace KCal;
00032 
00033 ResourceCalendar::ResourceCalendar( const KConfig *config )
00034     : KRES::Resource( config ),mResolveConflict( false )
00035 {
00036 }
00037 
00038 ResourceCalendar::~ResourceCalendar()
00039 {
00040 }
00041 
00042 void ResourceCalendar::setResolveConflict( bool b)
00043 {
00044  mResolveConflict = b;
00045 }
00046 QString ResourceCalendar::infoText() const
00047 {
00048   QString txt;
00049 
00050   txt += "<b>" + resourceName() + "</b>";
00051   txt += "<br>";
00052 
00053   KRES::Factory *factory = KRES::Factory::self( "calendar" );
00054   QString t = factory->typeName( type() );
00055   txt += i18n("Type: %1").arg( t );
00056 
00057   addInfoText( txt );
00058   
00059   return txt;
00060 }
00061 
00062 void ResourceCalendar::writeConfig( KConfig* config )
00063 {
00064 //  kdDebug(5800) << "ResourceCalendar::writeConfig()" << endl;
00065 
00066   KRES::Resource::writeConfig( config );
00067 }
00068 
00069 bool ResourceCalendar::addIncidence( Incidence *incidence )
00070 {
00071   Incidence::AddVisitor<ResourceCalendar> v( this );
00072   return incidence->accept( v );
00073 }
00074 
00075 Incidence::List ResourceCalendar::rawIncidences()
00076 {
00077   return Calendar::mergeIncidenceList( rawEvents(), rawTodos(), journals() );
00078 }
00079 
00080 void ResourceCalendar::setSubresourceActive( const QString &, bool )
00081 {
00082 }
00083 
00084 bool ResourceCalendar::addSubresource( const QString &, const QString & )
00085 {
00086   return true;
00087 }
00088 
00089 bool ResourceCalendar::removeSubresource( const QString & )
00090 {
00091   return true;
00092 }
00093 
00094 bool ResourceCalendar::load()
00095 {
00096   kdDebug(5800) << "Loading resource " + resourceName() << endl;
00097 
00098   // FIXME: test if resource is opened and remove this test from concrete
00099   // resources
00100 
00101   mReceivedLoadError = false;
00102 
00103   bool success = true;
00104   if ( !isOpen() ) success = open();
00105   if ( success ) {
00106     success = doLoad();
00107   }
00108   if ( !success && !mReceivedLoadError ) loadError();
00109 
00110   kdDebug(5800) << "Done loading resource " + resourceName() << endl;
00111 
00112   return success;
00113 }
00114 
00115 void ResourceCalendar::loadError( const QString &err )
00116 {
00117   kdDebug(5800) << "Error loading resource: " << err << endl;
00118 
00119   mReceivedLoadError = true;
00120 
00121   QString msg = i18n("Error while loading %1.\n") .arg( resourceName() );
00122   if ( !err.isEmpty() ) {
00123     msg += err;
00124   }
00125   emit resourceLoadError( this, msg );
00126 }
00127 
00128 bool ResourceCalendar::save()
00129 {
00130   kdDebug(5800) << "Save resource " + resourceName() << endl;
00131 
00132   mReceivedSaveError = false;
00133 
00134   bool success = doSave();
00135   if ( !success && !mReceivedSaveError ) saveError();
00136 
00137   return success;
00138 }
00139 
00140 void ResourceCalendar::saveError( const QString &err )
00141 {
00142   kdDebug(5800) << "Error saving resource: " << err << endl;
00143 
00144   mReceivedSaveError = true;
00145 
00146   QString msg = i18n("Error while saving %1.\n") .arg( resourceName() );
00147   if ( !err.isEmpty() ) {
00148     msg += err;
00149   }
00150   emit resourceSaveError( this, msg );
00151 }
00152 
00153 
00154 #include "resourcecalendar.moc"
KDE Logo
This file is part of the documentation for libkcal Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu May 3 20:17:58 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003