KCal Library
incidence.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the kcal library. 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 */ 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 //krazy:exclude=dpointer since nested class templates confuse krazy 00068 : public IncidenceBase, public Recurrence::RecurrenceObserver 00069 { 00070 public: 00075 //@cond PRIVATE 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 //@endcond 00103 00109 //@cond PRIVATE 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 //@endcond 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 typedef boost::shared_ptr<const Incidence> ConstPtr; 00181 00185 Incidence(); 00186 00191 Incidence( const Incidence &other ); 00192 00196 ~Incidence(); 00197 00202 virtual Incidence *clone() = 0; //TODO KDE5: make this const 00203 00210 void setReadOnly( bool readonly ); 00211 00216 void setAllDay( bool allDay ); 00217 00223 void recreate(); 00224 00231 void setCreated( const KDateTime &dt ); 00232 00237 KDateTime created() const; 00238 00245 void setRevision( int rev ); 00246 00251 int revision() const; 00252 00259 virtual void setDtStart( const KDateTime &dt ); 00260 00265 virtual KDateTime dtEnd() const; 00266 00271 virtual void shiftTimes( const KDateTime::Spec &oldSpec, 00272 const KDateTime::Spec &newSpec ); 00273 00281 void setDescription( const QString &description, bool isRich ); 00282 00291 void setDescription( const QString &description ); 00292 00298 QString description() const; 00299 00306 QString richDescription() const; 00307 00312 bool descriptionIsRich() const; 00313 00321 void setSummary( const QString &summary, bool isRich ); 00322 00330 void setSummary( const QString &summary ); 00331 00337 QString summary() const; 00338 00345 QString richSummary() const; 00346 00351 bool summaryIsRich() const; 00352 00360 void setLocation( const QString &location, bool isRich ); 00361 00370 void setLocation( const QString &location ); 00371 00377 QString location() const; 00378 00385 QString richLocation() const; 00386 00391 bool locationIsRich() const; 00392 00399 void setCategories( const QStringList &categories ); 00400 00408 void setCategories( const QString &catStr ); 00409 00414 QStringList categories() const; 00415 00420 QString categoriesStr() const; 00421 00429 void setRelatedToUid( const QString &uid ); 00430 00437 QString relatedToUid() const; 00438 00446 void setRelatedTo( Incidence *incidence ); 00447 00454 Incidence *relatedTo() const; 00455 00460 Incidence::List relations() const; 00461 00468 void addRelation( Incidence *incidence ); 00469 00476 void removeRelation( Incidence *incidence ); 00477 00478 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00479 // %%%%% Recurrence-related methods 00480 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00481 00486 Recurrence *recurrence() const; 00487 00491 void clearRecurrence(); 00492 00497 bool recurs() const; 00498 00503 ushort recurrenceType() const; 00504 00509 virtual bool recursOn( const QDate &date, const KDateTime::Spec &timeSpec ) const; 00510 00515 bool recursAt( const KDateTime &dt ) const; 00516 00528 virtual QList<KDateTime> startDateTimesForDate( 00529 const QDate &date, 00530 const KDateTime::Spec &timeSpec = KDateTime::LocalZone ) const; 00531 00541 virtual QList<KDateTime> startDateTimesForDateTime( 00542 const KDateTime &datetime ) const; 00543 00553 virtual KDateTime endDateForStart( const KDateTime &startDt ) const; 00554 00555 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00556 // %%%%% Attachment-related methods 00557 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00558 00565 void addAttachment( Attachment *attachment ); 00566 00574 void deleteAttachment( Attachment *attachment ); 00575 00583 void deleteAttachments( const QString &mime ); 00584 00589 Attachment::List attachments() const; 00590 00597 Attachment::List attachments( const QString &mime ) const; 00598 00603 void clearAttachments(); 00604 00609 QString writeAttachmentToTempFile( Attachment *attachment ) const; 00610 00611 void clearTempFiles(); 00612 00613 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00614 // %%%%% Secrecy and Status methods 00615 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00616 00623 void setSecrecy( Secrecy secrecy ); 00624 00629 Secrecy secrecy() const; 00630 00635 QString secrecyStr() const; 00636 00642 static QStringList secrecyList(); 00643 00650 static QString secrecyName( Secrecy secrecy ); 00651 00659 void setStatus( Status status ); 00660 00668 void setCustomStatus( const QString &status ); 00669 00674 Status status() const; 00675 00680 QString statusStr() const; 00681 00687 static QString statusName( Status status ); 00688 00689 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00690 // %%%%% Other methods 00691 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00692 00700 void setResources( const QStringList &resources ); 00701 00706 QStringList resources() const; 00707 00716 void setPriority( int priority ); 00717 00722 int priority() const; 00723 00729 bool hasGeo() const; 00730 00737 void setHasGeo( bool hasGeo ); 00738 00745 void setGeoLatitude( float geolatitude ); 00746 00753 float &geoLatitude() const; 00754 00761 void setGeoLongitude( float geolongitude ); 00762 00769 float &geoLongitude() const; 00770 00771 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00772 // %%%%% Alarm-related methods 00773 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00774 00778 const Alarm::List &alarms() const; 00779 00783 Alarm *newAlarm(); 00784 00791 void addAlarm( Alarm *alarm ); 00792 00799 void removeAlarm( Alarm *alarm ); 00800 00805 void clearAlarms(); 00806 00810 bool isAlarmEnabled() const; 00811 00812 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00813 // %%%%% Other methods 00814 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00815 00828 void setSchedulingID( const QString &sid ); 00829 00835 QString schedulingID() const; 00836 00844 virtual void recurrenceUpdated( Recurrence *recurrence ); 00845 00857 Incidence &operator=( const Incidence &other ); // KDE5: make protected to 00858 // prevent accidental usage 00859 00870 bool operator==( const Incidence &incidence ) const; // KDE5: make protected to 00871 // prevent accidental usage 00872 00873 protected: 00879 virtual KDateTime endDateRecurrenceBase() const 00880 { 00881 return dtStart(); 00882 } 00883 00884 private: 00885 void init( const Incidence &other ); 00886 //@cond PRIVATE 00887 class Private; 00888 Private *const d; 00889 //@endcond 00890 }; 00891 00892 } 00893 00894 #endif