Diffstat (limited to 'libopie2/opiepim/core/opimevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp index 9d46651..8752fce 100644 --- a/libopie2/opiepim/core/opimevent.cpp +++ b/libopie2/opiepim/core/opimevent.cpp | |||
@@ -12,48 +12,50 @@ | |||
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "opimevent.h" | 30 | #include "opimevent.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimrecurrence.h> | 33 | #include <opie2/opimrecurrence.h> |
34 | #include <opie2/opimresolver.h> | 34 | #include <opie2/opimresolver.h> |
35 | #include <opie2/opimnotifymanager.h> | 35 | #include <opie2/opimnotifymanager.h> |
36 | #include <opie2/odebug.h> | ||
37 | |||
36 | #include <qpe/categories.h> | 38 | #include <qpe/categories.h> |
37 | #include <qpe/stringutil.h> | 39 | #include <qpe/stringutil.h> |
38 | 40 | ||
39 | /* QT */ | 41 | /* QT */ |
40 | 42 | ||
41 | namespace Opie | 43 | namespace Opie |
42 | { | 44 | { |
43 | 45 | ||
44 | int OCalendarHelper::week( const QDate& date ) | 46 | int OCalendarHelper::week( const QDate& date ) |
45 | { | 47 | { |
46 | // Calculates the week this date is in within that | 48 | // Calculates the week this date is in within that |
47 | // month. Equals the "row" is is in in the month view | 49 | // month. Equals the "row" is is in in the month view |
48 | int week = 1; | 50 | int week = 1; |
49 | QDate tmp( date.year(), date.month(), 1 ); | 51 | QDate tmp( date.year(), date.month(), 1 ); |
50 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 52 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
51 | ++week; | 53 | ++week; |
52 | 54 | ||
53 | week += ( date.day() - 1 ) / 7; | 55 | week += ( date.day() - 1 ) / 7; |
54 | 56 | ||
55 | return week; | 57 | return week; |
56 | } | 58 | } |
57 | 59 | ||
58 | 60 | ||
59 | int OCalendarHelper::ocurrence( const QDate& date ) | 61 | int OCalendarHelper::ocurrence( const QDate& date ) |
@@ -534,53 +536,53 @@ void OPimEvent::changeOrModify() | |||
534 | 536 | ||
535 | 537 | ||
536 | void OPimEvent::deref() | 538 | void OPimEvent::deref() |
537 | { | 539 | { |
538 | if ( data->deref() ) | 540 | if ( data->deref() ) |
539 | { | 541 | { |
540 | delete data; | 542 | delete data; |
541 | data = 0; | 543 | data = 0; |
542 | } | 544 | } |
543 | } | 545 | } |
544 | // Exporting Event data to map. Using the same | 546 | // Exporting Event data to map. Using the same |
545 | // encoding as ODateBookAccessBackend_xml does.. | 547 | // encoding as ODateBookAccessBackend_xml does.. |
546 | // Thus, we could remove the stuff there and use this | 548 | // Thus, we could remove the stuff there and use this |
547 | // for it and for all other places.. | 549 | // for it and for all other places.. |
548 | // Encoding should happen at one place, only ! (eilers) | 550 | // Encoding should happen at one place, only ! (eilers) |
549 | QMap<int, QString> OPimEvent::toMap() const | 551 | QMap<int, QString> OPimEvent::toMap() const |
550 | { | 552 | { |
551 | QMap<int, QString> retMap; | 553 | QMap<int, QString> retMap; |
552 | 554 | ||
553 | retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); | 555 | retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); |
554 | retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); | 556 | retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); |
555 | retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); | 557 | retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); |
556 | retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); | 558 | retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); |
557 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); | 559 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); |
558 | if ( notifiers().alarms().count() ){ | 560 | if ( notifiers().alarms().count() ){ |
559 | // Currently we just support one alarm.. (eilers) | 561 | // Currently we just support one alarm.. (eilers) |
560 | OPimAlarm alarm = notifiers().alarms() [ 0 ]; | 562 | OPimAlarm alarm = notifiers().alarms() [ 0 ]; |
561 | retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); | 563 | retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); |
562 | retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); | 564 | retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); |
563 | } | 565 | } |
564 | 566 | ||
565 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); | 567 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); |
566 | retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); | 568 | retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); |
567 | retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); | 569 | retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); |
568 | retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); | 570 | retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); |
569 | retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); | 571 | retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); |
570 | if ( parent() ) | 572 | if ( parent() ) |
571 | retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); | 573 | retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); |
572 | if ( children().count() ) | 574 | if ( children().count() ) |
573 | { | 575 | { |
574 | QArray<int> childr = children(); | 576 | QArray<int> childr = children(); |
575 | QString buf; | 577 | QString buf; |
576 | for ( uint i = 0; i < childr.count(); i++ ) | 578 | for ( uint i = 0; i < childr.count(); i++ ) |
577 | { | 579 | { |
578 | if ( i != 0 ) buf += " "; | 580 | if ( i != 0 ) buf += " "; |
579 | buf += QString::number( childr[ i ] ); | 581 | buf += QString::number( childr[ i ] ); |
580 | } | 582 | } |
581 | retMap.insert( OPimEvent::FRecChildren, buf ); | 583 | retMap.insert( OPimEvent::FRecChildren, buf ); |
582 | } | 584 | } |
583 | 585 | ||
584 | // Add recurrence stuff | 586 | // Add recurrence stuff |
585 | if ( hasRecurrence() ) | 587 | if ( hasRecurrence() ) |
586 | { | 588 | { |
@@ -620,73 +622,73 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) | |||
620 | if ( map[ OPimEvent::FType ] == "AllDay" ) | 622 | if ( map[ OPimEvent::FType ] == "AllDay" ) |
621 | setAllDay( true ); | 623 | setAllDay( true ); |
622 | else | 624 | else |
623 | setAllDay( false ); | 625 | setAllDay( false ); |
624 | 626 | ||
625 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) | 627 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) |
626 | { | 628 | { |
627 | setTimeZone( map[ OPimEvent::FTimeZone ] ); | 629 | setTimeZone( map[ OPimEvent::FTimeZone ] ); |
628 | } | 630 | } |
629 | 631 | ||
630 | time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); | 632 | time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); |
631 | time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); | 633 | time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); |
632 | 634 | ||
633 | /* AllDay is always in UTC */ | 635 | /* AllDay is always in UTC */ |
634 | if ( isAllDay() ) | 636 | if ( isAllDay() ) |
635 | { | 637 | { |
636 | OPimTimeZone utc = OPimTimeZone::utc(); | 638 | OPimTimeZone utc = OPimTimeZone::utc(); |
637 | setStartDateTime( utc.fromUTCDateTime( start ) ); | 639 | setStartDateTime( utc.fromUTCDateTime( start ) ); |
638 | setEndDateTime ( utc.fromUTCDateTime( end ) ); | 640 | setEndDateTime ( utc.fromUTCDateTime( end ) ); |
639 | setTimeZone( "UTC" ); // make sure it is really utc | 641 | setTimeZone( "UTC" ); // make sure it is really utc |
640 | } | 642 | } |
641 | else | 643 | else |
642 | { | 644 | { |
643 | /* to current date time */ | 645 | /* to current date time */ |
644 | // qWarning(" Start is %d", start ); | 646 | // owarn << " Start is " << start << "" << oendl; |
645 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); | 647 | OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); |
646 | QDateTime date = zone.toDateTime( start ); | 648 | QDateTime date = zone.toDateTime( start ); |
647 | qWarning( " Start is %s", date.toString().latin1() ); | 649 | owarn << " Start is " << date.toString() << "" << oendl; |
648 | setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); | 650 | setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); |
649 | 651 | ||
650 | date = zone.toDateTime( end ); | 652 | date = zone.toDateTime( end ); |
651 | setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); | 653 | setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); |
652 | } | 654 | } |
653 | 655 | ||
654 | int alarmTime = -1; | 656 | int alarmTime = -1; |
655 | if ( !map[ OPimEvent::FAlarm ].isEmpty() ) | 657 | if ( !map[ OPimEvent::FAlarm ].isEmpty() ) |
656 | alarmTime = map[ OPimEvent::FAlarm ].toInt(); | 658 | alarmTime = map[ OPimEvent::FAlarm ].toInt(); |
657 | 659 | ||
658 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 660 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
659 | if ( ( alarmTime != -1 ) ) | 661 | if ( ( alarmTime != -1 ) ) |
660 | { | 662 | { |
661 | QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); | 663 | QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); |
662 | OPimAlarm al( sound , dt ); | 664 | OPimAlarm al( sound , dt ); |
663 | notifiers().add( al ); | 665 | notifiers().add( al ); |
664 | } | 666 | } |
665 | 667 | ||
666 | 668 | ||
667 | if ( !map[ OPimEvent::FNote ].isEmpty() ) | 669 | if ( !map[ OPimEvent::FNote ].isEmpty() ) |
668 | setNote( map[ OPimEvent::FNote ] ); | 670 | setNote( map[ OPimEvent::FNote ] ); |
669 | 671 | ||
670 | if ( !map[ OPimEvent::FRecParent ].isEmpty() ) | 672 | if ( !map[ OPimEvent::FRecParent ].isEmpty() ) |
671 | setParent( map[ OPimEvent::FRecParent ].toInt() ); | 673 | setParent( map[ OPimEvent::FRecParent ].toInt() ); |
672 | 674 | ||
673 | if ( !map[ OPimEvent::FRecChildren ].isEmpty() ) | 675 | if ( !map[ OPimEvent::FRecChildren ].isEmpty() ) |
674 | { | 676 | { |
675 | QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] ); | 677 | QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] ); |
676 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 678 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
677 | { | 679 | { |
678 | addChild( ( *it ).toInt() ); | 680 | addChild( ( *it ).toInt() ); |
679 | } | 681 | } |
680 | } | 682 | } |
681 | 683 | ||
682 | // Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap.. | 684 | // Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap.. |
683 | if ( !map[ OPimEvent::FRType ].isEmpty() ) | 685 | if ( !map[ OPimEvent::FRType ].isEmpty() ) |
684 | { | 686 | { |
685 | QMap<int, QString> recFields; | 687 | QMap<int, QString> recFields; |
686 | recFields.insert( OPimRecurrence::RType, map[ OPimEvent::FRType ] ); | 688 | recFields.insert( OPimRecurrence::RType, map[ OPimEvent::FRType ] ); |
687 | recFields.insert( OPimRecurrence::RWeekdays, map[ OPimEvent::FRWeekdays ] ); | 689 | recFields.insert( OPimRecurrence::RWeekdays, map[ OPimEvent::FRWeekdays ] ); |
688 | recFields.insert( OPimRecurrence::RPosition, map[ OPimEvent::FRPosition ] ); | 690 | recFields.insert( OPimRecurrence::RPosition, map[ OPimEvent::FRPosition ] ); |
689 | recFields.insert( OPimRecurrence::RFreq, map[ OPimEvent::FRFreq ] ); | 691 | recFields.insert( OPimRecurrence::RFreq, map[ OPimEvent::FRFreq ] ); |
690 | recFields.insert( OPimRecurrence::RHasEndDate, map[ OPimEvent::FRHasEndDate ] ); | 692 | recFields.insert( OPimRecurrence::RHasEndDate, map[ OPimEvent::FRHasEndDate ] ); |
691 | recFields.insert( OPimRecurrence::EndDate, map[ OPimEvent::FREndDate ] ); | 693 | recFields.insert( OPimRecurrence::EndDate, map[ OPimEvent::FREndDate ] ); |
692 | recFields.insert( OPimRecurrence::Created, map[ OPimEvent::FRCreated ] ); | 694 | recFields.insert( OPimRecurrence::Created, map[ OPimEvent::FRCreated ] ); |