summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/event.cpp5
-rw-r--r--library/backend/event.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/library/backend/event.cpp b/library/backend/event.cpp
index 8f3f780..7cac314 100644
--- a/library/backend/event.cpp
+++ b/library/backend/event.cpp
@@ -204,789 +204,792 @@ Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia );
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 { 589QDateTime Event::start() const {
589 return start( TRUE ); 590 return start( TRUE );
590} 591}
592*/
591/*! 593/*!
592 \internal 594 \internal
593*/ 595*/
594QDateTime Event::start( bool actual ) const 596QDateTime Event::start( bool actual ) const
595{ 597{
596 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); 598 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime();
597 599
598 if ( actual && typ == AllDay ) { 600 if ( actual && typ == AllDay ) {
599 QTime t = dt.time(); 601 QTime t = dt.time();
600 t.setHMS( 0, 0, 0 ); 602 t.setHMS( 0, 0, 0 );
601 dt.setTime( t ); 603 dt.setTime( t );
602 } 604 }
603 return dt; 605 return dt;
604} 606}
605 607/*
606QDateTime Event::end() const { 608QDateTime Event::end() const {
607 return end( TRUE ); 609 return end( TRUE );
608} 610}
611*/
609/*! 612/*!
610 \internal 613 \internal
611*/ 614*/
612QDateTime Event::end( bool actual ) const 615QDateTime Event::end( bool actual ) const
613{ 616{
614 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); 617 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime();
615 618
616 if ( actual && typ == AllDay ) { 619 if ( actual && typ == AllDay ) {
617 QTime t = dt.time(); 620 QTime t = dt.time();
618 t.setHMS( 23, 59, 59 ); 621 t.setHMS( 23, 59, 59 );
619 dt.setTime( t ); 622 dt.setTime( t );
620 } 623 }
621 return dt; 624 return dt;
622} 625}
623 626
624/*! 627/*!
625 \internal 628 \internal
626*/ 629*/
627const QString &Event::timeZone() const 630const QString &Event::timeZone() const
628{ 631{
629 return tz; 632 return tz;
630} 633}
631 634
632/*! 635/*!
633 \internal 636 \internal
634*/ 637*/
635bool Event::hasAlarm() const 638bool Event::hasAlarm() const
636{ 639{
637 return hAlarm; 640 return hAlarm;
638} 641}
639 642
640/*! 643/*!
641 \internal 644 \internal
642*/ 645*/
643int Event::alarmTime() const 646int Event::alarmTime() const
644{ 647{
645 return aMinutes; 648 return aMinutes;
646} 649}
647 650
648/*! 651/*!
649 Returns the sound type for the alarm of this event. 652 Returns the sound type for the alarm of this event.
650*/ 653*/
651Event::SoundTypeChoice Event::alarmSound() const 654Event::SoundTypeChoice Event::alarmSound() const
652{ 655{
653 return aSound; 656 return aSound;
654} 657}
655 658
656/*! 659/*!
657 \internal 660 \internal
658*/ 661*/
659bool Event::hasRepeat() const 662bool Event::hasRepeat() const
660{ 663{
661 return doRepeat(); 664 return doRepeat();
662} 665}
663 666
664/*! 667/*!
665 \internal 668 \internal
666*/ 669*/
667const Event::RepeatPattern &Event::repeatPattern() const 670const Event::RepeatPattern &Event::repeatPattern() const
668{ 671{
669 return pattern; 672 return pattern;
670} 673}
671 674
672/*! 675/*!
673 \internal 676 \internal
674*/ 677*/
675Event::RepeatPattern &Event::repeatPattern() 678Event::RepeatPattern &Event::repeatPattern()
676{ 679{
677 return pattern; 680 return pattern;
678} 681}
679 682
680/*! 683/*!
681 Returns the notes for the event. 684 Returns the notes for the event.
682*/ 685*/
683const QString &Event::notes() const 686const QString &Event::notes() const
684{ 687{
685 return note; 688 return note;
686} 689}
687 690
688/*! 691/*!
689 \internal 692 \internal
690*/ 693*/
691bool Event::operator==( const Event &e ) const 694bool Event::operator==( const Event &e ) const
692{ 695{
693 if ( uid() && e.uid() == uid() ) 696 if ( uid() && e.uid() == uid() )
694 return TRUE; 697 return TRUE;
695 return ( e.descript == descript && 698 return ( e.descript == descript &&
696 e.locat == locat && 699 e.locat == locat &&
697 e.categ == categ && 700 e.categ == categ &&
698 e.typ == typ && 701 e.typ == typ &&
699 e.startUTC == startUTC && 702 e.startUTC == startUTC &&
700 e.endUTC == endUTC && 703 e.endUTC == endUTC &&
701 e.tz == tz && 704 e.tz == tz &&
702 e.hAlarm == hAlarm && 705 e.hAlarm == hAlarm &&
703 e.aMinutes == aMinutes && 706 e.aMinutes == aMinutes &&
704 e.aSound == aSound && 707 e.aSound == aSound &&
705 e.hRepeat == hRepeat && 708 e.hRepeat == hRepeat &&
706 e.pattern == pattern && 709 e.pattern == pattern &&
707 e.note == note ); 710 e.note == note );
708} 711}
709 712
710/*! 713/*!
711 \internal 714 \internal
712 Appends the contact information to \a buf. 715 Appends the contact information to \a buf.
713*/ 716*/
714void Event::save( QString& buf ) 717void Event::save( QString& buf )
715{ 718{
716 buf += " description=\"" + Qtopia::escapeString(descript) + "\""; 719 buf += " description=\"" + Qtopia::escapeString(descript) + "\"";
717 if ( !locat.isEmpty() ) 720 if ( !locat.isEmpty() )
718 buf += " location=\"" + Qtopia::escapeString(locat) + "\""; 721 buf += " location=\"" + Qtopia::escapeString(locat) + "\"";
719 // save the categoies differently.... 722 // save the categoies differently....
720 QString strCats = idsToString( categories() ); 723 QString strCats = idsToString( categories() );
721 buf += " categories=\"" + Qtopia::escapeString(strCats) + "\""; 724 buf += " categories=\"" + Qtopia::escapeString(strCats) + "\"";
722 buf += " uid=\"" + QString::number( uid() ) + "\""; 725 buf += " uid=\"" + QString::number( uid() ) + "\"";
723 if ( (Type)typ != Normal ) 726 if ( (Type)typ != Normal )
724 buf += " type=\"AllDay\""; 727 buf += " type=\"AllDay\"";
725 if ( hAlarm ) { 728 if ( hAlarm ) {
726 buf += " alarm=\"" + QString::number( aMinutes ) + "\" sound=\""; 729 buf += " alarm=\"" + QString::number( aMinutes ) + "\" sound=\"";
727 if ( aSound == Event::Loud ) 730 if ( aSound == Event::Loud )
728 buf += "loud"; 731 buf += "loud";
729 else 732 else
730 buf += "silent"; 733 buf += "silent";
731 buf += "\""; 734 buf += "\"";
732 } 735 }
733 if ( hRepeat ) 736 if ( hRepeat )
734 write( buf, pattern ); 737 write( buf, pattern );
735 738
736 buf += " start=\"" 739 buf += " start=\""
737 + QString::number( startUTC ) 740 + QString::number( startUTC )
738 + "\""; 741 + "\"";
739 742
740 buf += " end=\"" 743 buf += " end=\""
741 + QString::number( endUTC ) 744 + QString::number( endUTC )
742 + "\""; 745 + "\"";
743 746
744 if ( !note.isEmpty() ) 747 if ( !note.isEmpty() )
745 buf += " note=\"" + Qtopia::escapeString( note ) + "\""; 748 buf += " note=\"" + Qtopia::escapeString( note ) + "\"";
746 buf += customToXml(); 749 buf += customToXml();
747} 750}
748 751
749/*! 752/*!
750 \internal 753 \internal
751*/ 754*/
752bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const 755bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
753{ 756{
754 // *sigh* 757 // *sigh*
755 return ( type == right.type 758 return ( type == right.type
756 && frequency == right.frequency 759 && frequency == right.frequency
757 && position == right.position 760 && position == right.position
758 && days == right.days 761 && days == right.days
759 && hasEndDate == right.hasEndDate 762 && hasEndDate == right.hasEndDate
760 && endDateUTC == right.endDateUTC 763 && endDateUTC == right.endDateUTC
761 && createTime == right.createTime ); 764 && createTime == right.createTime );
762} 765}
763 766
764/*! 767/*!
765 \class EffectiveEvent 768 \class EffectiveEvent
766 \brief The EffectiveEvent class the data for a single occurance of an event. 769 \brief The EffectiveEvent class the data for a single occurance of an event.
767 770
768 This class describes the event for a single occurance of it. For example if 771 This class describes the event for a single occurance of it. For example if
769 an Event occurs every week, the effective event might represent the third 772 an Event occurs every week, the effective event might represent the third
770 occurance of this Event. 773 occurance of this Event.
771 774
772 \ingroup qtopiaemb 775 \ingroup qtopiaemb
773 \ingroup qtopiadesktop 776 \ingroup qtopiadesktop
774 \warning This class will be phased out in Qtopia 3.x 777 \warning This class will be phased out in Qtopia 3.x
775*/ 778*/
776 779
777/*! 780/*!
778 \enum EffectiveEvent::Position 781 \enum EffectiveEvent::Position
779 \internal 782 \internal
780*/ 783*/
781 784
782/*! 785/*!
783 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &) 786 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &)
784 \internal 787 \internal
785*/ 788*/
786 789
787class EffectiveEventPrivate 790class EffectiveEventPrivate
788{ 791{
789public: 792public:
790 //currently the existence of the d pointer means multi-day repeating, 793 //currently the existence of the d pointer means multi-day repeating,
791 //msut be changed if we use the d pointer for anything else. 794 //msut be changed if we use the d pointer for anything else.
792 QDate startDate; 795 QDate startDate;
793 QDate endDate; 796 QDate endDate;
794}; 797};
795 798
796/*! 799/*!
797 \internal 800 \internal
798*/ 801*/
799EffectiveEvent::EffectiveEvent() 802EffectiveEvent::EffectiveEvent()
800{ 803{
801 mDate = QDate::currentDate(); 804 mDate = QDate::currentDate();
802 mStart = mEnd = QTime::currentTime(); 805 mStart = mEnd = QTime::currentTime();
803 d = 0; 806 d = 0;
804} 807}
805 808
806/*! 809/*!
807 \internal 810 \internal
808*/ 811*/
809EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) 812EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos )
810{ 813{
811 mEvent = e; 814 mEvent = e;
812 mDate = date; 815 mDate = date;
813 if ( pos & Start ) 816 if ( pos & Start )
814 mStart = e.start( TRUE ).time(); 817 mStart = e.start( TRUE ).time();
815 else 818 else
816 mStart = QTime( 0, 0, 0 ); 819 mStart = QTime( 0, 0, 0 );
817 820
818 if ( pos & End ) 821 if ( pos & End )
819 mEnd = e.end( TRUE ).time(); 822 mEnd = e.end( TRUE ).time();
820 else 823 else
821 mEnd = QTime( 23, 59, 59 ); 824 mEnd = QTime( 23, 59, 59 );
822 d = 0; 825 d = 0;
823} 826}
824 827
825/*! 828/*!
826 \internal 829 \internal
827*/ 830*/
828EffectiveEvent::~EffectiveEvent() 831EffectiveEvent::~EffectiveEvent()
829{ 832{
830 delete d; 833 delete d;
831} 834}
832 835
833/*! 836/*!
834 \internal 837 \internal
835*/ 838*/
836EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) 839EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
837{ 840{
838 d = 0; 841 d = 0;
839 *this = e; 842 *this = e;
840} 843}
841 844
842EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) 845EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
843{ 846{
844 if ( &e == this ) 847 if ( &e == this )
845 return *this; 848 return *this;
846 delete d; 849 delete d;
847 if ( e.d ) { 850 if ( e.d ) {
848 d = new EffectiveEventPrivate; 851 d = new EffectiveEventPrivate;
849 d->startDate = e.d->startDate; 852 d->startDate = e.d->startDate;
850 d->endDate = e.d->endDate; 853 d->endDate = e.d->endDate;
851 } else { 854 } else {
852 d = 0; 855 d = 0;
853 } 856 }
854 mEvent = e.mEvent; 857 mEvent = e.mEvent;
855 mDate = e.mDate; 858 mDate = e.mDate;
856 mStart = e.mStart; 859 mStart = e.mStart;
857 mEnd = e.mEnd; 860 mEnd = e.mEnd;
858 861
859 return *this; 862 return *this;
860 863
861} 864}
862 865
863// QString EffectiveEvent::category() const 866// QString EffectiveEvent::category() const
864// { 867// {
865// return mEvent.category(); 868// return mEvent.category();
866// } 869// }
867 870
868/*! 871/*!
869 Returns the description of the event for this effective event. 872 Returns the description of the event for this effective event.
870*/ 873*/
871const QString &EffectiveEvent::description( ) const 874const QString &EffectiveEvent::description( ) const
872{ 875{
873 return mEvent.description(); 876 return mEvent.description();
874} 877}
875 878
876/*! 879/*!
877\internal 880\internal
878*/ 881*/
879const QString &EffectiveEvent::location( ) const 882const QString &EffectiveEvent::location( ) const
880{ 883{
881 return mEvent.location(); 884 return mEvent.location();
882} 885}
883 886
884/*! 887/*!
885\internal 888\internal
886*/ 889*/
887const QString &EffectiveEvent::notes() const 890const QString &EffectiveEvent::notes() const
888{ 891{
889 return mEvent.notes(); 892 return mEvent.notes();
890} 893}
891 894
892/*! 895/*!
893 Returns the event associated with this effective event. 896 Returns the event associated with this effective event.
894*/ 897*/
895const Event &EffectiveEvent::event() const 898const Event &EffectiveEvent::event() const
896{ 899{
897 return mEvent; 900 return mEvent;
898} 901}
899 902
900/*! 903/*!
901 \internal 904 \internal
902*/ 905*/
903const QTime &EffectiveEvent::end() const 906const QTime &EffectiveEvent::end() const
904{ 907{
905 return mEnd; 908 return mEnd;
906} 909}
907 910
908/*! 911/*!
909 \internal 912 \internal
910*/ 913*/
911const QTime &EffectiveEvent::start() const 914const QTime &EffectiveEvent::start() const
912{ 915{
913 return mStart; 916 return mStart;
914} 917}
915 918
916/*! 919/*!
917 Returns the date the effective event occurs on. 920 Returns the date the effective event occurs on.
918*/ 921*/
919const QDate &EffectiveEvent::date() const 922const QDate &EffectiveEvent::date() const
920{ 923{
921 return mDate; 924 return mDate;
922} 925}
923 926
924/*! 927/*!
925 \internal 928 \internal
926*/ 929*/
927int EffectiveEvent::length() const 930int EffectiveEvent::length() const
928{ 931{
929 return (mEnd.hour() * 60 - mStart.hour() * 60) 932 return (mEnd.hour() * 60 - mStart.hour() * 60)
930 + QABS(mStart.minute() - mEnd.minute() ); 933 + QABS(mStart.minute() - mEnd.minute() );
931} 934}
932 935
933/*! 936/*!
934 \internal 937 \internal
935*/ 938*/
936void EffectiveEvent::setDate( const QDate &dt ) 939void EffectiveEvent::setDate( const QDate &dt )
937{ 940{
938 mDate = dt; 941 mDate = dt;
939} 942}
940 943
941/*! 944/*!
942 \internal 945 \internal
943*/ 946*/
944void EffectiveEvent::setStart( const QTime &start ) 947void EffectiveEvent::setStart( const QTime &start )
945{ 948{
946 mStart = start; 949 mStart = start;
947} 950}
948 951
949/*! 952/*!
950 \internal 953 \internal
951*/ 954*/
952void EffectiveEvent::setEnd( const QTime &end ) 955void EffectiveEvent::setEnd( const QTime &end )
953{ 956{
954 mEnd = end; 957 mEnd = end;
955} 958}
956 959
957/*! 960/*!
958 \internal 961 \internal
959*/ 962*/
960void EffectiveEvent::setEvent( Event e ) 963void EffectiveEvent::setEvent( Event e )
961{ 964{
962 mEvent = e; 965 mEvent = e;
963} 966}
964 967
965/*! 968/*!
966 \internal 969 \internal
967*/ 970*/
968bool EffectiveEvent::operator<( const EffectiveEvent &e ) const 971bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
969{ 972{
970 if ( mDate < e.date() ) 973 if ( mDate < e.date() )
971 return TRUE; 974 return TRUE;
972 if ( mDate == e.date() ) 975 if ( mDate == e.date() )
973 return ( mStart < e.start() ); 976 return ( mStart < e.start() );
974 else 977 else
975 return FALSE; 978 return FALSE;
976} 979}
977 980
978/*! 981/*!
979 \internal 982 \internal
980*/ 983*/
981bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const 984bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
982{ 985{
983 return (mDate <= e.date() ); 986 return (mDate <= e.date() );
984} 987}
985 988
986/*! 989/*!
987 \internal 990 \internal
988*/ 991*/
989bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 992bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
990{ 993{
991 return ( mDate == e.date() 994 return ( mDate == e.date()
992 && mStart == e.start() 995 && mStart == e.start()
diff --git a/library/backend/event.h b/library/backend/event.h
index 2b275a4..4610d85 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