00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KARECURRENCE_H
00022 #define KARECURRENCE_H
00023
00024 #include <libkcal/recurrence.h>
00025 class DateTime;
00026
00027
00028 class KARecurrence : public KCal::Recurrence
00029 {
00030 public:
00034 enum Type {
00035 NO_RECUR,
00036 MINUTELY,
00037 DAILY,
00038 WEEKLY,
00039 MONTHLY_POS,
00040 MONTHLY_DAY,
00041 ANNUAL_DATE,
00042 ANNUAL_POS
00043 };
00045 enum Feb29Type {
00046 FEB29_FEB29,
00047 FEB29_MAR1,
00048 FEB29_FEB28
00049 };
00050
00051 KARecurrence() : KCal::Recurrence(), mFeb29Type(FEB29_FEB29), mCachedType(-1) { }
00052 KARecurrence(const KCal::Recurrence& r) : KCal::Recurrence(r) { fix(); }
00053 KARecurrence(const KARecurrence& r) : KCal::Recurrence(r), mFeb29Type(r.mFeb29Type), mCachedType(r.mCachedType) { }
00054 bool set(const QString& icalRRULE);
00055 bool set(Type t, int freq, int count, const DateTime& start, const QDateTime& end)
00056 { return set(t, freq, count, -1, start, end); }
00057 bool set(Type t, int freq, int count, const DateTime& start, const QDateTime& end, Feb29Type f29)
00058 { return set(t, freq, count, f29, start, end); }
00059 bool init(KCal::RecurrenceRule::PeriodType t, int freq, int count, const DateTime& start, const QDateTime& end)
00060 { return init(t, freq, count, -1, start, end); }
00061 bool init(KCal::RecurrenceRule::PeriodType t, int freq, int count, const DateTime& start, const QDateTime& end, Feb29Type f29)
00062 { return init(t, freq, count, f29, start, end); }
00063 void fix();
00064 void writeRecurrence(KCal::Recurrence&) const;
00065 QDateTime endDateTime() const;
00066 QDate endDate() const;
00067 bool recursOn(const QDate&) const;
00068 QDateTime getNextDateTime(const QDateTime& preDateTime) const;
00069 QDateTime getPreviousDateTime(const QDateTime& afterDateTime) const;
00070 int longestInterval() const;
00071 Type type() const;
00072 static Type type(const KCal::RecurrenceRule*);
00073 static bool dailyType(const KCal::RecurrenceRule*);
00074 Feb29Type feb29Type() const { return mFeb29Type; }
00075 static Feb29Type defaultFeb29Type() { return mDefaultFeb29; }
00076 static void setDefaultFeb29Type(Feb29Type t) { mDefaultFeb29 = t; }
00077
00078 private:
00079 bool set(Type, int freq, int count, int feb29Type, const DateTime& start, const QDateTime& end);
00080 bool init(KCal::RecurrenceRule::PeriodType, int freq, int count, int feb29Type, const DateTime& start, const QDateTime& end);
00081 int combineDurations(const KCal::RecurrenceRule*, const KCal::RecurrenceRule*, QDate& end) const;
00082 int longestWeeklyInterval(const QBitArray& days, int frequency);
00083
00084 static Feb29Type mDefaultFeb29;
00085 Feb29Type mFeb29Type;
00086 mutable int mCachedType;
00087 };
00088
00089 #endif // KARECURRENCE_H