-rw-r--r-- | libopie2/opiepim/oevent.h | 165 |
1 files changed, 86 insertions, 79 deletions
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h index 9502efa..dc5e4d6 100644 --- a/libopie2/opiepim/oevent.h +++ b/libopie2/opiepim/oevent.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
@@ -27,23 +27,26 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | // CONTAINS GPLed code of TT | 29 | // CONTAINS GPLed code of TT |
30 | 30 | ||
31 | #ifndef OPIE_PIM_EVENT_H | 31 | #ifndef OEVENT_H |
32 | #define OPIE_PIM_EVENT_H | 32 | #define OEVENT_H |
33 | |||
34 | #include <qstring.h> | ||
35 | #include <qdatetime.h> | ||
36 | #include <qvaluelist.h> | ||
37 | 33 | ||
34 | /* OPIE */ | ||
35 | #include <opie2/otimezone.h> | ||
36 | #include <opie2/opimrecord.h> | ||
38 | #include <qpe/recordfields.h> | 37 | #include <qpe/recordfields.h> |
39 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
40 | 39 | ||
41 | #include <opie2/otimezone.h> | 40 | /* QT */ |
42 | #include <opie2/opimrecord.h> | 41 | #include <qstring.h> |
42 | #include <qdatetime.h> | ||
43 | #include <qvaluelist.h> | ||
43 | 44 | ||
44 | namespace Opie { | 45 | namespace Opie |
45 | struct OCalendarHelper { | 46 | { |
47 | struct OCalendarHelper | ||
48 | { | ||
46 | /** calculate the week number of the date */ | 49 | /** calculate the week number of the date */ |
47 | static int week( const QDate& ); | 50 | static int week( const QDate& ); |
48 | /** calculate the occurence of week days since the start of the month */ | 51 | /** calculate the occurence of week days since the start of the month */ |
49 | static int ocurrence( const QDate& ); | 52 | static int ocurrence( const QDate& ); |
@@ -64,10 +67,11 @@ class ORecur; | |||
64 | * This is the container for all Events. It encapsules all | 67 | * This is the container for all Events. It encapsules all |
65 | * available information for a single Event | 68 | * available information for a single Event |
66 | * @short container for events. | 69 | * @short container for events. |
67 | */ | 70 | */ |
68 | class OEvent : public OPimRecord { | 71 | class OEvent : public OPimRecord |
69 | public: | 72 | { |
73 | public: | ||
70 | typedef QValueList<OEvent> ValueList; | 74 | typedef QValueList<OEvent> ValueList; |
71 | /** | 75 | /** |
72 | * RecordFields contain possible attributes | 76 | * RecordFields contain possible attributes |
73 | * used in the Results of toMap().. | 77 | * used in the Results of toMap().. |
@@ -76,31 +80,31 @@ public: | |||
76 | FUid = Qtopia::UID_ID, | 80 | FUid = Qtopia::UID_ID, |
77 | FCategories = Qtopia::CATEGORY_ID, | 81 | FCategories = Qtopia::CATEGORY_ID, |
78 | FDescription = 0, | 82 | FDescription = 0, |
79 | FLocation, | 83 | FLocation, |
80 | FType, | 84 | FType, |
81 | FAlarm, | 85 | FAlarm, |
82 | FSound, | 86 | FSound, |
83 | FRType, | 87 | FRType, |
84 | FRWeekdays, | 88 | FRWeekdays, |
85 | FRPosition, | 89 | FRPosition, |
86 | FRFreq, | 90 | FRFreq, |
87 | FRHasEndDate, | 91 | FRHasEndDate, |
88 | FREndDate, | 92 | FREndDate, |
89 | FRCreated, | 93 | FRCreated, |
90 | FRExceptions, | 94 | FRExceptions, |
91 | FStart, | 95 | FStart, |
92 | FEnd, | 96 | FEnd, |
93 | FNote, | 97 | FNote, |
94 | FTimeZone, | 98 | FTimeZone, |
95 | FRecParent, | 99 | FRecParent, |
96 | FRecChildren, | 100 | FRecChildren, |
97 | }; | 101 | }; |
98 | 102 | ||
99 | /** | 103 | /** |
100 | * Start with an Empty OEvent. UID == 0 means that it is empty | 104 | * Start with an Empty OEvent. UID == 0 means that it is empty |
101 | */ | 105 | */ |
102 | OEvent(int uid = 0); | 106 | OEvent( int uid = 0 ); |
103 | 107 | ||
104 | /** | 108 | /** |
105 | * copy c'tor | 109 | * copy c'tor |
106 | */ | 110 | */ |
@@ -113,86 +117,87 @@ public: | |||
113 | OEvent( const QMap<int, QString> map ); | 117 | OEvent( const QMap<int, QString> map ); |
114 | ~OEvent(); | 118 | ~OEvent(); |
115 | OEvent &operator=( const OEvent& ); | 119 | OEvent &operator=( const OEvent& ); |
116 | 120 | ||
117 | QString description()const; | 121 | QString description() const; |
118 | void setDescription( const QString& description ); | 122 | void setDescription( const QString& description ); |
119 | 123 | ||
120 | QString location()const; | 124 | QString location() const; |
121 | void setLocation( const QString& loc ); | 125 | void setLocation( const QString& loc ); |
122 | 126 | ||
123 | bool hasNotifiers()const; | 127 | bool hasNotifiers() const; |
124 | OPimNotifyManager ¬ifiers()const; | 128 | OPimNotifyManager ¬ifiers() const; |
125 | 129 | ||
126 | ORecur recurrence()const; | 130 | ORecur recurrence() const; |
127 | void setRecurrence( const ORecur& ); | 131 | void setRecurrence( const ORecur& ); |
128 | bool hasRecurrence()const; | 132 | bool hasRecurrence() const; |
129 | 133 | ||
130 | QString note()const; | 134 | QString note() const; |
131 | void setNote( const QString& note ); | 135 | void setNote( const QString& note ); |
132 | 136 | ||
133 | 137 | ||
134 | QDateTime createdDateTime()const; | 138 | QDateTime createdDateTime() const; |
135 | void setCreatedDateTime( const QDateTime& dt); | 139 | void setCreatedDateTime( const QDateTime& dt ); |
136 | 140 | ||
137 | /** set the date to dt. dt is the QDateTime in localtime */ | 141 | /** set the date to dt. dt is the QDateTime in localtime */ |
138 | void setStartDateTime( const QDateTime& ); | 142 | void setStartDateTime( const QDateTime& ); |
139 | /** returns the datetime in the local timeZone */ | 143 | /** returns the datetime in the local timeZone */ |
140 | QDateTime startDateTime()const; | 144 | QDateTime startDateTime() const; |
141 | 145 | ||
142 | /** returns the start datetime in the current zone */ | 146 | /** returns the start datetime in the current zone */ |
143 | QDateTime startDateTimeInZone()const; | 147 | QDateTime startDateTimeInZone() const; |
144 | 148 | ||
145 | /** in current timezone */ | 149 | /** in current timezone */ |
146 | void setEndDateTime( const QDateTime& ); | 150 | void setEndDateTime( const QDateTime& ); |
147 | /** in current timezone */ | 151 | /** in current timezone */ |
148 | QDateTime endDateTime()const; | 152 | QDateTime endDateTime() const; |
149 | QDateTime endDateTimeInZone()const; | 153 | QDateTime endDateTimeInZone() const; |
150 | 154 | ||
151 | bool isMultipleDay()const; | 155 | bool isMultipleDay() const; |
152 | bool isAllDay()const; | 156 | bool isAllDay() const; |
153 | void setAllDay( bool isAllDay ); | 157 | void setAllDay( bool isAllDay ); |
154 | 158 | ||
155 | /* pin this event to a timezone! FIXME */ | 159 | /* pin this event to a timezone! FIXME */ |
156 | void setTimeZone( const QString& timeZone ); | 160 | void setTimeZone( const QString& timeZone ); |
157 | QString timeZone()const; | 161 | QString timeZone() const; |
158 | 162 | ||
159 | 163 | ||
160 | virtual bool match( const QRegExp& )const; | 164 | virtual bool match( const QRegExp& ) const; |
161 | 165 | ||
162 | /** For exception to recurrence here is a list of children... */ | 166 | /** For exception to recurrence here is a list of children... */ |
163 | QArray<int> children()const; | 167 | QArray<int> children() const; |
164 | void setChildren( const QArray<int>& ); | 168 | void setChildren( const QArray<int>& ); |
165 | void addChild( int uid ); | 169 | void addChild( int uid ); |
166 | void removeChild( int uid ); | 170 | void removeChild( int uid ); |
167 | 171 | ||
168 | /** return the parent OEvent */ | 172 | /** return the parent OEvent */ |
169 | int parent()const; | 173 | int parent() const; |
170 | void setParent( int uid ); | 174 | void setParent( int uid ); |
171 | 175 | ||
172 | 176 | ||
173 | /* needed reimp */ | 177 | /* needed reimp */ |
174 | QString toRichText()const; | 178 | QString toRichText() const; |
175 | QString toShortText()const; | 179 | QString toShortText() const; |
176 | QString type()const; | 180 | QString type() const; |
177 | 181 | ||
178 | QMap<int, QString> toMap()const; | 182 | QMap<int, QString> toMap() const; |
179 | void fromMap( const QMap<int, QString>& map ); | 183 | void fromMap( const QMap<int, QString>& map ); |
180 | QString recordField(int )const; | 184 | QString recordField( int ) const; |
181 | 185 | ||
182 | static int rtti(); | 186 | static int rtti(); |
183 | 187 | ||
184 | bool loadFromStream( QDataStream& ); | 188 | bool loadFromStream( QDataStream& ); |
185 | bool saveToStream( QDataStream& )const; | 189 | bool saveToStream( QDataStream& ) const; |
186 | 190 | ||
187 | /* bool operator==( const OEvent& ); | 191 | /* bool operator==( const OEvent& ); |
188 | bool operator!=( const OEvent& ); | 192 | bool operator!=( const OEvent& ); |
189 | bool operator<( const OEvent& ); | 193 | bool operator<( const OEvent& ); |
190 | bool operator<=( const OEvent& ); | 194 | bool operator<=( const OEvent& ); |
191 | bool operator>( const OEvent& ); | 195 | bool operator>( const OEvent& ); |
192 | bool operator>=(const OEvent& ); | 196 | bool operator>=(const OEvent& ); |
193 | */ | 197 | */ |
194 | private: | 198 | |
199 | private: | ||
195 | inline void changeOrModify(); | 200 | inline void changeOrModify(); |
196 | void deref(); | 201 | void deref(); |
197 | struct Data; | 202 | struct Data; |
198 | Data* data; | 203 | Data* data; |
@@ -203,13 +208,15 @@ private: | |||
203 | 208 | ||
204 | /** | 209 | /** |
205 | * AN Event can span through multiple days. We split up a multiday eve | 210 | * AN Event can span through multiple days. We split up a multiday eve |
206 | */ | 211 | */ |
207 | class OEffectiveEvent { | 212 | class OEffectiveEvent |
208 | public: | 213 | { |
214 | |||
215 | public: | ||
209 | typedef QValueList<OEffectiveEvent> ValueList; | 216 | typedef QValueList<OEffectiveEvent> ValueList; |
210 | enum Position { MidWay, Start, End, StartEnd }; | 217 | enum Position { MidWay, Start, End, StartEnd }; |
211 | // If we calculate the effective event of a multi-day event | 218 | // If we calculate the effective event of a multi-day event |
212 | // we have to figure out whether we are at the first day, | 219 | // we have to figure out whether we are at the first day, |
213 | // at the end, or anywhere else ("middle"). This is important | 220 | // at the end, or anywhere else ("middle"). This is important |
214 | // for the start/end times (00:00/23:59) | 221 | // for the start/end times (00:00/23:59) |
215 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 222 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
@@ -220,9 +227,9 @@ public: | |||
220 | // here we draw start time -> end time | 227 | // here we draw start time -> end time |
221 | OEffectiveEvent(); | 228 | OEffectiveEvent(); |
222 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | 229 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); |
223 | OEffectiveEvent( const OEffectiveEvent& ); | 230 | OEffectiveEvent( const OEffectiveEvent& ); |
224 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | 231 | OEffectiveEvent &operator=( const OEffectiveEvent& ); |
225 | ~OEffectiveEvent(); | 232 | ~OEffectiveEvent(); |
226 | 233 | ||
227 | void setStartTime( const QTime& ); | 234 | void setStartTime( const QTime& ); |
228 | void setEndTime( const QTime& ); | 235 | void setEndTime( const QTime& ); |
@@ -230,31 +237,31 @@ public: | |||
230 | void setDate( const QDate& ); | 237 | void setDate( const QDate& ); |
231 | 238 | ||
232 | void setEffectiveDates( const QDate& from, const QDate& to ); | 239 | void setEffectiveDates( const QDate& from, const QDate& to ); |
233 | 240 | ||
234 | QString description()const; | 241 | QString description() const; |
235 | QString location()const; | 242 | QString location() const; |
236 | QString note()const; | 243 | QString note() const; |
237 | OEvent event()const; | 244 | OEvent event() const; |
238 | QTime startTime()const; | 245 | QTime startTime() const; |
239 | QTime endTime()const; | 246 | QTime endTime() const; |
240 | QDate date()const; | 247 | QDate date() const; |
241 | 248 | ||
242 | /* return the length in hours */ | 249 | /* return the length in hours */ |
243 | int length()const; | 250 | int length() const; |
244 | int size()const; | 251 | int size() const; |
245 | 252 | ||
246 | QDate startDate()const; | 253 | QDate startDate() const; |
247 | QDate endDate()const; | 254 | QDate endDate() const; |
248 | 255 | ||
249 | bool operator<( const OEffectiveEvent &e ) const; | 256 | bool operator<( const OEffectiveEvent &e ) const; |
250 | bool operator<=( const OEffectiveEvent &e ) const; | 257 | bool operator<=( const OEffectiveEvent &e ) const; |
251 | bool operator==( const OEffectiveEvent &e ) const; | 258 | bool operator==( const OEffectiveEvent &e ) const; |
252 | bool operator!=( const OEffectiveEvent &e ) const; | 259 | bool operator!=( const OEffectiveEvent &e ) const; |
253 | bool operator>( const OEffectiveEvent &e ) const; | 260 | bool operator>( const OEffectiveEvent &e ) const; |
254 | bool operator>= ( const OEffectiveEvent &e ) const; | 261 | bool operator>= ( const OEffectiveEvent &e ) const; |
255 | 262 | ||
256 | private: | 263 | private: |
257 | void deref(); | 264 | void deref(); |
258 | inline void changeOrModify(); | 265 | inline void changeOrModify(); |
259 | class Private; | 266 | class Private; |
260 | Private* priv; | 267 | Private* priv; |