libkcal

incidence.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
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 INCIDENCE_H
00023 #define INCIDENCE_H
00024 
00025 #include <qdatetime.h>
00026 #include <qstringlist.h>
00027 #include <qvaluelist.h>
00028 
00029 #include "recurrence.h"
00030 #include "alarm.h"
00031 #include "attachment.h"
00032 #include "libkcal_export.h"
00033 
00034 #include "incidencebase.h"
00035 #include <kdepimmacros.h>
00036 
00037 namespace KCal {
00038 
00039 
00043 class LIBKCAL_EXPORT Incidence : public IncidenceBase, public Recurrence::Observer
00044 {
00045   public:
00050     template<class T>
00051     class AddVisitor : public IncidenceBase::Visitor
00052     {
00053       public:
00054         AddVisitor( T *r ) : mResource( r ) {}
00055 
00056         bool visit( Event *e ) { return mResource->addEvent( e ); }
00057         bool visit( Todo *t ) { return mResource->addTodo( t ); }
00058         bool visit( Journal *j ) { return mResource->addJournal( j ); }
00059 
00060       private:
00061         T *mResource;
00062     };
00063 
00068     template<class T>
00069     class DeleteVisitor : public IncidenceBase::Visitor
00070     {
00071       public:
00072         DeleteVisitor( T *r ) : mResource( r ) {}
00073 
00074         bool visit( Event *e ) { mResource->deleteEvent( e ); return true; }
00075         bool visit( Todo *t ) { mResource->deleteTodo( t ); return true; }
00076         bool visit( Journal *j ) { mResource->deleteJournal( j ); return true; }
00077 
00078       private:
00079         T *mResource;
00080     };
00081 
00083     enum Status {
00084         StatusNone, StatusTentative, StatusConfirmed, StatusCompleted,
00085         StatusNeedsAction, StatusCanceled, StatusInProcess, StatusDraft,
00086         StatusFinal,
00087         StatusX   // indicates a non-standard status string
00088     };
00089 
00091     enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
00092 
00093     typedef ListBase<Incidence> List;
00094 
00095     Incidence();
00096     Incidence( const Incidence & );
00097     ~Incidence();
00098 
00099     bool operator==( const Incidence & ) const;
00100 
00104     virtual Incidence *clone() = 0;
00105 
00112     void setReadOnly( bool readonly );
00113 
00115     void setFloats( bool f );
00116     
00122     void recreate();
00123 
00127     void setCreated( const QDateTime & );
00131     QDateTime created() const;
00132 
00136     void setRevision( int rev );
00140     int revision() const;
00141 
00145     virtual void setDtStart( const QDateTime &dtStart );
00149     virtual QDateTime dtEnd() const  { return QDateTime(); }
00150 
00154     void setDescription( const QString &description );
00158     QString description() const;
00159 
00163     void setSummary( const QString &summary );
00167     QString summary() const;
00168 
00172     void setCategories( const QStringList &categories );
00176     void setCategories(const QString &catStr);
00180     QStringList categories() const;
00184     QString categoriesStr() const;
00185 
00191     void setRelatedToUid(const QString &);
00197     QString relatedToUid() const;
00201     void setRelatedTo(Incidence *relatedTo);
00205     Incidence *relatedTo() const;
00209     Incidence::List relations() const;
00213     void addRelation(Incidence *);
00217     void removeRelation(Incidence *);
00218 
00219 
00220 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00221 // %%%%%  Recurrence-related methods
00222 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00223 
00228     Recurrence *recurrence() const;
00229 
00231     void clearRecurrence();
00232 
00236     bool doesRecur() const;
00237     uint recurrenceType() const;
00238 
00243     virtual bool recursOn( const QDate &qd ) const;
00248     bool recursAt( const QDateTime &qdt ) const;
00249 
00258     virtual QValueList<QDateTime> startDateTimesForDate( const QDate &date ) const;
00259 
00268     virtual QValueList<QDateTime> startDateTimesForDateTime( const QDateTime &datetime ) const;
00269 
00271     virtual QDateTime endDateForStart( const QDateTime &startDt ) const;
00272 
00273 
00274 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00275 // %%%%%  Attachment-related methods
00276 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00277 
00281     void addAttachment( Attachment *attachment );
00285     void deleteAttachment( Attachment *attachment );
00289     void deleteAttachments( const QString &mime );
00293     Attachment::List attachments() const;
00297     Attachment::List attachments( const QString &mime ) const;
00301     void clearAttachments();
00302 
00303 
00304 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00305 // %%%%%  Secrecy and Status methods
00306 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00307 
00312     void setSecrecy( int );
00316     int secrecy() const;
00320     QString secrecyStr() const;
00324     static QStringList secrecyList();
00328     static QString secrecyName( int );
00329 
00334     void setStatus( Status status );
00340     void setCustomStatus( const QString &status );
00344     Status status() const;
00348     QString statusStr() const;
00352     static QString statusName( Status );
00353 
00354 
00355 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00356 // %%%%%  Other methods
00357 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00358 
00362     void setResources( const QStringList &resources );
00366     QStringList resources() const;
00367 
00373     void setPriority( int priority );
00378     int priority() const;
00379 
00380 
00381 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00382 // %%%%%  Alarm-related methods
00383 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00384 
00388     const Alarm::List &alarms() const;
00392     Alarm *newAlarm();
00396     void addAlarm( Alarm * );
00400     void removeAlarm( Alarm * );
00404     void clearAlarms();
00408     bool isAlarmEnabled() const;
00409 
00410 
00411 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00412 // %%%%%  Other methods
00413 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00414 
00415 
00416 
00420     void setLocation(const QString &location);
00424     QString location() const;
00425 
00435     void setSchedulingID( const QString& sid );
00440     QString schedulingID() const;
00441 
00445     virtual void recurrenceUpdated( Recurrence * );
00446   protected:
00450     virtual QDateTime endDateRecurrenceBase() const { return dtStart(); }
00451 
00452   private:
00453     int mRevision;
00454 
00455     // base components of jounal, event and todo
00456     QDateTime mCreated;
00457     QString mDescription;
00458     QString mSummary;
00459     QStringList mCategories;
00460     Incidence *mRelatedTo;
00461     QString mRelatedToUid;
00462     Incidence::List mRelations;
00463     Attachment::List mAttachments;
00464     QStringList mResources;
00465 
00466     QString mStatusString;
00467     Status  mStatus;
00468     int mSecrecy;
00469     int mPriority;                        // 1 = highest, 2 = less, etc.
00470 
00471     Alarm::List mAlarms;
00472     Recurrence *mRecurrence;
00473 
00474     QString mLocation;
00475 
00476     // Scheduling ID - used only to identify between scheduling mails
00477     QString mSchedulingID;
00478 
00479     class Private;
00480     Private *d;
00481 };
00482 
00483 }
00484 
00485 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys