00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ORECUR_H
00031 #define ORECUR_H
00032
00033
00034 #include <qdatetime.h>
00035 #include <qvaluelist.h>
00036 #include <qmap.h>
00037
00038
00039 #include <sys/types.h>
00040
00041 namespace Opie {
00046 class OPimRecurrence {
00047
00048 public:
00049 typedef QValueList<QDate> ExceptionList;
00050 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
00051 MonthlyDate, Yearly };
00052 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
00053 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
00054 enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate,
00055 EndDate, Created, Exceptions };
00056
00057 OPimRecurrence();
00058 OPimRecurrence( const QMap<int, QString>& map );
00059 OPimRecurrence( const OPimRecurrence& );
00060 ~OPimRecurrence();
00061
00062 OPimRecurrence &operator=( const OPimRecurrence& );
00063 bool operator==(const OPimRecurrence& )const;
00064
00065 bool doesRecur()const;
00066
00067 bool doesRecur( const QDate& );
00068 RepeatType type()const;
00069 int frequency()const;
00070 int position()const;
00071 char days()const;
00072 bool hasEndDate()const;
00073 QDate start()const;
00074 QDate endDate()const;
00075 QDateTime createdDateTime()const;
00080 bool repeatOnWeekDay( int day )const;
00081
00085 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
00086
00090 QString service()const;
00091
00092
00093
00094
00095 ExceptionList &exceptions();
00096
00100 int repetition()const;
00101
00102 void setType( const RepeatType& );
00103 void setFrequency( int freq );
00104 void setPosition( int pos );
00105 void setDays( char c);
00106 void setEndDate( const QDate& dt );
00107 void setStart( const QDate& dt );
00108 void setCreatedDateTime( const QDateTime& );
00109 void setHasEndDate( bool b );
00110 void setRepitition(int );
00111
00112 void setService( const QString& ser );
00113
00114 QMap<int, QString> toMap() const;
00115 void fromMap( const QMap<int, QString>& map );
00116
00117
00118 QString toString()const;
00119
00120 private:
00121 bool p_nextOccurrence( const QDate& from, QDate& next );
00122 void deref();
00123 inline void checkOrModify();
00124
00125
00126 QString rTypeString() const;
00127
00128 QMap<QString, RepeatType> rTypeValueConvertMap() const;
00129
00130 class Data;
00131 Data* data;
00132 class OPimRecurrencePrivate;
00133 OPimRecurrencePrivate *d;
00134 };
00135
00136 }
00137 #endif