libkcal

incidence.h
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22#ifndef INCIDENCE_H
23#define INCIDENCE_H
24
25#include <tqdatetime.h>
26#include <tqstringlist.h>
27#include <tqvaluelist.h>
28
29#include "recurrence.h"
30#include "alarm.h"
31#include "attachment.h"
32#include "libkcal_export.h"
33
34#include "incidencebase.h"
35#include <tdemacros.h>
36
37namespace KCal {
38
39class Calendar;
40
41typedef TQStringList IncidenceList;
42typedef TQStringList::iterator IncidenceListIterator;
43
47class LIBKCAL_EXPORT Incidence : public IncidenceBase, public Recurrence::Observer
48{
49 public:
54 template<class T>
55 class AddVisitor : public IncidenceBase::Visitor
56 {
57 public:
58 AddVisitor( T *r ) : mResource( r ) {}
59
60 bool visit( Event *e ) { return mResource->addEvent( e ); }
61 bool visit( Todo *t ) { return mResource->addTodo( t ); }
62 bool visit( Journal *j ) { return mResource->addJournal( j ); }
63
64 private:
65 T *mResource;
66 };
67
72 template<class T>
73 class AddSubResourceVisitor : public IncidenceBase::Visitor
74 {
75 public:
76 AddSubResourceVisitor( T *r, const TQString &subResource )
77 : mResource( r ), mSubResource( subResource ) {}
78
79 protected:
80 bool visit( Event *e )
81 {
82 return mResource->addEvent( e, mSubResource );
83 }
84 bool visit( Todo *t )
85 {
86 return mResource->addTodo( t, mSubResource );
87 }
88 bool visit( Journal *j )
89 {
90 return mResource->addJournal( j, mSubResource );
91 }
92
93 private:
94 T *mResource;
95 TQString mSubResource;
96 };
97
102 template<class T>
103 class DeleteVisitor : public IncidenceBase::Visitor
104 {
105 public:
106 DeleteVisitor( T *r ) : mResource( r ) {}
107
108 bool visit( Event *e ) { mResource->deleteEvent( e ); return true; }
109 bool visit( Todo *t ) { mResource->deleteTodo( t ); return true; }
110 bool visit( Journal *j ) { mResource->deleteJournal( j ); return true; }
111
112 private:
113 T *mResource;
114 };
115
117 enum Status {
118 StatusNone, StatusTentative, StatusConfirmed, StatusCompleted,
119 StatusNeedsAction, StatusCanceled, StatusInProcess, StatusDraft,
120 StatusFinal,
121 StatusX // indicates a non-standard status string
122 };
123
125 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
126
127 typedef ListBase<Incidence> List;
128
129 Incidence();
130 Incidence( const Incidence & );
131 ~Incidence();
132
133 Incidence& operator=( const Incidence &i );
134 bool operator==( const Incidence & ) const;
135
139 virtual Incidence *clone() = 0;
140
147 void setReadOnly( bool readonly );
148
150 void setFloats( bool f );
151
157 void recreate();
158
162 void setCreated( const TQDateTime & );
166 TQDateTime created() const;
167
171 void setRevision( int rev );
175 int revision() const;
176
180 virtual void setDtStart( const TQDateTime &dtStart );
184 virtual TQDateTime dtEnd() const { return TQDateTime(); }
185
189 void setDescription( const TQString &description );
193 TQString description() const;
194
198 void setSummary( const TQString &summary );
202 TQString summary() const;
203
207 void setCategories( const TQStringList &categories );
211 void setCategories(const TQString &catStr);
215 TQStringList categories() const;
219 TQString categoriesStr() const;
220
226 void setRelatedToUid(const TQString &);
232 TQString relatedToUid() const;
236 void setRelatedTo(Incidence *relatedTo);
240 Incidence *relatedTo() const;
244 Incidence::List relations() const;
248 void addRelation(Incidence *);
252 void removeRelation(Incidence *);
253
254
255// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256// %%%%% Recurrence-related methods
257// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258
263 Recurrence *recurrence() const;
264
266 void clearRecurrence();
267
271 bool doesRecur() const;
272 uint recurrenceType() const;
273
278 virtual bool recursOn( const TQDate &qd ) const;
283 bool recursAt( const TQDateTime &qdt ) const;
284
291 virtual bool recursOn( const TQDate &qd, Calendar *cal ) const;
298 bool recursAt( const TQDateTime &qdt, Calendar *cal ) const;
299
308 virtual TQValueList<TQDateTime> startDateTimesForDate( const TQDate &date ) const;
309
318 virtual TQValueList<TQDateTime> startDateTimesForDateTime( const TQDateTime &datetime ) const;
319
321 virtual TQDateTime endDateForStart( const TQDateTime &startDt ) const;
322
323
324// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325// %%%%% Attachment-related methods
326// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327
331 void addAttachment( Attachment *attachment );
335 void deleteAttachment( Attachment *attachment );
339 void deleteAttachments( const TQString &mime );
343 Attachment::List attachments() const;
347 Attachment::List attachments( const TQString &mime ) const;
351 void clearAttachments();
352
353
354// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355// %%%%% Secrecy and Status methods
356// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357
362 void setSecrecy( int );
366 int secrecy() const;
370 TQString secrecyStr() const;
374 static TQStringList secrecyList();
378 static TQString secrecyName( int );
379
384 void setStatus( Status status );
390 void setCustomStatus( const TQString &status );
394 Status status() const;
398 TQString statusStr() const;
402 static TQString statusName( Status );
403
404
405// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406// %%%%% Other methods
407// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408
412 void setResources( const TQStringList &resources );
416 TQStringList resources() const;
417
423 void setPriority( int priority );
428 int priority() const;
429
435 bool hasRecurrenceID() const;
436
443 void setHasRecurrenceID( bool hasRecurrenceID );
444
451 void setRecurrenceID( const TQDateTime &recurrenceID );
452
459 TQDateTime recurrenceID() const;
460
466 void addChildIncidence( TQString childIncidence );
467
473 void deleteChildIncidence( TQString childIncidence );
474
480 IncidenceList childIncidences() const;
481
482
483// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484// %%%%% Alarm-related methods
485// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486
490 const Alarm::List &alarms() const;
494 Alarm *newAlarm();
498 void addAlarm( Alarm * );
502 void removeAlarm( Alarm * );
506 void clearAlarms();
510 bool isAlarmEnabled() const;
511
512
513// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514// %%%%% Other methods
515// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516
517
518
522 void setLocation(const TQString &location);
526 TQString location() const;
527
537 void setSchedulingID( const TQString& sid );
542 TQString schedulingID() const;
543
547 virtual void recurrenceUpdated( Recurrence * );
548 protected:
552 virtual TQDateTime endDateRecurrenceBase() const { return dtStart(); }
553
554 private:
555 int mRevision;
556
557 // base components of jounal, event and todo
558 TQDateTime mCreated;
559 TQString mDescription;
560 TQString mSummary;
561 TQStringList mCategories;
562 Incidence *mRelatedTo;
563 TQString mRelatedToUid;
564 Incidence::List mRelations;
565 Attachment::List mAttachments;
566 TQStringList mResources;
567
568 TQString mStatusString;
569 Status mStatus;
570 int mSecrecy;
571 int mPriority; // 1 = highest, 2 = less, etc.
572
573 Alarm::List mAlarms;
574 Recurrence *mRecurrence;
575
576 TQString mLocation;
577
578 // Scheduling ID - used only to identify between scheduling mails
579 TQString mSchedulingID;
580
581 TQDateTime mRecurrenceID; // recurrenceID
582 bool mHasRecurrenceID; // if incidence has recurrenceID
583
584 IncidenceList mChildRecurrenceEvents;
585
586 class Private;
587 Private *d;
588};
589
590}
591
592#endif
This class represents an alarm notification.
Definition alarm.h:46
This class represents information related to an attachment.
Definition attachment.h:35
This is the main "calendar" object class.
Definition calendar.h:171
This class provides an Event in the sense of RFC2445.
Definition event.h:33
This class provides the interface for a visitor of calendar components.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
bool visit(Journal *j)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:88
bool visit(Todo *t)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:84
bool visit(Event *e)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:80
bool visit(Journal *j)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:62
bool visit(Todo *t)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:61
bool visit(Event *e)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:60
bool visit(Journal *j)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:110
bool visit(Event *e)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:108
bool visit(Todo *t)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition incidence.h:109
This class provides the base class common to all calendar components.
Definition incidence.h:48
void setReadOnly(bool readonly)
Set readonly state of incidence.
virtual TQDateTime dtEnd() const
Return the incidence's ending date/time as a TQDateTime.
Definition incidence.h:184
void recreate()
Recreate event.
TQDateTime created() const
Return time and date of creation.
int revision() const
Return the number of revisions this event has seen.
Status
Enumeration for describing an event's status.
Definition incidence.h:117
void setFloats(bool f)
Set whether the incidence floats, i.e.
virtual Incidence * clone()=0
Return copy of this object.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.
virtual TQDateTime endDateRecurrenceBase() const
Return the end date/time of the base incidence (e.g.
Definition incidence.h:552
void setRevision(int rev)
Set the number of revisions this event has seen.
void setCreated(const TQDateTime &)
Set creation date.
This class provides a Journal in the sense of RFC2445.
Definition journal.h:34
This class represents a recurrence rule for a calendar incidence.
Definition recurrence.h:90
This class provides a Todo in the sense of RFC2445.
Definition todo.h:32
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition alarm.h:38