-rw-r--r-- | library/backend/event.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/backend/event.cpp b/library/backend/event.cpp index 90860e8..abc420b 100644 --- a/library/backend/event.cpp +++ b/library/backend/event.cpp | |||
@@ -338,129 +338,129 @@ Event::Event() : Record() | |||
338 | Event::Event( const QMap<int, QString> &map ) | 338 | Event::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 | */ |
364 | Event::~Event() | 364 | Event::~Event() |
365 | { | 365 | { |
366 | } | 366 | } |
367 | 367 | ||
368 | /*! | 368 | /*! |
369 | \internal | 369 | \internal |
370 | */ | 370 | */ |
371 | int Event::week( const QDate& date ) | 371 | int 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 | */ |
388 | int Event::occurrence( const QDate& date ) | 388 | int 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 | */ |
398 | int Event::dayOfWeek( char day ) | 398 | int 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 <= static_cast<char>(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 | */ |
412 | int Event::monthDiff( const QDate& first, const QDate& second ) | 412 | int 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 | */ |
421 | QMap<int, QString> Event::toMap() const | 421 | QMap<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 | */ |
457 | void Event::setRepeat( const RepeatPattern &p ) | 457 | void 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 | */ |
465 | void Event::setDescription( const QString &s ) | 465 | void Event::setDescription( const QString &s ) |
466 | { | 466 | { |