Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

opimrecurrence.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003                              Copyright (C) The Main Author <main-author@whereever.org>
00004               =.             Copyright (C) The Opie Team <opie-devel@handhelds.org>
00005             .=l.
00006            .>+-=
00007  _;:,     .>    :=|.         This program is free software; you can
00008 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00009 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00010 .="- .-=="i,     .._         License as published by the Free Software
00011  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00012      ._= =}       :          or (at your option) any later version.
00013     .%`+i>       _;_.
00014     .i_,=:_.      -<s.       This program is distributed in the hope that
00015      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00016     : ..    .:,     . . .    without even the implied warranty of
00017     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00018   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00019 ..}^=.=       =       ;      Library General Public License for more
00020 ++=   -.     .`     .:       details.
00021  :     =  ...= . :.=-
00022  -.   .:....=;==+<;          You should have received a copy of the GNU
00023   -_. . .   )=.  =           Library General Public License along with
00024     --        :-=`           this library; see the file COPYING.LIB.
00025                              If not, write to the Free Software Foundation,
00026                              Inc., 59 Temple Place - Suite 330,
00027                              Boston, MA 02111-1307, USA.
00028 */
00029 
00030 #ifndef ORECUR_H
00031 #define ORECUR_H
00032 
00033 /* QT */
00034 #include <qdatetime.h>
00035 #include <qvaluelist.h>
00036 #include <qmap.h>
00037 
00038 /* STD */
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     /* if it recurrs on that day */
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      * reference to the exception list
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     /* almost internal */
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     /* Converts rType to String */
00126     QString rTypeString() const;
00127     /* Returns a map to convert Stringname for RType to RepeatType */
00128     QMap<QString, RepeatType> rTypeValueConvertMap() const;
00129 
00130     class Data;
00131     Data* data;
00132     class OPimRecurrencePrivate;
00133     OPimRecurrencePrivate *d;
00134 };
00135 
00136 }
00137 #endif

Generated on Sat Nov 5 16:16:21 2005 for OPIE by  doxygen 1.4.2