libkcal

calendarlocal.h

Go to the documentation of this file.
00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 1998 Preston Brown <pbrown@kde.org>
00005     Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.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., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef KCAL_CALENDARLOCAL_H
00023 #define KCAL_CALENDARLOCAL_H
00024 
00025 #include "calendar.h"
00026 #include <qdict.h>
00027 #include <kdepimmacros.h>
00028 
00029 namespace KCal {
00030 
00031 class CalFormat;
00032 
00036 class LIBKCAL_EXPORT CalendarLocal : public Calendar
00037 {
00038   public:
00042     CalendarLocal( const QString &timeZoneId );
00043     ~CalendarLocal();
00044 
00058     bool load( const QString &fileName, CalFormat *format = 0 );
00059 
00065     bool reload( const QString &tz );
00066 
00074     bool save( const QString &fileName, CalFormat *format = 0 );
00075 
00079     void close();
00080 
00081     void save() {}
00082 
00086     bool addEvent( Event *event );
00090     bool deleteEvent( Event *event );
00094     void deleteAllEvents();
00095 
00099     Event *event( const QString &uid );
00103     Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00104 
00108     bool addTodo( Todo *todo );
00112     bool deleteTodo( Todo * );
00116     void deleteAllTodos();
00121     Todo *todo( const QString &uid );
00125     Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00129     Todo::List rawTodosForDate( const QDate &date );
00130 
00134     bool addJournal( Journal * );
00138     bool deleteJournal( Journal * );
00142     void deleteAllJournals();
00146     Journal *journal( const QString &uid );
00150     Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00154     Journal::List rawJournalsForDate( const QDate &date );
00155 
00159     Alarm::List alarms( const QDateTime &from, const QDateTime &to );
00160 
00164     Alarm::List alarmsTo( const QDateTime &to );
00165 
00170     Event::List rawEventsForDate( const QDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00174     Event::List rawEventsForDate( const QDateTime &qdt );
00184     Event::List rawEvents( const QDate &start, const QDate &end,
00185                                bool inclusive = false );
00186 
00192     void setTimeZoneIdViewOnly( const QString& tz );
00193   
00194   protected:
00195 
00197     void incidenceUpdated( IncidenceBase *i );
00198 
00200     void insertEvent( Event *event );
00201 
00203     void appendAlarms( Alarm::List &alarms, Incidence *incidence,
00204                        const QDateTime &from, const QDateTime &to );
00205 
00207     void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
00208                        const QDateTime &from, const QDateTime &to );
00209 
00210   private:
00211     void init();
00212 
00213     typedef QDict<Event> EventDict;
00214     typedef QDictIterator<Event> EventDictIterator;
00215     EventDict mEvents;
00216     Todo::List mTodoList;
00217     Journal::List mJournalList;
00218 
00219     Incidence::List mDeletedIncidences;
00220         QString mFileName;
00221 
00222     class Private;
00223     Private *d;
00224 };
00225 
00226 }
00227 
00228 #endif