knotes Library API Documentation

resourcelocal.cpp

00001 /******************************************************************* 00002 This file is part of KNotes. 00003 00004 Copyright (c) 2004, Bo Thorsen <bo@klaralvdalens-datakonsult.se> 00005 2004, Michael Brade <brade@kde.org> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program 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 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00020 MA 02111-1307, USA. 00021 00022 In addition, as a special exception, the copyright holders give 00023 permission to link the code of this program with any edition of 00024 the Qt library by Trolltech AS, Norway (or with modified versions 00025 of Qt that use the same license as Qt), and distribute linked 00026 combinations including the two. You must obey the GNU General 00027 Public License in all respects for all of the code used other than 00028 Qt. If you modify this file, you may extend this exception to 00029 your version of the file, but you are not obligated to do so. If 00030 you do not wish to do so, delete this exception statement from 00031 your version. 00032 *******************************************************************/ 00033 00034 #include <klocale.h> 00035 #include <kmessagebox.h> 00036 #include <kstandarddirs.h> 00037 00038 #include <libkcal/icalformat.h> 00039 00040 #include "knoteslegacy.h" 00041 00042 #include "knotes/resourcelocal.h" 00043 #include "knotes/resourcemanager.h" 00044 00045 00046 00047 ResourceLocal::ResourceLocal( const KConfig* config ) 00048 : ResourceNotes( config ) 00049 { 00050 if ( !config ) 00051 setType( "file" ); 00052 } 00053 00054 ResourceLocal::~ResourceLocal() 00055 { 00056 } 00057 00058 bool ResourceLocal::load() 00059 { 00060 mCalendar.load( KGlobal::dirs()->saveLocation( "data" ) + "knotes/notes.ics" ); 00061 00062 // TODO 00063 // initialize the Calendar 00064 //mCalendar.setOwner(..); 00065 //mCalendar.setEmail(..); 00066 00067 // read the old config files into mCalendar and convert them 00068 if ( KNotesLegacy::convert( &mCalendar ) ) 00069 save(); 00070 00071 KCal::Journal::List notes = mCalendar.journals(); 00072 KCal::Journal::List::ConstIterator it; 00073 for ( it = notes.begin(); it != notes.end(); ++it ) 00074 manager()->registerNote( this, *it ); 00075 00076 return true; 00077 } 00078 00079 bool ResourceLocal::save() 00080 { 00081 QString file = KGlobal::dirs()->saveLocation( "data" ) + "knotes/notes.ics"; 00082 00083 if ( !mCalendar.save( file, new KCal::ICalFormat() ) ) 00084 { 00085 KMessageBox::error( 0, 00086 i18n("<qt>Unable to save the notes to <b>%1</b>. " 00087 "Check that there is sufficient disk space." 00088 "<br>There should be a backup in the same directory " 00089 "though.</qt>").arg( file ) ); 00090 return false; 00091 } 00092 00093 return true; 00094 } 00095 00096 bool ResourceLocal::addNote( KCal::Journal* journal ) 00097 { 00098 mCalendar.addJournal( journal ); 00099 return true; 00100 } 00101 00102 bool ResourceLocal::deleteNote( KCal::Journal* journal ) 00103 { 00104 mCalendar.deleteJournal( journal ); 00105 return true; 00106 }
KDE Logo
This file is part of the documentation for knotes Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:50:15 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003