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 AddSubResourceVisitor : public IncidenceBase::Visitor
00070     {
00071       public:
00072         AddSubResourceVisitor( T *r, const QString &subResource )
00073           : mResource( r ), mSubResource( subResource ) {}
00074 
00075       protected:
00076         bool visit( Event *e )
00077         {
00078           return mResource->addEvent( e, mSubResource );
00079         }
00080         bool visit( Todo *t )
00081         {
00082           return mResource->addTodo( t, mSubResource );
00083         }
00084         bool visit( Journal *j )
00085         {
00086           return mResource->addJournal( j, mSubResource );
00087         }
00088 
00089       private:
00090         T *mResource;
00091         QString mSubResource;
00092     };
00093 
00098     template<class T>
00099     class DeleteVisitor : public IncidenceBase::Visitor
00100     {
00101       public:
00102         DeleteVisitor( T *r ) : mResource( r ) {}
00103 
00104         bool visit( Event *e ) { mResource->deleteEvent( e ); return true; }
00105         bool visit( Todo *t ) { mResource->deleteTodo( t ); return true; }
00106         bool visit( Journal *j ) { mResource->deleteJournal( j ); return true; }
00107 
00108       private:
00109         T *mResource;
00110     };
00111 
00113     enum Status {
00114         StatusNone, StatusTentative, StatusConfirmed, StatusCompleted,
00115         StatusNeedsAction, StatusCanceled, StatusInProcess, StatusDraft,
00116         StatusFinal,
00117         StatusX   // indicates a non-standard status string
00118     };
00119 
00121     enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
00122 
00123     typedef ListBase<Incidence> List;
00124 
00125     Incidence();
00126     Incidence( const Incidence & );
00127     ~Incidence();
00128 
00129     Incidence& operator=( const Incidence &i );
00130     bool operator==( const Incidence & ) const;
00131 
00135     virtual Incidence *clone() = 0;
00136 
00143     void setReadOnly( bool readonly );
00144 
00146     void setFloats( bool f );
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() const;
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 
00250 
00251 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00252 // %%%%%  Recurrence-related methods
00253 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00254 
00259     Recurrence *recurrence() const;
00260 
00262     void clearRecurrence();
00263 
00267     bool doesRecur() const;
00268     uint recurrenceType() const;
00269 
00274     virtual bool recursOn( const QDate &qd ) const;
00279     bool recursAt( const QDateTime &qdt ) const;
00280 
00289     virtual QValueList<QDateTime> startDateTimesForDate( const QDate &date ) const;
00290 
00299     virtual QValueList<QDateTime> startDateTimesForDateTime( const QDateTime &datetime ) const;
00300 
00302     virtual QDateTime endDateForStart( const QDateTime &startDt ) const;
00303 
00304 
00305 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00306 // %%%%%  Attachment-related methods
00307 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00308 
00312     void addAttachment( Attachment *attachment );
00316     void deleteAttachment( Attachment *attachment );
00320     void deleteAttachments( const QString &mime );
00324     Attachment::List attachments() const;
00328     Attachment::List attachments( const QString &mime ) const;
00332     void clearAttachments();
00333 
00334 
00335 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00336 // %%%%%  Secrecy and Status methods
00337 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00338 
00343     void setSecrecy( int );
00347     int secrecy() const;
00351     QString secrecyStr() const;
00355     static QStringList secrecyList();
00359     static QString secrecyName( int );
00360 
00365     void setStatus( Status status );
00371     void setCustomStatus( const QString &status );
00375     Status status() const;
00379     QString statusStr() const;
00383     static QString statusName( Status );
00384 
00385 
00386 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00387 // %%%%%  Other methods
00388 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00389 
00393     void setResources( const QStringList &resources );
00397     QStringList resources() const;
00398 
00404     void setPriority( int priority );
00409     int priority() const;
00410 
00411 
00412 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00413 // %%%%%  Alarm-related methods
00414 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00415 
00419     const Alarm::List &alarms() const;
00423     Alarm *newAlarm();
00427     void addAlarm( Alarm * );
00431     void removeAlarm( Alarm * );
00435     void clearAlarms();
00439     bool isAlarmEnabled() const;
00440 
00441 
00442 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00443 // %%%%%  Other methods
00444 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00445 
00446 
00447 
00451     void setLocation(const QString &location);
00455     QString location() const;
00456 
00466     void setSchedulingID( const QString& sid );
00467 
00472     void setUids( const QString &uid, const QString &schedulingId );
00473 
00478     QString schedulingID() const;
00479 
00483     virtual void recurrenceUpdated( Recurrence * );
00484   protected:
00488     virtual QDateTime endDateRecurrenceBase() const { return dtStart(); }
00489 
00490   private:
00491     int mRevision;
00492 
00493     // base components of jounal, event and todo
00494     QDateTime mCreated;
00495     QString mDescription;
00496     QString mSummary;
00497     QStringList mCategories;
00498     Incidence *mRelatedTo;
00499     QString mRelatedToUid;
00500     Incidence::List mRelations;
00501     Attachment::List mAttachments;
00502     QStringList mResources;
00503 
00504     QString mStatusString;
00505     Status  mStatus;
00506     int mSecrecy;
00507     int mPriority;                        // 1 = highest, 2 = less, etc.
00508 
00509     Alarm::List mAlarms;
00510     Recurrence *mRecurrence;
00511 
00512     QString mLocation;
00513 
00514     // Scheduling ID - used only to identify between scheduling mails
00515     QString mSchedulingID;
00516 
00517     class Private;
00518     Private *d;
00519 };
00520 
00521 }
00522 
00523 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys