libkcal Library API Documentation

calendar.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 1998 Preston Brown
00005     Copyright (c) 2001,2003,2004 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., 59 Temple Place - Suite 330,
00020     Boston, MA 02111-1307, USA.
00021 */
00022 #ifndef KCAL_CALENDAR_H
00023 #define KCAL_CALENDAR_H
00024 
00025 #include <qobject.h>
00026 #include <qstring.h>
00027 #include <qdatetime.h>
00028 #include <qptrlist.h>
00029 #include <qdict.h>
00030 
00031 #include "customproperties.h"
00032 #include "event.h"
00033 #include "todo.h"
00034 #include "journal.h"
00035 #include "kcalversion.h"
00036 
00037 #define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
00038 
00039 class KConfig;
00040 
00041 namespace KCal {
00042 
00043 class CalFilter;
00044 
00061 class Calendar : public QObject, public CustomProperties,
00062                  public IncidenceBase::Observer
00063 {
00064     Q_OBJECT
00065   public:
00066     Calendar();
00067     Calendar(const QString &timeZoneId);
00068     virtual ~Calendar();
00069 
00073     virtual void close() = 0;
00074 
00078     virtual void save() = 0;
00079 
00080     virtual bool isSaving() { return false; }
00081 
00085     const QString &getOwner() const;
00089     void setOwner( const QString &os );
00093     const QString &getEmail();
00097     void setEmail( const QString & );
00098 
00103     void setTimeZoneId( const QString & );
00107     QString timeZoneId() const;
00111     void setLocalTime();
00115     bool isLocalTime() const;
00116 
00122     virtual bool addIncidence( Incidence * );
00128     virtual bool deleteIncidence( Incidence * );
00132     virtual Incidence::List incidences();
00133     virtual Incidence::List incidences( const QDate &qdt );
00134 
00138     virtual Incidence::List rawIncidences();
00139 
00143     QStringList incidenceCategories();
00144 
00151     virtual bool addEvent( Event *anEvent ) = 0;
00155     virtual void deleteEvent( Event * ) = 0;
00159     virtual Event *event( const QString &UniqueStr ) = 0;
00165     Event::List events( const QDate &date, bool sorted = false );
00170     Event::List events( const QDateTime &qdt );
00176     Event::List events( const QDate &start, const QDate &end,
00177                         bool inclusive = false);
00181     virtual Event::List events();
00185     virtual Event::List rawEvents() = 0;
00186 
00192     virtual bool addTodo( Todo *todo ) = 0;
00196     virtual void deleteTodo( Todo * ) = 0;
00200     virtual Todo::List todos();
00205     virtual Todo *todo( const QString &uid ) = 0;
00209     virtual Todo::List todos( const QDate &date );
00213     virtual Todo::List rawTodos() = 0;
00217     virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00218 
00224     virtual bool addJournal( Journal * ) = 0;
00228     virtual void deleteJournal( Journal * ) = 0;
00232     virtual Journal *journal( const QDate & ) = 0;
00236     virtual Journal *journal( const QString &UID ) = 0;
00240     virtual Journal::List journals() = 0;
00241     // TODO: Add rawJournals() and rawJournal( QDate )
00242 
00247     Incidence *incidence( const QString &UID );
00248 
00253     Incidence *incidenceFromSchedulingID( const QString &UID );
00254 
00259     Incidence::List incidencesFromSchedulingID( const QString &UID );
00260 
00264     virtual void setupRelations( Incidence * );
00268     virtual void removeRelations( Incidence * );
00269 
00274     void setFilter( CalFilter * );
00278     CalFilter *filter();
00279 
00283     virtual Alarm::List alarms( const QDateTime &from,
00284                                 const QDateTime &to ) = 0;
00285 
00286     class Observer {
00287       public:
00288         virtual ~Observer(){}
00289         virtual void calendarModified( bool, Calendar * ) {};
00290 
00291         virtual void calendarIncidenceAdded( Incidence * ) {}
00292         virtual void calendarIncidenceChanged( Incidence * ) {}
00293         virtual void calendarIncidenceDeleted( Incidence * ) {}
00294     };
00295 
00296     void registerObserver( Observer * );
00297     void unregisterObserver( Observer * );
00298 
00299     void setModified( bool );
00300 
00305     void setLoadedProductId( const QString & );
00310     QString loadedProductId();
00311 
00315     static Incidence::List mergeIncidenceList( const Event::List &,
00316                                                const Todo::List &,
00317                                                const Journal::List & );
00318 
00319     virtual bool beginChange( Incidence * );
00320     virtual bool endChange( Incidence * );
00321 
00329     Incidence *dissociateOccurrence( Incidence *incidence, QDate date,
00330                                      bool single = true );
00331 
00332   signals:
00333     void calendarChanged();
00334     void calendarSaved();
00335     void calendarLoaded();
00336 
00337   public:
00341     virtual Event::List rawEventsForDate( const QDateTime &qdt ) = 0;
00345     virtual Event::List rawEventsForDate( const QDate &date,
00346                                           bool sorted = false ) = 0;
00351     virtual Event::List rawEvents( const QDate &start, const QDate &end,
00352                                    bool inclusive = false ) = 0;
00353   protected:
00357     virtual void doSetTimeZoneId( const QString & ) {}
00358 
00359     void notifyIncidenceAdded( Incidence * );
00360     void notifyIncidenceChanged( Incidence * );
00361     void notifyIncidenceDeleted( Incidence * );
00362 
00363     void setObserversEnabled( bool enabled );
00364 
00365   private:
00366     void init();
00367 
00368     QString mOwner;        // who the calendar belongs to
00369     QString mOwnerEmail;   // email address of the owner
00370     int mTimeZone;         // timezone OFFSET from GMT (MINUTES)
00371     bool mLocalTime;       // use local time, not UTC or a time zone
00372 
00373     CalFilter *mFilter;
00374     CalFilter *mDefaultFilter;
00375 
00376     QString mTimeZoneId;
00377 
00378     QPtrList<Observer> mObservers;
00379     bool mNewObserver;
00380     bool mObserversEnabled;
00381 
00382     bool mModified;
00383 
00384     QString mLoadedProductId;
00385 
00386     // This list is used to put together related todos
00387     QDict<Incidence> mOrphans;
00388     QDict<Incidence> mOrphanUids;
00389 
00390     class Private;
00391     Private *d;
00392 };
00393 
00394 }
00395 
00396 #endif
KDE Logo
This file is part of the documentation for libkcal Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 25 11:17:25 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003