resourcelocal.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <klocale.h>
00035 #include <kmessagebox.h>
00036 #include <kstandarddirs.h>
00037
00038 #include <libkcal/icalformat.h>
00039
00040 #include "knotes/resourcelocal.h"
00041 #include "knotes/resourcemanager.h"
00042
00043
00044
00045 ResourceLocal::ResourceLocal( const KConfig* config )
00046 : ResourceNotes( config )
00047 {
00048 if ( !config )
00049 setType( "file" );
00050 }
00051
00052 ResourceLocal::~ResourceLocal()
00053 {
00054 }
00055
00056 bool ResourceLocal::load()
00057 {
00058 mCalendar.load( KGlobal::dirs()->saveLocation( "data" ) + "knotes/notes.ics" );
00059
00060 KCal::Journal::List notes = mCalendar.journals();
00061 KCal::Journal::List::ConstIterator it;
00062 for ( it = notes.begin(); it != notes.end(); ++it )
00063 manager()->registerNote( this, *it );
00064
00065 return true;
00066 }
00067
00068 bool ResourceLocal::save()
00069 {
00070 QString file = KGlobal::dirs()->saveLocation( "data", "knotes/" ) + "notes.ics";
00071
00072 if ( !mCalendar.save( file, new KCal::ICalFormat() ) )
00073 {
00074 KMessageBox::error( 0,
00075 i18n("<qt>Unable to save the notes to <b>%1</b>. "
00076 "Check that there is sufficient disk space."
00077 "<br>There should be a backup in the same directory "
00078 "though.</qt>").arg( file ) );
00079 return false;
00080 }
00081
00082 return true;
00083 }
00084
00085 bool ResourceLocal::addNote( KCal::Journal* journal )
00086 {
00087 mCalendar.addJournal( journal );
00088 return true;
00089 }
00090
00091 bool ResourceLocal::deleteNote( KCal::Journal* journal )
00092 {
00093 mCalendar.deleteJournal( journal );
00094 return true;
00095 }
This file is part of the documentation for knotes Library Version 3.3.2.