calendar.h
00001 /* 00002 This file is part of libkcal. 00003 Copyright (c) 1998 Preston Brown 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef CALENDAR_H 00023 #define CALENDAR_H 00024 00025 #include <qstring.h> 00026 #include <qdatetime.h> 00027 #include <qptrlist.h> 00028 00029 #include "event.h" 00030 #include "todo.h" 00031 00032 #define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 00033 00034 class KConfig; 00035 00036 namespace KCal { 00037 00038 class CalFilter; 00039 00056 class Calendar { 00057 public: 00058 Calendar(); 00059 Calendar(const QString &timeZoneId); 00060 virtual ~Calendar(); 00061 00065 virtual void close() = 0; 00066 00070 const QString &getOwner() const; 00074 void setOwner( const QString &os ); 00078 const QString &getEmail(); 00082 void setEmail( const QString & ); 00083 00087 void setTimeZone( const QString &tz ); 00091 void setTimeZone( int tz ); 00095 int getTimeZone() const; 00099 QString getTimeZoneStr() const; 00104 void setTimeZoneId( const QString & ); 00108 QString timeZoneId() const; 00112 void setLocalTime(); 00116 bool isLocalTime() const; 00117 00122 virtual void addEvent( Event *anEvent ) = 0; 00126 virtual void deleteEvent( Event * ) = 0; 00127 00131 virtual Event *event( const QString &UniqueStr ) = 0; 00137 QPtrList<Event> events( const QDate &date, bool sorted = false); 00142 QPtrList<Event> events( const QDateTime &qdt ); 00148 QPtrList<Event> events( const QDate &start, const QDate &end, 00149 bool inclusive = false); 00153 virtual QPtrList<Event> events(); 00157 virtual QPtrList<Event> rawEvents() = 0; 00158 00162 virtual int numEvents( const QDate &qd ) = 0; 00163 00167 virtual void addTodo( Todo *todo ) = 0; 00171 virtual void deleteTodo( Todo * ) = 0; 00175 virtual QPtrList<Todo> todos(); 00180 virtual Todo *todo( const QString &uid ) = 0; 00184 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 00188 virtual QPtrList<Todo> rawTodos() const = 0; 00189 00193 virtual void addJournal( Journal * ) = 0; 00197 virtual Journal *journal( const QDate & ) = 0; 00201 virtual Journal *journal( const QString &UID ) = 0; 00205 virtual QPtrList<Journal> journals() = 0; 00206 00210 void addIncidence( Incidence * ); 00211 00216 void setFilter( CalFilter * ); 00220 CalFilter *filter(); 00221 00225 virtual Alarm::List alarms( const QDateTime &from, 00226 const QDateTime &to ) = 0; 00227 00228 class Observer { 00229 public: 00230 virtual void calendarModified( bool, Calendar * ) = 0; 00231 }; 00232 00233 void registerObserver( Observer * ); 00234 00235 void setModified( bool ); 00236 00241 void setLoadedProductId( const QString & ); 00246 QString loadedProductId(); 00247 00248 protected: 00252 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 00256 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 00257 bool sorted = false ) = 0; 00262 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 00263 bool inclusive = false ) = 0; 00264 00265 private: 00266 void init(); 00267 00268 QString mOwner; // who the calendar belongs to 00269 QString mOwnerEmail; // email address of the owner 00270 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 00271 bool mLocalTime; // use local time, not UTC or a time zone 00272 00273 CalFilter *mFilter; 00274 CalFilter *mDefaultFilter; 00275 00276 QString mTimeZoneId; 00277 00278 Observer *mObserver; 00279 bool mNewObserver; 00280 00281 bool mModified; 00282 00283 QString mLoadedProductId; 00284 }; 00285 00286 } 00287 00288 #endif