libkcal
recurrence.hGo 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
00022
00023
00024 #ifndef KCAL_RECURRENCE_H
00025 #define KCAL_RECURRENCE_H
00026
00027 #include <qstring.h>
00028 #include <qbitarray.h>
00029 #include <qptrlist.h>
00030
00031 #include "libkcal_export.h"
00032 #include "recurrencerule.h"
00033
00034 namespace KCal {
00035
00036 class RecurrenceRule;
00037
00089 class LIBKCAL_EXPORT Recurrence : public RecurrenceRule::Observer
00090 {
00091 public:
00092 class Observer {
00093 public:
00094 virtual ~Observer() {}
00096 virtual void recurrenceUpdated( Recurrence * ) = 0;
00097 };
00098
00100 enum { rNone = 0, rMinutely = 0x001, rHourly = 0x0002, rDaily = 0x0003,
00101 rWeekly = 0x0004, rMonthlyPos = 0x0005, rMonthlyDay = 0x0006,
00102 rYearlyMonth = 0x0007, rYearlyDay = 0x0008, rYearlyPos = 0x0009,
00103 rOther = 0x000A, rMax=0x00FF };
00104
00105 Recurrence();
00106 Recurrence( const Recurrence& );
00107 virtual ~Recurrence();
00108
00109 bool operator==( const Recurrence& ) const;
00110 bool operator!=( const Recurrence& r ) const { return !operator==(r); }
00111
00114 QDateTime startDateTime() const;
00116 QDate startDate() const { return mStartDateTime.date(); }
00120 void setStartDateTime( const QDateTime &start );
00124 void setStartDate( const QDate &start );
00125
00132 bool doesFloat() const { return mFloating; }
00136 void setFloats( bool floats );
00137
00139 void setRecurReadOnly(bool readOnly) { mRecurReadOnly = readOnly; }
00141 bool recurReadOnly() const { return mRecurReadOnly; }
00142
00144 bool doesRecur() const;
00147 ushort recurrenceType() const;
00150 static ushort recurrenceType( const RecurrenceRule *rrule );
00153 bool recursOn( const QDate &qd ) const;
00156 bool recursAt( const QDateTime & ) const;
00159 void unsetRecurs();
00161 void clear();
00162
00167 QValueList<QTime> recurTimesOn(const QDate &date) const;
00168
00174 QDateTime getNextDateTime( const QDateTime& preDateTime ) const;
00181 QDateTime getPreviousDateTime( const QDateTime& afterDateTime ) const;
00182
00184 int frequency() const;
00186 void setFrequency(int freq);
00187
00192 int duration() const;
00195 void setDuration(int duration);
00197 int durationTo(const QDateTime &) const;
00199 int durationTo( const QDate &date ) const { return durationTo( QDateTime( date, QTime( 23, 59, 59 ) ) ); }
00200
00204 QDateTime endDateTime() const;
00208 QDate endDate() const;
00212 void setEndDate( const QDate &endDate );
00215 void setEndDateTime( const QDateTime &endDateTime );
00216
00217
00218
00229 void setMinutely( int freq );
00230
00244 void setHourly( int freq );
00245
00259 void setDaily( int freq );
00260
00272 void setWeekly( int freq, int weekStart = 1 );
00285 void setWeekly( int freq, const QBitArray &days, int weekStart = 1 );
00289 void addWeeklyDays( const QBitArray &days );
00295 int weekStart() const;
00297 QBitArray days() const;
00298
00313 void setMonthly( int freq );
00321 void addMonthlyPos( short pos, const QBitArray &days );
00322 void addMonthlyPos( short pos, ushort day );
00327 void addMonthlyDate( short day );
00329 QValueList<RecurrenceRule::WDayPos> monthPositions() const;
00331
00332 QValueList<int> monthDays() const;
00333
00356 void setYearly( int freq );
00363 void addYearlyDay( int day );
00372 void addYearlyDate( int date );
00378 void addYearlyMonth( short _rNum );
00395 void addYearlyPos( short pos, const QBitArray &days );
00396
00402 QValueList<int> yearDays() const;
00410 QValueList<int> yearDates() const;
00419 QValueList<int> yearMonths() const;
00429 QValueList<RecurrenceRule::WDayPos> yearPositions() const;
00430
00432 static const QDate MAX_DATE;
00433
00437 void dump() const;
00438
00439
00440
00441 RecurrenceRule::List rRules() const;
00442 void addRRule( RecurrenceRule *rrule );
00443 void removeRRule( RecurrenceRule *rrule );
00444
00445 RecurrenceRule::List exRules() const;
00446 void addExRule( RecurrenceRule *exrule );
00447 void removeExRule( RecurrenceRule *exrule );
00448
00449
00450 DateTimeList rDateTimes() const;
00451 DateList rDates() const;
00452 void setRDateTimes( const DateTimeList &rdates);
00453 void setRDates( const DateList &rdates);
00454 void addRDateTime( const QDateTime &rdate );
00455 void addRDate( const QDate &rdate );
00456
00457
00458 DateTimeList exDateTimes() const;
00459 DateList exDates() const;
00460 void setExDateTimes( const DateTimeList &exdates);
00461 void setExDates( const DateList &exdates);
00462 void addExDateTime( const QDateTime &exdate );
00463 void addExDate( const QDate &exdate );
00464
00465 RecurrenceRule *defaultRRule( bool create = false ) const;
00466 RecurrenceRule *defaultRRuleConst() const;
00467 void updated();
00468
00476 void addObserver( Observer *observer );
00483 void removeObserver( Observer *observer );
00484
00485 void recurrenceChanged( RecurrenceRule * );
00486
00487 protected:
00488 RecurrenceRule *setNewRecurrenceType( RecurrenceRule::PeriodType type, int freq );
00489
00490 private:
00491 RecurrenceRule::List mExRules;
00492 RecurrenceRule::List mRRules;
00493 QValueList<QDateTime>mRDateTimes;
00494 QValueList<QDate> mRDates;
00495 QValueList<QDateTime> mExDateTimes;
00496 QValueList<QDate> mExDates;
00497
00498 QDateTime mStartDateTime;
00499 bool mFloating;
00500 bool mRecurReadOnly;
00501
00502
00503 mutable ushort mCachedType;
00504
00505 QValueList<Observer*> mObservers;
00506
00507 class Private;
00508 Private *d;
00509 };
00510
00511 }
00512
00513 #endif
|