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