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 ),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
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
00099
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"
This file is part of the documentation for libkcal Library Version 3.3.2.