summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-10 13:11:25 (UTC)
committer zecke <zecke>2002-09-10 13:11:25 (UTC)
commita73774e8ab1d14c76f17c854c6b6cdf801abfe82 (patch) (unidiff)
tree27b0ddb41a40133bfaad34781ce69890615e4acc
parent8064c0e86eed8a48c2c7745195bf991b1d83f504 (diff)
downloadopie-a73774e8ab1d14c76f17c854c6b6cdf801abfe82.zip
opie-a73774e8ab1d14c76f17c854c6b6cdf801abfe82.tar.gz
opie-a73774e8ab1d14c76f17c854c6b6cdf801abfe82.tar.bz2
Fix inline for Event::start
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/event.cpp9
-rw-r--r--library/backend/event.h8
2 files changed, 11 insertions, 6 deletions
diff --git a/library/backend/event.cpp b/library/backend/event.cpp
index 7110717..8f3f780 100644
--- a/library/backend/event.cpp
+++ b/library/backend/event.cpp
@@ -1,1315 +1,1320 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "event.h" 21#include "event.h"
22#include "qfiledirect_p.h" 22#include "qfiledirect_p.h"
23#include <qtopia/timeconversion.h> 23#include <qtopia/timeconversion.h>
24#include <qtopia/stringutil.h> 24#include <qtopia/stringutil.h>
25#include <qtopia/private/recordfields.h> 25#include <qtopia/private/recordfields.h>
26#include <qbuffer.h> 26#include <qbuffer.h>
27#include <time.h> 27#include <time.h>
28#include "vobject_p.h" 28#include "vobject_p.h"
29 29
30#include <stdio.h> 30#include <stdio.h>
31 31
32using namespace Qtopia; 32using namespace Qtopia;
33 33
34static void write( QString& buf, const Event::RepeatPattern &r ) 34static void write( QString& buf, const Event::RepeatPattern &r )
35{ 35{
36 buf += " rtype=\""; 36 buf += " rtype=\"";
37 switch ( r.type ) { 37 switch ( r.type ) {
38 case Event::Daily: 38 case Event::Daily:
39 buf += "Daily"; 39 buf += "Daily";
40 break; 40 break;
41 case Event::Weekly: 41 case Event::Weekly:
42 buf += "Weekly"; 42 buf += "Weekly";
43 break; 43 break;
44 case Event::MonthlyDay: 44 case Event::MonthlyDay:
45 buf += "MonthlyDay"; 45 buf += "MonthlyDay";
46 break; 46 break;
47 case Event::MonthlyDate: 47 case Event::MonthlyDate:
48 buf += "MonthlyDate"; 48 buf += "MonthlyDate";
49 break; 49 break;
50 case Event::Yearly: 50 case Event::Yearly:
51 buf += "Yearly"; 51 buf += "Yearly";
52 break; 52 break;
53 default: 53 default:
54 buf += "NoRepeat"; 54 buf += "NoRepeat";
55 break; 55 break;
56 } 56 }
57 buf += "\""; 57 buf += "\"";
58 if ( r.days > 0 ) 58 if ( r.days > 0 )
59 buf += " rweekdays=\"" + QString::number( static_cast<int>( r.days ) ) + "\""; 59 buf += " rweekdays=\"" + QString::number( static_cast<int>( r.days ) ) + "\"";
60 if ( r.position != 0 ) 60 if ( r.position != 0 )
61 buf += " rposition=\"" + QString::number( r.position ) + "\""; 61 buf += " rposition=\"" + QString::number( r.position ) + "\"";
62 62
63 buf += " rfreq=\"" + QString::number( r.frequency ) + "\""; 63 buf += " rfreq=\"" + QString::number( r.frequency ) + "\"";
64 buf += " rhasenddate=\"" + QString::number( static_cast<int>( r.hasEndDate ) ) + "\""; 64 buf += " rhasenddate=\"" + QString::number( static_cast<int>( r.hasEndDate ) ) + "\"";
65 if ( r.hasEndDate ) 65 if ( r.hasEndDate )
66 buf += " enddt=\"" 66 buf += " enddt=\""
67 + QString::number( r.endDateUTC ? r.endDateUTC : time( 0 ) ) 67 + QString::number( r.endDateUTC ? r.endDateUTC : time( 0 ) )
68 + "\""; 68 + "\"";
69 buf += " created=\"" + QString::number( r.createTime ) + "\""; 69 buf += " created=\"" + QString::number( r.createTime ) + "\"";
70} 70}
71 71
72Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); 72Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia );
73 73
74/*! 74/*!
75 \class Event event.h 75 \class Event event.h
76 \brief The Event class holds the data of a calendar event. 76 \brief The Event class holds the data of a calendar event.
77 77
78 This data includes descriptive data of the event and schedualing information. 78 This data includes descriptive data of the event and schedualing information.
79 79
80 \ingroup qtopiaemb 80 \ingroup qtopiaemb
81 \ingroup qtopiadesktop 81 \ingroup qtopiadesktop
82*/ 82*/
83 83
84/*! 84/*!
85 \class Event::RepeatPattern 85 \class Event::RepeatPattern
86 \class The Event::RepeatPattern class is internal. 86 \class The Event::RepeatPattern class is internal.
87 \internal 87 \internal
88*/ 88*/
89 89
90/*! 90/*!
91 \enum Event::Days 91 \enum Event::Days
92 \internal 92 \internal
93*/ 93*/
94 94
95/*! 95/*!
96 \enum Event::Type 96 \enum Event::Type
97 \internal 97 \internal
98*/ 98*/
99 99
100/*! 100/*!
101 \enum Event::SoundTypeChoice 101 \enum Event::SoundTypeChoice
102 102
103 This enum type defines what kind of sound is made when an alarm occurs 103 This enum type defines what kind of sound is made when an alarm occurs
104 for an event. The currently defined types are: 104 for an event. The currently defined types are:
105 105
106 <ul> 106 <ul>
107 <li>\c Silent - No sound is produced. 107 <li>\c Silent - No sound is produced.
108 <li>\c Loud - A loud sound is produced. 108 <li>\c Loud - A loud sound is produced.
109 </ul> 109 </ul>
110*/ 110*/
111 111
112/*! 112/*!
113 \fn bool Event::operator<( const Event & ) const 113 \fn bool Event::operator<( const Event & ) const
114 \internal 114 \internal
115*/ 115*/
116 116
117/*! 117/*!
118 \fn bool Event::operator<=( const Event & ) const 118 \fn bool Event::operator<=( const Event & ) const
119 \internal 119 \internal
120*/ 120*/
121 121
122/*! 122/*!
123 \fn bool Event::operator!=( const Event & ) const 123 \fn bool Event::operator!=( const Event & ) const
124 \internal 124 \internal
125*/ 125*/
126 126
127/*! 127/*!
128 \fn bool Event::operator>( const Event & ) const 128 \fn bool Event::operator>( const Event & ) const
129 \internal 129 \internal
130*/ 130*/
131 131
132/*! 132/*!
133 \fn bool Event::operator>=( const Event & ) const 133 \fn bool Event::operator>=( const Event & ) const
134 \internal 134 \internal
135*/ 135*/
136 136
137/*! 137/*!
138 \enum Event::RepeatType 138 \enum Event::RepeatType
139 139
140 This enum defines how a event will repeat, if at all. 140 This enum defines how a event will repeat, if at all.
141 141
142 <ul> 142 <ul>
143 <li>\c NoRepeat - Event does not repeat. 143 <li>\c NoRepeat - Event does not repeat.
144 <li>\c Daily - Event occurs every n days. 144 <li>\c Daily - Event occurs every n days.
145 <li>\c Weekly - Event occurs every n weeks. 145 <li>\c Weekly - Event occurs every n weeks.
146 <li>\c MonthlyDay - Event occurs every n months. Event will always occur in 146 <li>\c MonthlyDay - Event occurs every n months. Event will always occur in
147 the same week and same day of week as the first event. 147 the same week and same day of week as the first event.
148 <li>\c MonthlyDate - Event occurs every n months. Event will always occur 148 <li>\c MonthlyDate - Event occurs every n months. Event will always occur
149 on the same day of the month as the first event. 149 on the same day of the month as the first event.
150 <li>\c Yearly - Event occurs every n years. 150 <li>\c Yearly - Event occurs every n years.
151 </ul> 151 </ul>
152*/ 152*/
153 153
154/*! 154/*!
155 \fn bool Event::isAllDay() const 155 \fn bool Event::isAllDay() const
156 156
157 Returns TRUE if the event is an all day event. Otherwise returns FALSE. 157 Returns TRUE if the event is an all day event. Otherwise returns FALSE.
158*/ 158*/
159 159
160/*! 160/*!
161 \fn void Event::setAllDay(bool allday) 161 \fn void Event::setAllDay(bool allday)
162 162
163 If \a allday is TRUE, will set the event to be an all day event. 163 If \a allday is TRUE, will set the event to be an all day event.
164 Otherwise sets the event to not be an all day event. 164 Otherwise sets the event to not be an all day event.
165 165
166 \warning This function may affect the start and end times of the event. 166 \warning This function may affect the start and end times of the event.
167*/ 167*/
168 168
169/*! 169/*!
170 \fn QDateTime Event::start() const 170 \fn QDateTime Event::start() const
171 171
172 Returns the start date and time of the first occurance of the event. 172 Returns the start date and time of the first occurance of the event.
173*/ 173*/
174 174
175/*! 175/*!
176 \fn QDateTime Event::end() const 176 \fn QDateTime Event::end() const
177 177
178 Returns the end date and time of the first occurance of the event. 178 Returns the end date and time of the first occurance of the event.
179*/ 179*/
180 180
181/*! 181/*!
182 \fn time_t Event::startTime() const 182 \fn time_t Event::startTime() const
183 \internal 183 \internal
184*/ 184*/
185 185
186/*! 186/*!
187 \fn time_t Event::endTime() const 187 \fn time_t Event::endTime() const
188 \internal 188 \internal
189*/ 189*/
190 190
191/*! 191/*!
192 \fn void Event::setAlarm(int delay, SoundTypeChoice s) 192 \fn void Event::setAlarm(int delay, SoundTypeChoice s)
193 193
194 Sets the alarm delay of the event to \a delay and the sound type of the 194 Sets the alarm delay of the event to \a delay and the sound type of the
195 alarm to \a s. 195 alarm to \a s.
196*/ 196*/
197 197
198/*! 198/*!
199 \fn void Event::clearAlarm() 199 \fn void Event::clearAlarm()
200 200
201 Clears the alarm for the event. 201 Clears the alarm for the event.
202*/ 202*/
203 203
204/*! 204/*!
205 \fn int Event::alarmDelay() const 205 \fn int Event::alarmDelay() const
206 206
207 Returns the delay in minutes between the alarm for an event and the 207 Returns the delay in minutes between the alarm for an event and the
208 start of the event. 208 start of the event.
209*/ 209*/
210 210
211/*! 211/*!
212 \fn Event::RepeatType Event::repeatType() const 212 \fn Event::RepeatType Event::repeatType() const
213 213
214 Returns the repeat pattern type for the event. 214 Returns the repeat pattern type for the event.
215 215
216 \sa frequency() 216 \sa frequency()
217*/ 217*/
218 218
219/*! 219/*!
220 \fn int Event::weekOffset() const 220 \fn int Event::weekOffset() const
221 221
222 Returns the number of weeks from the start of the month that this event 222 Returns the number of weeks from the start of the month that this event
223 occurs. 223 occurs.
224*/ 224*/
225 225
226/*! 226/*!
227 \fn QDate Event::repeatTill() const 227 \fn QDate Event::repeatTill() const
228 228
229 Returns the date that the event will continue to repeat until. If the event 229 Returns the date that the event will continue to repeat until. If the event
230 repeats forever the value returned is undefined. 230 repeats forever the value returned is undefined.
231 231
232 \sa repeatForever() 232 \sa repeatForever()
233*/ 233*/
234 234
235/*! 235/*!
236 \fn bool Event::repeatForever() const 236 \fn bool Event::repeatForever() const
237 237
238 Returns FALSE if there is a date set for the event to continue until. 238 Returns FALSE if there is a date set for the event to continue until.
239 Otherwise returns TRUE. 239 Otherwise returns TRUE.
240*/ 240*/
241 241
242/*! 242/*!
243 \fn bool Event::doRepeat() const 243 \fn bool Event::doRepeat() const
244 \internal 244 \internal
245*/ 245*/
246 246
247/*! 247/*!
248 \fn bool Event::repeatOnWeekDay(int day) const 248 \fn bool Event::repeatOnWeekDay(int day) const
249 249
250 Returns TRUE if the event has a RepeatType of Weekly and is set to occur on 250 Returns TRUE if the event has a RepeatType of Weekly and is set to occur on
251 \a day each week. Otherwise returns FALSE. 251 \a day each week. Otherwise returns FALSE.
252 252
253 \sa QDate::dayName() 253 \sa QDate::dayName()
254*/ 254*/
255 255
256/*! 256/*!
257 \fn void Event::setRepeatOnWeekDay(int day, bool enable) 257 \fn void Event::setRepeatOnWeekDay(int day, bool enable)
258 258
259 If \a enable is TRUE then sets the event to occur on \a day each week. 259 If \a enable is TRUE then sets the event to occur on \a day each week.
260 Otherwise sets the event not to occur on \a day. 260 Otherwise sets the event not to occur on \a day.
261 261
262 \warning this function is only relavent for a event with RepeatType of 262 \warning this function is only relavent for a event with RepeatType of
263 Weekly. 263 Weekly.
264 264
265 \sa QDate::dayName() 265 \sa QDate::dayName()
266*/ 266*/
267 267
268/*! 268/*!
269 \fn int Event::frequency() const 269 \fn int Event::frequency() const
270 270
271 Returns how often the event repeats. 271 Returns how often the event repeats.
272 272
273 \sa repeatType() 273 \sa repeatType()
274*/ 274*/
275 275
276/*! 276/*!
277 \fn void Event::setRepeatType(RepeatType t) 277 \fn void Event::setRepeatType(RepeatType t)
278 278
279 Sets the repeat pattern type of the event to \a t. 279 Sets the repeat pattern type of the event to \a t.
280 280
281 \sa setFrequency() 281 \sa setFrequency()
282*/ 282*/
283 283
284/*! 284/*!
285 \fn void Event::setFrequency(int n) 285 \fn void Event::setFrequency(int n)
286 286
287 Sets how often the event occurs with in its repeat pattern. 287 Sets how often the event occurs with in its repeat pattern.
288 288
289 \sa setRepeatType() 289 \sa setRepeatType()
290*/ 290*/
291 291
292/*! 292/*!
293 \fn void Event::setRepeatTill(const QDate &d) 293 \fn void Event::setRepeatTill(const QDate &d)
294 294
295 Sets the event to repeat until \a d. 295 Sets the event to repeat until \a d.
296*/ 296*/
297 297
298/*! 298/*!
299 \fn void Event::setRepeatForever(bool enable) 299 \fn void Event::setRepeatForever(bool enable)
300 300
301 If \a enable is TRUE, sets the event to repeat forever. Otherwise 301 If \a enable is TRUE, sets the event to repeat forever. Otherwise
302 sets the event to stop repeating at some date. 302 sets the event to stop repeating at some date.
303 303
304 \warning This function may affect the specific date the event will repeat 304 \warning This function may affect the specific date the event will repeat
305 till. 305 till.
306*/ 306*/
307 307
308/*! 308/*!
309 \fn bool Event::match(const QRegExp &r) const 309 \fn bool Event::match(const QRegExp &r) const
310 310
311 Returns TRUE if the event matches the regular expression \a r. 311 Returns TRUE if the event matches the regular expression \a r.
312 Otherwise returns FALSE. 312 Otherwise returns FALSE.
313*/ 313*/
314 314
315/*! 315/*!
316 \fn char Event::day(int) 316 \fn char Event::day(int)
317 \internal 317 \internal
318*/ 318*/
319 319
320/*! 320/*!
321 Creates a new, empty event. 321 Creates a new, empty event.
322*/ 322*/
323Event::Event() : Record() 323Event::Event() : Record()
324{ 324{
325 startUTC = endUTC = time( 0 ); 325 startUTC = endUTC = time( 0 );
326 typ = Normal; 326 typ = Normal;
327 hAlarm = FALSE; 327 hAlarm = FALSE;
328 hRepeat = FALSE; 328 hRepeat = FALSE;
329 aMinutes = 0; 329 aMinutes = 0;
330 aSound = Silent; 330 aSound = Silent;
331 pattern.type = NoRepeat; 331 pattern.type = NoRepeat;
332 pattern.frequency = -1; 332 pattern.frequency = -1;
333} 333}
334 334
335/*! 335/*!
336 \internal 336 \internal
337*/ 337*/
338Event::Event( const QMap<int, QString> &map ) 338Event::Event( const QMap<int, QString> &map )
339{ 339{
340 setDescription( map[DatebookDescription] ); 340 setDescription( map[DatebookDescription] );
341 setLocation( map[Location] ); 341 setLocation( map[Location] );
342 setCategories( idsFromString( map[DatebookCategory] ) ); 342 setCategories( idsFromString( map[DatebookCategory] ) );
343 setTimeZone( map[TimeZone] ); 343 setTimeZone( map[TimeZone] );
344 setNotes( map[Note] ); 344 setNotes( map[Note] );
345 setStart( TimeConversion::fromUTC( map[StartDateTime].toUInt() ) ); 345 setStart( TimeConversion::fromUTC( map[StartDateTime].toUInt() ) );
346 setEnd( TimeConversion::fromUTC( map[EndDateTime].toUInt() ) ); 346 setEnd( TimeConversion::fromUTC( map[EndDateTime].toUInt() ) );
347 setType( (Event::Type) map[DatebookType].toInt() ); 347 setType( (Event::Type) map[DatebookType].toInt() );
348 setAlarm( ( map[HasAlarm] == "1" ? TRUE : FALSE ), map[AlarmTime].toInt(), (Event::SoundTypeChoice)map[SoundType].toInt() ); 348 setAlarm( ( map[HasAlarm] == "1" ? TRUE : FALSE ), map[AlarmTime].toInt(), (Event::SoundTypeChoice)map[SoundType].toInt() );
349 Event::RepeatPattern p; 349 Event::RepeatPattern p;
350 p.type = (Event::RepeatType) map[ RepeatPatternType ].toInt(); 350 p.type = (Event::RepeatType) map[ RepeatPatternType ].toInt();
351 p.frequency = map[ RepeatPatternFrequency ].toInt(); 351 p.frequency = map[ RepeatPatternFrequency ].toInt();
352 p.position = map[ RepeatPatternPosition ].toInt(); 352 p.position = map[ RepeatPatternPosition ].toInt();
353 p.days = map[ RepeatPatternDays ].toInt(); 353 p.days = map[ RepeatPatternDays ].toInt();
354 p.hasEndDate = map[ RepeatPatternHasEndDate ].toInt(); 354 p.hasEndDate = map[ RepeatPatternHasEndDate ].toInt();
355 p.endDateUTC = map[ RepeatPatternEndDate ].toUInt(); 355 p.endDateUTC = map[ RepeatPatternEndDate ].toUInt();
356 setRepeat( p ); 356 setRepeat( p );
357 357
358 setUid( map[ DatebookUid ].toInt() ); 358 setUid( map[ DatebookUid ].toInt() );
359} 359}
360 360
361/*! 361/*!
362 Destroys an event. 362 Destroys an event.
363*/ 363*/
364Event::~Event() 364Event::~Event()
365{ 365{
366} 366}
367 367
368/*! 368/*!
369 \internal 369 \internal
370*/ 370*/
371int Event::week( const QDate& date ) 371int Event::week( const QDate& date )
372{ 372{
373 // Calculates the week this date is in within that 373 // Calculates the week this date is in within that
374 // month. Equals the "row" is is in in the month view 374 // month. Equals the "row" is is in in the month view
375 int week = 1; 375 int week = 1;
376 QDate tmp( date.year(), date.month(), 1 ); 376 QDate tmp( date.year(), date.month(), 1 );
377 377
378 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 378 if ( date.dayOfWeek() < tmp.dayOfWeek() )
379 ++week; 379 ++week;
380 380
381 week += ( date.day() - 1 ) / 7; 381 week += ( date.day() - 1 ) / 7;
382 return week; 382 return week;
383} 383}
384 384
385/*! 385/*!
386 \internal 386 \internal
387*/ 387*/
388int Event::occurrence( const QDate& date ) 388int Event::occurrence( const QDate& date )
389{ 389{
390 // calculates the number of occurrances of this day of the 390 // calculates the number of occurrances of this day of the
391 // week till the given date (e.g 3rd Wednesday of the month) 391 // week till the given date (e.g 3rd Wednesday of the month)
392 return ( date.day() - 1 ) / 7 + 1; 392 return ( date.day() - 1 ) / 7 + 1;
393} 393}
394 394
395/*! 395/*!
396 \internal 396 \internal
397*/ 397*/
398int Event::dayOfWeek( char day ) 398int Event::dayOfWeek( char day )
399{ 399{
400 int dayOfWeek = 1; 400 int dayOfWeek = 1;
401 char i = Event::MON; 401 char i = Event::MON;
402 while ( !( i & day ) && i <= Event::SUN ) { 402 while ( !( i & day ) && i <= Event::SUN ) {
403 i <<= 1; 403 i <<= 1;
404 ++dayOfWeek; 404 ++dayOfWeek;
405 } 405 }
406 return dayOfWeek; 406 return dayOfWeek;
407} 407}
408 408
409/*! 409/*!
410 \internal 410 \internal
411*/ 411*/
412int Event::monthDiff( const QDate& first, const QDate& second ) 412int Event::monthDiff( const QDate& first, const QDate& second )
413{ 413{
414 return ( second.year() - first.year() ) * 12 + 414 return ( second.year() - first.year() ) * 12 +
415 second.month() - first.month(); 415 second.month() - first.month();
416} 416}
417 417
418/*! 418/*!
419 \internal 419 \internal
420*/ 420*/
421QMap<int, QString> Event::toMap() const 421QMap<int, QString> Event::toMap() const
422{ 422{
423 QMap<int, QString> m; 423 QMap<int, QString> m;
424 424
425 if ( !description().isEmpty() ) 425 if ( !description().isEmpty() )
426 m.insert( DatebookDescription, description() ); 426 m.insert( DatebookDescription, description() );
427 if ( !location().isEmpty() ) 427 if ( !location().isEmpty() )
428 m.insert ( Location, location() ); 428 m.insert ( Location, location() );
429 if ( categories().count() ) 429 if ( categories().count() )
430 m.insert ( DatebookCategory, idsToString( categories() ) ); 430 m.insert ( DatebookCategory, idsToString( categories() ) );
431 if ( !timeZone().isEmpty() ) 431 if ( !timeZone().isEmpty() )
432 m.insert ( TimeZone, timeZone() ); 432 m.insert ( TimeZone, timeZone() );
433 if ( !notes().isEmpty() ) 433 if ( !notes().isEmpty() )
434 m.insert ( Note, notes() ); 434 m.insert ( Note, notes() );
435 435
436 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); 436 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) );
437 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); 437 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) );
438 m.insert ( DatebookType, QString::number( (int)type() ) ); 438 m.insert ( DatebookType, QString::number( (int)type() ) );
439 m.insert ( HasAlarm, ( hasAlarm() ? "1" : "0" ) ); 439 m.insert ( HasAlarm, ( hasAlarm() ? "1" : "0" ) );
440 m.insert ( SoundType, QString::number( (int)alarmSound() ) ); 440 m.insert ( SoundType, QString::number( (int)alarmSound() ) );
441 m.insert ( AlarmTime, QString::number( alarmTime() ) ); 441 m.insert ( AlarmTime, QString::number( alarmTime() ) );
442 m.insert ( RepeatPatternType, QString::number( static_cast<int>( repeatPattern().type ) ) ); 442 m.insert ( RepeatPatternType, QString::number( static_cast<int>( repeatPattern().type ) ) );
443 m.insert ( RepeatPatternFrequency, QString::number( repeatPattern().frequency ) ); 443 m.insert ( RepeatPatternFrequency, QString::number( repeatPattern().frequency ) );
444 m.insert ( RepeatPatternPosition, QString::number( repeatPattern().position ) ); 444 m.insert ( RepeatPatternPosition, QString::number( repeatPattern().position ) );
445 m.insert ( RepeatPatternDays, QString::number( repeatPattern().days ) ); 445 m.insert ( RepeatPatternDays, QString::number( repeatPattern().days ) );
446 m.insert ( RepeatPatternHasEndDate, QString::number( static_cast<int>( repeatPattern().hasEndDate ) ) ); 446 m.insert ( RepeatPatternHasEndDate, QString::number( static_cast<int>( repeatPattern().hasEndDate ) ) );
447 m.insert ( RepeatPatternEndDate, QString::number( repeatPattern().endDateUTC ) ); 447 m.insert ( RepeatPatternEndDate, QString::number( repeatPattern().endDateUTC ) );
448 448
449 m.insert( DatebookUid, QString::number( uid()) ); 449 m.insert( DatebookUid, QString::number( uid()) );
450 450
451 return m; 451 return m;
452} 452}
453 453
454/*! 454/*!
455 \internal 455 \internal
456*/ 456*/
457void Event::setRepeat( const RepeatPattern &p ) 457void Event::setRepeat( const RepeatPattern &p )
458{ 458{
459 setRepeat( p.type != NoRepeat, p ); 459 setRepeat( p.type != NoRepeat, p );
460} 460}
461 461
462/*! 462/*!
463 Sets the description of the event to \a s. 463 Sets the description of the event to \a s.
464*/ 464*/
465void Event::setDescription( const QString &s ) 465void Event::setDescription( const QString &s )
466{ 466{
467 descript = s; 467 descript = s;
468} 468}
469 469
470/*! 470/*!
471 Sets the location of the event to \a s. 471 Sets the location of the event to \a s.
472*/ 472*/
473void Event::setLocation( const QString &s ) 473void Event::setLocation( const QString &s )
474{ 474{
475 locat = s; 475 locat = s;
476} 476}
477 477
478// void Event::setCategory( const QString &s ) 478// void Event::setCategory( const QString &s )
479// { 479// {
480// categ = s; 480// categ = s;
481// } 481// }
482 482
483/*! 483/*!
484 \internal 484 \internal
485*/ 485*/
486void Event::setType( Type t ) 486void Event::setType( Type t )
487{ 487{
488 typ = t; 488 typ = t;
489} 489}
490 490
491/*! 491/*!
492 Sets the start date and time of the first or only occurance of this event 492 Sets the start date and time of the first or only occurance of this event
493 to the date and time \a d. \a d should be in local time. 493 to the date and time \a d. \a d should be in local time.
494*/ 494*/
495void Event::setStart( const QDateTime &d ) 495void Event::setStart( const QDateTime &d )
496{ 496{
497 startUTC = TimeConversion::toUTC( d ); 497 startUTC = TimeConversion::toUTC( d );
498} 498}
499 499
500/*! 500/*!
501 \internal 501 \internal
502*/ 502*/
503void Event::setStart( time_t time ) 503void Event::setStart( time_t time )
504{ 504{
505 startUTC = time; 505 startUTC = time;
506} 506}
507 507
508/*! 508/*!
509 Sets the end date and time of the first or only occurance of this event 509 Sets the end date and time of the first or only occurance of this event
510 to the date and time \a d. \a d should be in local time. 510 to the date and time \a d. \a d should be in local time.
511*/ 511*/
512void Event::setEnd( const QDateTime &d ) 512void Event::setEnd( const QDateTime &d )
513{ 513{
514 endUTC = TimeConversion::toUTC( d ); 514 endUTC = TimeConversion::toUTC( d );
515} 515}
516 516
517/*! 517/*!
518 \internal 518 \internal
519*/ 519*/
520void Event::setEnd( time_t time ) 520void Event::setEnd( time_t time )
521{ 521{
522 endUTC = time; 522 endUTC = time;
523} 523}
524 524
525/*! 525/*!
526 \internal 526 \internal
527*/ 527*/
528void Event::setTimeZone( const QString &z ) 528void Event::setTimeZone( const QString &z )
529{ 529{
530 tz = z; 530 tz = z;
531} 531}
532 532
533/*! 533/*!
534 \internal 534 \internal
535*/ 535*/
536void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) 536void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
537{ 537{
538 hAlarm = b; 538 hAlarm = b;
539 aMinutes = minutes; 539 aMinutes = minutes;
540 aSound = s; 540 aSound = s;
541} 541}
542 542
543/*! 543/*!
544 \internal 544 \internal
545*/ 545*/
546void Event::setRepeat( bool b, const RepeatPattern &p ) 546void Event::setRepeat( bool b, const RepeatPattern &p )
547{ 547{
548 hRepeat = b; 548 hRepeat = b;
549 pattern = p; 549 pattern = p;
550} 550}
551 551
552/*! 552/*!
553 Sets the notes for the event to \a n. 553 Sets the notes for the event to \a n.
554*/ 554*/
555void Event::setNotes( const QString &n ) 555void Event::setNotes( const QString &n )
556{ 556{
557 note = n; 557 note = n;
558} 558}
559 559
560/*! 560/*!
561 Returns the description of the event. 561 Returns the description of the event.
562*/ 562*/
563const QString &Event::description() const 563const QString &Event::description() const
564{ 564{
565 return descript; 565 return descript;
566} 566}
567 567
568/*! 568/*!
569 Returns the location of the event. 569 Returns the location of the event.
570*/ 570*/
571const QString &Event::location() const 571const QString &Event::location() const
572{ 572{
573 return locat; 573 return locat;
574} 574}
575 575
576// QString Event::category() const 576// QString Event::category() const
577// { 577// {
578// return categ; 578// return categ;
579// } 579// }
580 580
581/*! 581/*!
582 \internal 582 \internal
583*/ 583*/
584Event::Type Event::type() const 584Event::Type Event::type() const
585{ 585{
586 return typ; 586 return typ;
587} 587}
588 588QDateTime Event::start() const {
589 return start( TRUE );
590}
589/*! 591/*!
590 \internal 592 \internal
591*/ 593*/
592QDateTime Event::start( bool actual ) const 594QDateTime Event::start( bool actual ) const
593{ 595{
594 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); 596 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime();
595 597
596 if ( actual && typ == AllDay ) { 598 if ( actual && typ == AllDay ) {
597 QTime t = dt.time(); 599 QTime t = dt.time();
598 t.setHMS( 0, 0, 0 ); 600 t.setHMS( 0, 0, 0 );
599 dt.setTime( t ); 601 dt.setTime( t );
600 } 602 }
601 return dt; 603 return dt;
602} 604}
603 605
606QDateTime Event::end() const {
607 return end( TRUE );
608}
604/*! 609/*!
605 \internal 610 \internal
606*/ 611*/
607QDateTime Event::end( bool actual ) const 612QDateTime Event::end( bool actual ) const
608{ 613{
609 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); 614 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime();
610 615
611 if ( actual && typ == AllDay ) { 616 if ( actual && typ == AllDay ) {
612 QTime t = dt.time(); 617 QTime t = dt.time();
613 t.setHMS( 23, 59, 59 ); 618 t.setHMS( 23, 59, 59 );
614 dt.setTime( t ); 619 dt.setTime( t );
615 } 620 }
616 return dt; 621 return dt;
617} 622}
618 623
619/*! 624/*!
620 \internal 625 \internal
621*/ 626*/
622const QString &Event::timeZone() const 627const QString &Event::timeZone() const
623{ 628{
624 return tz; 629 return tz;
625} 630}
626 631
627/*! 632/*!
628 \internal 633 \internal
629*/ 634*/
630bool Event::hasAlarm() const 635bool Event::hasAlarm() const
631{ 636{
632 return hAlarm; 637 return hAlarm;
633} 638}
634 639
635/*! 640/*!
636 \internal 641 \internal
637*/ 642*/
638int Event::alarmTime() const 643int Event::alarmTime() const
639{ 644{
640 return aMinutes; 645 return aMinutes;
641} 646}
642 647
643/*! 648/*!
644 Returns the sound type for the alarm of this event. 649 Returns the sound type for the alarm of this event.
645*/ 650*/
646Event::SoundTypeChoice Event::alarmSound() const 651Event::SoundTypeChoice Event::alarmSound() const
647{ 652{
648 return aSound; 653 return aSound;
649} 654}
650 655
651/*! 656/*!
652 \internal 657 \internal
653*/ 658*/
654bool Event::hasRepeat() const 659bool Event::hasRepeat() const
655{ 660{
656 return doRepeat(); 661 return doRepeat();
657} 662}
658 663
659/*! 664/*!
660 \internal 665 \internal
661*/ 666*/
662const Event::RepeatPattern &Event::repeatPattern() const 667const Event::RepeatPattern &Event::repeatPattern() const
663{ 668{
664 return pattern; 669 return pattern;
665} 670}
666 671
667/*! 672/*!
668 \internal 673 \internal
669*/ 674*/
670Event::RepeatPattern &Event::repeatPattern() 675Event::RepeatPattern &Event::repeatPattern()
671{ 676{
672 return pattern; 677 return pattern;
673} 678}
674 679
675/*! 680/*!
676 Returns the notes for the event. 681 Returns the notes for the event.
677*/ 682*/
678const QString &Event::notes() const 683const QString &Event::notes() const
679{ 684{
680 return note; 685 return note;
681} 686}
682 687
683/*! 688/*!
684 \internal 689 \internal
685*/ 690*/
686bool Event::operator==( const Event &e ) const 691bool Event::operator==( const Event &e ) const
687{ 692{
688 if ( uid() && e.uid() == uid() ) 693 if ( uid() && e.uid() == uid() )
689 return TRUE; 694 return TRUE;
690 return ( e.descript == descript && 695 return ( e.descript == descript &&
691 e.locat == locat && 696 e.locat == locat &&
692 e.categ == categ && 697 e.categ == categ &&
693 e.typ == typ && 698 e.typ == typ &&
694 e.startUTC == startUTC && 699 e.startUTC == startUTC &&
695 e.endUTC == endUTC && 700 e.endUTC == endUTC &&
696 e.tz == tz && 701 e.tz == tz &&
697 e.hAlarm == hAlarm && 702 e.hAlarm == hAlarm &&
698 e.aMinutes == aMinutes && 703 e.aMinutes == aMinutes &&
699 e.aSound == aSound && 704 e.aSound == aSound &&
700 e.hRepeat == hRepeat && 705 e.hRepeat == hRepeat &&
701 e.pattern == pattern && 706 e.pattern == pattern &&
702 e.note == note ); 707 e.note == note );
703} 708}
704 709
705/*! 710/*!
706 \internal 711 \internal
707 Appends the contact information to \a buf. 712 Appends the contact information to \a buf.
708*/ 713*/
709void Event::save( QString& buf ) 714void Event::save( QString& buf )
710{ 715{
711 buf += " description=\"" + Qtopia::escapeString(descript) + "\""; 716 buf += " description=\"" + Qtopia::escapeString(descript) + "\"";
712 if ( !locat.isEmpty() ) 717 if ( !locat.isEmpty() )
713 buf += " location=\"" + Qtopia::escapeString(locat) + "\""; 718 buf += " location=\"" + Qtopia::escapeString(locat) + "\"";
714 // save the categoies differently.... 719 // save the categoies differently....
715 QString strCats = idsToString( categories() ); 720 QString strCats = idsToString( categories() );
716 buf += " categories=\"" + Qtopia::escapeString(strCats) + "\""; 721 buf += " categories=\"" + Qtopia::escapeString(strCats) + "\"";
717 buf += " uid=\"" + QString::number( uid() ) + "\""; 722 buf += " uid=\"" + QString::number( uid() ) + "\"";
718 if ( (Type)typ != Normal ) 723 if ( (Type)typ != Normal )
719 buf += " type=\"AllDay\""; 724 buf += " type=\"AllDay\"";
720 if ( hAlarm ) { 725 if ( hAlarm ) {
721 buf += " alarm=\"" + QString::number( aMinutes ) + "\" sound=\""; 726 buf += " alarm=\"" + QString::number( aMinutes ) + "\" sound=\"";
722 if ( aSound == Event::Loud ) 727 if ( aSound == Event::Loud )
723 buf += "loud"; 728 buf += "loud";
724 else 729 else
725 buf += "silent"; 730 buf += "silent";
726 buf += "\""; 731 buf += "\"";
727 } 732 }
728 if ( hRepeat ) 733 if ( hRepeat )
729 write( buf, pattern ); 734 write( buf, pattern );
730 735
731 buf += " start=\"" 736 buf += " start=\""
732 + QString::number( startUTC ) 737 + QString::number( startUTC )
733 + "\""; 738 + "\"";
734 739
735 buf += " end=\"" 740 buf += " end=\""
736 + QString::number( endUTC ) 741 + QString::number( endUTC )
737 + "\""; 742 + "\"";
738 743
739 if ( !note.isEmpty() ) 744 if ( !note.isEmpty() )
740 buf += " note=\"" + Qtopia::escapeString( note ) + "\""; 745 buf += " note=\"" + Qtopia::escapeString( note ) + "\"";
741 buf += customToXml(); 746 buf += customToXml();
742} 747}
743 748
744/*! 749/*!
745 \internal 750 \internal
746*/ 751*/
747bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const 752bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
748{ 753{
749 // *sigh* 754 // *sigh*
750 return ( type == right.type 755 return ( type == right.type
751 && frequency == right.frequency 756 && frequency == right.frequency
752 && position == right.position 757 && position == right.position
753 && days == right.days 758 && days == right.days
754 && hasEndDate == right.hasEndDate 759 && hasEndDate == right.hasEndDate
755 && endDateUTC == right.endDateUTC 760 && endDateUTC == right.endDateUTC
756 && createTime == right.createTime ); 761 && createTime == right.createTime );
757} 762}
758 763
759/*! 764/*!
760 \class EffectiveEvent 765 \class EffectiveEvent
761 \brief The EffectiveEvent class the data for a single occurance of an event. 766 \brief The EffectiveEvent class the data for a single occurance of an event.
762 767
763 This class describes the event for a single occurance of it. For example if 768 This class describes the event for a single occurance of it. For example if
764 an Event occurs every week, the effective event might represent the third 769 an Event occurs every week, the effective event might represent the third
765 occurance of this Event. 770 occurance of this Event.
766 771
767 \ingroup qtopiaemb 772 \ingroup qtopiaemb
768 \ingroup qtopiadesktop 773 \ingroup qtopiadesktop
769 \warning This class will be phased out in Qtopia 3.x 774 \warning This class will be phased out in Qtopia 3.x
770*/ 775*/
771 776
772/*! 777/*!
773 \enum EffectiveEvent::Position 778 \enum EffectiveEvent::Position
774 \internal 779 \internal
775*/ 780*/
776 781
777/*! 782/*!
778 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &) 783 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &)
779 \internal 784 \internal
780*/ 785*/
781 786
782class EffectiveEventPrivate 787class EffectiveEventPrivate
783{ 788{
784public: 789public:
785 //currently the existence of the d pointer means multi-day repeating, 790 //currently the existence of the d pointer means multi-day repeating,
786 //msut be changed if we use the d pointer for anything else. 791 //msut be changed if we use the d pointer for anything else.
787 QDate startDate; 792 QDate startDate;
788 QDate endDate; 793 QDate endDate;
789}; 794};
790 795
791/*! 796/*!
792 \internal 797 \internal
793*/ 798*/
794EffectiveEvent::EffectiveEvent() 799EffectiveEvent::EffectiveEvent()
795{ 800{
796 mDate = QDate::currentDate(); 801 mDate = QDate::currentDate();
797 mStart = mEnd = QTime::currentTime(); 802 mStart = mEnd = QTime::currentTime();
798 d = 0; 803 d = 0;
799} 804}
800 805
801/*! 806/*!
802 \internal 807 \internal
803*/ 808*/
804EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) 809EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos )
805{ 810{
806 mEvent = e; 811 mEvent = e;
807 mDate = date; 812 mDate = date;
808 if ( pos & Start ) 813 if ( pos & Start )
809 mStart = e.start( TRUE ).time(); 814 mStart = e.start( TRUE ).time();
810 else 815 else
811 mStart = QTime( 0, 0, 0 ); 816 mStart = QTime( 0, 0, 0 );
812 817
813 if ( pos & End ) 818 if ( pos & End )
814 mEnd = e.end( TRUE ).time(); 819 mEnd = e.end( TRUE ).time();
815 else 820 else
816 mEnd = QTime( 23, 59, 59 ); 821 mEnd = QTime( 23, 59, 59 );
817 d = 0; 822 d = 0;
818} 823}
819 824
820/*! 825/*!
821 \internal 826 \internal
822*/ 827*/
823EffectiveEvent::~EffectiveEvent() 828EffectiveEvent::~EffectiveEvent()
824{ 829{
825 delete d; 830 delete d;
826} 831}
827 832
828/*! 833/*!
829 \internal 834 \internal
830*/ 835*/
831EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) 836EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
832{ 837{
833 d = 0; 838 d = 0;
834 *this = e; 839 *this = e;
835} 840}
836 841
837EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) 842EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
838{ 843{
839 if ( &e == this ) 844 if ( &e == this )
840 return *this; 845 return *this;
841 delete d; 846 delete d;
842 if ( e.d ) { 847 if ( e.d ) {
843 d = new EffectiveEventPrivate; 848 d = new EffectiveEventPrivate;
844 d->startDate = e.d->startDate; 849 d->startDate = e.d->startDate;
845 d->endDate = e.d->endDate; 850 d->endDate = e.d->endDate;
846 } else { 851 } else {
847 d = 0; 852 d = 0;
848 } 853 }
849 mEvent = e.mEvent; 854 mEvent = e.mEvent;
850 mDate = e.mDate; 855 mDate = e.mDate;
851 mStart = e.mStart; 856 mStart = e.mStart;
852 mEnd = e.mEnd; 857 mEnd = e.mEnd;
853 858
854 return *this; 859 return *this;
855 860
856} 861}
857 862
858// QString EffectiveEvent::category() const 863// QString EffectiveEvent::category() const
859// { 864// {
860// return mEvent.category(); 865// return mEvent.category();
861// } 866// }
862 867
863/*! 868/*!
864 Returns the description of the event for this effective event. 869 Returns the description of the event for this effective event.
865*/ 870*/
866const QString &EffectiveEvent::description( ) const 871const QString &EffectiveEvent::description( ) const
867{ 872{
868 return mEvent.description(); 873 return mEvent.description();
869} 874}
870 875
871/*! 876/*!
872\internal 877\internal
873*/ 878*/
874const QString &EffectiveEvent::location( ) const 879const QString &EffectiveEvent::location( ) const
875{ 880{
876 return mEvent.location(); 881 return mEvent.location();
877} 882}
878 883
879/*! 884/*!
880\internal 885\internal
881*/ 886*/
882const QString &EffectiveEvent::notes() const 887const QString &EffectiveEvent::notes() const
883{ 888{
884 return mEvent.notes(); 889 return mEvent.notes();
885} 890}
886 891
887/*! 892/*!
888 Returns the event associated with this effective event. 893 Returns the event associated with this effective event.
889*/ 894*/
890const Event &EffectiveEvent::event() const 895const Event &EffectiveEvent::event() const
891{ 896{
892 return mEvent; 897 return mEvent;
893} 898}
894 899
895/*! 900/*!
896 \internal 901 \internal
897*/ 902*/
898const QTime &EffectiveEvent::end() const 903const QTime &EffectiveEvent::end() const
899{ 904{
900 return mEnd; 905 return mEnd;
901} 906}
902 907
903/*! 908/*!
904 \internal 909 \internal
905*/ 910*/
906const QTime &EffectiveEvent::start() const 911const QTime &EffectiveEvent::start() const
907{ 912{
908 return mStart; 913 return mStart;
909} 914}
910 915
911/*! 916/*!
912 Returns the date the effective event occurs on. 917 Returns the date the effective event occurs on.
913*/ 918*/
914const QDate &EffectiveEvent::date() const 919const QDate &EffectiveEvent::date() const
915{ 920{
916 return mDate; 921 return mDate;
917} 922}
918 923
919/*! 924/*!
920 \internal 925 \internal
921*/ 926*/
922int EffectiveEvent::length() const 927int EffectiveEvent::length() const
923{ 928{
924 return (mEnd.hour() * 60 - mStart.hour() * 60) 929 return (mEnd.hour() * 60 - mStart.hour() * 60)
925 + QABS(mStart.minute() - mEnd.minute() ); 930 + QABS(mStart.minute() - mEnd.minute() );
926} 931}
927 932
928/*! 933/*!
929 \internal 934 \internal
930*/ 935*/
931void EffectiveEvent::setDate( const QDate &dt ) 936void EffectiveEvent::setDate( const QDate &dt )
932{ 937{
933 mDate = dt; 938 mDate = dt;
934} 939}
935 940
936/*! 941/*!
937 \internal 942 \internal
938*/ 943*/
939void EffectiveEvent::setStart( const QTime &start ) 944void EffectiveEvent::setStart( const QTime &start )
940{ 945{
941 mStart = start; 946 mStart = start;
942} 947}
943 948
944/*! 949/*!
945 \internal 950 \internal
946*/ 951*/
947void EffectiveEvent::setEnd( const QTime &end ) 952void EffectiveEvent::setEnd( const QTime &end )
948{ 953{
949 mEnd = end; 954 mEnd = end;
950} 955}
951 956
952/*! 957/*!
953 \internal 958 \internal
954*/ 959*/
955void EffectiveEvent::setEvent( Event e ) 960void EffectiveEvent::setEvent( Event e )
956{ 961{
957 mEvent = e; 962 mEvent = e;
958} 963}
959 964
960/*! 965/*!
961 \internal 966 \internal
962*/ 967*/
963bool EffectiveEvent::operator<( const EffectiveEvent &e ) const 968bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
964{ 969{
965 if ( mDate < e.date() ) 970 if ( mDate < e.date() )
966 return TRUE; 971 return TRUE;
967 if ( mDate == e.date() ) 972 if ( mDate == e.date() )
968 return ( mStart < e.start() ); 973 return ( mStart < e.start() );
969 else 974 else
970 return FALSE; 975 return FALSE;
971} 976}
972 977
973/*! 978/*!
974 \internal 979 \internal
975*/ 980*/
976bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const 981bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
977{ 982{
978 return (mDate <= e.date() ); 983 return (mDate <= e.date() );
979} 984}
980 985
981/*! 986/*!
982 \internal 987 \internal
983*/ 988*/
984bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 989bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
985{ 990{
986 return ( mDate == e.date() 991 return ( mDate == e.date()
987 && mStart == e.start() 992 && mStart == e.start()
988 && mEnd == e.end() 993 && mEnd == e.end()
989 && mEvent == e.event() ); 994 && mEvent == e.event() );
990} 995}
991 996
992/*! 997/*!
993 \internal 998 \internal
994*/ 999*/
995bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const 1000bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
996{ 1001{
997 return !(*this == e); 1002 return !(*this == e);
998} 1003}
999 1004
1000/*! 1005/*!
1001 \internal 1006 \internal
1002*/ 1007*/
1003bool EffectiveEvent::operator>( const EffectiveEvent &e ) const 1008bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
1004{ 1009{
1005 return !(*this <= e ); 1010 return !(*this <= e );
1006} 1011}
1007 1012
1008/*! 1013/*!
1009 \internal 1014 \internal
1010*/ 1015*/
1011bool EffectiveEvent::operator>=(const EffectiveEvent &e) const 1016bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
1012{ 1017{
1013 return !(*this < e); 1018 return !(*this < e);
1014} 1019}
1015 1020
1016/*! 1021/*!
1017 \internal 1022 \internal
1018*/ 1023*/
1019void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) 1024void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
1020{ 1025{
1021 if ( !from.isValid() ) { 1026 if ( !from.isValid() ) {
1022 delete d; 1027 delete d;
1023 d = 0; 1028 d = 0;
1024 return; 1029 return;
1025 } 1030 }
1026 if ( !d ) 1031 if ( !d )
1027 d = new EffectiveEventPrivate; 1032 d = new EffectiveEventPrivate;
1028 d->startDate = from; 1033 d->startDate = from;
1029 d->endDate = to; 1034 d->endDate = to;
1030} 1035}
1031 1036
1032/*! 1037/*!
1033 \internal 1038 \internal
1034*/ 1039*/
1035QDate EffectiveEvent::startDate() const 1040QDate EffectiveEvent::startDate() const
1036{ 1041{
1037 if ( d ) 1042 if ( d )
1038 return d->startDate; 1043 return d->startDate;
1039 else if ( mEvent.hasRepeat() ) 1044 else if ( mEvent.hasRepeat() )
1040 return mDate; // single day, since multi-day should have a d pointer 1045 return mDate; // single day, since multi-day should have a d pointer
1041 else 1046 else
1042 return mEvent.start().date(); 1047 return mEvent.start().date();
1043} 1048}
1044 1049
1045/*! 1050/*!
1046 \internal 1051 \internal
1047*/ 1052*/
1048QDate EffectiveEvent::endDate() const 1053QDate EffectiveEvent::endDate() const
1049{ 1054{
1050 if ( d ) 1055 if ( d )
1051 return d->endDate; 1056 return d->endDate;
1052 else if ( mEvent.hasRepeat() ) 1057 else if ( mEvent.hasRepeat() )
1053 return mDate; // single day, since multi-day should have a d pointer 1058 return mDate; // single day, since multi-day should have a d pointer
1054 else 1059 else
1055 return mEvent.end().date(); 1060 return mEvent.end().date();
1056} 1061}
1057 1062
1058/*! 1063/*!
1059 \internal 1064 \internal
1060*/ 1065*/
1061int EffectiveEvent::size() const 1066int EffectiveEvent::size() const
1062{ 1067{
1063 return ( mEnd.hour() - mStart.hour() ) * 3600 1068 return ( mEnd.hour() - mStart.hour() ) * 3600
1064 + (mEnd.minute() - mStart.minute() * 60 1069 + (mEnd.minute() - mStart.minute() * 60
1065 + mEnd.second() - mStart.second() ); 1070 + mEnd.second() - mStart.second() );
1066} 1071}
1067 1072
1068 1073
1069// vcal conversion code 1074// vcal conversion code
1070static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 1075static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
1071{ 1076{
1072 VObject *ret = 0; 1077 VObject *ret = 0;
1073 if ( o && !value.isEmpty() ) 1078 if ( o && !value.isEmpty() )
1074 ret = addPropValue( o, prop, value.latin1() ); 1079 ret = addPropValue( o, prop, value.latin1() );
1075 return ret; 1080 return ret;
1076} 1081}
1077 1082
1078static inline VObject *safeAddProp( VObject *o, const char *prop) 1083static inline VObject *safeAddProp( VObject *o, const char *prop)
1079{ 1084{
1080 VObject *ret = 0; 1085 VObject *ret = 0;
1081 if ( o ) 1086 if ( o )
1082 ret = addProp( o, prop ); 1087 ret = addProp( o, prop );
1083 return ret; 1088 return ret;
1084} 1089}
1085 1090
1086static VObject *createVObject( const Event &e ) 1091static VObject *createVObject( const Event &e )
1087{ 1092{
1088 VObject *vcal = newVObject( VCCalProp ); 1093 VObject *vcal = newVObject( VCCalProp );
1089 safeAddPropValue( vcal, VCVersionProp, "1.0" ); 1094 safeAddPropValue( vcal, VCVersionProp, "1.0" );
1090 VObject *event = safeAddProp( vcal, VCEventProp ); 1095 VObject *event = safeAddProp( vcal, VCEventProp );
1091 1096
1092 safeAddPropValue( event, VCDTstartProp, TimeConversion::toISO8601( e.start() ) ); 1097 safeAddPropValue( event, VCDTstartProp, TimeConversion::toISO8601( e.start() ) );
1093 safeAddPropValue( event, VCDTendProp, TimeConversion::toISO8601( e.end() ) ); 1098 safeAddPropValue( event, VCDTendProp, TimeConversion::toISO8601( e.end() ) );
1094 safeAddPropValue( event, "X-Qtopia-NOTES", e.description() ); 1099 safeAddPropValue( event, "X-Qtopia-NOTES", e.description() );
1095 safeAddPropValue( event, VCDescriptionProp, e.description() ); 1100 safeAddPropValue( event, VCDescriptionProp, e.description() );
1096 safeAddPropValue( event, VCLocationProp, e.location() ); 1101 safeAddPropValue( event, VCLocationProp, e.location() );
1097 1102
1098 if ( e.hasAlarm() ) { 1103 if ( e.hasAlarm() ) {
1099 VObject *alarm = safeAddProp( event, VCAAlarmProp ); 1104 VObject *alarm = safeAddProp( event, VCAAlarmProp );
1100 QDateTime dt = e.start(); 1105 QDateTime dt = e.start();
1101 dt = dt.addSecs( -e.alarmTime()*60 ); 1106 dt = dt.addSecs( -e.alarmTime()*60 );
1102 safeAddPropValue( alarm, VCRunTimeProp, TimeConversion::toISO8601( dt ) ); 1107 safeAddPropValue( alarm, VCRunTimeProp, TimeConversion::toISO8601( dt ) );
1103 safeAddPropValue( alarm, VCAudioContentProp, 1108 safeAddPropValue( alarm, VCAudioContentProp,
1104 (e.alarmSound() == Event::Silent ? "silent" : "alarm" ) ); 1109 (e.alarmSound() == Event::Silent ? "silent" : "alarm" ) );
1105 } 1110 }
1106 1111
1107 safeAddPropValue( event, "X-Qtopia-TIMEZONE", e.timeZone() ); 1112 safeAddPropValue( event, "X-Qtopia-TIMEZONE", e.timeZone() );
1108 1113
1109 if ( e.type() == Event::AllDay ) 1114 if ( e.type() == Event::AllDay )
1110 safeAddPropValue( event, "X-Qtopia-AllDay", e.timeZone() ); 1115 safeAddPropValue( event, "X-Qtopia-AllDay", e.timeZone() );
1111 1116
1112 // ### repeat missing 1117 // ### repeat missing
1113 1118
1114 // ### categories missing 1119 // ### categories missing
1115 1120
1116 return vcal; 1121 return vcal;
1117} 1122}
1118 1123
1119 1124
1120static Event parseVObject( VObject *obj ) 1125static Event parseVObject( VObject *obj )
1121{ 1126{
1122 Event e; 1127 Event e;
1123 1128
1124 bool haveAlarm = FALSE; 1129 bool haveAlarm = FALSE;
1125 bool haveStart = FALSE; 1130 bool haveStart = FALSE;
1126 bool haveEnd = FALSE; 1131 bool haveEnd = FALSE;
1127 QDateTime alarmTime; 1132 QDateTime alarmTime;
1128 Event::SoundTypeChoice soundType = Event::Silent; 1133 Event::SoundTypeChoice soundType = Event::Silent;
1129 1134
1130 VObjectIterator it; 1135 VObjectIterator it;
1131 initPropIterator( &it, obj ); 1136 initPropIterator( &it, obj );
1132 while( moreIteration( &it ) ) { 1137 while( moreIteration( &it ) ) {
1133 VObject *o = nextVObject( &it ); 1138 VObject *o = nextVObject( &it );
1134 QCString name = vObjectName( o ); 1139 QCString name = vObjectName( o );
1135 QCString value = vObjectStringZValue( o ); 1140 QCString value = vObjectStringZValue( o );
1136 if ( name == VCDTstartProp ) { 1141 if ( name == VCDTstartProp ) {
1137 e.setStart( TimeConversion::fromISO8601( value ) ); 1142 e.setStart( TimeConversion::fromISO8601( value ) );
1138 haveStart = TRUE; 1143 haveStart = TRUE;
1139 } 1144 }
1140 else if ( name == VCDTendProp ) { 1145 else if ( name == VCDTendProp ) {
1141 e.setEnd( TimeConversion::fromISO8601( value ) ); 1146 e.setEnd( TimeConversion::fromISO8601( value ) );
1142 haveEnd = TRUE; 1147 haveEnd = TRUE;
1143 } 1148 }
1144 else if ( name == "X-Qtopia-NOTES" ) { 1149 else if ( name == "X-Qtopia-NOTES" ) {
1145 e.setNotes( value ); 1150 e.setNotes( value );
1146 } 1151 }
1147 else if ( name == VCDescriptionProp ) { 1152 else if ( name == VCDescriptionProp ) {
1148 e.setDescription( value ); 1153 e.setDescription( value );
1149 } 1154 }
1150 else if ( name == VCLocationProp ) { 1155 else if ( name == VCLocationProp ) {
1151 e.setLocation( value ); 1156 e.setLocation( value );
1152 } 1157 }
1153 else if ( name == VCAudioContentProp ) { 1158 else if ( name == VCAudioContentProp ) {
1154 haveAlarm = TRUE; 1159 haveAlarm = TRUE;
1155 VObjectIterator nit; 1160 VObjectIterator nit;
1156 initPropIterator( &nit, o ); 1161 initPropIterator( &nit, o );
1157 while( moreIteration( &nit ) ) { 1162 while( moreIteration( &nit ) ) {
1158 VObject *o = nextVObject( &nit ); 1163 VObject *o = nextVObject( &nit );
1159 QCString name = vObjectName( o ); 1164 QCString name = vObjectName( o );
1160 QCString value = vObjectStringZValue( o ); 1165 QCString value = vObjectStringZValue( o );
1161 if ( name == VCRunTimeProp ) 1166 if ( name == VCRunTimeProp )
1162 alarmTime = TimeConversion::fromISO8601( value ); 1167 alarmTime = TimeConversion::fromISO8601( value );
1163 else if ( name == VCAudioContentProp ) { 1168 else if ( name == VCAudioContentProp ) {
1164 if ( value == "silent" ) 1169 if ( value == "silent" )
1165 soundType = Event::Silent; 1170 soundType = Event::Silent;
1166 else 1171 else
1167 soundType = Event::Loud; 1172 soundType = Event::Loud;
1168 } 1173 }
1169 } 1174 }
1170 } 1175 }
1171 else if ( name == "X-Qtopia-TIMEZONE") { 1176 else if ( name == "X-Qtopia-TIMEZONE") {
1172 e.setTimeZone( value ); 1177 e.setTimeZone( value );
1173 } 1178 }
1174 else if ( name == "X-Qtopia-AllDay" ) { 1179 else if ( name == "X-Qtopia-AllDay" ) {
1175 e.setType( Event::AllDay ); 1180 e.setType( Event::AllDay );
1176 } 1181 }
1177#if 0 1182#if 0
1178 else { 1183 else {
1179 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1184 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1180 VObjectIterator nit; 1185 VObjectIterator nit;
1181 initPropIterator( &nit, o ); 1186 initPropIterator( &nit, o );
1182 while( moreIteration( &nit ) ) { 1187 while( moreIteration( &nit ) ) {
1183 VObject *o = nextVObject( &nit ); 1188 VObject *o = nextVObject( &nit );
1184 QCString name = vObjectName( o ); 1189 QCString name = vObjectName( o );
1185 QString value = vObjectStringZValue( o ); 1190 QString value = vObjectStringZValue( o );
1186 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1191 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1187 } 1192 }
1188 } 1193 }
1189#endif 1194#endif
1190 } 1195 }
1191 1196
1192 if ( !haveStart && !haveEnd ) 1197 if ( !haveStart && !haveEnd )
1193 e.setStart( QDateTime::currentDateTime() ); 1198 e.setStart( QDateTime::currentDateTime() );
1194 1199
1195 if ( !haveEnd ) { 1200 if ( !haveEnd ) {
1196 e.setType( Event::AllDay ); 1201 e.setType( Event::AllDay );
1197 e.setEnd( e.start() ); 1202 e.setEnd( e.start() );
1198 } 1203 }
1199 1204
1200 if ( haveAlarm ) { 1205 if ( haveAlarm ) {
1201 int minutes = alarmTime.secsTo( e.start() ) / 60; 1206 int minutes = alarmTime.secsTo( e.start() ) / 60;
1202 e.setAlarm( TRUE, minutes, soundType ); 1207 e.setAlarm( TRUE, minutes, soundType );
1203 } 1208 }
1204 return e; 1209 return e;
1205} 1210}
1206 1211
1207 1212
1208/*! 1213/*!
1209 Writes the list of \a events as a set of VCards to the file \a filename. 1214 Writes the list of \a events as a set of VCards to the file \a filename.
1210*/ 1215*/
1211void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) 1216void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events)
1212{ 1217{
1213 1218
1214 QFileDirect f( filename.utf8().data() ); 1219 QFileDirect f( filename.utf8().data() );
1215 1220
1216 if ( !f.open( IO_WriteOnly ) ) { 1221 if ( !f.open( IO_WriteOnly ) ) {
1217 1222
1218 qWarning("Unable to open vcard write"); 1223 qWarning("Unable to open vcard write");
1219 1224
1220 return; 1225 return;
1221 1226
1222 } 1227 }
1223 1228
1224 1229
1225 QValueList<Event>::ConstIterator it; 1230 QValueList<Event>::ConstIterator it;
1226 for( it = events.begin(); it != events.end(); ++it ) { 1231 for( it = events.begin(); it != events.end(); ++it ) {
1227 VObject *obj = createVObject( *it ); 1232 VObject *obj = createVObject( *it );
1228 writeVObject( f.directHandle() , obj ); 1233 writeVObject( f.directHandle() , obj );
1229 cleanVObject( obj ); 1234 cleanVObject( obj );
1230 } 1235 }
1231 1236
1232 1237
1233 cleanStrTbl(); 1238 cleanStrTbl();
1234} 1239}
1235 1240
1236/*! 1241/*!
1237 Writes \a event as a VCard to the file \a filename. 1242 Writes \a event as a VCard to the file \a filename.
1238*/ 1243*/
1239void Event::writeVCalendar( const QString &filename, const Event &event) 1244void Event::writeVCalendar( const QString &filename, const Event &event)
1240{ 1245{
1241 1246
1242 QFileDirect f( filename.utf8().data() ); 1247 QFileDirect f( filename.utf8().data() );
1243 1248
1244 if ( !f.open( IO_WriteOnly ) ) { 1249 if ( !f.open( IO_WriteOnly ) ) {
1245 1250
1246 qWarning("Unable to open vcard write"); 1251 qWarning("Unable to open vcard write");
1247 1252
1248 return; 1253 return;
1249 1254
1250 } 1255 }
1251 1256
1252 1257
1253 VObject *obj = createVObject( event ); 1258 VObject *obj = createVObject( event );
1254 writeVObject( f.directHandle() , obj ); 1259 writeVObject( f.directHandle() , obj );
1255 cleanVObject( obj ); 1260 cleanVObject( obj );
1256 1261
1257 cleanStrTbl(); 1262 cleanStrTbl();
1258} 1263}
1259 1264
1260/*! 1265/*!
1261 Returns the set of events read as VCards from the file \a filename. 1266 Returns the set of events read as VCards from the file \a filename.
1262*/ 1267*/
1263QValueList<Event> Event::readVCalendar( const QString &filename ) 1268QValueList<Event> Event::readVCalendar( const QString &filename )
1264{ 1269{
1265 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1270 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1266 1271
1267 QValueList<Event> events; 1272 QValueList<Event> events;
1268 1273
1269 while ( obj ) { 1274 while ( obj ) {
1270 QCString name = vObjectName( obj ); 1275 QCString name = vObjectName( obj );
1271 if ( name == VCCalProp ) { 1276 if ( name == VCCalProp ) {
1272 VObjectIterator nit; 1277 VObjectIterator nit;
1273 initPropIterator( &nit, obj ); 1278 initPropIterator( &nit, obj );
1274 while( moreIteration( &nit ) ) { 1279 while( moreIteration( &nit ) ) {
1275 VObject *o = nextVObject( &nit ); 1280 VObject *o = nextVObject( &nit );
1276 QCString name = vObjectName( o ); 1281 QCString name = vObjectName( o );
1277 if ( name == VCEventProp ) 1282 if ( name == VCEventProp )
1278 events.append( parseVObject( o ) ); 1283 events.append( parseVObject( o ) );
1279 } 1284 }
1280 } else if ( name == VCEventProp ) { 1285 } else if ( name == VCEventProp ) {
1281 // shouldn't happen, but just to be sure 1286 // shouldn't happen, but just to be sure
1282 events.append( parseVObject( obj ) ); 1287 events.append( parseVObject( obj ) );
1283 } 1288 }
1284 VObject *t = obj; 1289 VObject *t = obj;
1285 obj = nextVObjectInList(obj); 1290 obj = nextVObjectInList(obj);
1286 cleanVObject( t ); 1291 cleanVObject( t );
1287 } 1292 }
1288 1293
1289 return events; 1294 return events;
1290} 1295}
1291 1296
1292bool Event::match( const QRegExp &r ) const 1297bool Event::match( const QRegExp &r ) const
1293{ 1298{
1294 bool returnMe; 1299 bool returnMe;
1295 returnMe = false; 1300 returnMe = false;
1296 1301
1297 if ( descript.find( r ) > -1 ) 1302 if ( descript.find( r ) > -1 )
1298 returnMe = true; 1303 returnMe = true;
1299 else if ( locat.find( r ) > -1 ) 1304 else if ( locat.find( r ) > -1 )
1300 returnMe = true; 1305 returnMe = true;
1301 else if ( TimeConversion::fromUTC( startUTC ).toString().find( r ) > -1 ) 1306 else if ( TimeConversion::fromUTC( startUTC ).toString().find( r ) > -1 )
1302 returnMe = true; 1307 returnMe = true;
1303 else if ( TimeConversion::fromUTC( endUTC ).toString().find( r ) > -1 ) 1308 else if ( TimeConversion::fromUTC( endUTC ).toString().find( r ) > -1 )
1304 returnMe = true; 1309 returnMe = true;
1305 else if ( tz.find( r ) > -1 ) 1310 else if ( tz.find( r ) > -1 )
1306 returnMe = true; 1311 returnMe = true;
1307 else if ( note.find( r ) > -1 ) 1312 else if ( note.find( r ) > -1 )
1308 returnMe = true; 1313 returnMe = true;
1309 else if ( doRepeat() ) { 1314 else if ( doRepeat() ) {
1310 if ( pattern.hasEndDate ) 1315 if ( pattern.hasEndDate )
1311 if ( TimeConversion::fromUTC( pattern.endDateUTC ).toString().find(r) > -1 ) 1316 if ( TimeConversion::fromUTC( pattern.endDateUTC ).toString().find(r) > -1 )
1312 returnMe = true; 1317 returnMe = true;
1313 } 1318 }
1314 return returnMe; 1319 return returnMe;
1315} 1320}
diff --git a/library/backend/event.h b/library/backend/event.h
index 7fe41a5..2b275a4 100644
--- a/library/backend/event.h
+++ b/library/backend/event.h
@@ -1,375 +1,375 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __EVENT_H__ 21#ifndef __EVENT_H__
22#define __EVENT_H__ 22#define __EVENT_H__
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qcolor.h> 26#include <qcolor.h>
27 27
28#ifdef PALMTOPCENTER 28#ifdef PALMTOPCENTER
29#include <qpc/qsorter.h> 29#include <qpc/qsorter.h>
30#endif 30#endif
31#include <qtopia/private/palmtoprecord.h> 31#include <qtopia/private/palmtoprecord.h>
32 32
33#include <qpe/timeconversion.h> 33#include <qpe/timeconversion.h>
34 34
35static const QColor colorNormal = QColor(255, 0 , 0 ); 35static const QColor colorNormal = QColor(255, 0 , 0 );
36static const QColor colorRepeat = QColor(0 , 0 , 255); 36static const QColor colorRepeat = QColor(0 , 0 , 255);
37static const QColor colorNormalLight = QColor(255, 220, 220); 37static const QColor colorNormalLight = QColor(255, 220, 220);
38static const QColor colorRepeatLight = QColor(200, 200, 255); 38static const QColor colorRepeatLight = QColor(200, 200, 255);
39 39
40class EventPrivate; 40class EventPrivate;
41class QPC_EXPORT Event : public Qtopia::Record 41class QPC_EXPORT Event : public Qtopia::Record
42{ 42{
43public: 43public:
44 enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, 44 enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay,
45 MonthlyDate, Yearly }; 45 MonthlyDate, Yearly };
46 46
47 // Don't use this. 47 // Don't use this.
48 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, 48 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
49 FRI = 0x10, SAT = 0x20, SUN = 0x40 }; 49 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
50 // Don't use this. 50 // Don't use this.
51 struct QPC_EXPORT RepeatPattern 51 struct QPC_EXPORT RepeatPattern
52 { 52 {
53 RepeatPattern() { 53 RepeatPattern() {
54 type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1; 54 type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1;
55 hasEndDate = FALSE; endDateUTC = 0; } 55 hasEndDate = FALSE; endDateUTC = 0; }
56 bool operator ==( const RepeatPattern &right ) const; 56 bool operator ==( const RepeatPattern &right ) const;
57 57
58 RepeatType type; 58 RepeatType type;
59 int frequency; 59 int frequency;
60 int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end... 60 int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end...
61 char days; // a mask for days OR in your days! 61 char days; // a mask for days OR in your days!
62 bool hasEndDate; 62 bool hasEndDate;
63 QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); } 63 QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); }
64 void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); } 64 void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); }
65 time_t endDateUTC; 65 time_t endDateUTC;
66 time_t createTime; 66 time_t createTime;
67 }; 67 };
68 68
69 Event(); 69 Event();
70 Event( const QMap<int, QString > & map ); 70 Event( const QMap<int, QString > & map );
71 virtual ~Event(); 71 virtual ~Event();
72 72
73 QMap<int, QString> toMap() const; 73 QMap<int, QString> toMap() const;
74 74
75 static void writeVCalendar( const QString &filename, const QValueList<Event> &events); 75 static void writeVCalendar( const QString &filename, const QValueList<Event> &events);
76 static void writeVCalendar( const QString &filename, const Event &event); 76 static void writeVCalendar( const QString &filename, const Event &event);
77 static QValueList<Event> readVCalendar( const QString &filename ); 77 static QValueList<Event> readVCalendar( const QString &filename );
78 78
79 enum Type { Normal, AllDay }; 79 enum Type { Normal, AllDay };
80 enum SoundTypeChoice { Silent, Loud }; 80 enum SoundTypeChoice { Silent, Loud };
81 81
82 // Don't use these, there are essentially meaningless. 82 // Don't use these, there are essentially meaningless.
83 bool operator<( const Event &e1) const { return start() < e1.start(); }; 83 bool operator<( const Event &e1) const { return start() < e1.start(); };
84 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; 84 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); };
85 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; 85 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); };
86 bool operator>( const Event &e1 ) const { return start() > e1.start(); }; 86 bool operator>( const Event &e1 ) const { return start() > e1.start(); };
87 bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; 87 bool operator>=(const Event &e1 ) const { return start() >= e1.start(); };
88 bool operator==( const Event &e ) const; 88 bool operator==( const Event &e ) const;
89 89
90 void setDescription( const QString &s ); 90 void setDescription( const QString &s );
91 const QString &description() const; 91 const QString &description() const;
92 92
93 void setLocation( const QString &s ); 93 void setLocation( const QString &s );
94 const QString &location() const; 94 const QString &location() const;
95 95
96 void setNotes( const QString &n ); 96 void setNotes( const QString &n );
97 const QString &notes() const; 97 const QString &notes() const;
98 98
99 void setType( Type t ); // Don't use me. 99 void setType( Type t ); // Don't use me.
100 Type type() const; // Don't use me. 100 Type type() const; // Don't use me.
101 101
102 void setAllDay(bool); 102 void setAllDay(bool);
103 bool isAllDay() const; 103 bool isAllDay() const;
104 104
105 void setStart( const QDateTime &d ); 105 void setStart( const QDateTime &d );
106 void setStart( time_t time ); // don't use me. 106 void setStart( time_t time ); // don't use me.
107 QDateTime start( ) const; 107 QDateTime start( ) const;
108 QDateTime start( bool actual ) const; // don't use me. 108 QDateTime start( bool actual ) const; // don't use me.
109 time_t startTime() const { return startUTC; } // don't use me. 109 time_t startTime() const { return startUTC; } // don't use me.
110 void setEnd( const QDateTime &e ); 110 void setEnd( const QDateTime &e );
111 void setEnd( time_t time ); // don't use me 111 void setEnd( time_t time ); // don't use me
112 QDateTime end( ) const; 112 QDateTime end( ) const;
113 QDateTime end( bool actual ) const; // don't use me. 113 QDateTime end( bool actual ) const; // don't use me.
114 time_t endTime() const { return endUTC; } // don't use me. 114 time_t endTime() const { return endUTC; } // don't use me.
115 void setTimeZone( const QString & ); 115 void setTimeZone( const QString & );
116 const QString &timeZone() const; 116 const QString &timeZone() const;
117 void setAlarm( int minutes, SoundTypeChoice ); 117 void setAlarm( int minutes, SoundTypeChoice );
118 void clearAlarm(); 118 void clearAlarm();
119 void setAlarm( bool b, int minutes, SoundTypeChoice ); // Don't use me. 119 void setAlarm( bool b, int minutes, SoundTypeChoice ); // Don't use me.
120 bool hasAlarm() const; 120 bool hasAlarm() const;
121 int alarmDelay() const; 121 int alarmDelay() const;
122 int alarmTime() const; // Don't use me. 122 int alarmTime() const; // Don't use me.
123 SoundTypeChoice alarmSound() const; 123 SoundTypeChoice alarmSound() const;
124 124
125 RepeatType repeatType() const; 125 RepeatType repeatType() const;
126 int frequency() const; 126 int frequency() const;
127 int weekOffset() const; 127 int weekOffset() const;
128 QDate repeatTill() const; 128 QDate repeatTill() const;
129 bool repeatForever() const; 129 bool repeatForever() const;
130 bool repeatOnWeekDay(int day) const; 130 bool repeatOnWeekDay(int day) const;
131 131
132 void setRepeatType(RepeatType); 132 void setRepeatType(RepeatType);
133 void setFrequency(int); 133 void setFrequency(int);
134 void setRepeatTill(const QDate &); 134 void setRepeatTill(const QDate &);
135 void setRepeatForever(bool); 135 void setRepeatForever(bool);
136 void setRepeatOnWeekDay(int day, bool enable); 136 void setRepeatOnWeekDay(int day, bool enable);
137 137
138 // Don't use any of these. 138 // Don't use any of these.
139 void setRepeat( bool b, const RepeatPattern &p ); 139 void setRepeat( bool b, const RepeatPattern &p );
140 void setRepeat( const RepeatPattern &p ); 140 void setRepeat( const RepeatPattern &p );
141 bool hasRepeat() const; 141 bool hasRepeat() const;
142 const RepeatPattern &repeatPattern() const; 142 const RepeatPattern &repeatPattern() const;
143 RepeatPattern &repeatPattern(); 143 RepeatPattern &repeatPattern();
144 bool doRepeat() const { return pattern.type != NoRepeat; } 144 bool doRepeat() const { return pattern.type != NoRepeat; }
145 145
146 void save( QString& buf ); 146 void save( QString& buf );
147 //void load( Node *n ); 147 //void load( Node *n );
148 148
149 bool match( const QRegExp &r ) const; 149 bool match( const QRegExp &r ) const;
150 150
151 // Don't use these either. Functionality will be moved elsewhere. 151 // Don't use these either. Functionality will be moved elsewhere.
152 152
153 // helper function to calculate the week of the given date 153 // helper function to calculate the week of the given date
154 static int week( const QDate& date ); 154 static int week( const QDate& date );
155 // calculates the number of occurrences of the week day of 155 // calculates the number of occurrences of the week day of
156 // the given date from the start of the month 156 // the given date from the start of the month
157 static int occurrence( const QDate& date ); 157 static int occurrence( const QDate& date );
158 // returns a proper days-char for a given dayOfWeek() 158 // returns a proper days-char for a given dayOfWeek()
159 static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } 159 static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); }
160 // returns the dayOfWeek for the *first* day it finds (ignores 160 // returns the dayOfWeek for the *first* day it finds (ignores
161 // any further days!). Returns 1 (Monday) if there isn't any day found 161 // any further days!). Returns 1 (Monday) if there isn't any day found
162 static int dayOfWeek( char day ); 162 static int dayOfWeek( char day );
163 // returns the difference of months from first to second. 163 // returns the difference of months from first to second.
164 static int monthDiff( const QDate& first, const QDate& second ); 164 static int monthDiff( const QDate& first, const QDate& second );
165 165
166private: 166private:
167 Qtopia::UidGen &uidGen() { return sUidGen; } 167 Qtopia::UidGen &uidGen() { return sUidGen; }
168 static Qtopia::UidGen sUidGen; 168 static Qtopia::UidGen sUidGen;
169 169
170 QString descript, locat, categ; 170 QString descript, locat, categ;
171 Type typ : 4; 171 Type typ : 4;
172 bool startTimeDirty : 1; 172 bool startTimeDirty : 1;
173 bool endTimeDirty : 1; 173 bool endTimeDirty : 1;
174 time_t startUTC, endUTC; 174 time_t startUTC, endUTC;
175 QString tz; 175 QString tz;
176 bool hAlarm, hRepeat; 176 bool hAlarm, hRepeat;
177 int aMinutes; 177 int aMinutes;
178 SoundTypeChoice aSound; 178 SoundTypeChoice aSound;
179 RepeatPattern pattern; 179 RepeatPattern pattern;
180 QString note; 180 QString note;
181 // ADDITION 181 // ADDITION
182 int mRid;// Recode ID 182 int mRid;// Recode ID
183 int mRinfo;// Recode Info 183 int mRinfo;// Recode Info
184 // 184 //
185 EventPrivate *d; 185 EventPrivate *d;
186 186
187}; 187};
188 188
189// Since an event spans multiple day, it is better to have this 189// Since an event spans multiple day, it is better to have this
190// class to represent a day instead of creating many 190// class to represent a day instead of creating many
191// dummy events... 191// dummy events...
192 192
193class EffectiveEventPrivate; 193class EffectiveEventPrivate;
194class QPC_EXPORT EffectiveEvent 194class QPC_EXPORT EffectiveEvent
195{ 195{
196public: 196public:
197 // If we calculate the effective event of a multi-day event 197 // If we calculate the effective event of a multi-day event
198 // we have to figure out whether we are at the first day, 198 // we have to figure out whether we are at the first day,
199 // at the end, or anywhere else ("middle"). This is important 199 // at the end, or anywhere else ("middle"). This is important
200 // for the start/end times (00:00/23:59) 200 // for the start/end times (00:00/23:59)
201 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 201 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
202 // day event 202 // day event
203 // Start: start time -> 23:59 203 // Start: start time -> 23:59
204 // End: 00:00 -> end time 204 // End: 00:00 -> end time
205 // Start | End == StartEnd: for single-day events (default) 205 // Start | End == StartEnd: for single-day events (default)
206 // here we draw start time -> end time 206 // here we draw start time -> end time
207 enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; 207 enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 };
208 208
209 EffectiveEvent(); 209 EffectiveEvent();
210 EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); 210 EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd );
211 EffectiveEvent( const EffectiveEvent & ); 211 EffectiveEvent( const EffectiveEvent & );
212 EffectiveEvent& operator=( const EffectiveEvent & ); 212 EffectiveEvent& operator=( const EffectiveEvent & );
213 ~EffectiveEvent(); 213 ~EffectiveEvent();
214 214
215 215
216 bool operator<( const EffectiveEvent &e ) const; 216 bool operator<( const EffectiveEvent &e ) const;
217 bool operator<=( const EffectiveEvent &e ) const; 217 bool operator<=( const EffectiveEvent &e ) const;
218 bool operator==( const EffectiveEvent &e ) const; 218 bool operator==( const EffectiveEvent &e ) const;
219 bool operator!=( const EffectiveEvent &e ) const; 219 bool operator!=( const EffectiveEvent &e ) const;
220 bool operator>( const EffectiveEvent &e ) const; 220 bool operator>( const EffectiveEvent &e ) const;
221 bool operator>= ( const EffectiveEvent &e ) const; 221 bool operator>= ( const EffectiveEvent &e ) const;
222 222
223 void setStart( const QTime &start ); 223 void setStart( const QTime &start );
224 void setEnd( const QTime &end ); 224 void setEnd( const QTime &end );
225 void setEvent( Event e ); 225 void setEvent( Event e );
226 void setDate( const QDate &date ); 226 void setDate( const QDate &date );
227 void setEffectiveDates( const QDate &from, const QDate &to ); 227 void setEffectiveDates( const QDate &from, const QDate &to );
228 228
229 // QString category() const; 229 // QString category() const;
230 const QString &description() const; 230 const QString &description() const;
231 const QString &location() const; 231 const QString &location() const;
232 const QString &notes() const; 232 const QString &notes() const;
233 const Event &event() const; 233 const Event &event() const;
234 const QTime &start() const; 234 const QTime &start() const;
235 const QTime &end() const; 235 const QTime &end() const;
236 const QDate &date() const; 236 const QDate &date() const;
237 int length() const; 237 int length() const;
238 int size() const; 238 int size() const;
239 239
240 QDate startDate() const; 240 QDate startDate() const;
241 QDate endDate() const; 241 QDate endDate() const;
242 242
243private: 243private:
244 class EffectiveEventPrivate *d; 244 class EffectiveEventPrivate *d;
245 Event mEvent; 245 Event mEvent;
246 QDate mDate; 246 QDate mDate;
247 QTime mStart, 247 QTime mStart,
248 mEnd; 248 mEnd;
249 249
250}; 250};
251 251
252inline void Event::setAlarm( int minutes, SoundTypeChoice s ) 252inline void Event::setAlarm( int minutes, SoundTypeChoice s )
253{ 253{
254 setAlarm(TRUE, minutes, s); 254 setAlarm(TRUE, minutes, s);
255} 255}
256 256
257inline void Event::clearAlarm() 257inline void Event::clearAlarm()
258{ 258{
259 setAlarm(FALSE, 0, Silent); 259 setAlarm(FALSE, 0, Silent);
260} 260}
261 261
262inline int Event::alarmDelay() const 262inline int Event::alarmDelay() const
263{ 263{
264 return alarmTime(); 264 return alarmTime();
265} 265}
266 266
267inline void Event::setAllDay(bool enable) 267inline void Event::setAllDay(bool enable)
268{ 268{
269 if (enable) 269 if (enable)
270 setType(AllDay); 270 setType(AllDay);
271 else 271 else
272 setType(Normal); 272 setType(Normal);
273}; 273};
274 274
275inline bool Event::isAllDay() const 275inline bool Event::isAllDay() const
276{ 276{
277 return type() == AllDay; 277 return type() == AllDay;
278} 278}
279 279
280inline Event::RepeatType Event::repeatType() const 280inline Event::RepeatType Event::repeatType() const
281{ 281{
282 return repeatPattern().type; 282 return repeatPattern().type;
283} 283}
284 284
285inline int Event::frequency() const 285inline int Event::frequency() const
286{ 286{
287 return repeatPattern().frequency; 287 return repeatPattern().frequency;
288} 288}
289 289
290inline int Event::weekOffset() const 290inline int Event::weekOffset() const
291{ 291{
292 if (start().date().day() == 1) 292 if (start().date().day() == 1)
293 return 1; 293 return 1;
294 return (start().date().day() - 1) / 7 + 1; 294 return (start().date().day() - 1) / 7 + 1;
295} 295}
296 296
297inline QDate Event::repeatTill() const 297inline QDate Event::repeatTill() const
298{ 298{
299 return repeatPattern().endDate(); 299 return repeatPattern().endDate();
300} 300}
301 301
302inline bool Event::repeatForever() const 302inline bool Event::repeatForever() const
303{ 303{
304 return !repeatPattern().hasEndDate; 304 return !repeatPattern().hasEndDate;
305} 305}
306 306
307inline void Event::setRepeatType(RepeatType t) 307inline void Event::setRepeatType(RepeatType t)
308{ 308{
309 pattern.type = t; 309 pattern.type = t;
310} 310}
311 311
312inline void Event::setFrequency(int f) 312inline void Event::setFrequency(int f)
313{ 313{
314 pattern.frequency = f; 314 pattern.frequency = f;
315} 315}
316 316
317inline void Event::setRepeatTill(const QDate &d) 317inline void Event::setRepeatTill(const QDate &d)
318{ 318{
319 pattern.setEndDate(d); 319 pattern.setEndDate(d);
320 pattern.hasEndDate = TRUE; 320 pattern.hasEndDate = TRUE;
321} 321}
322 322
323inline void Event::setRepeatForever(bool b) 323inline void Event::setRepeatForever(bool b)
324{ 324{
325 if (!b == pattern.hasEndDate) 325 if (!b == pattern.hasEndDate)
326 return; 326 return;
327 if (!b && !pattern.hasEndDate) 327 if (!b && !pattern.hasEndDate)
328 pattern.setEndDate(end().date()); 328 pattern.setEndDate(end().date());
329 pattern.hasEndDate = !b; 329 pattern.hasEndDate = !b;
330} 330}
331 331
332inline bool Event::repeatOnWeekDay(int day) const 332inline bool Event::repeatOnWeekDay(int day) const
333{ 333{
334 if (pattern.type != Weekly) 334 if (pattern.type != Weekly)
335 return FALSE; 335 return FALSE;
336 return ( (1 << (day - 1)) & pattern.days ) != 0; 336 return ( (1 << (day - 1)) & pattern.days ) != 0;
337} 337}
338 338
339inline void Event::setRepeatOnWeekDay(int day, bool enable) 339inline void Event::setRepeatOnWeekDay(int day, bool enable)
340{ 340{
341 if ( repeatOnWeekDay( day ) != enable ) 341 if ( repeatOnWeekDay( day ) != enable )
342 pattern.days ^= 1 << (day - 1); 342 pattern.days ^= 1 << (day - 1);
343} 343}
344 344/*
345inline QDateTime Event::start( ) const 345inline QDateTime Event::start( ) const
346{ 346{
347 return start(FALSE); 347 return start(FALSE);
348} 348}
349 349
350inline QDateTime Event::end( ) const 350inline QDateTime Event::end( ) const
351{ 351{
352 return end(FALSE); 352 return end(FALSE);
353} 353}
354 354*/
355#ifdef PALMTOPCENTER 355#ifdef PALMTOPCENTER
356class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> 356class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent>
357{ 357{
358public: 358public:
359 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const 359 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const
360 { 360 {
361 return a.size() - b.size(); 361 return a.size() - b.size();
362 } 362 }
363}; 363};
364 364
365class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent> 365class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent>
366{ 366{
367public: 367public:
368 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const 368 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const
369 { 369 {
370 return a.start().secsTo( b.start() ); 370 return a.start().secsTo( b.start() );
371 } 371 }
372}; 372};
373#endif 373#endif
374 374
375#endif 375#endif