Diffstat (limited to 'noncore/unsupported/libopie/pim/oevent.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/libopie/pim/oevent.h | 236 |
1 files changed, 236 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/oevent.h b/noncore/unsupported/libopie/pim/oevent.h new file mode 100644 index 0000000..9eb948f --- a/dev/null +++ b/noncore/unsupported/libopie/pim/oevent.h | |||
@@ -0,0 +1,236 @@ | |||
1 | // CONTAINS GPLed code of TT | ||
2 | |||
3 | #ifndef OPIE_PIM_EVENT_H | ||
4 | #define OPIE_PIM_EVENT_H | ||
5 | |||
6 | #include <qstring.h> | ||
7 | #include <qdatetime.h> | ||
8 | #include <qvaluelist.h> | ||
9 | |||
10 | #include <qpe/recordfields.h> | ||
11 | #include <qpe/palmtopuidgen.h> | ||
12 | |||
13 | #include "otimezone.h" | ||
14 | #include "opimrecord.h" | ||
15 | |||
16 | struct OCalendarHelper { | ||
17 | /** calculate the week number of the date */ | ||
18 | static int week( const QDate& ); | ||
19 | /** calculate the occurence of week days since the start of the month */ | ||
20 | static int ocurrence( const QDate& ); | ||
21 | |||
22 | // returns the dayOfWeek for the *first* day it finds (ignores | ||
23 | // any further days!). Returns 1 (Monday) if there isn't any day found | ||
24 | static int dayOfWeek( char day ); | ||
25 | |||
26 | /** returns the diff of month */ | ||
27 | static int monthDiff( const QDate& first, const QDate& second ); | ||
28 | |||
29 | }; | ||
30 | |||
31 | class OPimNotifyManager; | ||
32 | class ORecur; | ||
33 | |||
34 | /** | ||
35 | * This is the container for all Events. It encapsules all | ||
36 | * available information for a single Event | ||
37 | * @short container for events. | ||
38 | */ | ||
39 | class OEvent : public OPimRecord { | ||
40 | public: | ||
41 | typedef QValueList<OEvent> ValueList; | ||
42 | /** | ||
43 | * RecordFields contain possible attributes | ||
44 | * used in the Results of toMap().. | ||
45 | */ | ||
46 | enum RecordFields { | ||
47 | FUid = Qtopia::UID_ID, | ||
48 | FCategories = Qtopia::CATEGORY_ID, | ||
49 | FDescription = 0, | ||
50 | FLocation, | ||
51 | FType, | ||
52 | FAlarm, | ||
53 | FSound, | ||
54 | FRType, | ||
55 | FRWeekdays, | ||
56 | FRPosition, | ||
57 | FRFreq, | ||
58 | FRHasEndDate, | ||
59 | FREndDate, | ||
60 | FRCreated, | ||
61 | FRExceptions, | ||
62 | FStart, | ||
63 | FEnd, | ||
64 | FNote, | ||
65 | FTimeZone, | ||
66 | FRecParent, | ||
67 | FRecChildren, | ||
68 | }; | ||
69 | |||
70 | /** | ||
71 | * Start with an Empty OEvent. UID == 0 means that it is empty | ||
72 | */ | ||
73 | OEvent(int uid = 0); | ||
74 | |||
75 | /** | ||
76 | * copy c'tor | ||
77 | */ | ||
78 | OEvent( const OEvent& ); | ||
79 | |||
80 | /** | ||
81 | * Create OEvent, initialized by map | ||
82 | * @see enum RecordFields | ||
83 | */ | ||
84 | OEvent( const QMap<int, QString> map ); | ||
85 | ~OEvent(); | ||
86 | OEvent &operator=( const OEvent& ); | ||
87 | |||
88 | QString description()const; | ||
89 | void setDescription( const QString& description ); | ||
90 | |||
91 | QString location()const; | ||
92 | void setLocation( const QString& loc ); | ||
93 | |||
94 | bool hasNotifiers()const; | ||
95 | OPimNotifyManager ¬ifiers()const; | ||
96 | |||
97 | ORecur recurrence()const; | ||
98 | void setRecurrence( const ORecur& ); | ||
99 | bool hasRecurrence()const; | ||
100 | |||
101 | QString note()const; | ||
102 | void setNote( const QString& note ); | ||
103 | |||
104 | |||
105 | QDateTime createdDateTime()const; | ||
106 | void setCreatedDateTime( const QDateTime& dt); | ||
107 | |||
108 | /** set the date to dt. dt is the QDateTime in localtime */ | ||
109 | void setStartDateTime( const QDateTime& ); | ||
110 | /** returns the datetime in the local timeZone */ | ||
111 | QDateTime startDateTime()const; | ||
112 | |||
113 | /** returns the start datetime in the current zone */ | ||
114 | QDateTime startDateTimeInZone()const; | ||
115 | |||
116 | /** in current timezone */ | ||
117 | void setEndDateTime( const QDateTime& ); | ||
118 | /** in current timezone */ | ||
119 | QDateTime endDateTime()const; | ||
120 | QDateTime endDateTimeInZone()const; | ||
121 | |||
122 | bool isMultipleDay()const; | ||
123 | bool isAllDay()const; | ||
124 | void setAllDay( bool isAllDay ); | ||
125 | |||
126 | /* pin this event to a timezone! FIXME */ | ||
127 | void setTimeZone( const QString& timeZone ); | ||
128 | QString timeZone()const; | ||
129 | |||
130 | |||
131 | virtual bool match( const QRegExp& )const; | ||
132 | |||
133 | /** For exception to recurrence here is a list of children... */ | ||
134 | QArray<int> children()const; | ||
135 | void setChildren( const QArray<int>& ); | ||
136 | void addChild( int uid ); | ||
137 | void removeChild( int uid ); | ||
138 | |||
139 | /** return the parent OEvent */ | ||
140 | int parent()const; | ||
141 | void setParent( int uid ); | ||
142 | |||
143 | |||
144 | /* needed reimp */ | ||
145 | QString toRichText()const; | ||
146 | QString toShortText()const; | ||
147 | QString type()const; | ||
148 | |||
149 | QMap<int, QString> toMap()const; | ||
150 | void fromMap( const QMap<int, QString>& map ); | ||
151 | QString recordField(int )const; | ||
152 | |||
153 | static int rtti(); | ||
154 | |||
155 | bool loadFromStream( QDataStream& ); | ||
156 | bool saveToStream( QDataStream& )const; | ||
157 | |||
158 | /* bool operator==( const OEvent& ); | ||
159 | bool operator!=( const OEvent& ); | ||
160 | bool operator<( const OEvent& ); | ||
161 | bool operator<=( const OEvent& ); | ||
162 | bool operator>( const OEvent& ); | ||
163 | bool operator>=(const OEvent& ); | ||
164 | */ | ||
165 | private: | ||
166 | inline void changeOrModify(); | ||
167 | void deref(); | ||
168 | struct Data; | ||
169 | Data* data; | ||
170 | class Private; | ||
171 | Private* priv; | ||
172 | |||
173 | }; | ||
174 | |||
175 | /** | ||
176 | * AN Event can span through multiple days. We split up a multiday eve | ||
177 | */ | ||
178 | class OEffectiveEvent { | ||
179 | public: | ||
180 | typedef QValueList<OEffectiveEvent> ValueList; | ||
181 | enum Position { MidWay, Start, End, StartEnd }; | ||
182 | // If we calculate the effective event of a multi-day event | ||
183 | // we have to figure out whether we are at the first day, | ||
184 | // at the end, or anywhere else ("middle"). This is important | ||
185 | // for the start/end times (00:00/23:59) | ||
186 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | ||
187 | // day event | ||
188 | // Start: start time -> 23:59 | ||
189 | // End: 00:00 -> end time | ||
190 | // Start | End == StartEnd: for single-day events (default) | ||
191 | // here we draw start time -> end time | ||
192 | OEffectiveEvent(); | ||
193 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | ||
194 | OEffectiveEvent( const OEffectiveEvent& ); | ||
195 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | ||
196 | ~OEffectiveEvent(); | ||
197 | |||
198 | void setStartTime( const QTime& ); | ||
199 | void setEndTime( const QTime& ); | ||
200 | void setEvent( const OEvent& ); | ||
201 | void setDate( const QDate& ); | ||
202 | |||
203 | void setEffectiveDates( const QDate& from, const QDate& to ); | ||
204 | |||
205 | QString description()const; | ||
206 | QString location()const; | ||
207 | QString note()const; | ||
208 | OEvent event()const; | ||
209 | QTime startTime()const; | ||
210 | QTime endTime()const; | ||
211 | QDate date()const; | ||
212 | |||
213 | /* return the length in hours */ | ||
214 | int length()const; | ||
215 | int size()const; | ||
216 | |||
217 | QDate startDate()const; | ||
218 | QDate endDate()const; | ||
219 | |||
220 | bool operator<( const OEffectiveEvent &e ) const; | ||
221 | bool operator<=( const OEffectiveEvent &e ) const; | ||
222 | bool operator==( const OEffectiveEvent &e ) const; | ||
223 | bool operator!=( const OEffectiveEvent &e ) const; | ||
224 | bool operator>( const OEffectiveEvent &e ) const; | ||
225 | bool operator>= ( const OEffectiveEvent &e ) const; | ||
226 | |||
227 | private: | ||
228 | void deref(); | ||
229 | inline void changeOrModify(); | ||
230 | class Private; | ||
231 | Private* priv; | ||
232 | struct Data; | ||
233 | Data* data; | ||
234 | |||
235 | }; | ||
236 | #endif | ||