KCal Library
incidence.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00031 #ifndef INCIDENCE_H
00032 #define INCIDENCE_H
00033
00034 #include "kcal_export.h"
00035 #include "incidencebase.h"
00036 #include "alarm.h"
00037 #include "attachment.h"
00038 #include "recurrence.h"
00039
00040 #include <QtCore/QList>
00041
00042 namespace KCal {
00043
00063 class KCAL_EXPORT Incidence
00064 : public IncidenceBase, public Recurrence::RecurrenceObserver
00065 {
00066 public:
00071
00072 template<class T>
00073 class AddVisitor : public IncidenceBase::Visitor
00074 {
00075 public:
00076 AddVisitor( T *r ) : mResource( r ) {}
00077
00078 bool visit( Event *e )
00079 {
00080 return mResource->addEvent( e );
00081 }
00082 bool visit( Todo *t )
00083 {
00084 return mResource->addTodo( t );
00085 }
00086 bool visit( Journal *j )
00087 {
00088 return mResource->addJournal( j );
00089 }
00090
00091 private:
00092 bool visit( FreeBusy * ) { return false; }
00093 T *mResource;
00094 };
00095
00096
00102
00103 template<class T>
00104 class DeleteVisitor : public IncidenceBase::Visitor
00105 {
00106 public:
00107 DeleteVisitor( T *r ) : mResource( r ) {}
00108
00109 bool visit( Event *e )
00110 {
00111 mResource->deleteEvent( e );
00112 return true;
00113 }
00114 bool visit( Todo *t )
00115 {
00116 mResource->deleteTodo( t );
00117 return true;
00118 }
00119 bool visit( Journal *j )
00120 {
00121 mResource->deleteJournal( j );
00122 return true;
00123 }
00124
00125 private:
00126 bool visit( FreeBusy * ) { return false; }
00127
00128 T *mResource;
00129 };
00130
00131
00136 enum Status {
00137 StatusNone,
00138 StatusTentative,
00139 StatusConfirmed,
00140 StatusCompleted,
00141 StatusNeedsAction,
00142 StatusCanceled,
00143 StatusInProcess,
00144 StatusDraft,
00145 StatusFinal,
00146 StatusX
00147 };
00148
00152 enum Secrecy {
00153 SecrecyPublic=0,
00154 SecrecyPrivate=1,
00155 SecrecyConfidential=2
00156 };
00157
00161 typedef ListBase<Incidence> List;
00162
00166 Incidence();
00167
00172 Incidence( const Incidence &other );
00173
00177 ~Incidence();
00178
00183 virtual Incidence *clone() = 0;
00184
00191 void setReadOnly( bool readonly );
00192
00197 void setAllDay( bool allDay );
00198
00204 void recreate();
00205
00212 void setCreated( const KDateTime &dt );
00213
00218 KDateTime created() const;
00219
00226 void setRevision( int rev );
00227
00232 int revision() const;
00233
00240 virtual void setDtStart( const KDateTime &dt );
00241
00246 virtual KDateTime dtEnd() const;
00247
00252 virtual void shiftTimes( const KDateTime::Spec &oldSpec,
00253 const KDateTime::Spec &newSpec );
00254
00262 void setDescription( const QString &description, bool isRich=false );
00263
00268 QString description() const;
00269
00274 bool descriptionIsRich() const;
00275
00283 void setSummary( const QString &summary, bool isRich=false );
00284
00289 QString summary() const;
00290
00295 bool summaryIsRich() const;
00296
00304 void setLocation( const QString &location, bool isRich=false );
00305
00310 QString location() const;
00311
00316 bool locationIsRich() const;
00317
00324 void setCategories( const QStringList &categories );
00325
00333 void setCategories( const QString &catStr );
00334
00339 QStringList categories() const;
00340
00345 QString categoriesStr() const;
00346
00354 void setRelatedToUid( const QString &uid );
00355
00362 QString relatedToUid() const;
00363
00371 void setRelatedTo( Incidence *incidence );
00372
00379 Incidence *relatedTo() const;
00380
00385 Incidence::List relations() const;
00386
00393 void addRelation( Incidence *incidence );
00394
00401 void removeRelation( Incidence *incidence );
00402
00403
00404
00405
00406
00411 Recurrence *recurrence() const;
00412
00416 void clearRecurrence();
00417
00422 bool recurs() const;
00423
00428 ushort recurrenceType() const;
00429
00434 virtual bool recursOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00435
00440 bool recursAt( const KDateTime &dt ) const;
00441
00453 virtual QList<KDateTime> startDateTimesForDate(
00454 const QDate &date,
00455 const KDateTime::Spec &timeSpec = KDateTime::LocalZone ) const;
00456
00466 virtual QList<KDateTime> startDateTimesForDateTime(
00467 const KDateTime &datetime ) const;
00468
00478 virtual KDateTime endDateForStart( const KDateTime &startDt ) const;
00479
00480
00481
00482
00483
00490 void addAttachment( Attachment *attachment );
00491
00499 void deleteAttachment( Attachment *attachment );
00500
00508 void deleteAttachments( const QString &mime );
00509
00514 Attachment::List attachments() const;
00515
00522 Attachment::List attachments( const QString &mime ) const;
00523
00528 void clearAttachments();
00529
00530
00531
00532
00533
00540 void setSecrecy( Secrecy secrecy );
00541
00546 Secrecy secrecy() const;
00547
00552 QString secrecyStr() const;
00553
00559 static QStringList secrecyList();
00560
00567 static QString secrecyName( Secrecy secrecy );
00568
00576 void setStatus( Status status );
00577
00585 void setCustomStatus( const QString &status );
00586
00591 Status status() const;
00592
00597 QString statusStr() const;
00598
00604 static QString statusName( Status status );
00605
00606
00607
00608
00609
00617 void setResources( const QStringList &resources );
00618
00623 QStringList resources() const;
00624
00633 void setPriority( int priority );
00634
00639 int priority() const;
00640
00641
00642
00643
00644
00648 const Alarm::List &alarms() const;
00649
00653 Alarm *newAlarm();
00654
00661 void addAlarm( Alarm *alarm );
00662
00669 void removeAlarm( Alarm *alarm );
00670
00675 void clearAlarms();
00676
00680 bool isAlarmEnabled() const;
00681
00682
00683
00684
00685
00698 void setSchedulingID( const QString &sid );
00699
00705 QString schedulingID() const;
00706
00714 virtual void recurrenceUpdated( Recurrence *recurrence );
00715
00721 bool operator==( const Incidence &incidence ) const;
00722
00723 protected:
00729 virtual KDateTime endDateRecurrenceBase() const
00730 {
00731 return dtStart();
00732 }
00733
00734 private:
00735
00736 class Private;
00737 Private *const d;
00738
00739 };
00740
00741 }
00742
00743 #endif