libkcal Library API Documentation

incidence.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2001-2003 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 #ifndef INCIDENCE_H
00022 #define INCIDENCE_H
00023 
00024 #include <qdatetime.h>
00025 #include <qstringlist.h>
00026 #include <qvaluelist.h>
00027 
00028 #include "recurrence.h"
00029 #include "alarm.h"
00030 #include "attachment.h"
00031 
00032 #include "incidencebase.h"
00033 
00034 namespace KCal {
00035 
00036 class Event;
00037 class Todo;
00038 class Journal;
00039 
00043 class Incidence : public IncidenceBase
00044 {
00045   public:
00052     class Visitor
00053     {
00054       public:
00056         virtual ~Visitor() {}
00057 
00062         virtual bool visit(Event *) { return false; }
00067         virtual bool visit(Todo *) { return false; }
00072         virtual bool visit(Journal *) { return false; }
00073 
00074       protected:
00076         Visitor() {}
00077     };
00078 
00083     template<class T>
00084     class AddVisitor : public Visitor
00085     {
00086       public:
00087         AddVisitor( T *r ) : mResource( r ) {}
00088 
00089         bool visit( Event *e ) { return mResource->addEvent( e ); }
00090         bool visit( Todo *t ) { return mResource->addTodo( t ); }
00091         bool visit( Journal *j ) { return mResource->addJournal( j ); }
00092 
00093       private:
00094         T *mResource;
00095     };
00096 
00101     template<class T>
00102     class DeleteVisitor : public Visitor
00103     {
00104       public:
00105         DeleteVisitor( T *r ) : mResource( r ) {}
00106 
00107         bool visit( Event *e ) { mResource->deleteEvent( e ); return true; }
00108         bool visit( Todo *t ) { mResource->deleteTodo( t ); return true; }
00109         bool visit( Journal *j ) { mResource->deleteJournal( j ); return true; }
00110 
00111       private:
00112         T *mResource;
00113     };
00114 
00116     enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
00117 
00118     typedef ListBase<Incidence> List;
00119 
00120     Incidence();
00121     Incidence( const Incidence & );
00122     ~Incidence();
00123 
00124     bool operator==( const Incidence & ) const;
00125 
00133     virtual bool accept(Visitor &) { return false; }
00134 
00138     virtual Incidence *clone() = 0;
00139 
00146     void setReadOnly( bool );
00147 
00153     void recreate();
00154 
00158     void setCreated( const QDateTime & );
00162     QDateTime created() const;
00163 
00167     void setRevision( int rev );
00171     int revision() const;
00172 
00176     virtual void setDtStart( const QDateTime &dtStart );
00180     virtual QDateTime dtEnd() const  { return QDateTime(); }
00181 
00185     void setDescription( const QString &description );
00189     QString description() const;
00190 
00194     void setSummary( const QString &summary );
00198     QString summary() const;
00199 
00203     void setCategories( const QStringList &categories );
00207     void setCategories(const QString &catStr);
00211     QStringList categories() const;
00215     QString categoriesStr();
00216 
00222     void setRelatedToUid(const QString &);
00228     QString relatedToUid() const;
00232     void setRelatedTo(Incidence *relatedTo);
00236     Incidence *relatedTo() const;
00240     Incidence::List relations() const;
00244     void addRelation(Incidence *);
00248     void removeRelation(Incidence *);
00249 
00253     DateList exDates() const;
00258     DateTimeList exDateTimes() const;
00263     void setExDates( const DateList &exDates );
00268     void setExDateTimes( const DateTimeList &exDateTimes );
00272     void addExDate( const QDate &date );
00276     void addExDateTime( const QDateTime &dateTime );
00277 
00282     bool isException( const QDate &qd ) const;
00287     bool isException( const QDateTime &qdt ) const;
00288 
00292     void addAttachment( Attachment *attachment );
00296     void deleteAttachment( Attachment *attachment );
00300     void deleteAttachments( const QString &mime );
00304     Attachment::List attachments() const;
00308     Attachment::List attachments( const QString &mime ) const;
00312     void clearAttachments();
00313 
00318     void setSecrecy( int );
00322     int secrecy() const;
00326     QString secrecyStr() const;
00330     static QStringList secrecyList();
00334     static QString secrecyName( int );
00335 
00340     bool recursOn( const QDate &qd ) const;
00345     bool recursAt( const QDateTime &qdt ) const;
00346 
00347     // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
00348 
00352     void setResources( const QStringList &resources );
00356     QStringList resources() const;
00357 
00361     void setPriority( int priority );
00366     int priority() const;
00367 
00371     const Alarm::List &alarms() const;
00375     Alarm *newAlarm();
00379     void addAlarm( Alarm * );
00383     void removeAlarm( Alarm * );
00387     void clearAlarms();
00391     bool isAlarmEnabled() const;
00392 
00397     Recurrence *recurrence() const;
00398 
00402     ushort doesRecur() const;
00403 
00407     void setLocation(const QString &location);
00411     QString location() const;
00412     
00413   private:
00414     int mRevision;
00415 
00416     // base components of jounal, event and todo
00417     QDateTime mCreated;
00418     QString mDescription;
00419     QString mSummary;
00420     QStringList mCategories;
00421     Incidence *mRelatedTo;
00422     QString mRelatedToUid;
00423     Incidence::List mRelations;
00424     DateList mExDates;
00425     DateTimeList mExDateTimes;
00426     Attachment::List mAttachments;
00427     QStringList mResources;
00428 
00429     int mSecrecy;
00430     int mPriority;                        // 1 = highest, 2 = less, etc.
00431 
00432     Alarm::List mAlarms;
00433     Recurrence *mRecurrence;
00434     
00435     QString mLocation;
00436 
00437     class Private;
00438     Private *d;
00439 };
00440 
00441 }
00442 
00443 #endif
KDE Logo
This file is part of the documentation for libkcal Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:22 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003