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 Status {
00117         StatusNone, StatusTentative, StatusConfirmed, StatusCompleted,
00118         StatusNeedsAction, StatusCanceled, StatusInProcess, StatusDraft,
00119         StatusFinal,
00120         StatusX   // indicates a non-standard status string
00121     };
00122 
00124     enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
00125 
00126     typedef ListBase<Incidence> List;
00127 
00128     Incidence();
00129     Incidence( const Incidence & );
00130     ~Incidence();
00131 
00132     bool operator==( const Incidence & ) const;
00133 
00141     virtual bool accept(Visitor &) { return false; }
00142 
00146     virtual Incidence *clone() = 0;
00147 
00154     void setReadOnly( bool );
00155 
00161     void recreate();
00162 
00166     void setCreated( const QDateTime & );
00170     QDateTime created() const;
00171 
00175     void setRevision( int rev );
00179     int revision() const;
00180 
00184     virtual void setDtStart( const QDateTime &dtStart );
00188     virtual QDateTime dtEnd() const  { return QDateTime(); }
00189 
00193     void setDescription( const QString &description );
00197     QString description() const;
00198 
00202     void setSummary( const QString &summary );
00206     QString summary() const;
00207 
00211     void setCategories( const QStringList &categories );
00215     void setCategories(const QString &catStr);
00219     QStringList categories() const;
00223     QString categoriesStr() const;
00224 
00230     void setRelatedToUid(const QString &);
00236     QString relatedToUid() const;
00240     void setRelatedTo(Incidence *relatedTo);
00244     Incidence *relatedTo() const;
00248     Incidence::List relations() const;
00252     void addRelation(Incidence *);
00256     void removeRelation(Incidence *);
00257 
00261     DateList exDates() const;
00266     DateTimeList exDateTimes() const;
00271     void setExDates( const DateList &exDates );
00276     void setExDateTimes( const DateTimeList &exDateTimes );
00280     void addExDate( const QDate &date );
00284     void addExDateTime( const QDateTime &dateTime );
00285 
00290     bool isException( const QDate &qd ) const;
00295     bool isException( const QDateTime &qdt ) const;
00296 
00300     void addAttachment( Attachment *attachment );
00304     void deleteAttachment( Attachment *attachment );
00308     void deleteAttachments( const QString &mime );
00312     Attachment::List attachments() const;
00316     Attachment::List attachments( const QString &mime ) const;
00320     void clearAttachments();
00321 
00326     void setSecrecy( int );
00330     int secrecy() const;
00334     QString secrecyStr() const;
00338     static QStringList secrecyList();
00342     static QString secrecyName( int );
00343 
00348     void setStatus( Status status );
00354     void setCustomStatus( const QString &status );
00358     Status status() const;
00362     QString statusStr() const;
00366     static QString statusName( Status );
00367 
00372     bool recursOn( const QDate &qd ) const;
00377     bool recursAt( const QDateTime &qdt ) const;
00378 
00379     // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
00380 
00384     void setResources( const QStringList &resources );
00388     QStringList resources() const;
00389 
00393     void setPriority( int priority );
00398     int priority() const;
00399 
00403     const Alarm::List &alarms() const;
00407     Alarm *newAlarm();
00411     void addAlarm( Alarm * );
00415     void removeAlarm( Alarm * );
00419     void clearAlarms();
00423     bool isAlarmEnabled() const;
00424 
00429     Recurrence *recurrence() const;
00430 
00434     ushort doesRecur() const;
00435 
00439     void setLocation(const QString &location);
00443     QString location() const;
00444 
00445   private:
00446     int mRevision;
00447 
00448     // base components of jounal, event and todo
00449     QDateTime mCreated;
00450     QString mDescription;
00451     QString mSummary;
00452     QStringList mCategories;
00453     Incidence *mRelatedTo;
00454     QString mRelatedToUid;
00455     Incidence::List mRelations;
00456     DateList mExDates;
00457     DateTimeList mExDateTimes;
00458     Attachment::List mAttachments;
00459     QStringList mResources;
00460 
00461     QString mStatusString;
00462     Status  mStatus;
00463     int mSecrecy;
00464     int mPriority;                        // 1 = highest, 2 = less, etc.
00465 
00466     Alarm::List mAlarms;
00467     Recurrence *mRecurrence;
00468 
00469     QString mLocation;
00470 
00471     class Private;
00472     Private *d;
00473 };
00474 
00475 }
00476 
00477 #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 Mon Apr 4 04:45:02 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003