summaryrefslogtreecommitdiff
Unidiff
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
@@ -363,129 +363,129 @@ Event::Event( const QMap<int, QString> &map )
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/*!
@@ -524,144 +524,149 @@ void Event::setEnd( time_t time )
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/*!
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
@@ -207,169 +207,169 @@ public:
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