resourcecalendar.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 )
00035 {
00036 }
00037
00038 ResourceCalendar::~ResourceCalendar()
00039 {
00040 }
00041
00042 QString ResourceCalendar::infoText() const
00043 {
00044 QString txt;
00045
00046 txt += "<b>" + resourceName() + "</b>";
00047 txt += "<br>";
00048
00049 KRES::Factory *factory = KRES::Factory::self( "calendar" );
00050 QString t = factory->typeName( type() );
00051 txt += i18n("Type: %1").arg( t );
00052
00053 addInfoText( txt );
00054
00055 return txt;
00056 }
00057
00058 void ResourceCalendar::writeConfig( KConfig* config )
00059 {
00060
00061
00062 KRES::Resource::writeConfig( config );
00063 }
00064
00065 bool ResourceCalendar::addIncidence( Incidence *incidence )
00066 {
00067 Incidence::AddVisitor<ResourceCalendar> v( this );
00068 return incidence->accept( v );
00069 }
00070
00071 Incidence::List ResourceCalendar::rawIncidences()
00072 {
00073 return Calendar::mergeIncidenceList( rawEvents(), rawTodos(), journals() );
00074 }
00075
00076 void ResourceCalendar::setSubresourceActive( const QString &, bool )
00077 {
00078 }
00079
00080 bool ResourceCalendar::load()
00081 {
00082 kdDebug(5800) << "Loading resource " + resourceName() << endl;
00083
00084
00085
00086
00087 mReceivedLoadError = false;
00088
00089 bool success = true;
00090 if ( !isOpen() ) success = open();
00091 if ( success ) {
00092 success = doLoad();
00093 }
00094 if ( !success && !mReceivedLoadError ) loadError();
00095
00096 kdDebug(5800) << "Done loading resource " + resourceName() << endl;
00097
00098 return success;
00099 }
00100
00101 void ResourceCalendar::loadError( const QString &err )
00102 {
00103 kdDebug(5800) << "Error loading resource: " << err << endl;
00104
00105 mReceivedLoadError = true;
00106
00107 QString msg = i18n("Error while loading %1.\n") .arg( resourceName() );
00108 if ( !err.isEmpty() ) {
00109 msg += err;
00110 }
00111 emit resourceLoadError( this, msg );
00112 }
00113
00114 bool ResourceCalendar::save()
00115 {
00116 if ( !readOnly() ) {
00117 kdDebug(5800) << "Save resource " + resourceName() << endl;
00118
00119 mReceivedSaveError = false;
00120
00121 bool success = doSave();
00122 if ( !success && !mReceivedSaveError ) saveError();
00123
00124 return success;
00125 } else {
00126
00127 kdDebug(5800) << "Don't save read-only resource " + resourceName() << endl;
00128 return true;
00129 }
00130 }
00131
00132 void ResourceCalendar::saveError( const QString &err )
00133 {
00134 kdDebug(5800) << "Error saving resource: " << err << endl;
00135
00136 mReceivedSaveError = true;
00137
00138 QString msg = i18n("Error while saving %1.\n") .arg( resourceName() );
00139 if ( !err.isEmpty() ) {
00140 msg += err;
00141 }
00142 emit resourceSaveError( this, msg );
00143 }
00144
00145
00146 #include "resourcecalendar.moc"
This file is part of the documentation for libkcal Library Version 3.3.2.