summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimrecurrence.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimrecurrence.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecurrence.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimrecurrence.h b/libopie2/opiepim/core/opimrecurrence.h
new file mode 100644
index 0000000..f186cfe
--- a/dev/null
+++ b/libopie2/opiepim/core/opimrecurrence.h
@@ -0,0 +1,137 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ORECUR_H
31#define ORECUR_H
32
33/* QT */
34#include <qdatetime.h>
35#include <qvaluelist.h>
36#include <qmap.h>
37
38/* STD */
39#include <sys/types.h>
40
41namespace Opie {
42/**
43 * Class to handle Recurrencies..
44 */
45
46class OPimRecurrence {
47
48 public:
49 typedef QValueList<QDate> ExceptionList;
50 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
51 MonthlyDate, Yearly };
52 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
53 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
54 enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate,
55 EndDate, Created, Exceptions };
56
57 OPimRecurrence();
58 OPimRecurrence( const QMap<int, QString>& map );
59 OPimRecurrence( const OPimRecurrence& );
60 ~OPimRecurrence();
61
62 OPimRecurrence &operator=( const OPimRecurrence& );
63 bool operator==(const OPimRecurrence& )const;
64
65 bool doesRecur()const;
66 /* if it recurrs on that day */
67 bool doesRecur( const QDate& );
68 RepeatType type()const;
69 int frequency()const;
70 int position()const;
71 char days()const;
72 bool hasEndDate()const;
73 QDate start()const;
74 QDate endDate()const;
75 QDateTime createdDateTime()const;
76 /**
77 * starting on monday=0, sunday=6
78 * for convience
79 */
80 bool repeatOnWeekDay( int day )const;
81
82 /**
83 * FromWhereToStart is not included!!!
84 */
85 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
86
87 /**
88 * The module this OPimRecurrence belongs to
89 */
90 QString service()const;
91
92 /*
93 * reference to the exception list
94 */
95 ExceptionList &exceptions();
96
97 /**
98 * the current repetition
99 */
100 int repetition()const;
101
102 void setType( const RepeatType& );
103 void setFrequency( int freq );
104 void setPosition( int pos );
105 void setDays( char c);
106 void setEndDate( const QDate& dt );
107 void setStart( const QDate& dt );
108 void setCreatedDateTime( const QDateTime& );
109 void setHasEndDate( bool b );
110 void setRepitition(int );
111
112 void setService( const QString& ser );
113
114 QMap<int, QString> toMap() const;
115 void fromMap( const QMap<int, QString>& map );
116
117 /* almost internal */
118 QString toString()const;
119
120 private:
121 bool p_nextOccurrence( const QDate& from, QDate& next );
122 void deref();
123 inline void checkOrModify();
124
125 /* Converts rType to String */
126 QString rTypeString() const;
127 /* Returns a map to convert Stringname for RType to RepeatType */
128 QMap<QString, RepeatType> rTypeValueConvertMap() const;
129
130 class Data;
131 Data* data;
132 class OPimRecurrencePrivate;
133 OPimRecurrencePrivate *d;
134};
135
136}
137#endif