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 boost {
00043 template <typename T> class shared_ptr;
00044 }
00045
00046 namespace KCal {
00047
00067 class KCAL_EXPORT Incidence
00068 : public IncidenceBase, public Recurrence::RecurrenceObserver
00069 {
00070 public:
00075
00076 template<class T>
00077 class AddVisitor : public IncidenceBase::Visitor
00078 {
00079 public:
00080 AddVisitor( T *r ) : mResource( r ) {}
00081
00082 bool visit( Event *e )
00083 {
00084 return mResource->addEvent( e );
00085 }
00086 bool visit( Todo *t )
00087 {
00088 return mResource->addTodo( t );
00089 }
00090 bool visit( Journal *j )
00091 {
00092 return mResource->addJournal( j );
00093 }
00094 bool visit( FreeBusy * )
00095 {
00096 return false;
00097 }
00098
00099 private:
00100 T *mResource;
00101 };
00102
00103
00109
00110 template<class T>
00111 class DeleteVisitor : public IncidenceBase::Visitor
00112 {
00113 public:
00114 DeleteVisitor( T *r ) : mResource( r ) {}
00115
00116 bool visit( Event *e )
00117 {
00118 mResource->deleteEvent( e );
00119 return true;
00120 }
00121 bool visit( Todo *t )
00122 {
00123 mResource->deleteTodo( t );
00124 return true;
00125 }
00126 bool visit( Journal *j )
00127 {
00128 mResource->deleteJournal( j );
00129 return true;
00130 }
00131 bool visit( FreeBusy * )
00132 {
00133 return false;
00134 }
00135
00136 private:
00137 T *mResource;
00138 };
00139
00140
00145 enum Status {
00146 StatusNone,
00147 StatusTentative,
00148 StatusConfirmed,
00149 StatusCompleted,
00150 StatusNeedsAction,
00151 StatusCanceled,
00152 StatusInProcess,
00153 StatusDraft,
00154 StatusFinal,
00155 StatusX
00156 };
00157
00161 enum Secrecy {
00162 SecrecyPublic=0,
00163 SecrecyPrivate=1,
00164 SecrecyConfidential=2
00165 };
00166
00170 typedef ListBase<Incidence> List;
00171
00175 typedef boost::shared_ptr<Incidence> Ptr;
00176
00180 Incidence();
00181
00186 Incidence( const Incidence &other );
00187
00191 ~Incidence();
00192
00197 virtual Incidence *clone() = 0;
00198
00205 void setReadOnly( bool readonly );
00206
00211 void setAllDay( bool allDay );
00212
00218 void recreate();
00219
00226 void setCreated( const KDateTime &dt );
00227
00232 KDateTime created() const;
00233
00240 void setRevision( int rev );
00241
00246 int revision() const;
00247
00254 virtual void setDtStart( const KDateTime &dt );
00255
00260 virtual KDateTime dtEnd() const;
00261
00266 virtual void shiftTimes( const KDateTime::Spec &oldSpec,
00267 const KDateTime::Spec &newSpec );
00268
00276 void setDescription( const QString &description, bool isRich );
00277
00286 void setDescription( const QString &description );
00287
00293 QString description() const;
00294
00301 QString richDescription() const;
00302
00307 bool descriptionIsRich() const;
00308
00316 void setSummary( const QString &summary, bool isRich );
00317
00325 void setSummary( const QString &summary );
00326
00332 QString summary() const;
00333
00340 QString richSummary() const;
00341
00346 bool summaryIsRich() const;
00347
00355 void setLocation( const QString &location, bool isRich );
00356
00365 void setLocation( const QString &location );
00366
00372 QString location() const;
00373
00380 QString richLocation() const;
00381
00386 bool locationIsRich() const;
00387
00394 void setCategories( const QStringList &categories );
00395
00403 void setCategories( const QString &catStr );
00404
00409 QStringList categories() const;
00410
00415 QString categoriesStr() const;
00416
00424 void setRelatedToUid( const QString &uid );
00425
00432 QString relatedToUid() const;
00433
00441 void setRelatedTo( Incidence *incidence );
00442
00449 Incidence *relatedTo() const;
00450
00455 Incidence::List relations() const;
00456
00463 void addRelation( Incidence *incidence );
00464
00471 void removeRelation( Incidence *incidence );
00472
00473
00474
00475
00476
00481 Recurrence *recurrence() const;
00482
00486 void clearRecurrence();
00487
00492 bool recurs() const;
00493
00498 ushort recurrenceType() const;
00499
00504 virtual bool recursOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00505
00510 bool recursAt( const KDateTime &dt ) const;
00511
00523 virtual QList<KDateTime> startDateTimesForDate(
00524 const QDate &date,
00525 const KDateTime::Spec &timeSpec = KDateTime::LocalZone ) const;
00526
00536 virtual QList<KDateTime> startDateTimesForDateTime(
00537 const KDateTime &datetime ) const;
00538
00548 virtual KDateTime endDateForStart( const KDateTime &startDt ) const;
00549
00550
00551
00552
00553
00560 void addAttachment( Attachment *attachment );
00561
00569 void deleteAttachment( Attachment *attachment );
00570
00578 void deleteAttachments( const QString &mime );
00579
00584 Attachment::List attachments() const;
00585
00592 Attachment::List attachments( const QString &mime ) const;
00593
00598 void clearAttachments();
00599
00600
00601
00602
00603
00610 void setSecrecy( Secrecy secrecy );
00611
00616 Secrecy secrecy() const;
00617
00622 QString secrecyStr() const;
00623
00629 static QStringList secrecyList();
00630
00637 static QString secrecyName( Secrecy secrecy );
00638
00646 void setStatus( Status status );
00647
00655 void setCustomStatus( const QString &status );
00656
00661 Status status() const;
00662
00667 QString statusStr() const;
00668
00674 static QString statusName( Status status );
00675
00676
00677
00678
00679
00687 void setResources( const QStringList &resources );
00688
00693 QStringList resources() const;
00694
00703 void setPriority( int priority );
00704
00709 int priority() const;
00710
00716 bool hasGeo() const;
00717
00724 void setHasGeo( bool hasGeo );
00725
00732 void setGeoLatitude( float geolatitude );
00733
00740 float &geoLatitude() const;
00741
00748 void setGeoLongitude( float geolongitude );
00749
00756 float &geoLongitude() const;
00757
00758
00759
00760
00761
00765 const Alarm::List &alarms() const;
00766
00770 Alarm *newAlarm();
00771
00778 void addAlarm( Alarm *alarm );
00779
00786 void removeAlarm( Alarm *alarm );
00787
00792 void clearAlarms();
00793
00797 bool isAlarmEnabled() const;
00798
00799
00800
00801
00802
00815 void setSchedulingID( const QString &sid );
00816
00822 QString schedulingID() const;
00823
00831 virtual void recurrenceUpdated( Recurrence *recurrence );
00832
00844 Incidence &operator=( const Incidence &other );
00845
00846
00857 bool operator==( const Incidence &incidence ) const;
00858
00859
00860 protected:
00866 virtual KDateTime endDateRecurrenceBase() const
00867 {
00868 return dtStart();
00869 }
00870
00871 private:
00872 void init( const Incidence &other );
00873
00874 class Private;
00875 Private *const d;
00876
00877 };
00878
00879 }
00880
00881 #endif