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 <kcal/recurrence.h>
00025 #include <kcal/duration.h>
00026
00027 #include "preferences.h"
00028 class DateTime;
00029
00030
00031 class KARecurrence : public KCal::Recurrence
00032 {
00033 public:
00037 enum Type {
00038 NO_RECUR,
00039 MINUTELY,
00040 DAILY,
00041 WEEKLY,
00042 MONTHLY_POS,
00043 MONTHLY_DAY,
00044 ANNUAL_DATE,
00045 ANNUAL_POS
00046 };
00047
00048 KARecurrence() : KCal::Recurrence(), mFeb29Type(Preferences::Feb29_None), mCachedType(-1) { }
00049 KARecurrence(const KCal::Recurrence& r) : KCal::Recurrence(r) { fix(); }
00050 KARecurrence(const KARecurrence& r) : KCal::Recurrence(r), mFeb29Type(r.mFeb29Type), mCachedType(r.mCachedType) { }
00051 bool set(const QString& icalRRULE);
00052 bool set(Type t, int freq, int count, const KDateTime& start, const KDateTime& end)
00053 { return set(t, freq, count, -1, start, end); }
00054 bool set(Type t, int freq, int count, const KDateTime& start, const KDateTime& end, Preferences::Feb29Type f29)
00055 { return set(t, freq, count, f29, start, end); }
00056 bool init(KCal::RecurrenceRule::PeriodType t, int freq, int count, const KDateTime& start, const KDateTime& end)
00057 { return init(t, freq, count, -1, start, end); }
00058 bool init(KCal::RecurrenceRule::PeriodType t, int freq, int count, const KDateTime& start, const KDateTime& end, Preferences::Feb29Type f29)
00059 { return init(t, freq, count, f29, start, end); }
00060 void fix();
00061 void writeRecurrence(KCal::Recurrence&) const;
00062 KDateTime endDateTime() const;
00063 QDate endDate() const;
00064 bool recursOn(const QDate&, const KDateTime::Spec&) const;
00065 KDateTime getNextDateTime(const KDateTime& preDateTime) const;
00066 KDateTime getPreviousDateTime(const KDateTime& afterDateTime) const;
00067 KCal::Duration longestInterval() const;
00068 KCal::Duration regularInterval() const;
00069 Type type() const;
00070 static Type type(const KCal::RecurrenceRule*);
00071 static bool dailyType(const KCal::RecurrenceRule*);
00072 Preferences::Feb29Type feb29Type() const { return mFeb29Type; }
00073 static Preferences::Feb29Type defaultFeb29Type() { return mDefaultFeb29; }
00074 static void setDefaultFeb29Type(Preferences::Feb29Type t) { mDefaultFeb29 = t; }
00075
00076 private:
00077 bool set(Type, int freq, int count, int feb29Type, const KDateTime& start, const KDateTime& end);
00078 bool init(KCal::RecurrenceRule::PeriodType, int freq, int count, int feb29Type, const KDateTime& start, const KDateTime& end);
00079 int combineDurations(const KCal::RecurrenceRule*, const KCal::RecurrenceRule*, QDate& end) const;
00080 int longestWeeklyInterval(const QBitArray& days, int frequency);
00081
00082 static Preferences::Feb29Type mDefaultFeb29;
00083 Preferences::Feb29Type mFeb29Type;
00084 mutable int mCachedType;
00085 };
00086
00087 #endif // KARECURRENCE_H