summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--libkcal/icalformatimpl.cpp8
-rw-r--r--libkcal/incidencebase.cpp12
-rw-r--r--libkcal/incidencebase.h6
-rw-r--r--libkcal/sharpformat.cpp14
5 files changed, 18 insertions, 26 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fd68dc4..b543eca 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -812,555 +812,555 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
812 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
813 return 1; 813 return 1;
814 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
815 return 2; 815 return 2;
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
817 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
818 if ( localIsNew ) 818 if ( localIsNew )
819 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
820 else 820 else
821 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
822 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
823 if ( localIsNew ) 823 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
825 else 825 else
826 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
827 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
828 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
831 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
832 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
833 return result; 833 return result;
834 834
835 break; 835 break;
836 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
837 return 1; 837 return 1;
838 break; 838 break;
839 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
840 return 2; 840 return 2;
841 break; 841 break;
842 842
843 default: 843 default:
844 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
845 break; 845 break;
846 } 846 }
847 return 0; 847 return 0;
848} 848}
849Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
850{ 850{
851 Event* lse; 851 Event* lse;
852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
854 if (!lse) { 854 if (!lse) {
855 lse = new Event(); 855 lse = new Event();
856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
858 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
860 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
861 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
862 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
863 } 863 }
864 864
865 return lse; 865 return lse;
866 866
867} 867}
868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
869{ 869{
870 if ( ! lastSync ) 870 if ( ! lastSync )
871 return; 871 return;
872 if ( toDelete->zaurusId() < 0 ) 872 if ( toDelete->zaurusId() < 0 )
873 return; 873 return;
874 if ( toDelete->type() == "Journal" ) 874 if ( toDelete->type() == "Journal" )
875 return; 875 return;
876 QString des = lastSync->description(); 876 QString des = lastSync->description();
877 QString pref = "e"; 877 QString pref = "e";
878 if ( toDelete->type() == "Todo" ) 878 if ( toDelete->type() == "Todo" )
879 pref = "t"; 879 pref = "t";
880 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 880 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
881 lastSync->setReadOnly( false ); 881 lastSync->setReadOnly( false );
882 lastSync->setDescription( des ); 882 lastSync->setDescription( des );
883 lastSync->setReadOnly( true ); 883 lastSync->setReadOnly( true );
884 884
885} 885}
886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
887{ 887{
888 bool syncOK = true; 888 bool syncOK = true;
889 int addedEvent = 0; 889 int addedEvent = 0;
890 int addedEventR = 0; 890 int addedEventR = 0;
891 int deletedEventR = 0; 891 int deletedEventR = 0;
892 int deletedEventL = 0; 892 int deletedEventL = 0;
893 int changedLocal = 0; 893 int changedLocal = 0;
894 int changedRemote = 0; 894 int changedRemote = 0;
895 //QPtrList<Event> el = local->rawEvents(); 895 //QPtrList<Event> el = local->rawEvents();
896 Event* eventR; 896 Event* eventR;
897 QString uid; 897 QString uid;
898 int take; 898 int take;
899 Event* eventL; 899 Event* eventL;
900 Event* eventRSync; 900 Event* eventRSync;
901 Event* eventLSync; 901 Event* eventLSync;
902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
904 bool fullDateRange = false; 904 bool fullDateRange = false;
905 mLastCalendarSync = QDateTime::currentDateTime(); 905 mLastCalendarSync = QDateTime::currentDateTime();
906 QDateTime modifiedCalendar = mLastCalendarSync;; 906 QDateTime modifiedCalendar = mLastCalendarSync;;
907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
908 if ( eventR ) { 908 if ( eventR ) {
909 eventRSync = (Event*) eventR->clone(); 909 eventRSync = (Event*) eventR->clone();
910 remote->deleteEvent(eventR ); 910 remote->deleteEvent(eventR );
911 911
912 } else { 912 } else {
913 fullDateRange = true; 913 fullDateRange = true;
914 eventRSync = new Event(); 914 eventRSync = new Event();
915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
917 eventRSync->setDtStart( mLastCalendarSync ); 917 eventRSync->setDtStart( mLastCalendarSync );
918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
919 eventRSync->setCategories( i18n("SyncEvent") ); 919 eventRSync->setCategories( i18n("SyncEvent") );
920 } 920 }
921 eventLSync = getLastSyncEvent(); 921 eventLSync = getLastSyncEvent();
922 if ( eventLSync->dtStart() == mLastCalendarSync ) 922 if ( eventLSync->dtStart() == mLastCalendarSync )
923 fullDateRange = true; 923 fullDateRange = true;
924 924
925 if ( ! fullDateRange ) { 925 if ( ! fullDateRange ) {
926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
927 927
928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
930 fullDateRange = true; 930 fullDateRange = true;
931 } 931 }
932 } 932 }
933 if ( fullDateRange ) 933 if ( fullDateRange )
934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
935 else 935 else
936 mLastCalendarSync = eventLSync->dtStart(); 936 mLastCalendarSync = eventLSync->dtStart();
937 // for resyncing if own file has changed 937 // for resyncing if own file has changed
938 if ( mCurrentSyncDevice == "deleteaftersync" ) { 938 if ( mCurrentSyncDevice == "deleteaftersync" ) {
939 mLastCalendarSync = loadedFileVersion; 939 mLastCalendarSync = loadedFileVersion;
940 qDebug("setting mLastCalendarSync "); 940 qDebug("setting mLastCalendarSync ");
941 } 941 }
942 //qDebug("*************************** "); 942 //qDebug("*************************** ");
943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
944 QPtrList<Incidence> er = remote->rawIncidences(); 944 QPtrList<Incidence> er = remote->rawIncidences();
945 Incidence* inR = er.first(); 945 Incidence* inR = er.first();
946 Incidence* inL; 946 Incidence* inL;
947 QProgressBar bar( er.count(),0 ); 947 QProgressBar bar( er.count(),0 );
948 bar.setCaption (i18n("Syncing - close to abort!") ); 948 bar.setCaption (i18n("Syncing - close to abort!") );
949 949
950 int w = 300; 950 int w = 300;
951 if ( QApplication::desktop()->width() < 320 ) 951 if ( QApplication::desktop()->width() < 320 )
952 w = 220; 952 w = 220;
953 int h = bar.sizeHint().height() ; 953 int h = bar.sizeHint().height() ;
954 int dw = QApplication::desktop()->width(); 954 int dw = QApplication::desktop()->width();
955 int dh = QApplication::desktop()->height(); 955 int dh = QApplication::desktop()->height();
956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
957 bar.show(); 957 bar.show();
958 int modulo = (er.count()/10)+1; 958 int modulo = (er.count()/10)+1;
959 int incCounter = 0; 959 int incCounter = 0;
960 while ( inR ) { 960 while ( inR ) {
961 if ( ! bar.isVisible() ) 961 if ( ! bar.isVisible() )
962 return false; 962 return false;
963 if ( incCounter % modulo == 0 ) 963 if ( incCounter % modulo == 0 )
964 bar.setProgress( incCounter ); 964 bar.setProgress( incCounter );
965 ++incCounter; 965 ++incCounter;
966 uid = inR->uid(); 966 uid = inR->uid();
967 bool skipIncidence = false; 967 bool skipIncidence = false;
968 if ( uid.left(21) == QString("last-syncEvent-device") ) 968 if ( uid.left(21) == QString("last-syncEvent-device") )
969 skipIncidence = true; 969 skipIncidence = true;
970 970
971 qApp->processEvents(); 971 qApp->processEvents();
972 if ( !skipIncidence ) { 972 if ( !skipIncidence ) {
973 inL = local->incidence( uid ); 973 inL = local->incidence( uid );
974 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
975 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
976 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
977 maxrev = inR->revision(); 977 maxrev = inR->revision();
978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
979 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
980 if ( take == 3 ) 980 if ( take == 3 )
981 return false; 981 return false;
982 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
983 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
984 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
985 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
986 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
987 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
988 ++changedRemote; 988 ++changedRemote;
989 } else { 989 } else {
990 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
991 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
992 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
993 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
994 ++changedLocal; 994 ++changedLocal;
995 } 995 }
996 } 996 }
997 } else { // no conflict 997 } else { // no conflict
998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
999 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1000 QString pref = "e"; 1000 QString pref = "e";
1001 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1002 pref = "t"; 1002 pref = "t";
1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1004 inR->setZaurusStat( SYNC_TEMPSTATE_DELETE ); 1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1005 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1006 ++deletedEventR; 1006 ++deletedEventR;
1007 } else { 1007 } else {
1008 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1009 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1010 ++addedEvent; 1010 ++addedEvent;
1011 } 1011 }
1012 } else { 1012 } else {
1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1014 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1015 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1016 ++addedEvent; 1016 ++addedEvent;
1017 } else { 1017 } else {
1018 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1019 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1020 ++deletedEventR; 1020 ++deletedEventR;
1021 } 1021 }
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 inR = er.next(); 1025 inR = er.next();
1026 } 1026 }
1027 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1028 inL = el.first(); 1028 inL = el.first();
1029 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1030 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1031 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1032 bar.show(); 1032 bar.show();
1033 incCounter = 0; 1033 incCounter = 0;
1034 1034
1035 while ( inL ) { 1035 while ( inL ) {
1036 1036
1037 qApp->processEvents(); 1037 qApp->processEvents();
1038 if ( ! bar.isVisible() ) 1038 if ( ! bar.isVisible() )
1039 return false; 1039 return false;
1040 if ( incCounter % modulo == 0 ) 1040 if ( incCounter % modulo == 0 )
1041 bar.setProgress( incCounter ); 1041 bar.setProgress( incCounter );
1042 ++incCounter; 1042 ++incCounter;
1043 uid = inL->uid(); 1043 uid = inL->uid();
1044 bool skipIncidence = false; 1044 bool skipIncidence = false;
1045 if ( uid.left(21) == QString("last-syncEvent-device") ) 1045 if ( uid.left(21) == QString("last-syncEvent-device") )
1046 skipIncidence = true; 1046 skipIncidence = true;
1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1048 skipIncidence = true; 1048 skipIncidence = true;
1049 if ( !skipIncidence ) { 1049 if ( !skipIncidence ) {
1050 inR = remote->incidence( uid ); 1050 inR = remote->incidence( uid );
1051 if ( ! inR ) { 1051 if ( ! inR ) {
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1053 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1054 local->deleteIncidence( inL ); 1054 local->deleteIncidence( inL );
1055 ++deletedEventL; 1055 ++deletedEventL;
1056 } else { 1056 } else {
1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1058 inL->setZaurusId( -1 ); 1058 inL->setZaurusId( -1 );
1059 ++addedEventR; 1059 ++addedEventR;
1060 inL->setLastModified( modifiedCalendar ); 1060 inL->setLastModified( modifiedCalendar );
1061 remote->addIncidence( inL->clone() ); 1061 remote->addIncidence( inL->clone() );
1062 } 1062 }
1063 } 1063 }
1064 } else { 1064 } else {
1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1066 checkSharpEvent(eventLSyncSharp, inL); 1066 checkSharpEvent(eventLSyncSharp, inL);
1067 local->deleteIncidence( inL ); 1067 local->deleteIncidence( inL );
1068 ++deletedEventL; 1068 ++deletedEventL;
1069 } else { 1069 } else {
1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1071 ++addedEventR; 1071 ++addedEventR;
1072 inL->setLastModified( modifiedCalendar ); 1072 inL->setLastModified( modifiedCalendar );
1073 remote->addIncidence( inL->clone() ); 1073 remote->addIncidence( inL->clone() );
1074 } 1074 }
1075 } 1075 }
1076 } 1076 }
1077 } 1077 }
1078 } 1078 }
1079 inL = el.next(); 1079 inL = el.next();
1080 } 1080 }
1081 1081
1082 bar.hide(); 1082 bar.hide();
1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1084 eventLSync->setReadOnly( false ); 1084 eventLSync->setReadOnly( false );
1085 eventLSync->setDtStart( mLastCalendarSync ); 1085 eventLSync->setDtStart( mLastCalendarSync );
1086 eventRSync->setDtStart( mLastCalendarSync ); 1086 eventRSync->setDtStart( mLastCalendarSync );
1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1091 eventLSync->setReadOnly( true ); 1091 eventLSync->setReadOnly( true );
1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1093 remote->addEvent( eventRSync ); 1093 remote->addEvent( eventRSync );
1094 QString mes; 1094 QString mes;
1095 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1095 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1096 if ( KOPrefs::instance()->mShowSyncSummary ) { 1096 if ( KOPrefs::instance()->mShowSyncSummary ) {
1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1098 } 1098 }
1099 qDebug( mes ); 1099 qDebug( mes );
1100 mCalendar->checkAlarmForIncidence( 0, true ); 1100 mCalendar->checkAlarmForIncidence( 0, true );
1101 return syncOK; 1101 return syncOK;
1102} 1102}
1103 1103
1104void CalendarView::setSyncDevice( QString s ) 1104void CalendarView::setSyncDevice( QString s )
1105{ 1105{
1106 mCurrentSyncDevice= s; 1106 mCurrentSyncDevice= s;
1107} 1107}
1108void CalendarView::setSyncName( QString s ) 1108void CalendarView::setSyncName( QString s )
1109{ 1109{
1110 mCurrentSyncName= s; 1110 mCurrentSyncName= s;
1111} 1111}
1112bool CalendarView::syncCalendar(QString filename, int mode) 1112bool CalendarView::syncCalendar(QString filename, int mode)
1113{ 1113{
1114 mGlobalSyncMode = SYNC_MODE_NORMAL; 1114 mGlobalSyncMode = SYNC_MODE_NORMAL;
1115 CalendarLocal* calendar = new CalendarLocal(); 1115 CalendarLocal* calendar = new CalendarLocal();
1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1117 FileStorage* storage = new FileStorage( calendar ); 1117 FileStorage* storage = new FileStorage( calendar );
1118 bool syncOK = false; 1118 bool syncOK = false;
1119 storage->setFileName( filename ); 1119 storage->setFileName( filename );
1120 // qDebug("loading ... "); 1120 // qDebug("loading ... ");
1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1122 getEventViewerDialog()->setSyncMode( true ); 1122 getEventViewerDialog()->setSyncMode( true );
1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1124 getEventViewerDialog()->setSyncMode( false ); 1124 getEventViewerDialog()->setSyncMode( false );
1125 if ( syncOK ) { 1125 if ( syncOK ) {
1126 if ( KOPrefs::instance()->mWriteBackFile ) 1126 if ( KOPrefs::instance()->mWriteBackFile )
1127 { 1127 {
1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1129 storage->save(); 1129 storage->save();
1130 } 1130 }
1131 } 1131 }
1132 setModified( true ); 1132 setModified( true );
1133 } 1133 }
1134 delete storage; 1134 delete storage;
1135 delete calendar; 1135 delete calendar;
1136 if ( syncOK ) 1136 if ( syncOK )
1137 updateView(); 1137 updateView();
1138 return syncOK; 1138 return syncOK;
1139} 1139}
1140void CalendarView::syncSharp() 1140void CalendarView::syncSharp()
1141{ 1141{
1142#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1144 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1145 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1146 edit_sync_options(); 1146 edit_sync_options();
1147 qApp->processEvents(); 1147 qApp->processEvents();
1148 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1150 bool syncOK = false; 1150 bool syncOK = false;
1151 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1152 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1153 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1155 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1156 qApp->processEvents(); 1156 qApp->processEvents();
1157 if ( syncOK ) { 1157 if ( syncOK ) {
1158 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1159 { 1159 {
1160 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1161 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1162 /* obsolete 1162 /* obsolete
1163 while ( inc ) { 1163 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1165 inc = iL.next();
1166 } 1166 }
1167 */ 1167 */
1168 // pending: clean last sync event description 1168 // pending: clean last sync event description
1169 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1170 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1171 inc = iL.first(); 1171 inc = iL.first();
1172 Incidence* loc; 1172 Incidence* loc;
1173 while ( inc ) { 1173 while ( inc ) {
1174 if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) { 1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1175 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1176 if ( loc ) { 1176 if ( loc ) {
1177 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1178 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1179 } 1179 }
1180 } 1180 }
1181 inc = iL.next(); 1181 inc = iL.next();
1182 } 1182 }
1183 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1184 if ( lse ) { 1184 if ( lse ) {
1185 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1186 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1187 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1188 } 1188 }
1189 } 1189 }
1190 } 1190 }
1191 setModified( true ); 1191 setModified( true );
1192 } else { 1192 } else {
1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1195 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1196 1196
1197 } 1197 }
1198 delete calendar; 1198 delete calendar;
1199 updateView(); 1199 updateView();
1200 return ;//syncOK; 1200 return ;//syncOK;
1201#endif 1201#endif
1202} 1202}
1203 1203
1204 1204
1205#include <kabc/stdaddressbook.h> 1205#include <kabc/stdaddressbook.h>
1206bool CalendarView::importBday() 1206bool CalendarView::importBday()
1207{ 1207{
1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1209 KABC::AddressBook::Iterator it; 1209 KABC::AddressBook::Iterator it;
1210 int count = 0; 1210 int count = 0;
1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1212 ++count; 1212 ++count;
1213 } 1213 }
1214 QProgressBar bar(count,0 ); 1214 QProgressBar bar(count,0 );
1215 int w = 300; 1215 int w = 300;
1216 if ( QApplication::desktop()->width() < 320 ) 1216 if ( QApplication::desktop()->width() < 320 )
1217 w = 220; 1217 w = 220;
1218 int h = bar.sizeHint().height() ; 1218 int h = bar.sizeHint().height() ;
1219 int dw = QApplication::desktop()->width(); 1219 int dw = QApplication::desktop()->width();
1220 int dh = QApplication::desktop()->height(); 1220 int dh = QApplication::desktop()->height();
1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1222 bar.show(); 1222 bar.show();
1223 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1223 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1224 qApp->processEvents(); 1224 qApp->processEvents();
1225 count = 0; 1225 count = 0;
1226 int addCount = 0; 1226 int addCount = 0;
1227 KCal::Attendee* a = 0; 1227 KCal::Attendee* a = 0;
1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1229 if ( ! bar.isVisible() ) 1229 if ( ! bar.isVisible() )
1230 return false; 1230 return false;
1231 bar.setProgress( count++ ); 1231 bar.setProgress( count++ );
1232 qApp->processEvents(); 1232 qApp->processEvents();
1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1234 if ( (*it).birthday().date().isValid() ){ 1234 if ( (*it).birthday().date().isValid() ){
1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1237 ++addCount; 1237 ++addCount;
1238 } 1238 }
1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1240 if ( anni.isValid() ){ 1240 if ( anni.isValid() ){
1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1243 ++addCount; 1243 ++addCount;
1244 } 1244 }
1245 } 1245 }
1246 updateView(); 1246 updateView();
1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1248 return true; 1248 return true;
1249} 1249}
1250 1250
1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1252{ 1252{
1253 //qDebug("addAnni "); 1253 //qDebug("addAnni ");
1254 Event * ev = new Event(); 1254 Event * ev = new Event();
1255 if ( a ) { 1255 if ( a ) {
1256 ev->addAttendee( a ); 1256 ev->addAttendee( a );
1257 } 1257 }
1258 QString kind; 1258 QString kind;
1259 if ( birthday ) 1259 if ( birthday )
1260 kind = i18n( "Birthday" ); 1260 kind = i18n( "Birthday" );
1261 else 1261 else
1262 kind = i18n( "Anniversary" ); 1262 kind = i18n( "Anniversary" );
1263 ev->setSummary( name + " - " + kind ); 1263 ev->setSummary( name + " - " + kind );
1264 ev->setOrganizer( "nobody@nowhere" ); 1264 ev->setOrganizer( "nobody@nowhere" );
1265 ev->setCategories( kind ); 1265 ev->setCategories( kind );
1266 ev->setDtStart( QDateTime(date) ); 1266 ev->setDtStart( QDateTime(date) );
1267 ev->setDtEnd( QDateTime(date) ); 1267 ev->setDtEnd( QDateTime(date) );
1268 ev->setFloats( true ); 1268 ev->setFloats( true );
1269 Recurrence * rec = ev->recurrence(); 1269 Recurrence * rec = ev->recurrence();
1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1271 rec->addYearlyNum( date.month() ); 1271 rec->addYearlyNum( date.month() );
1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1273 delete ev; 1273 delete ev;
1274 return false; 1274 return false;
1275 } 1275 }
1276 return true; 1276 return true;
1277 1277
1278} 1278}
1279bool CalendarView::importQtopia( const QString &categories, 1279bool CalendarView::importQtopia( const QString &categories,
1280 const QString &datebook, 1280 const QString &datebook,
1281 const QString &todolist ) 1281 const QString &todolist )
1282{ 1282{
1283 1283
1284 QtopiaFormat qtopiaFormat; 1284 QtopiaFormat qtopiaFormat;
1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1289 1289
1290 updateView(); 1290 updateView();
1291 return true; 1291 return true;
1292 1292
1293#if 0 1293#if 0
1294 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1294 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1295 mCurrentSyncDevice = "qtopia-XML"; 1295 mCurrentSyncDevice = "qtopia-XML";
1296 if ( KOPrefs::instance()->mAskForPreferences ) 1296 if ( KOPrefs::instance()->mAskForPreferences )
1297 edit_sync_options(); 1297 edit_sync_options();
1298 qApp->processEvents(); 1298 qApp->processEvents();
1299 CalendarLocal* calendar = new CalendarLocal(); 1299 CalendarLocal* calendar = new CalendarLocal();
1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1301 bool syncOK = false; 1301 bool syncOK = false;
1302 QtopiaFormat qtopiaFormat; 1302 QtopiaFormat qtopiaFormat;
1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1304 bool loadOk = true; 1304 bool loadOk = true;
1305 if ( !categories.isEmpty() ) 1305 if ( !categories.isEmpty() )
1306 loadOk = qtopiaFormat.load( calendar, categories ); 1306 loadOk = qtopiaFormat.load( calendar, categories );
1307 if ( loadOk && !datebook.isEmpty() ) 1307 if ( loadOk && !datebook.isEmpty() )
1308 loadOk = qtopiaFormat.load( calendar, datebook ); 1308 loadOk = qtopiaFormat.load( calendar, datebook );
1309 if ( loadOk && !todolist.isEmpty() ) 1309 if ( loadOk && !todolist.isEmpty() )
1310 loadOk = qtopiaFormat.load( calendar, todolist ); 1310 loadOk = qtopiaFormat.load( calendar, todolist );
1311 1311
1312 if ( loadOk ) { 1312 if ( loadOk ) {
1313 getEventViewerDialog()->setSyncMode( true ); 1313 getEventViewerDialog()->setSyncMode( true );
1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1315 getEventViewerDialog()->setSyncMode( false ); 1315 getEventViewerDialog()->setSyncMode( false );
1316 qApp->processEvents(); 1316 qApp->processEvents();
1317 if ( syncOK ) { 1317 if ( syncOK ) {
1318 if ( KOPrefs::instance()->mWriteBackFile ) 1318 if ( KOPrefs::instance()->mWriteBackFile )
1319 { 1319 {
1320 // write back XML file 1320 // write back XML file
1321 1321
1322 } 1322 }
1323 setModified( true ); 1323 setModified( true );
1324 } 1324 }
1325 } else { 1325 } else {
1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1328 question, i18n("Ok")) ; 1328 question, i18n("Ok")) ;
1329 } 1329 }
1330 delete calendar; 1330 delete calendar;
1331 updateView(); 1331 updateView();
1332 return syncOK; 1332 return syncOK;
1333 1333
1334 1334
1335#endif 1335#endif
1336 1336
1337} 1337}
1338 1338
1339void CalendarView::setSyncEventsReadOnly() 1339void CalendarView::setSyncEventsReadOnly()
1340{ 1340{
1341 Event * ev; 1341 Event * ev;
1342 QPtrList<Event> eL = mCalendar->rawEvents(); 1342 QPtrList<Event> eL = mCalendar->rawEvents();
1343 ev = eL.first(); 1343 ev = eL.first();
1344 while ( ev ) { 1344 while ( ev ) {
1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1346 ev->setReadOnly( true ); 1346 ev->setReadOnly( true );
1347 ev = eL.next(); 1347 ev = eL.next();
1348 } 1348 }
1349} 1349}
1350bool CalendarView::openCalendar(QString filename, bool merge) 1350bool CalendarView::openCalendar(QString filename, bool merge)
1351{ 1351{
1352 1352
1353 if (filename.isEmpty()) { 1353 if (filename.isEmpty()) {
1354 return false; 1354 return false;
1355 } 1355 }
1356 1356
1357 if (!QFile::exists(filename)) { 1357 if (!QFile::exists(filename)) {
1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1359 return false; 1359 return false;
1360 } 1360 }
1361 1361
1362 globalFlagBlockAgenda = 1; 1362 globalFlagBlockAgenda = 1;
1363 if (!merge) mCalendar->close(); 1363 if (!merge) mCalendar->close();
1364 1364
1365 mStorage->setFileName( filename ); 1365 mStorage->setFileName( filename );
1366 1366
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 3437f45..df05ab3 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -85,387 +85,384 @@ icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence)
85 85
86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) 86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo)
87{ 87{
88 QString tmpStr; 88 QString tmpStr;
89 QStringList tmpStrList; 89 QStringList tmpStrList;
90 90
91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); 91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
92 92
93 writeIncidence(vtodo,todo); 93 writeIncidence(vtodo,todo);
94 94
95 // due date 95 // due date
96 if (todo->hasDueDate()) { 96 if (todo->hasDueDate()) {
97 icaltimetype due; 97 icaltimetype due;
98 if (todo->doesFloat()) { 98 if (todo->doesFloat()) {
99 due = writeICalDate(todo->dtDue().date()); 99 due = writeICalDate(todo->dtDue().date());
100 } else { 100 } else {
101 due = writeICalDateTime(todo->dtDue()); 101 due = writeICalDateTime(todo->dtDue());
102 } 102 }
103 icalcomponent_add_property(vtodo,icalproperty_new_due(due)); 103 icalcomponent_add_property(vtodo,icalproperty_new_due(due));
104 } 104 }
105 105
106 // start time 106 // start time
107 if (todo->hasStartDate()) { 107 if (todo->hasStartDate()) {
108 icaltimetype start; 108 icaltimetype start;
109 if (todo->doesFloat()) { 109 if (todo->doesFloat()) {
110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; 110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl;
111 start = writeICalDate(todo->dtStart().date()); 111 start = writeICalDate(todo->dtStart().date());
112 } else { 112 } else {
113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; 113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl;
114 start = writeICalDateTime(todo->dtStart()); 114 start = writeICalDateTime(todo->dtStart());
115 } 115 }
116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); 116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start));
117 } 117 }
118 118
119 // completion date 119 // completion date
120 if (todo->isCompleted()) { 120 if (todo->isCompleted()) {
121 if (!todo->hasCompletedDate()) { 121 if (!todo->hasCompletedDate()) {
122 // If todo was created by KOrganizer <2.2 it has no correct completion 122 // If todo was created by KOrganizer <2.2 it has no correct completion
123 // date. Set it to now. 123 // date. Set it to now.
124 todo->setCompleted(QDateTime::currentDateTime()); 124 todo->setCompleted(QDateTime::currentDateTime());
125 } 125 }
126 icaltimetype completed = writeICalDateTime(todo->completed()); 126 icaltimetype completed = writeICalDateTime(todo->completed());
127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); 127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed));
128 } 128 }
129 129
130 icalcomponent_add_property(vtodo, 130 icalcomponent_add_property(vtodo,
131 icalproperty_new_percentcomplete(todo->percentComplete())); 131 icalproperty_new_percentcomplete(todo->percentComplete()));
132 132
133 return vtodo; 133 return vtodo;
134} 134}
135 135
136icalcomponent *ICalFormatImpl::writeEvent(Event *event) 136icalcomponent *ICalFormatImpl::writeEvent(Event *event)
137{ 137{
138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() 138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid()
139 << ")" << endl; 139 << ")" << endl;
140 140
141 QString tmpStr; 141 QString tmpStr;
142 QStringList tmpStrList; 142 QStringList tmpStrList;
143 143
144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); 144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
145 145
146 writeIncidence(vevent,event); 146 writeIncidence(vevent,event);
147 147
148 // start time 148 // start time
149 icaltimetype start; 149 icaltimetype start;
150 if (event->doesFloat()) { 150 if (event->doesFloat()) {
151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
152 start = writeICalDate(event->dtStart().date()); 152 start = writeICalDate(event->dtStart().date());
153 } else { 153 } else {
154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
155 start = writeICalDateTime(event->dtStart()); 155 start = writeICalDateTime(event->dtStart());
156 } 156 }
157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); 157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start));
158 158
159 if (event->hasEndDate()) { 159 if (event->hasEndDate()) {
160 // end time 160 // end time
161 icaltimetype end; 161 icaltimetype end;
162 if (event->doesFloat()) { 162 if (event->doesFloat()) {
163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; 163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl;
164 // +1 day because end date is non-inclusive. 164 // +1 day because end date is non-inclusive.
165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); 165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) );
166 } else { 166 } else {
167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; 167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl;
168 end = writeICalDateTime(event->dtEnd()); 168 end = writeICalDateTime(event->dtEnd());
169 } 169 }
170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); 170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end));
171 } 171 }
172 172
173// TODO: attachments, resources 173// TODO: attachments, resources
174#if 0 174#if 0
175 // attachments 175 // attachments
176 tmpStrList = anEvent->attachments(); 176 tmpStrList = anEvent->attachments();
177 for ( QStringList::Iterator it = tmpStrList.begin(); 177 for ( QStringList::Iterator it = tmpStrList.begin();
178 it != tmpStrList.end(); 178 it != tmpStrList.end();
179 ++it ) 179 ++it )
180 addPropValue(vevent, VCAttachProp, (*it).utf8()); 180 addPropValue(vevent, VCAttachProp, (*it).utf8());
181 181
182 // resources 182 // resources
183 tmpStrList = anEvent->resources(); 183 tmpStrList = anEvent->resources();
184 tmpStr = tmpStrList.join(";"); 184 tmpStr = tmpStrList.join(";");
185 if (!tmpStr.isEmpty()) 185 if (!tmpStr.isEmpty())
186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); 186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8());
187 187
188#endif 188#endif
189 189
190 // Transparency 190 // Transparency
191 switch( event->transparency() ) { 191 switch( event->transparency() ) {
192 case Event::Transparent: 192 case Event::Transparent:
193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); 193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT));
194 break; 194 break;
195 case Event::Opaque: 195 case Event::Opaque:
196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); 196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
197 break; 197 break;
198 } 198 }
199 199
200 return vevent; 200 return vevent;
201} 201}
202 202
203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, 203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
204 Scheduler::Method method) 204 Scheduler::Method method)
205{ 205{
206#if QT_VERSION >= 300 206#if QT_VERSION >= 300
207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " 207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: "
208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " 208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: "
209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; 209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl;
210#endif 210#endif
211 211
212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); 212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
213 213
214 writeIncidenceBase(vfreebusy,freebusy); 214 writeIncidenceBase(vfreebusy,freebusy);
215 215
216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
217 writeICalDateTime(freebusy->dtStart()))); 217 writeICalDateTime(freebusy->dtStart())));
218 218
219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
220 writeICalDateTime(freebusy->dtEnd()))); 220 writeICalDateTime(freebusy->dtEnd())));
221 221
222 if (method == Scheduler::Request) { 222 if (method == Scheduler::Request) {
223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
224 freebusy->uid().utf8())); 224 freebusy->uid().utf8()));
225 } 225 }
226 226
227 //Loops through all the periods in the freebusy object 227 //Loops through all the periods in the freebusy object
228 QValueList<Period> list = freebusy->busyPeriods(); 228 QValueList<Period> list = freebusy->busyPeriods();
229 QValueList<Period>::Iterator it; 229 QValueList<Period>::Iterator it;
230 icalperiodtype period; 230 icalperiodtype period;
231 for (it = list.begin(); it!= list.end(); ++it) { 231 for (it = list.begin(); it!= list.end(); ++it) {
232 period.start = writeICalDateTime((*it).start()); 232 period.start = writeICalDateTime((*it).start());
233 period.end = writeICalDateTime((*it).end()); 233 period.end = writeICalDateTime((*it).end());
234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
235 } 235 }
236 236
237 return vfreebusy; 237 return vfreebusy;
238} 238}
239 239
240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
241{ 241{
242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
243 243
244 writeIncidence(vjournal,journal); 244 writeIncidence(vjournal,journal);
245 245
246 // start time 246 // start time
247 if (journal->dtStart().isValid()) { 247 if (journal->dtStart().isValid()) {
248 icaltimetype start; 248 icaltimetype start;
249 if (journal->doesFloat()) { 249 if (journal->doesFloat()) {
250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
251 start = writeICalDate(journal->dtStart().date()); 251 start = writeICalDate(journal->dtStart().date());
252 } else { 252 } else {
253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
254 start = writeICalDateTime(journal->dtStart()); 254 start = writeICalDateTime(journal->dtStart());
255 } 255 }
256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
257 } 257 }
258 258
259 return vjournal; 259 return vjournal;
260} 260}
261 261
262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
263{ 263{
264 // pilot sync stuff 264 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 265// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 266 if (incidence->pilotId()) {
267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
269 } 269 }
270 if (incidence->zaurusId() >= 0) { 270 if (incidence->zaurusId() >= 0) {
271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); 271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId()));
272 } 272 }
273 273
274 if (incidence->zaurusUid() > 0) { 274 if (incidence->zaurusUid() > 0) {
275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); 275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid()));
276 } 276 }
277 if (incidence->zaurusStat() > 0) {
278 incidence->setNonKDECustomProperty("X-ZAURUSSTAT", QString::number(incidence->zaurusStat()));
279 }
280 277
281 writeIncidenceBase(parent,incidence); 278 writeIncidenceBase(parent,incidence);
282 if (incidence->cancelled()) { 279 if (incidence->cancelled()) {
283 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 280 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
284 } 281 }
285 282
286 // creation date 283 // creation date
287 icalcomponent_add_property(parent,icalproperty_new_created( 284 icalcomponent_add_property(parent,icalproperty_new_created(
288 writeICalDateTime(incidence->created()))); 285 writeICalDateTime(incidence->created())));
289 286
290 // unique id 287 // unique id
291 icalcomponent_add_property(parent,icalproperty_new_uid( 288 icalcomponent_add_property(parent,icalproperty_new_uid(
292 incidence->uid().utf8())); 289 incidence->uid().utf8()));
293 290
294 // revision 291 // revision
295 icalcomponent_add_property(parent,icalproperty_new_sequence( 292 icalcomponent_add_property(parent,icalproperty_new_sequence(
296 incidence->revision())); 293 incidence->revision()));
297 294
298 // last modification date 295 // last modification date
299 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 296 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
300 writeICalDateTime(incidence->lastModified()))); 297 writeICalDateTime(incidence->lastModified())));
301 298
302 // description 299 // description
303 if (!incidence->description().isEmpty()) { 300 if (!incidence->description().isEmpty()) {
304 icalcomponent_add_property(parent,icalproperty_new_description( 301 icalcomponent_add_property(parent,icalproperty_new_description(
305 incidence->description().utf8())); 302 incidence->description().utf8()));
306 } 303 }
307 304
308 // summary 305 // summary
309 if (!incidence->summary().isEmpty()) { 306 if (!incidence->summary().isEmpty()) {
310 icalcomponent_add_property(parent,icalproperty_new_summary( 307 icalcomponent_add_property(parent,icalproperty_new_summary(
311 incidence->summary().utf8())); 308 incidence->summary().utf8()));
312 } 309 }
313 310
314 // location 311 // location
315 if (!incidence->location().isEmpty()) { 312 if (!incidence->location().isEmpty()) {
316 icalcomponent_add_property(parent,icalproperty_new_location( 313 icalcomponent_add_property(parent,icalproperty_new_location(
317 incidence->location().utf8())); 314 incidence->location().utf8()));
318 } 315 }
319 316
320// TODO: 317// TODO:
321 // status 318 // status
322// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 319// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
323 320
324 // secrecy 321 // secrecy
325 enum icalproperty_class classInt; 322 enum icalproperty_class classInt;
326 switch (incidence->secrecy()) { 323 switch (incidence->secrecy()) {
327 case Incidence::SecrecyPublic: 324 case Incidence::SecrecyPublic:
328 classInt = ICAL_CLASS_PUBLIC; 325 classInt = ICAL_CLASS_PUBLIC;
329 break; 326 break;
330 case Incidence::SecrecyConfidential: 327 case Incidence::SecrecyConfidential:
331 classInt = ICAL_CLASS_CONFIDENTIAL; 328 classInt = ICAL_CLASS_CONFIDENTIAL;
332 break; 329 break;
333 case Incidence::SecrecyPrivate: 330 case Incidence::SecrecyPrivate:
334 classInt =ICAL_CLASS_PRIVATE ; 331 classInt =ICAL_CLASS_PRIVATE ;
335 default: 332 default:
336 classInt =ICAL_CLASS_PRIVATE ; 333 classInt =ICAL_CLASS_PRIVATE ;
337 break; 334 break;
338 } 335 }
339 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 336 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
340 337
341 // priority 338 // priority
342 icalcomponent_add_property(parent,icalproperty_new_priority( 339 icalcomponent_add_property(parent,icalproperty_new_priority(
343 incidence->priority())); 340 incidence->priority()));
344 341
345 // categories 342 // categories
346 QStringList categories = incidence->categories(); 343 QStringList categories = incidence->categories();
347 QStringList::Iterator it; 344 QStringList::Iterator it;
348 for(it = categories.begin(); it != categories.end(); ++it ) { 345 for(it = categories.begin(); it != categories.end(); ++it ) {
349 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 346 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
350 } 347 }
351// TODO: Ensure correct concatenation of categories properties. 348// TODO: Ensure correct concatenation of categories properties.
352 349
353/* 350/*
354 // categories 351 // categories
355 tmpStrList = incidence->getCategories(); 352 tmpStrList = incidence->getCategories();
356 tmpStr = ""; 353 tmpStr = "";
357 QString catStr; 354 QString catStr;
358 for ( QStringList::Iterator it = tmpStrList.begin(); 355 for ( QStringList::Iterator it = tmpStrList.begin();
359 it != tmpStrList.end(); 356 it != tmpStrList.end();
360 ++it ) { 357 ++it ) {
361 catStr = *it; 358 catStr = *it;
362 if (catStr[0] == ' ') 359 if (catStr[0] == ' ')
363 tmpStr += catStr.mid(1); 360 tmpStr += catStr.mid(1);
364 else 361 else
365 tmpStr += catStr; 362 tmpStr += catStr;
366 // this must be a ';' character as the vCalendar specification requires! 363 // this must be a ';' character as the vCalendar specification requires!
367 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 364 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
368 // read in. 365 // read in.
369 tmpStr += ";"; 366 tmpStr += ";";
370 } 367 }
371 if (!tmpStr.isEmpty()) { 368 if (!tmpStr.isEmpty()) {
372 tmpStr.truncate(tmpStr.length()-1); 369 tmpStr.truncate(tmpStr.length()-1);
373 icalcomponent_add_property(parent,icalproperty_new_categories( 370 icalcomponent_add_property(parent,icalproperty_new_categories(
374 writeText(incidence->getCategories().join(";")))); 371 writeText(incidence->getCategories().join(";"))));
375 } 372 }
376*/ 373*/
377 374
378 // related event 375 // related event
379 if (incidence->relatedTo()) { 376 if (incidence->relatedTo()) {
380 icalcomponent_add_property(parent,icalproperty_new_relatedto( 377 icalcomponent_add_property(parent,icalproperty_new_relatedto(
381 incidence->relatedTo()->uid().utf8())); 378 incidence->relatedTo()->uid().utf8()));
382 } 379 }
383 380
384 // recurrence rule stuff 381 // recurrence rule stuff
385 Recurrence *recur = incidence->recurrence(); 382 Recurrence *recur = incidence->recurrence();
386 if (recur->doesRecur()) { 383 if (recur->doesRecur()) {
387 384
388 icalcomponent_add_property(parent,writeRecurrenceRule(recur)); 385 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
389 } 386 }
390 387
391 // recurrence excpetion dates 388 // recurrence excpetion dates
392 DateList dateList = incidence->exDates(); 389 DateList dateList = incidence->exDates();
393 DateList::ConstIterator exIt; 390 DateList::ConstIterator exIt;
394 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 391 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
395 icalcomponent_add_property(parent,icalproperty_new_exdate( 392 icalcomponent_add_property(parent,icalproperty_new_exdate(
396 writeICalDate(*exIt))); 393 writeICalDate(*exIt)));
397 } 394 }
398 395
399 // attachments 396 // attachments
400 QPtrList<Attachment> attachments = incidence->attachments(); 397 QPtrList<Attachment> attachments = incidence->attachments();
401 for (Attachment *at = attachments.first(); at; at = attachments.next()) 398 for (Attachment *at = attachments.first(); at; at = attachments.next())
402 icalcomponent_add_property(parent,writeAttachment(at)); 399 icalcomponent_add_property(parent,writeAttachment(at));
403 400
404 // alarms 401 // alarms
405 QPtrList<Alarm> alarms = incidence->alarms(); 402 QPtrList<Alarm> alarms = incidence->alarms();
406 Alarm* alarm; 403 Alarm* alarm;
407 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 404 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
408 if (alarm->enabled()) { 405 if (alarm->enabled()) {
409 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 406 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
410 icalcomponent_add_component(parent,writeAlarm(alarm)); 407 icalcomponent_add_component(parent,writeAlarm(alarm));
411 } 408 }
412 } 409 }
413 410
414 // duration 411 // duration
415 412
416// turned off as it always is set to PTS0 (and must not occur together with DTEND 413// turned off as it always is set to PTS0 (and must not occur together with DTEND
417 414
418// if (incidence->hasDuration()) { 415// if (incidence->hasDuration()) {
419// icaldurationtype duration; 416// icaldurationtype duration;
420// duration = writeICalDuration(incidence->duration()); 417// duration = writeICalDuration(incidence->duration());
421// icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 418// icalcomponent_add_property(parent,icalproperty_new_duration(duration));
422// } 419// }
423} 420}
424 421
425void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 422void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
426{ 423{
427 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 424 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
428 writeICalDateTime(QDateTime::currentDateTime()))); 425 writeICalDateTime(QDateTime::currentDateTime())));
429 426
430 // organizer stuff 427 // organizer stuff
431 icalcomponent_add_property(parent,icalproperty_new_organizer( 428 icalcomponent_add_property(parent,icalproperty_new_organizer(
432 ("MAILTO:" + incidenceBase->organizer()).utf8())); 429 ("MAILTO:" + incidenceBase->organizer()).utf8()));
433 430
434 // attendees 431 // attendees
435 if (incidenceBase->attendeeCount() != 0) { 432 if (incidenceBase->attendeeCount() != 0) {
436 QPtrList<Attendee> al = incidenceBase->attendees(); 433 QPtrList<Attendee> al = incidenceBase->attendees();
437 QPtrListIterator<Attendee> ai(al); 434 QPtrListIterator<Attendee> ai(al);
438 for (; ai.current(); ++ai) { 435 for (; ai.current(); ++ai) {
439 icalcomponent_add_property(parent,writeAttendee(ai.current())); 436 icalcomponent_add_property(parent,writeAttendee(ai.current()));
440 } 437 }
441 } 438 }
442 439
443 // custom properties 440 // custom properties
444 writeCustomProperties(parent, incidenceBase); 441 writeCustomProperties(parent, incidenceBase);
445} 442}
446 443
447void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 444void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
448{ 445{
449 QMap<QCString, QString> custom = properties->customProperties(); 446 QMap<QCString, QString> custom = properties->customProperties();
450 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 447 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
451 icalproperty *p = icalproperty_new_x(c.data().utf8()); 448 icalproperty *p = icalproperty_new_x(c.data().utf8());
452 icalproperty_set_x_name(p,c.key()); 449 icalproperty_set_x_name(p,c.key());
453 icalcomponent_add_property(parent,p); 450 icalcomponent_add_property(parent,p);
454 } 451 }
455} 452}
456 453
457icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 454icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
458{ 455{
459 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); 456 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8());
460 457
461 if (!attendee->name().isEmpty()) { 458 if (!attendee->name().isEmpty()) {
462 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); 459 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8()));
463 } 460 }
464 461
465 462
466 icalproperty_add_parameter(p,icalparameter_new_rsvp( 463 icalproperty_add_parameter(p,icalparameter_new_rsvp(
467 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); 464 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE ));
468 465
469 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; 466 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION;
470 switch (attendee->status()) { 467 switch (attendee->status()) {
471 default: 468 default:
@@ -1104,389 +1101,384 @@ Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee)
1104 1101
1105 p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); 1102 p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER);
1106 uid = icalparameter_get_xvalue(p); 1103 uid = icalparameter_get_xvalue(p);
1107 // This should be added, but there seems to be a libical bug here. 1104 // This should be added, but there seems to be a libical bug here.
1108 /*while (p) { 1105 /*while (p) {
1109 // if (icalparameter_get_xname(p) == "X-UID") { 1106 // if (icalparameter_get_xname(p) == "X-UID") {
1110 uid = icalparameter_get_xvalue(p); 1107 uid = icalparameter_get_xvalue(p);
1111 p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); 1108 p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER);
1112 } */ 1109 } */
1113 1110
1114 return new Attendee( name, email, rsvp, status, role, uid ); 1111 return new Attendee( name, email, rsvp, status, role, uid );
1115} 1112}
1116 1113
1117Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) 1114Attachment *ICalFormatImpl::readAttachment(icalproperty *attach)
1118{ 1115{
1119 icalattach *a = icalproperty_get_attach(attach); 1116 icalattach *a = icalproperty_get_attach(attach);
1120 icalparameter_value v = ICAL_VALUE_NONE; 1117 icalparameter_value v = ICAL_VALUE_NONE;
1121 icalparameter_encoding e = ICAL_ENCODING_NONE; 1118 icalparameter_encoding e = ICAL_ENCODING_NONE;
1122 1119
1123 Attachment *attachment = 0; 1120 Attachment *attachment = 0;
1124 /* 1121 /*
1125 icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); 1122 icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER);
1126 if (vp) 1123 if (vp)
1127 v = icalparameter_get_value(vp); 1124 v = icalparameter_get_value(vp);
1128 1125
1129 icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); 1126 icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER);
1130 if (ep) 1127 if (ep)
1131 e = icalparameter_get_encoding(ep); 1128 e = icalparameter_get_encoding(ep);
1132 */ 1129 */
1133 int isurl = icalattach_get_is_url (a); 1130 int isurl = icalattach_get_is_url (a);
1134 if (isurl == 0) 1131 if (isurl == 0)
1135 attachment = new Attachment((const char*)icalattach_get_data(a)); 1132 attachment = new Attachment((const char*)icalattach_get_data(a));
1136 else { 1133 else {
1137 attachment = new Attachment(QString(icalattach_get_url(a))); 1134 attachment = new Attachment(QString(icalattach_get_url(a)));
1138 } 1135 }
1139 1136
1140 icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); 1137 icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER);
1141 if (p) 1138 if (p)
1142 attachment->setMimeType(QString(icalparameter_get_fmttype(p))); 1139 attachment->setMimeType(QString(icalparameter_get_fmttype(p)));
1143 1140
1144 return attachment; 1141 return attachment;
1145} 1142}
1146#include <qtextcodec.h> 1143#include <qtextcodec.h>
1147void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) 1144void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1148{ 1145{
1149 readIncidenceBase(parent,incidence); 1146 readIncidenceBase(parent,incidence);
1150 1147
1151 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1148 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1152 bool readrec = false; 1149 bool readrec = false;
1153 const char *text; 1150 const char *text;
1154 int intvalue; 1151 int intvalue;
1155 icaltimetype icaltime; 1152 icaltimetype icaltime;
1156 icaldurationtype icalduration; 1153 icaldurationtype icalduration;
1157 struct icalrecurrencetype rectype; 1154 struct icalrecurrencetype rectype;
1158 QStringList categories; 1155 QStringList categories;
1159 1156
1160 while (p) { 1157 while (p) {
1161 icalproperty_kind kind = icalproperty_isa(p); 1158 icalproperty_kind kind = icalproperty_isa(p);
1162 switch (kind) { 1159 switch (kind) {
1163 1160
1164 case ICAL_CREATED_PROPERTY: 1161 case ICAL_CREATED_PROPERTY:
1165 icaltime = icalproperty_get_created(p); 1162 icaltime = icalproperty_get_created(p);
1166 incidence->setCreated(readICalDateTime(icaltime)); 1163 incidence->setCreated(readICalDateTime(icaltime));
1167 break; 1164 break;
1168 1165
1169 case ICAL_SEQUENCE_PROPERTY: // sequence 1166 case ICAL_SEQUENCE_PROPERTY: // sequence
1170 intvalue = icalproperty_get_sequence(p); 1167 intvalue = icalproperty_get_sequence(p);
1171 incidence->setRevision(intvalue); 1168 incidence->setRevision(intvalue);
1172 break; 1169 break;
1173 1170
1174 case ICAL_LASTMODIFIED_PROPERTY: // last modification date 1171 case ICAL_LASTMODIFIED_PROPERTY: // last modification date
1175 icaltime = icalproperty_get_lastmodified(p); 1172 icaltime = icalproperty_get_lastmodified(p);
1176 incidence->setLastModified(readICalDateTime(icaltime)); 1173 incidence->setLastModified(readICalDateTime(icaltime));
1177 break; 1174 break;
1178 1175
1179 case ICAL_DTSTART_PROPERTY: // start date and time 1176 case ICAL_DTSTART_PROPERTY: // start date and time
1180 icaltime = icalproperty_get_dtstart(p); 1177 icaltime = icalproperty_get_dtstart(p);
1181 if (icaltime.is_date) { 1178 if (icaltime.is_date) {
1182 incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); 1179 incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0)));
1183 incidence->setFloats(true); 1180 incidence->setFloats(true);
1184 } else { 1181 } else {
1185 incidence->setDtStart(readICalDateTime(icaltime)); 1182 incidence->setDtStart(readICalDateTime(icaltime));
1186 } 1183 }
1187 break; 1184 break;
1188 1185
1189 case ICAL_DURATION_PROPERTY: // start date and time 1186 case ICAL_DURATION_PROPERTY: // start date and time
1190 icalduration = icalproperty_get_duration(p); 1187 icalduration = icalproperty_get_duration(p);
1191 incidence->setDuration(readICalDuration(icalduration)); 1188 incidence->setDuration(readICalDuration(icalduration));
1192 break; 1189 break;
1193 1190
1194 case ICAL_DESCRIPTION_PROPERTY: // description 1191 case ICAL_DESCRIPTION_PROPERTY: // description
1195 text = icalproperty_get_description(p); 1192 text = icalproperty_get_description(p);
1196 incidence->setDescription(QString::fromUtf8(text)); 1193 incidence->setDescription(QString::fromUtf8(text));
1197 break; 1194 break;
1198 1195
1199 case ICAL_SUMMARY_PROPERTY: // summary 1196 case ICAL_SUMMARY_PROPERTY: // summary
1200 { 1197 {
1201 text = icalproperty_get_summary(p); 1198 text = icalproperty_get_summary(p);
1202 incidence->setSummary(QString::fromUtf8(text)); 1199 incidence->setSummary(QString::fromUtf8(text));
1203 } 1200 }
1204 break; 1201 break;
1205 case ICAL_STATUS_PROPERTY: // summary 1202 case ICAL_STATUS_PROPERTY: // summary
1206 { 1203 {
1207 if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) 1204 if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) )
1208 incidence->setCancelled( true ); 1205 incidence->setCancelled( true );
1209 } 1206 }
1210 break; 1207 break;
1211 1208
1212 case ICAL_LOCATION_PROPERTY: // location 1209 case ICAL_LOCATION_PROPERTY: // location
1213 text = icalproperty_get_location(p); 1210 text = icalproperty_get_location(p);
1214 incidence->setLocation(QString::fromUtf8(text)); 1211 incidence->setLocation(QString::fromUtf8(text));
1215 break; 1212 break;
1216 1213
1217#if 0 1214#if 0
1218 // status 1215 // status
1219 if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { 1216 if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) {
1220 incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); 1217 incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo)));
1221 deleteStr(s); 1218 deleteStr(s);
1222 } 1219 }
1223 else 1220 else
1224 incidence->setStatus("NEEDS ACTION"); 1221 incidence->setStatus("NEEDS ACTION");
1225#endif 1222#endif
1226 1223
1227 case ICAL_PRIORITY_PROPERTY: // priority 1224 case ICAL_PRIORITY_PROPERTY: // priority
1228 intvalue = icalproperty_get_priority(p); 1225 intvalue = icalproperty_get_priority(p);
1229 incidence->setPriority(intvalue); 1226 incidence->setPriority(intvalue);
1230 break; 1227 break;
1231 1228
1232 case ICAL_CATEGORIES_PROPERTY: // categories 1229 case ICAL_CATEGORIES_PROPERTY: // categories
1233 text = icalproperty_get_categories(p); 1230 text = icalproperty_get_categories(p);
1234 categories.append(QString::fromUtf8(text)); 1231 categories.append(QString::fromUtf8(text));
1235 break; 1232 break;
1236 //******************************************* 1233 //*******************************************
1237 case ICAL_RRULE_PROPERTY: 1234 case ICAL_RRULE_PROPERTY:
1238 // we do need (maybe )start datetime of incidence for recurrence 1235 // we do need (maybe )start datetime of incidence for recurrence
1239 // such that we can read recurrence only after we read incidence completely 1236 // such that we can read recurrence only after we read incidence completely
1240 readrec = true; 1237 readrec = true;
1241 rectype = icalproperty_get_rrule(p); 1238 rectype = icalproperty_get_rrule(p);
1242 break; 1239 break;
1243 1240
1244 case ICAL_EXDATE_PROPERTY: 1241 case ICAL_EXDATE_PROPERTY:
1245 icaltime = icalproperty_get_exdate(p); 1242 icaltime = icalproperty_get_exdate(p);
1246 incidence->addExDate(readICalDate(icaltime)); 1243 incidence->addExDate(readICalDate(icaltime));
1247 break; 1244 break;
1248 1245
1249 case ICAL_CLASS_PROPERTY: { 1246 case ICAL_CLASS_PROPERTY: {
1250 int inttext = icalproperty_get_class(p); 1247 int inttext = icalproperty_get_class(p);
1251 if (inttext == ICAL_CLASS_PUBLIC ) { 1248 if (inttext == ICAL_CLASS_PUBLIC ) {
1252 incidence->setSecrecy(Incidence::SecrecyPublic); 1249 incidence->setSecrecy(Incidence::SecrecyPublic);
1253 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { 1250 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) {
1254 incidence->setSecrecy(Incidence::SecrecyConfidential); 1251 incidence->setSecrecy(Incidence::SecrecyConfidential);
1255 } else { 1252 } else {
1256 incidence->setSecrecy(Incidence::SecrecyPrivate); 1253 incidence->setSecrecy(Incidence::SecrecyPrivate);
1257 } 1254 }
1258 } 1255 }
1259 break; 1256 break;
1260 1257
1261 case ICAL_ATTACH_PROPERTY: // attachments 1258 case ICAL_ATTACH_PROPERTY: // attachments
1262 incidence->addAttachment(readAttachment(p)); 1259 incidence->addAttachment(readAttachment(p));
1263 break; 1260 break;
1264 1261
1265 default: 1262 default:
1266// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind 1263// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
1267// << endl; 1264// << endl;
1268 break; 1265 break;
1269 } 1266 }
1270 1267
1271 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1268 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1272 } 1269 }
1273 if ( readrec ) { 1270 if ( readrec ) {
1274 readRecurrenceRule(rectype,incidence); 1271 readRecurrenceRule(rectype,incidence);
1275 } 1272 }
1276 // kpilot stuff 1273 // kpilot stuff
1277// TODO: move this application-specific code to kpilot 1274// TODO: move this application-specific code to kpilot
1278 QString kp = incidence->nonKDECustomProperty("X-PILOTID"); 1275 QString kp = incidence->nonKDECustomProperty("X-PILOTID");
1279 if (!kp.isNull()) { 1276 if (!kp.isNull()) {
1280 incidence->setPilotId(kp.toInt()); 1277 incidence->setPilotId(kp.toInt());
1281 } 1278 }
1282 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1279 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
1283 if (!kp.isNull()) { 1280 if (!kp.isNull()) {
1284 incidence->setSyncStatus(kp.toInt()); 1281 incidence->setSyncStatus(kp.toInt());
1285 } 1282 }
1286 kp = incidence->nonKDECustomProperty("X-ZAURUSID"); 1283 kp = incidence->nonKDECustomProperty("X-ZAURUSID");
1287 if (!kp.isNull()) { 1284 if (!kp.isNull()) {
1288 incidence->setZaurusId(kp.toInt()); 1285 incidence->setZaurusId(kp.toInt());
1289 } 1286 }
1290 1287
1291 kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); 1288 kp = incidence->nonKDECustomProperty("X-ZAURUSUID");
1292 if (!kp.isNull()) { 1289 if (!kp.isNull()) {
1293 incidence->setZaurusUid(kp.toInt()); 1290 incidence->setZaurusUid(kp.toInt());
1294 } 1291 }
1295 1292
1296 kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT");
1297 if (!kp.isNull()) {
1298 incidence->setZaurusStat(kp.toInt());
1299 }
1300
1301 // Cancel backwards compatibility mode for subsequent changes by the application 1293 // Cancel backwards compatibility mode for subsequent changes by the application
1302 incidence->recurrence()->setCompatVersion(); 1294 incidence->recurrence()->setCompatVersion();
1303 1295
1304 // add categories 1296 // add categories
1305 incidence->setCategories(categories); 1297 incidence->setCategories(categories);
1306 1298
1307 // iterate through all alarms 1299 // iterate through all alarms
1308 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1300 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1309 alarm; 1301 alarm;
1310 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1302 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1311 readAlarm(alarm,incidence); 1303 readAlarm(alarm,incidence);
1312 } 1304 }
1313} 1305}
1314 1306
1315void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1307void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1316{ 1308{
1317 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1309 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1318 1310
1319 while (p) { 1311 while (p) {
1320 icalproperty_kind kind = icalproperty_isa(p); 1312 icalproperty_kind kind = icalproperty_isa(p);
1321 switch (kind) { 1313 switch (kind) {
1322 1314
1323 case ICAL_UID_PROPERTY: // unique id 1315 case ICAL_UID_PROPERTY: // unique id
1324 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1316 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1325 break; 1317 break;
1326 1318
1327 case ICAL_ORGANIZER_PROPERTY: // organizer 1319 case ICAL_ORGANIZER_PROPERTY: // organizer
1328 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1320 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1329 break; 1321 break;
1330 1322
1331 case ICAL_ATTENDEE_PROPERTY: // attendee 1323 case ICAL_ATTENDEE_PROPERTY: // attendee
1332 incidenceBase->addAttendee(readAttendee(p)); 1324 incidenceBase->addAttendee(readAttendee(p));
1333 break; 1325 break;
1334 1326
1335 default: 1327 default:
1336 break; 1328 break;
1337 } 1329 }
1338 1330
1339 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1331 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1340 } 1332 }
1341 1333
1342 // custom properties 1334 // custom properties
1343 readCustomProperties(parent, incidenceBase); 1335 readCustomProperties(parent, incidenceBase);
1344} 1336}
1345 1337
1346void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1338void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1347{ 1339{
1348 QMap<QCString, QString> customProperties; 1340 QMap<QCString, QString> customProperties;
1349 1341
1350 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); 1342 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
1351 1343
1352 while (p) { 1344 while (p) {
1353 QString value = QString::fromUtf8(icalproperty_get_x(p)); 1345 QString value = QString::fromUtf8(icalproperty_get_x(p));
1354 customProperties[icalproperty_get_x_name(p)] = value; 1346 customProperties[icalproperty_get_x_name(p)] = value;
1355 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); 1347 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) );
1356 1348
1357 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); 1349 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY);
1358 } 1350 }
1359 1351
1360 properties->setCustomProperties(customProperties); 1352 properties->setCustomProperties(customProperties);
1361} 1353}
1362 1354
1363void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) 1355void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence)
1364{ 1356{
1365// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; 1357// kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl;
1366 1358
1367 Recurrence *recur = incidence->recurrence(); 1359 Recurrence *recur = incidence->recurrence();
1368 recur->setCompatVersion(mCalendarVersion); 1360 recur->setCompatVersion(mCalendarVersion);
1369 recur->unsetRecurs(); 1361 recur->unsetRecurs();
1370 1362
1371 struct icalrecurrencetype r = rrule; 1363 struct icalrecurrencetype r = rrule;
1372 1364
1373 dumpIcalRecurrence(r); 1365 dumpIcalRecurrence(r);
1374 readRecurrence( r, recur, incidence); 1366 readRecurrence( r, recur, incidence);
1375} 1367}
1376 1368
1377void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) 1369void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence)
1378{ 1370{
1379 int wkst; 1371 int wkst;
1380 int index = 0; 1372 int index = 0;
1381 short day = 0; 1373 short day = 0;
1382 QBitArray qba(7); 1374 QBitArray qba(7);
1383 int frequ = r.freq; 1375 int frequ = r.freq;
1384 int interv = r.interval; 1376 int interv = r.interval;
1385 // preprocessing for odd recurrence definitions 1377 // preprocessing for odd recurrence definitions
1386 1378
1387 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { 1379 if ( r.freq == ICAL_MONTHLY_RECURRENCE ) {
1388 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1380 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1389 interv = 12; 1381 interv = 12;
1390 } 1382 }
1391 } 1383 }
1392 if ( r.freq == ICAL_YEARLY_RECURRENCE ) { 1384 if ( r.freq == ICAL_YEARLY_RECURRENCE ) {
1393 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { 1385 if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
1394 frequ = ICAL_MONTHLY_RECURRENCE; 1386 frequ = ICAL_MONTHLY_RECURRENCE;
1395 interv = 12* r.interval; 1387 interv = 12* r.interval;
1396 } 1388 }
1397 } 1389 }
1398 1390
1399 switch (frequ) { 1391 switch (frequ) {
1400 case ICAL_MINUTELY_RECURRENCE: 1392 case ICAL_MINUTELY_RECURRENCE:
1401 if (!icaltime_is_null_time(r.until)) { 1393 if (!icaltime_is_null_time(r.until)) {
1402 recur->setMinutely(interv,readICalDateTime(r.until)); 1394 recur->setMinutely(interv,readICalDateTime(r.until));
1403 } else { 1395 } else {
1404 if (r.count == 0) 1396 if (r.count == 0)
1405 recur->setMinutely(interv,-1); 1397 recur->setMinutely(interv,-1);
1406 else 1398 else
1407 recur->setMinutely(interv,r.count); 1399 recur->setMinutely(interv,r.count);
1408 } 1400 }
1409 break; 1401 break;
1410 case ICAL_HOURLY_RECURRENCE: 1402 case ICAL_HOURLY_RECURRENCE:
1411 if (!icaltime_is_null_time(r.until)) { 1403 if (!icaltime_is_null_time(r.until)) {
1412 recur->setHourly(interv,readICalDateTime(r.until)); 1404 recur->setHourly(interv,readICalDateTime(r.until));
1413 } else { 1405 } else {
1414 if (r.count == 0) 1406 if (r.count == 0)
1415 recur->setHourly(interv,-1); 1407 recur->setHourly(interv,-1);
1416 else 1408 else
1417 recur->setHourly(interv,r.count); 1409 recur->setHourly(interv,r.count);
1418 } 1410 }
1419 break; 1411 break;
1420 case ICAL_DAILY_RECURRENCE: 1412 case ICAL_DAILY_RECURRENCE:
1421 if (!icaltime_is_null_time(r.until)) { 1413 if (!icaltime_is_null_time(r.until)) {
1422 recur->setDaily(interv,readICalDate(r.until)); 1414 recur->setDaily(interv,readICalDate(r.until));
1423 } else { 1415 } else {
1424 if (r.count == 0) 1416 if (r.count == 0)
1425 recur->setDaily(interv,-1); 1417 recur->setDaily(interv,-1);
1426 else 1418 else
1427 recur->setDaily(interv,r.count); 1419 recur->setDaily(interv,r.count);
1428 } 1420 }
1429 break; 1421 break;
1430 case ICAL_WEEKLY_RECURRENCE: 1422 case ICAL_WEEKLY_RECURRENCE:
1431 // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; 1423 // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl;
1432 wkst = (r.week_start + 5)%7 + 1; 1424 wkst = (r.week_start + 5)%7 + 1;
1433 if (!icaltime_is_null_time(r.until)) { 1425 if (!icaltime_is_null_time(r.until)) {
1434 recur->setWeekly(interv,qba,readICalDate(r.until),wkst); 1426 recur->setWeekly(interv,qba,readICalDate(r.until),wkst);
1435 } else { 1427 } else {
1436 if (r.count == 0) 1428 if (r.count == 0)
1437 recur->setWeekly(interv,qba,-1,wkst); 1429 recur->setWeekly(interv,qba,-1,wkst);
1438 else 1430 else
1439 recur->setWeekly(interv,qba,r.count,wkst); 1431 recur->setWeekly(interv,qba,r.count,wkst);
1440 } 1432 }
1441 if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { 1433 if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) {
1442 int wday = incidence->dtStart().date().dayOfWeek ()-1; 1434 int wday = incidence->dtStart().date().dayOfWeek ()-1;
1443 //qDebug("weekly error found "); 1435 //qDebug("weekly error found ");
1444 qba.setBit(wday); 1436 qba.setBit(wday);
1445 } else { 1437 } else {
1446 while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 1438 while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
1447 // kdDebug(5800) << " " << day << endl; 1439 // kdDebug(5800) << " " << day << endl;
1448 qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 1440 qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0
1449 } 1441 }
1450 } 1442 }
1451 break; 1443 break;
1452 case ICAL_MONTHLY_RECURRENCE: 1444 case ICAL_MONTHLY_RECURRENCE:
1453 1445
1454 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1446 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1455 if (!icaltime_is_null_time(r.until)) { 1447 if (!icaltime_is_null_time(r.until)) {
1456 recur->setMonthly(Recurrence::rMonthlyPos,interv, 1448 recur->setMonthly(Recurrence::rMonthlyPos,interv,
1457 readICalDate(r.until)); 1449 readICalDate(r.until));
1458 } else { 1450 } else {
1459 if (r.count == 0) 1451 if (r.count == 0)
1460 recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); 1452 recur->setMonthly(Recurrence::rMonthlyPos,interv,-1);
1461 else 1453 else
1462 recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); 1454 recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count);
1463 } 1455 }
1464 bool useSetPos = false; 1456 bool useSetPos = false;
1465 short pos = 0; 1457 short pos = 0;
1466 while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 1458 while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
1467 // kdDebug(5800) << "----a " << index << ": " << day << endl; 1459 // kdDebug(5800) << "----a " << index << ": " << day << endl;
1468 pos = icalrecurrencetype_day_position(day); 1460 pos = icalrecurrencetype_day_position(day);
1469 if (pos) { 1461 if (pos) {
1470 day = icalrecurrencetype_day_day_of_week(day); 1462 day = icalrecurrencetype_day_day_of_week(day);
1471 QBitArray ba(7); // don't wipe qba 1463 QBitArray ba(7); // don't wipe qba
1472 ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 1464 ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0
1473 recur->addMonthlyPos(pos,ba); 1465 recur->addMonthlyPos(pos,ba);
1474 } else { 1466 } else {
1475 qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 1467 qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0
1476 useSetPos = true; 1468 useSetPos = true;
1477 } 1469 }
1478 } 1470 }
1479 if (useSetPos) { 1471 if (useSetPos) {
1480 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1472 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1481 recur->addMonthlyPos(r.by_set_pos[0],qba); 1473 recur->addMonthlyPos(r.by_set_pos[0],qba);
1482 } 1474 }
1483 } 1475 }
1484 } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 1476 } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
1485 if (!icaltime_is_null_time(r.until)) { 1477 if (!icaltime_is_null_time(r.until)) {
1486 recur->setMonthly(Recurrence::rMonthlyDay,interv, 1478 recur->setMonthly(Recurrence::rMonthlyDay,interv,
1487 readICalDate(r.until)); 1479 readICalDate(r.until));
1488 } else { 1480 } else {
1489 if (r.count == 0) 1481 if (r.count == 0)
1490 recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); 1482 recur->setMonthly(Recurrence::rMonthlyDay,interv,-1);
1491 else 1483 else
1492 recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); 1484 recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count);
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 9479048..707d666 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,393 +1,393 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidencebase.h" 27#include "incidencebase.h"
28 28
29using namespace KCal; 29using namespace KCal;
30 30
31IncidenceBase::IncidenceBase() : 31IncidenceBase::IncidenceBase() :
32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 32 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
33 mPilotId(0), mSyncStatus(SYNCMOD) 33 mPilotId(0), mSyncStatus(SYNCMOD)
34{ 34{
35 setUid(CalFormat::createUniqueId()); 35 setUid(CalFormat::createUniqueId());
36 mOrganizer = ""; 36 mOrganizer = "";
37 mFloats = false; 37 mFloats = false;
38 mDuration = 0; 38 mDuration = 0;
39 mHasDuration = false; 39 mHasDuration = false;
40 mPilotId = 0; 40 mPilotId = 0;
41 mZaurusId = -1; 41 mZaurusId = -1;
42 mZaurusUid = 0; 42 mZaurusUid = 0;
43 mZaurusStat = 0; 43 mTempSyncStat = 0;
44 mSyncStatus = 0; 44 mSyncStatus = 0;
45 mAttendees.setAutoDelete( true ); 45 mAttendees.setAutoDelete( true );
46} 46}
47 47
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 48IncidenceBase::IncidenceBase(const IncidenceBase &i) :
49 CustomProperties( i ) 49 CustomProperties( i )
50{ 50{
51 mReadOnly = i.mReadOnly; 51 mReadOnly = i.mReadOnly;
52 mDtStart = i.mDtStart; 52 mDtStart = i.mDtStart;
53 mDuration = i.mDuration; 53 mDuration = i.mDuration;
54 mHasDuration = i.mHasDuration; 54 mHasDuration = i.mHasDuration;
55 mOrganizer = i.mOrganizer; 55 mOrganizer = i.mOrganizer;
56 mUid = i.mUid; 56 mUid = i.mUid;
57 QPtrList<Attendee> attendees = i.attendees(); 57 QPtrList<Attendee> attendees = i.attendees();
58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
59 mAttendees.append( new Attendee( *a ) ); 59 mAttendees.append( new Attendee( *a ) );
60 } 60 }
61 mFloats = i.mFloats; 61 mFloats = i.mFloats;
62 mLastModified = i.mLastModified; 62 mLastModified = i.mLastModified;
63 mPilotId = i.mPilotId; 63 mPilotId = i.mPilotId;
64 mZaurusId = i.mZaurusId; 64 mZaurusId = i.mZaurusId;
65 mZaurusUid = i.mZaurusUid; 65 mZaurusUid = i.mZaurusUid;
66 mZaurusStat = i.mZaurusStat; 66 mTempSyncStat = i.mTempSyncStat;
67 mSyncStatus = i.mSyncStatus; 67 mSyncStatus = i.mSyncStatus;
68 68
69 // The copied object is a new one, so it isn't observed by the observer 69 // The copied object is a new one, so it isn't observed by the observer
70 // of the original object. 70 // of the original object.
71 mObservers.clear(); 71 mObservers.clear();
72 72
73 mAttendees.setAutoDelete( true ); 73 mAttendees.setAutoDelete( true );
74} 74}
75 75
76IncidenceBase::~IncidenceBase() 76IncidenceBase::~IncidenceBase()
77{ 77{
78} 78}
79 79
80 80
81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
82{ 82{
83 83
84 if( i1.attendees().count() != i2.attendees().count() ) { 84 if( i1.attendees().count() != i2.attendees().count() ) {
85 return false; // no need to check further 85 return false; // no need to check further
86 } 86 }
87 if ( i1.attendees().count() > 0 ) { 87 if ( i1.attendees().count() > 0 ) {
88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
89 while ( a1 ) { 89 while ( a1 ) {
90 if ( !( (*a1) == (*a2)) ) 90 if ( !( (*a1) == (*a2)) )
91 { 91 {
92 //qDebug("Attendee not equal "); 92 //qDebug("Attendee not equal ");
93 return false; 93 return false;
94 } 94 }
95 a1 = i1.attendees().next(); 95 a1 = i1.attendees().next();
96 a2 = i2.attendees().next(); 96 a2 = i2.attendees().next();
97 } 97 }
98 } 98 }
99 //if ( i1.dtStart() != i2.dtStart() ) 99 //if ( i1.dtStart() != i2.dtStart() )
100 // return false; 100 // return false;
101#if 0 101#if 0
102 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 102 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
103 qDebug("1 %d ",i1.duration() == i2.duration() ); 103 qDebug("1 %d ",i1.duration() == i2.duration() );
104 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 104 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
105 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 105 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
106 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 106 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
107 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 107 qDebug("6 %d ",i1.organizer() == i2.organizer() );
108 108
109#endif 109#endif
110 return ( i1.organizer() == i2.organizer() && 110 return ( i1.organizer() == i2.organizer() &&
111 // i1.uid() == i2.uid() && 111 // i1.uid() == i2.uid() &&
112 // Don't compare lastModified, otherwise the operator is not 112 // Don't compare lastModified, otherwise the operator is not
113 // of much use. We are not comparing for identity, after all. 113 // of much use. We are not comparing for identity, after all.
114 i1.doesFloat() == i2.doesFloat() && 114 i1.doesFloat() == i2.doesFloat() &&
115 i1.duration() == i2.duration() && 115 i1.duration() == i2.duration() &&
116 i1.hasDuration() == i2.hasDuration() && 116 i1.hasDuration() == i2.hasDuration() &&
117 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 117 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
118 // no need to compare mObserver 118 // no need to compare mObserver
119} 119}
120 120
121 121
122QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 122QDateTime IncidenceBase::getEvenTime( QDateTime dt )
123{ 123{
124 QTime t = dt.time(); 124 QTime t = dt.time();
125 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 125 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
126 return dt; 126 return dt;
127} 127}
128 128
129 129
130void IncidenceBase::setUid(const QString &uid) 130void IncidenceBase::setUid(const QString &uid)
131{ 131{
132 mUid = uid; 132 mUid = uid;
133 updated(); 133 updated();
134} 134}
135 135
136QString IncidenceBase::uid() const 136QString IncidenceBase::uid() const
137{ 137{
138 return mUid; 138 return mUid;
139} 139}
140 140
141void IncidenceBase::setLastModified(const QDateTime &lm) 141void IncidenceBase::setLastModified(const QDateTime &lm)
142{ 142{
143 // DON'T! updated() because we call this from 143 // DON'T! updated() because we call this from
144 // Calendar::updateEvent(). 144 // Calendar::updateEvent().
145 mLastModified = getEvenTime(lm); 145 mLastModified = getEvenTime(lm);
146 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 146 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
147} 147}
148 148
149QDateTime IncidenceBase::lastModified() const 149QDateTime IncidenceBase::lastModified() const
150{ 150{
151 return mLastModified; 151 return mLastModified;
152} 152}
153 153
154void IncidenceBase::setOrganizer(const QString &o) 154void IncidenceBase::setOrganizer(const QString &o)
155{ 155{
156 // we don't check for readonly here, because it is 156 // we don't check for readonly here, because it is
157 // possible that by setting the organizer we are changing 157 // possible that by setting the organizer we are changing
158 // the event's readonly status... 158 // the event's readonly status...
159 mOrganizer = o; 159 mOrganizer = o;
160 if (mOrganizer.left(7).upper() == "MAILTO:") 160 if (mOrganizer.left(7).upper() == "MAILTO:")
161 mOrganizer = mOrganizer.remove(0,7); 161 mOrganizer = mOrganizer.remove(0,7);
162 162
163 updated(); 163 updated();
164} 164}
165 165
166QString IncidenceBase::organizer() const 166QString IncidenceBase::organizer() const
167{ 167{
168 return mOrganizer; 168 return mOrganizer;
169} 169}
170 170
171void IncidenceBase::setReadOnly( bool readOnly ) 171void IncidenceBase::setReadOnly( bool readOnly )
172{ 172{
173 mReadOnly = readOnly; 173 mReadOnly = readOnly;
174} 174}
175 175
176void IncidenceBase::setDtStart(const QDateTime &dtStart) 176void IncidenceBase::setDtStart(const QDateTime &dtStart)
177{ 177{
178// if (mReadOnly) return; 178// if (mReadOnly) return;
179 mDtStart = getEvenTime(dtStart); 179 mDtStart = getEvenTime(dtStart);
180 updated(); 180 updated();
181} 181}
182 182
183QDateTime IncidenceBase::dtStart() const 183QDateTime IncidenceBase::dtStart() const
184{ 184{
185 return mDtStart; 185 return mDtStart;
186} 186}
187 187
188QString IncidenceBase::dtStartTimeStr() const 188QString IncidenceBase::dtStartTimeStr() const
189{ 189{
190 return KGlobal::locale()->formatTime(dtStart().time()); 190 return KGlobal::locale()->formatTime(dtStart().time());
191} 191}
192 192
193QString IncidenceBase::dtStartDateStr(bool shortfmt) const 193QString IncidenceBase::dtStartDateStr(bool shortfmt) const
194{ 194{
195 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 195 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
196} 196}
197 197
198QString IncidenceBase::dtStartStr(bool shortfmt) const 198QString IncidenceBase::dtStartStr(bool shortfmt) const
199{ 199{
200 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 200 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
201} 201}
202 202
203 203
204bool IncidenceBase::doesFloat() const 204bool IncidenceBase::doesFloat() const
205{ 205{
206 return mFloats; 206 return mFloats;
207} 207}
208 208
209void IncidenceBase::setFloats(bool f) 209void IncidenceBase::setFloats(bool f)
210{ 210{
211 if (mReadOnly) return; 211 if (mReadOnly) return;
212 mFloats = f; 212 mFloats = f;
213 updated(); 213 updated();
214} 214}
215 215
216 216
217void IncidenceBase::addAttendee(Attendee *a, bool doupdate) 217void IncidenceBase::addAttendee(Attendee *a, bool doupdate)
218{ 218{
219 if (mReadOnly) return; 219 if (mReadOnly) return;
220 if (a->name().left(7).upper() == "MAILTO:") 220 if (a->name().left(7).upper() == "MAILTO:")
221 a->setName(a->name().remove(0,7)); 221 a->setName(a->name().remove(0,7));
222 222
223 mAttendees.append(a); 223 mAttendees.append(a);
224 if (doupdate) updated(); 224 if (doupdate) updated();
225} 225}
226 226
227#if 0 227#if 0
228void IncidenceBase::removeAttendee(Attendee *a) 228void IncidenceBase::removeAttendee(Attendee *a)
229{ 229{
230 if (mReadOnly) return; 230 if (mReadOnly) return;
231 mAttendees.removeRef(a); 231 mAttendees.removeRef(a);
232 updated(); 232 updated();
233} 233}
234 234
235void IncidenceBase::removeAttendee(const char *n) 235void IncidenceBase::removeAttendee(const char *n)
236{ 236{
237 Attendee *a; 237 Attendee *a;
238 238
239 if (mReadOnly) return; 239 if (mReadOnly) return;
240 for (a = mAttendees.first(); a; a = mAttendees.next()) 240 for (a = mAttendees.first(); a; a = mAttendees.next())
241 if (a->getName() == n) { 241 if (a->getName() == n) {
242 mAttendees.remove(); 242 mAttendees.remove();
243 break; 243 break;
244 } 244 }
245} 245}
246#endif 246#endif
247 247
248void IncidenceBase::clearAttendees() 248void IncidenceBase::clearAttendees()
249{ 249{
250 if (mReadOnly) return; 250 if (mReadOnly) return;
251 mAttendees.clear(); 251 mAttendees.clear();
252} 252}
253 253
254#if 0 254#if 0
255Attendee *IncidenceBase::getAttendee(const char *n) const 255Attendee *IncidenceBase::getAttendee(const char *n) const
256{ 256{
257 QPtrListIterator<Attendee> qli(mAttendees); 257 QPtrListIterator<Attendee> qli(mAttendees);
258 258
259 qli.toFirst(); 259 qli.toFirst();
260 while (qli) { 260 while (qli) {
261 if (qli.current()->getName() == n) 261 if (qli.current()->getName() == n)
262 return qli.current(); 262 return qli.current();
263 ++qli; 263 ++qli;
264 } 264 }
265 return 0L; 265 return 0L;
266} 266}
267#endif 267#endif
268 268
269Attendee *IncidenceBase::attendeeByMail(const QString &email) 269Attendee *IncidenceBase::attendeeByMail(const QString &email)
270{ 270{
271 QPtrListIterator<Attendee> qli(mAttendees); 271 QPtrListIterator<Attendee> qli(mAttendees);
272 272
273 qli.toFirst(); 273 qli.toFirst();
274 while (qli) { 274 while (qli) {
275 if (qli.current()->email() == email) 275 if (qli.current()->email() == email)
276 return qli.current(); 276 return qli.current();
277 ++qli; 277 ++qli;
278 } 278 }
279 return 0L; 279 return 0L;
280} 280}
281 281
282Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 282Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
283{ 283{
284 QPtrListIterator<Attendee> qli(mAttendees); 284 QPtrListIterator<Attendee> qli(mAttendees);
285 285
286 QStringList mails = emails; 286 QStringList mails = emails;
287 if (!email.isEmpty()) { 287 if (!email.isEmpty()) {
288 mails.append(email); 288 mails.append(email);
289 } 289 }
290 qli.toFirst(); 290 qli.toFirst();
291 while (qli) { 291 while (qli) {
292 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 292 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
293 if (qli.current()->email() == *it) 293 if (qli.current()->email() == *it)
294 return qli.current(); 294 return qli.current();
295 } 295 }
296 296
297 ++qli; 297 ++qli;
298 } 298 }
299 return 0L; 299 return 0L;
300} 300}
301 301
302void IncidenceBase::setDuration(int seconds) 302void IncidenceBase::setDuration(int seconds)
303{ 303{
304 mDuration = seconds; 304 mDuration = seconds;
305 setHasDuration(true); 305 setHasDuration(true);
306} 306}
307 307
308int IncidenceBase::duration() const 308int IncidenceBase::duration() const
309{ 309{
310 return mDuration; 310 return mDuration;
311} 311}
312 312
313void IncidenceBase::setHasDuration(bool b) 313void IncidenceBase::setHasDuration(bool b)
314{ 314{
315 mHasDuration = b; 315 mHasDuration = b;
316} 316}
317 317
318bool IncidenceBase::hasDuration() const 318bool IncidenceBase::hasDuration() const
319{ 319{
320 return mHasDuration; 320 return mHasDuration;
321} 321}
322 322
323void IncidenceBase::setSyncStatus(int stat) 323void IncidenceBase::setSyncStatus(int stat)
324{ 324{
325 if (mReadOnly) return; 325 if (mReadOnly) return;
326 mSyncStatus = stat; 326 mSyncStatus = stat;
327} 327}
328 328
329int IncidenceBase::syncStatus() const 329int IncidenceBase::syncStatus() const
330{ 330{
331 return mSyncStatus; 331 return mSyncStatus;
332} 332}
333 333
334void IncidenceBase::setPilotId( int id ) 334void IncidenceBase::setPilotId( int id )
335{ 335{
336 if (mReadOnly) return; 336 if (mReadOnly) return;
337 mPilotId = id; 337 mPilotId = id;
338} 338}
339 339
340int IncidenceBase::pilotId() const 340int IncidenceBase::pilotId() const
341{ 341{
342 return mPilotId; 342 return mPilotId;
343} 343}
344void IncidenceBase::setZaurusId( int id ) 344void IncidenceBase::setZaurusId( int id )
345{ 345{
346 if (mReadOnly) return; 346 if (mReadOnly) return;
347 mZaurusId = id; 347 mZaurusId = id;
348} 348}
349 349
350int IncidenceBase::zaurusId() const 350int IncidenceBase::zaurusId() const
351{ 351{
352 return mZaurusId; 352 return mZaurusId;
353} 353}
354 354
355int IncidenceBase::zaurusUid() const 355int IncidenceBase::zaurusUid() const
356{ 356{
357 return mZaurusUid; 357 return mZaurusUid;
358} 358}
359void IncidenceBase::setZaurusUid( int id ) 359void IncidenceBase::setZaurusUid( int id )
360{ 360{
361 if (mReadOnly) return; 361 if (mReadOnly) return;
362 mZaurusUid = id; 362 mZaurusUid = id;
363} 363}
364 364
365int IncidenceBase::zaurusStat() const 365int IncidenceBase::tempSyncStat() const
366{ 366{
367 return mZaurusStat; 367 return mTempSyncStat;
368} 368}
369void IncidenceBase::setZaurusStat( int id ) 369void IncidenceBase::setTempSyncStat( int id )
370{ 370{
371 if (mReadOnly) return; 371 if (mReadOnly) return;
372 mZaurusStat = id; 372 mTempSyncStat = id;
373} 373}
374 374
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
376{ 376{
377 if( !mObservers.contains(observer) ) mObservers.append( observer ); 377 if( !mObservers.contains(observer) ) mObservers.append( observer );
378} 378}
379 379
380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
381{ 381{
382 mObservers.remove( observer ); 382 mObservers.remove( observer );
383} 383}
384 384
385void IncidenceBase::updated() 385void IncidenceBase::updated()
386{ 386{
387 QPtrListIterator<Observer> it(mObservers); 387 QPtrListIterator<Observer> it(mObservers);
388 while( it.current() ) { 388 while( it.current() ) {
389 Observer *o = it.current(); 389 Observer *o = it.current();
390 ++it; 390 ++it;
391 o->incidenceUpdated( this ); 391 o->incidenceUpdated( this );
392 } 392 }
393} 393}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 0ab7eef..ce6e254 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,170 +1,170 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 37
38/** 38/**
39 This class provides the base class common to all calendar components. 39 This class provides the base class common to all calendar components.
40*/ 40*/
41class IncidenceBase : public CustomProperties 41class IncidenceBase : public CustomProperties
42{ 42{
43 public: 43 public:
44 class Observer { 44 class Observer {
45 public: 45 public:
46 virtual void incidenceUpdated( IncidenceBase * ) = 0; 46 virtual void incidenceUpdated( IncidenceBase * ) = 0;
47 }; 47 };
48 48
49 IncidenceBase(); 49 IncidenceBase();
50 IncidenceBase(const IncidenceBase &); 50 IncidenceBase(const IncidenceBase &);
51 virtual ~IncidenceBase(); 51 virtual ~IncidenceBase();
52 52
53 virtual QCString type() const = 0; 53 virtual QCString type() const = 0;
54 54
55 /** Set the unique id for the event */ 55 /** Set the unique id for the event */
56 void setUid(const QString &); 56 void setUid(const QString &);
57 /** Return the unique id for the event */ 57 /** Return the unique id for the event */
58 QString uid() const; 58 QString uid() const;
59 59
60 /** Sets the time the incidence was last modified. */ 60 /** Sets the time the incidence was last modified. */
61 void setLastModified(const QDateTime &lm); 61 void setLastModified(const QDateTime &lm);
62 /** Return the time the incidence was last modified. */ 62 /** Return the time the incidence was last modified. */
63 QDateTime lastModified() const; 63 QDateTime lastModified() const;
64 64
65 /** sets the organizer for the event */ 65 /** sets the organizer for the event */
66 void setOrganizer(const QString &o); 66 void setOrganizer(const QString &o);
67 QString organizer() const; 67 QString organizer() const;
68 68
69 /** Set readonly status. */ 69 /** Set readonly status. */
70 virtual void setReadOnly( bool ); 70 virtual void setReadOnly( bool );
71 /** Return if the object is read-only. */ 71 /** Return if the object is read-only. */
72 bool isReadOnly() const { return mReadOnly; } 72 bool isReadOnly() const { return mReadOnly; }
73 73
74 /** for setting the event's starting date/time with a QDateTime. */ 74 /** for setting the event's starting date/time with a QDateTime. */
75 virtual void setDtStart(const QDateTime &dtStart); 75 virtual void setDtStart(const QDateTime &dtStart);
76 /** returns an event's starting date/time as a QDateTime. */ 76 /** returns an event's starting date/time as a QDateTime. */
77 QDateTime dtStart() const; 77 QDateTime dtStart() const;
78 /** returns an event's starting time as a string formatted according to the 78 /** returns an event's starting time as a string formatted according to the
79 users locale settings */ 79 users locale settings */
80 QString dtStartTimeStr() const; 80 QString dtStartTimeStr() const;
81 /** returns an event's starting date as a string formatted according to the 81 /** returns an event's starting date as a string formatted according to the
82 users locale settings */ 82 users locale settings */
83 QString dtStartDateStr(bool shortfmt=true) const; 83 QString dtStartDateStr(bool shortfmt=true) const;
84 /** returns an event's starting date and time as a string formatted according 84 /** returns an event's starting date and time as a string formatted according
85 to the users locale settings */ 85 to the users locale settings */
86 QString dtStartStr(bool shortfmt=true) const; 86 QString dtStartStr(bool shortfmt=true) const;
87 87
88 virtual void setDuration(int seconds); 88 virtual void setDuration(int seconds);
89 int duration() const; 89 int duration() const;
90 void setHasDuration(bool); 90 void setHasDuration(bool);
91 bool hasDuration() const; 91 bool hasDuration() const;
92 92
93 /** Return true or false depending on whether the incidence "floats," 93 /** Return true or false depending on whether the incidence "floats,"
94 * i.e. has a date but no time attached to it. */ 94 * i.e. has a date but no time attached to it. */
95 bool doesFloat() const; 95 bool doesFloat() const;
96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
97 void setFloats(bool f); 97 void setFloats(bool f);
98 98
99 /** 99 /**
100 Add Attendee to this incidence. IncidenceBase takes ownership of the 100 Add Attendee to this incidence. IncidenceBase takes ownership of the
101 Attendee object. 101 Attendee object.
102 */ 102 */
103 void addAttendee(Attendee *a, bool doupdate=true ); 103 void addAttendee(Attendee *a, bool doupdate=true );
104// void removeAttendee(Attendee *a); 104// void removeAttendee(Attendee *a);
105// void removeAttendee(const char *n); 105// void removeAttendee(const char *n);
106 /** Remove all Attendees. */ 106 /** Remove all Attendees. */
107 void clearAttendees(); 107 void clearAttendees();
108 /** Return list of attendees. */ 108 /** Return list of attendees. */
109 QPtrList<Attendee> attendees() const { return mAttendees; }; 109 QPtrList<Attendee> attendees() const { return mAttendees; };
110 /** Return number of attendees. */ 110 /** Return number of attendees. */
111 int attendeeCount() const { return mAttendees.count(); }; 111 int attendeeCount() const { return mAttendees.count(); };
112 /** Return the Attendee with this email */ 112 /** Return the Attendee with this email */
113 Attendee* attendeeByMail(const QString &); 113 Attendee* attendeeByMail(const QString &);
114 /** Return first Attendee with one of this emails */ 114 /** Return first Attendee with one of this emails */
115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
116 116
117 /** pilot syncronization states */ 117 /** pilot syncronization states */
118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
119 /** Set synchronisation satus. */ 119 /** Set synchronisation satus. */
120 void setSyncStatus(int stat); 120 void setSyncStatus(int stat);
121 /** Return synchronisation status. */ 121 /** Return synchronisation status. */
122 int syncStatus() const; 122 int syncStatus() const;
123 123
124 /** Set Pilot Id. */ 124 /** Set Pilot Id. */
125 void setPilotId(int id); 125 void setPilotId(int id);
126 /** Return Pilot Id. */ 126 /** Return Pilot Id. */
127 int pilotId() const; 127 int pilotId() const;
128 128
129 void setZaurusId(int id); 129 void setZaurusId(int id);
130 int zaurusId() const; 130 int zaurusId() const;
131 void setZaurusUid(int id); 131 void setZaurusUid(int id);
132 int zaurusUid() const; 132 int zaurusUid() const;
133 void setZaurusStat(int id); 133 void setTempSyncStat(int id);
134 int zaurusStat() const; 134 int tempSyncStat() const;
135 135
136 void registerObserver( Observer * ); 136 void registerObserver( Observer * );
137 void unRegisterObserver( Observer * ); 137 void unRegisterObserver( Observer * );
138 void updated(); 138 void updated();
139 139
140 protected: 140 protected:
141 bool mReadOnly; 141 bool mReadOnly;
142 QDateTime getEvenTime( QDateTime ); 142 QDateTime getEvenTime( QDateTime );
143 143
144 private: 144 private:
145 // base components 145 // base components
146 QDateTime mDtStart; 146 QDateTime mDtStart;
147 QString mOrganizer; 147 QString mOrganizer;
148 QString mUid; 148 QString mUid;
149 QDateTime mLastModified; 149 QDateTime mLastModified;
150 QPtrList<Attendee> mAttendees; 150 QPtrList<Attendee> mAttendees;
151 151
152 bool mFloats; 152 bool mFloats;
153 153
154 int mDuration; 154 int mDuration;
155 bool mHasDuration; 155 bool mHasDuration;
156 int mZaurusId; 156 int mZaurusId;
157 int mZaurusUid; 157 int mZaurusUid;
158 int mZaurusStat; 158 int mTempSyncStat;
159 159
160 // PILOT SYNCHRONIZATION STUFF 160 // PILOT SYNCHRONIZATION STUFF
161 int mPilotId; // unique id for pilot sync 161 int mPilotId; // unique id for pilot sync
162 int mSyncStatus; // status (for sync) 162 int mSyncStatus; // status (for sync)
163 163
164 QPtrList<Observer> mObservers; 164 QPtrList<Observer> mObservers;
165}; 165};
166 166
167bool operator==( const IncidenceBase&, const IncidenceBase& ); 167bool operator==( const IncidenceBase&, const IncidenceBase& );
168} 168}
169 169
170#endif 170#endif
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 973f19d..d39d2dd 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -1,792 +1,792 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "sharpformat.h" 44#include "sharpformat.h"
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
51 51
52//ARSD silentalarm = 0 52//ARSD silentalarm = 0
53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
54// 12 RFRQ 54// 12 RFRQ
55// 13 RPOS pos = 4. monday in month 55// 13 RPOS pos = 4. monday in month
56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
57// 15 REND 0 = no end/ 1 = end 57// 15 REND 0 = no end/ 1 = end
58// 16 REDT rec end dt 58// 16 REDT rec end dt
59//ALSD 59//ALSD
60//ALED 60//ALED
61//MDAY 61//MDAY
62 62
63class SharpParser : public QObject 63class SharpParser : public QObject
64{ 64{
65 public: 65 public:
66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
67 oldCategories = 0; 67 oldCategories = 0;
68 } 68 }
69 69
70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
71 { 71 {
72 int i = 1; 72 int i = 1;
73 bool skip = true; 73 bool skip = true;
74 int max = attList.count() -2; 74 int max = attList.count() -2;
75 while ( i < max ) { 75 while ( i < max ) {
76 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
77 skip = false; 77 skip = false;
78 break; 78 break;
79 } 79 }
80 ++i ; 80 ++i ;
81 } 81 }
82 if ( skip ) 82 if ( skip )
83 return false; 83 return false;
84 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
85 85
86 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
87 Event *event; 87 Event *event;
88 event = existingCalendar->event( attList[0].toInt() ); 88 event = existingCalendar->event( attList[0].toInt() );
89 if ( event ) 89 if ( event )
90 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
91 else 91 else
92 event = new Event; 92 event = new Event;
93 event->setZaurusId( attList[0].toInt() ); 93 event->setZaurusId( attList[0].toInt() );
94 event->setZaurusUid( cSum ); 94 event->setZaurusUid( cSum );
95 event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
96 96
97 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
98 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
99 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
100 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
101 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
102 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
103 event->setFloats( true ); 103 event->setFloats( true );
104 } else { 104 } else {
105 event->setFloats( false ); 105 event->setFloats( false );
106 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
107 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
108 } 108 }
109 109
110 QString rtype = attList[11]; 110 QString rtype = attList[11];
111 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
112 // qDebug("recurs "); 112 // qDebug("recurs ");
113 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
114 114
115 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
116 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
117 117
118 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
119 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
120 120
121 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
122 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
123 123
124 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
125 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
126 126
127 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
128 int i; 128 int i;
129 int bb = 1; 129 int bb = 1;
130 for( i = 1; i <= 7; ++i ) { 130 for( i = 1; i <= 7; ++i ) {
131 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 131 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
132 bb = 2 << (i-1); 132 bb = 2 << (i-1);
133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
134 } 134 }
135 // qDebug("next "); 135 // qDebug("next ");
136 QString posStr = attList[13]; 136 QString posStr = attList[13];
137 int pos = posStr.toInt(); 137 int pos = posStr.toInt();
138 Recurrence *r = event->recurrence(); 138 Recurrence *r = event->recurrence();
139 139
140 if ( rtype == "0" ) { 140 if ( rtype == "0" ) {
141 if ( hasEndDate ) r->setDaily( freq, endDate ); 141 if ( hasEndDate ) r->setDaily( freq, endDate );
142 else r->setDaily( freq, -1 ); 142 else r->setDaily( freq, -1 );
143 } else if ( rtype == "1" ) { 143 } else if ( rtype == "1" ) {
144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
145 else r->setWeekly( freq, weekDays, -1 ); 145 else r->setWeekly( freq, weekDays, -1 );
146 } else if ( rtype == "3" ) { 146 } else if ( rtype == "3" ) {
147 if ( hasEndDate ) 147 if ( hasEndDate )
148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
149 else 149 else
150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
151 r->addMonthlyDay( startDate.day() ); 151 r->addMonthlyDay( startDate.day() );
152 } else if ( rtype == "2" ) { 152 } else if ( rtype == "2" ) {
153 if ( hasEndDate ) 153 if ( hasEndDate )
154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
155 else 155 else
156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
157 QBitArray days( 7 ); 157 QBitArray days( 7 );
158 days.fill( false ); 158 days.fill( false );
159 days.setBit( startDate.dayOfWeek() - 1 ); 159 days.setBit( startDate.dayOfWeek() - 1 );
160 r->addMonthlyPos( pos, days ); 160 r->addMonthlyPos( pos, days );
161 } else if ( rtype == "4" ) { 161 } else if ( rtype == "4" ) {
162 if ( hasEndDate ) 162 if ( hasEndDate )
163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
164 else 164 else
165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
166 r->addYearlyNum( startDate.month() ); 166 r->addYearlyNum( startDate.month() );
167 } 167 }
168 } 168 }
169 169
170 QString categoryList = attList[1] ; 170 QString categoryList = attList[1] ;
171 event->setCategories( lookupCategories( categoryList ) ); 171 event->setCategories( lookupCategories( categoryList ) );
172 172
173 // strange 0 semms to mean: alarm enabled 173 // strange 0 semms to mean: alarm enabled
174 if ( attList[8] == "0" ) { 174 if ( attList[8] == "0" ) {
175 Alarm *alarm; 175 Alarm *alarm;
176 if ( event->alarms().count() > 0 ) 176 if ( event->alarms().count() > 0 )
177 alarm = event->alarms().first(); 177 alarm = event->alarms().first();
178 else { 178 else {
179 alarm = new Alarm( event ); 179 alarm = new Alarm( event );
180 event->addAlarm( alarm ); 180 event->addAlarm( alarm );
181 } 181 }
182 alarm->setType( Alarm::Audio ); 182 alarm->setType( Alarm::Audio );
183 alarm->setEnabled( true ); 183 alarm->setEnabled( true );
184 int alarmOffset = attList[9].toInt(); 184 int alarmOffset = attList[9].toInt();
185 alarm->setStartOffset( alarmOffset * -60 ); 185 alarm->setStartOffset( alarmOffset * -60 );
186 } 186 }
187 187
188 mCalendar->addEvent( event); 188 mCalendar->addEvent( event);
189 } else if ( qName == "Todo" ) { 189 } else if ( qName == "Todo" ) {
190 Todo *todo; 190 Todo *todo;
191 191
192 todo = existingCalendar->todo( attList[0].toInt() ); 192 todo = existingCalendar->todo( attList[0].toInt() );
193 if (todo ) 193 if (todo )
194 todo = (Todo*)todo->clone(); 194 todo = (Todo*)todo->clone();
195 else 195 else
196 todo = new Todo; 196 todo = new Todo;
197 197
198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
199// 0 1 2 3 4 5 6 7 8 199// 0 1 2 3 4 5 6 7 8
200//1,,,,,1,4,Loch zumachen,"" 200//1,,,,,1,4,Loch zumachen,""
201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
203 203
204 todo->setZaurusId( attList[0].toInt() ); 204 todo->setZaurusId( attList[0].toInt() );
205 todo->setZaurusUid( cSum ); 205 todo->setZaurusUid( cSum );
206 todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 206 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
207 207
208 todo->setSummary( attList[7] ); 208 todo->setSummary( attList[7] );
209 todo->setDescription( attList[8]); 209 todo->setDescription( attList[8]);
210 210
211 int priority = attList[6].toInt(); 211 int priority = attList[6].toInt();
212 if ( priority == 0 ) priority = 3; 212 if ( priority == 0 ) priority = 3;
213 todo->setPriority( priority ); 213 todo->setPriority( priority );
214 214
215 QString categoryList = attList[1]; 215 QString categoryList = attList[1];
216 todo->setCategories( lookupCategories( categoryList ) ); 216 todo->setCategories( lookupCategories( categoryList ) );
217 217
218 218
219 219
220 QString hasDateStr = attList[3]; // due 220 QString hasDateStr = attList[3]; // due
221 if ( !hasDateStr.isEmpty() ) { 221 if ( !hasDateStr.isEmpty() ) {
222 if ( hasDateStr.right(6) == "000000" ) { 222 if ( hasDateStr.right(6) == "000000" ) {
223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
224 todo->setFloats( true ); 224 todo->setFloats( true );
225 } 225 }
226 else { 226 else {
227 todo->setDtDue( fromString( hasDateStr ) ); 227 todo->setDtDue( fromString( hasDateStr ) );
228 todo->setFloats( false ); 228 todo->setFloats( false );
229 } 229 }
230 230
231 todo->setHasDueDate( true ); 231 todo->setHasDueDate( true );
232 } 232 }
233 hasDateStr = attList[2];//start 233 hasDateStr = attList[2];//start
234 if ( !hasDateStr.isEmpty() ) { 234 if ( !hasDateStr.isEmpty() ) {
235 235
236 todo->setDtStart( fromString( hasDateStr ) ); 236 todo->setDtStart( fromString( hasDateStr ) );
237 todo->setHasStartDate( true); 237 todo->setHasStartDate( true);
238 } else 238 } else
239 todo->setHasStartDate( false ); 239 todo->setHasStartDate( false );
240 hasDateStr = attList[4];//completed 240 hasDateStr = attList[4];//completed
241 if ( !hasDateStr.isEmpty() ) { 241 if ( !hasDateStr.isEmpty() ) {
242 todo->setCompleted(fromString( hasDateStr ) ); 242 todo->setCompleted(fromString( hasDateStr ) );
243 } 243 }
244 QString completedStr = attList[5]; 244 QString completedStr = attList[5];
245 if ( completedStr == "0" ) 245 if ( completedStr == "0" )
246 todo->setCompleted( true ); 246 todo->setCompleted( true );
247 else 247 else
248 todo->setCompleted( false ); 248 todo->setCompleted( false );
249 mCalendar->addTodo( todo ); 249 mCalendar->addTodo( todo );
250 250
251 } else if ( qName == "Category" ) { 251 } else if ( qName == "Category" ) {
252 /* 252 /*
253 QString id = attributes.value( "id" ); 253 QString id = attributes.value( "id" );
254 QString name = attributes.value( "name" ); 254 QString name = attributes.value( "name" );
255 setCategory( id, name ); 255 setCategory( id, name );
256 */ 256 */
257 } 257 }
258 //qDebug("end "); 258 //qDebug("end ");
259 return true; 259 return true;
260 } 260 }
261 261
262 262
263 void setCategoriesList ( QStringList * c ) 263 void setCategoriesList ( QStringList * c )
264 { 264 {
265 oldCategories = c; 265 oldCategories = c;
266 } 266 }
267 267
268 QDateTime fromString ( QString s, bool useTz = true ) { 268 QDateTime fromString ( QString s, bool useTz = true ) {
269 QDateTime dt; 269 QDateTime dt;
270 int y,m,t,h,min,sec; 270 int y,m,t,h,min,sec;
271 y = s.mid(0,4).toInt(); 271 y = s.mid(0,4).toInt();
272 m = s.mid(4,2).toInt(); 272 m = s.mid(4,2).toInt();
273 t = s.mid(6,2).toInt(); 273 t = s.mid(6,2).toInt();
274 h = s.mid(9,2).toInt(); 274 h = s.mid(9,2).toInt();
275 min = s.mid(11,2).toInt(); 275 min = s.mid(11,2).toInt();
276 sec = s.mid(13,2).toInt(); 276 sec = s.mid(13,2).toInt();
277 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 277 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
278 int offset = KGlobal::locale()->localTimeOffset( dt ); 278 int offset = KGlobal::locale()->localTimeOffset( dt );
279 if ( useTz ) 279 if ( useTz )
280 dt = dt.addSecs ( offset*60); 280 dt = dt.addSecs ( offset*60);
281 return dt; 281 return dt;
282 282
283 } 283 }
284 protected: 284 protected:
285 QDateTime toDateTime( const QString &value ) 285 QDateTime toDateTime( const QString &value )
286 { 286 {
287 QDateTime dt; 287 QDateTime dt;
288 dt.setTime_t( value.toUInt() ); 288 dt.setTime_t( value.toUInt() );
289 289
290 return dt; 290 return dt;
291 } 291 }
292 292
293 QStringList lookupCategories( const QString &categoryList ) 293 QStringList lookupCategories( const QString &categoryList )
294 { 294 {
295 QStringList categoryIds = QStringList::split( ";", categoryList ); 295 QStringList categoryIds = QStringList::split( ";", categoryList );
296 QStringList categories; 296 QStringList categories;
297 QStringList::ConstIterator it; 297 QStringList::ConstIterator it;
298 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 298 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
299 QString cate = category( *it ); 299 QString cate = category( *it );
300 if ( oldCategories ) { 300 if ( oldCategories ) {
301 if ( ! oldCategories->contains( cate ) ) 301 if ( ! oldCategories->contains( cate ) )
302 oldCategories->append( cate ); 302 oldCategories->append( cate );
303 } 303 }
304 categories.append(cate ); 304 categories.append(cate );
305 } 305 }
306 return categories; 306 return categories;
307 } 307 }
308 308
309 private: 309 private:
310 Calendar *mCalendar; 310 Calendar *mCalendar;
311 QStringList * oldCategories; 311 QStringList * oldCategories;
312 static QString category( const QString &id ) 312 static QString category( const QString &id )
313 { 313 {
314 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 314 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
315 if ( it == mCategoriesMap.end() ) return id; 315 if ( it == mCategoriesMap.end() ) return id;
316 else return *it; 316 else return *it;
317 } 317 }
318 318
319 static void setCategory( const QString &id, const QString &name ) 319 static void setCategory( const QString &id, const QString &name )
320 { 320 {
321 mCategoriesMap.insert( id, name ); 321 mCategoriesMap.insert( id, name );
322 } 322 }
323 323
324 static QMap<QString,QString> mCategoriesMap; 324 static QMap<QString,QString> mCategoriesMap;
325}; 325};
326 326
327QMap<QString,QString> SharpParser::mCategoriesMap; 327QMap<QString,QString> SharpParser::mCategoriesMap;
328 328
329SharpFormat::SharpFormat() 329SharpFormat::SharpFormat()
330{ 330{
331 mCategories = 0; 331 mCategories = 0;
332} 332}
333 333
334SharpFormat::~SharpFormat() 334SharpFormat::~SharpFormat()
335{ 335{
336} 336}
337ulong SharpFormat::getCsum( const QStringList & attList) 337ulong SharpFormat::getCsum( const QStringList & attList)
338{ 338{
339 int max = attList.count() -1; 339 int max = attList.count() -1;
340 ulong cSum = 0; 340 ulong cSum = 0;
341 int j,k,i; 341 int j,k,i;
342 int add; 342 int add;
343 for ( i = 1; i < max ; ++i ) { 343 for ( i = 1; i < max ; ++i ) {
344 QString s = attList[i]; 344 QString s = attList[i];
345 if ( ! s.isEmpty() ){ 345 if ( ! s.isEmpty() ){
346 j = s.length(); 346 j = s.length();
347 for ( k = 0; k < j; ++k ) { 347 for ( k = 0; k < j; ++k ) {
348 int mul = k +1; 348 int mul = k +1;
349 add = s[k].unicode (); 349 add = s[k].unicode ();
350 if ( k < 16 ) 350 if ( k < 16 )
351 mul = mul * mul; 351 mul = mul * mul;
352 add = add * mul *i*i*i; 352 add = add * mul *i*i*i;
353 cSum += add; 353 cSum += add;
354 } 354 }
355 } 355 }
356 } 356 }
357 return cSum; 357 return cSum;
358 358
359} 359}
360#include <stdlib.h> 360#include <stdlib.h>
361#define DEBUGMODE false 361#define DEBUGMODE false
362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
363{ 363{
364 364
365 365
366 bool debug = DEBUGMODE; 366 bool debug = DEBUGMODE;
367 //debug = true; 367 //debug = true;
368 QString text; 368 QString text;
369 QString codec = "utf8"; 369 QString codec = "utf8";
370 QLabel status ( i18n("Reading events ..."), 0 ); 370 QLabel status ( i18n("Reading events ..."), 0 );
371 371
372 int w = status.sizeHint().width()+20 ; 372 int w = status.sizeHint().width()+20 ;
373 if ( w < 200 ) w = 200; 373 if ( w < 200 ) w = 200;
374 int h = status.sizeHint().height()+20 ; 374 int h = status.sizeHint().height()+20 ;
375 int dw = QApplication::desktop()->width(); 375 int dw = QApplication::desktop()->width();
376 int dh = QApplication::desktop()->height(); 376 int dh = QApplication::desktop()->height();
377 status.setCaption(i18n("Reading DTM Data") ); 377 status.setCaption(i18n("Reading DTM Data") );
378 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 378 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
379 status.show(); 379 status.show();
380 status.raise(); 380 status.raise();
381 qApp->processEvents(); 381 qApp->processEvents();
382 QString fileName; 382 QString fileName;
383 if ( ! debug ) { 383 if ( ! debug ) {
384 fileName = "/tmp/kopitempout"; 384 fileName = "/tmp/kopitempout";
385 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 385 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
386 system ( command.latin1() ); 386 system ( command.latin1() );
387 } else { 387 } else {
388 fileName = "/tmp/events.txt"; 388 fileName = "/tmp/events.txt";
389 389
390 } 390 }
391 QFile file( fileName ); 391 QFile file( fileName );
392 if (!file.open( IO_ReadOnly ) ) { 392 if (!file.open( IO_ReadOnly ) ) {
393 return false; 393 return false;
394 394
395 } 395 }
396 QTextStream ts( &file ); 396 QTextStream ts( &file );
397 ts.setCodec( QTextCodec::codecForName("utf8") ); 397 ts.setCodec( QTextCodec::codecForName("utf8") );
398 text = ts.read(); 398 text = ts.read();
399 file.close(); 399 file.close();
400 status.setText( i18n("Processing events ...") ); 400 status.setText( i18n("Processing events ...") );
401 status.raise(); 401 status.raise();
402 qApp->processEvents(); 402 qApp->processEvents();
403 fromString2Cal( calendar, existngCal, text, "Event" ); 403 fromString2Cal( calendar, existngCal, text, "Event" );
404 status.setText( i18n("Reading todos ...") ); 404 status.setText( i18n("Reading todos ...") );
405 qApp->processEvents(); 405 qApp->processEvents();
406 if ( ! debug ) { 406 if ( ! debug ) {
407 fileName = "/tmp/kopitempout"; 407 fileName = "/tmp/kopitempout";
408 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 408 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
409 system ( command.latin1() ); 409 system ( command.latin1() );
410 } else { 410 } else {
411 fileName = "/tmp/todo.txt"; 411 fileName = "/tmp/todo.txt";
412 } 412 }
413 file.setName( fileName ); 413 file.setName( fileName );
414 if (!file.open( IO_ReadOnly ) ) { 414 if (!file.open( IO_ReadOnly ) ) {
415 return false; 415 return false;
416 416
417 } 417 }
418 ts.setDevice( &file ); 418 ts.setDevice( &file );
419 text = ts.read(); 419 text = ts.read();
420 file.close(); 420 file.close();
421 421
422 status.setText( i18n("Processing todos ...") ); 422 status.setText( i18n("Processing todos ...") );
423 status.raise(); 423 status.raise();
424 qApp->processEvents(); 424 qApp->processEvents();
425 fromString2Cal( calendar, existngCal, text, "Todo" ); 425 fromString2Cal( calendar, existngCal, text, "Todo" );
426 return true; 426 return true;
427} 427}
428int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) 428int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
429{ 429{
430 int retval = -1; 430 int retval = -1;
431 QStringList templist; 431 QStringList templist;
432 QString tempString; 432 QString tempString;
433 int start = 0; 433 int start = 0;
434 int len = answer.length(); 434 int len = answer.length();
435 int end = answer.find ("\n",start)+1; 435 int end = answer.find ("\n",start)+1;
436 bool ok = true; 436 bool ok = true;
437 start = end; 437 start = end;
438 int ccc = 0; 438 int ccc = 0;
439 while ( start > 0 ) { 439 while ( start > 0 ) {
440 templist.clear(); 440 templist.clear();
441 ok = true; 441 ok = true;
442 int loopCount = 0; 442 int loopCount = 0;
443 while ( ok ) { 443 while ( ok ) {
444 ++loopCount; 444 ++loopCount;
445 if ( loopCount > 25 ) { 445 if ( loopCount > 25 ) {
446 qDebug("KO: Error in while loop"); 446 qDebug("KO: Error in while loop");
447 ok = false; 447 ok = false;
448 start = 0; 448 start = 0;
449 break; 449 break;
450 } 450 }
451 if ( ok ) 451 if ( ok )
452 tempString = getPart( answer, ok, start ); 452 tempString = getPart( answer, ok, start );
453 if ( start >= len || start == 0 ) { 453 if ( start >= len || start == 0 ) {
454 start = 0; 454 start = 0;
455 ok = false; 455 ok = false;
456 } 456 }
457 if ( tempString.right(1) =="\n" ) 457 if ( tempString.right(1) =="\n" )
458 tempString = tempString.left( tempString.length()-1); 458 tempString = tempString.left( tempString.length()-1);
459 459
460 templist.append( tempString ); 460 templist.append( tempString );
461 } 461 }
462 ++ccc; 462 ++ccc;
463 if ( ccc == 2 && loopCount < 25 ) { 463 if ( ccc == 2 && loopCount < 25 ) {
464 start = 0; 464 start = 0;
465 bool ok; 465 bool ok;
466 int newnum = templist[0].toInt( &ok ); 466 int newnum = templist[0].toInt( &ok );
467 if ( ok && newnum > 0) { 467 if ( ok && newnum > 0) {
468 retval = newnum; 468 retval = newnum;
469 inc->setZaurusId( newnum ); 469 inc->setZaurusId( newnum );
470 inc->setZaurusUid( getCsum( templist ) ); 470 inc->setZaurusUid( getCsum( templist ) );
471 inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID ); 471 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
472 } 472 }
473 } 473 }
474 } 474 }
475 //qDebug("getNumFromRecord returning : %d ", retval); 475 //qDebug("getNumFromRecord returning : %d ", retval);
476 return retval; 476 return retval;
477} 477}
478bool SharpFormat::save( Calendar *calendar) 478bool SharpFormat::save( Calendar *calendar)
479{ 479{
480 480
481 QLabel status ( i18n("Processing/adding events ..."), 0 ); 481 QLabel status ( i18n("Processing/adding events ..."), 0 );
482 int w = status.sizeHint().width()+20 ; 482 int w = status.sizeHint().width()+20 ;
483 if ( w < 200 ) w = 200; 483 if ( w < 200 ) w = 200;
484 int h = status.sizeHint().height()+20 ; 484 int h = status.sizeHint().height()+20 ;
485 int dw = QApplication::desktop()->width(); 485 int dw = QApplication::desktop()->width();
486 int dh = QApplication::desktop()->height(); 486 int dh = QApplication::desktop()->height();
487 status.setCaption(i18n("Writing DTM Data") ); 487 status.setCaption(i18n("Writing DTM Data") );
488 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 488 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
489 status.show(); 489 status.show();
490 status.raise(); 490 status.raise();
491 qApp->processEvents(); 491 qApp->processEvents();
492 bool debug = DEBUGMODE; 492 bool debug = DEBUGMODE;
493 QString codec = "utf8"; 493 QString codec = "utf8";
494 QString answer; 494 QString answer;
495 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 495 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
496 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 496 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
497 QString command; 497 QString command;
498 QPtrList<Event> er = calendar->rawEvents(); 498 QPtrList<Event> er = calendar->rawEvents();
499 Event* ev = er.first(); 499 Event* ev = er.first();
500 QString fileName = "/tmp/kopitempout"; 500 QString fileName = "/tmp/kopitempout";
501 int i = 0; 501 int i = 0;
502 QString changeString = ePrefix; 502 QString changeString = ePrefix;
503 QString deleteString = ePrefix; 503 QString deleteString = ePrefix;
504 bool deleteEnt = false; 504 bool deleteEnt = false;
505 bool changeEnt = false; 505 bool changeEnt = false;
506 QString message = i18n("Processing event # "); 506 QString message = i18n("Processing event # ");
507 int procCount = 0; 507 int procCount = 0;
508 while ( ev ) { 508 while ( ev ) {
509 //qDebug("i %d ", ++i); 509 //qDebug("i %d ", ++i);
510 if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 510 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
511 status.setText ( message + QString::number ( ++procCount ) ); 511 status.setText ( message + QString::number ( ++procCount ) );
512 qApp->processEvents(); 512 qApp->processEvents();
513 QString eString = getEventString( ev ); 513 QString eString = getEventString( ev );
514 if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete 514 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
515 // deleting empty strings does not work. 515 // deleting empty strings does not work.
516 // we write first and x and then delete the record with the x 516 // we write first and x and then delete the record with the x
517 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 517 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
518 changeString += eString + "\n"; 518 changeString += eString + "\n";
519 deleteString += eString + "\n"; 519 deleteString += eString + "\n";
520 deleteEnt = true; 520 deleteEnt = true;
521 changeEnt = true; 521 changeEnt = true;
522 } 522 }
523 else if ( ev->zaurusId() == -1 ) { // add new 523 else if ( ev->zaurusId() == -1 ) { // add new
524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
525 system ( command.utf8() ); 525 system ( command.utf8() );
526 QFile file( fileName ); 526 QFile file( fileName );
527 if (!file.open( IO_ReadOnly ) ) { 527 if (!file.open( IO_ReadOnly ) ) {
528 return false; 528 return false;
529 529
530 } 530 }
531 QTextStream ts( &file ); 531 QTextStream ts( &file );
532 ts.setCodec( QTextCodec::codecForName("utf8") ); 532 ts.setCodec( QTextCodec::codecForName("utf8") );
533 answer = ts.read(); 533 answer = ts.read();
534 file.close(); 534 file.close();
535 //qDebug("answer \n%s ", answer.latin1()); 535 //qDebug("answer \n%s ", answer.latin1());
536 getNumFromRecord( answer, ev ) ; 536 getNumFromRecord( answer, ev ) ;
537 537
538 } 538 }
539 else { // change existing 539 else { // change existing
540 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 540 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
541 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 541 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
542 changeString += eString + "\n"; 542 changeString += eString + "\n";
543 changeEnt = true; 543 changeEnt = true;
544 544
545 } 545 }
546 } 546 }
547 ev = er.next(); 547 ev = er.next();
548 } 548 }
549 status.setText ( i18n("Changing events ...") ); 549 status.setText ( i18n("Changing events ...") );
550 qApp->processEvents(); 550 qApp->processEvents();
551 //qDebug("changing... "); 551 //qDebug("changing... ");
552 if ( changeEnt ) { 552 if ( changeEnt ) {
553 QFile file( fileName ); 553 QFile file( fileName );
554 if (!file.open( IO_WriteOnly ) ) { 554 if (!file.open( IO_WriteOnly ) ) {
555 return false; 555 return false;
556 556
557 } 557 }
558 QTextStream ts( &file ); 558 QTextStream ts( &file );
559 ts.setCodec( QTextCodec::codecForName("utf8") ); 559 ts.setCodec( QTextCodec::codecForName("utf8") );
560 ts << changeString ; 560 ts << changeString ;
561 file.close(); 561 file.close();
562 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 562 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
563 system ( command.latin1() ); 563 system ( command.latin1() );
564 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 564 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
565 565
566 } 566 }
567 status.setText ( i18n("Deleting events ...") ); 567 status.setText ( i18n("Deleting events ...") );
568 qApp->processEvents(); 568 qApp->processEvents();
569 //qDebug("deleting... "); 569 //qDebug("deleting... ");
570 if ( deleteEnt ) { 570 if ( deleteEnt ) {
571 QFile file( fileName ); 571 QFile file( fileName );
572 if (!file.open( IO_WriteOnly ) ) { 572 if (!file.open( IO_WriteOnly ) ) {
573 return false; 573 return false;
574 574
575 } 575 }
576 QTextStream ts( &file ); 576 QTextStream ts( &file );
577 ts.setCodec( QTextCodec::codecForName("utf8") ); 577 ts.setCodec( QTextCodec::codecForName("utf8") );
578 ts << deleteString; 578 ts << deleteString;
579 file.close(); 579 file.close();
580 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 580 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
581 system ( command.latin1() ); 581 system ( command.latin1() );
582 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 582 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
583 } 583 }
584 584
585 585
586 changeString = tPrefix; 586 changeString = tPrefix;
587 deleteString = tPrefix; 587 deleteString = tPrefix;
588 status.setText ( i18n("Processing todos ...") ); 588 status.setText ( i18n("Processing todos ...") );
589 qApp->processEvents(); 589 qApp->processEvents();
590 QPtrList<Todo> tl = calendar->rawTodos(); 590 QPtrList<Todo> tl = calendar->rawTodos();
591 Todo* to = tl.first(); 591 Todo* to = tl.first();
592 i = 0; 592 i = 0;
593 message = i18n("Processing todo # "); 593 message = i18n("Processing todo # ");
594 procCount = 0; 594 procCount = 0;
595 while ( to ) { 595 while ( to ) {
596 if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 596 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
597 status.setText ( message + QString::number ( ++procCount ) ); 597 status.setText ( message + QString::number ( ++procCount ) );
598 qApp->processEvents(); 598 qApp->processEvents();
599 QString eString = getTodoString( to ); 599 QString eString = getTodoString( to );
600 if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete 600 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
601 // deleting empty strings does not work. 601 // deleting empty strings does not work.
602 // we write first and x and then delete the record with the x 602 // we write first and x and then delete the record with the x
603 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 603 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
604 changeString += eString + "\n"; 604 changeString += eString + "\n";
605 deleteString += eString + "\n"; 605 deleteString += eString + "\n";
606 deleteEnt = true; 606 deleteEnt = true;
607 changeEnt = true; 607 changeEnt = true;
608 } 608 }
609 else if ( to->zaurusId() == -1 ) { // add new 609 else if ( to->zaurusId() == -1 ) { // add new
610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
611 system ( command.utf8() ); 611 system ( command.utf8() );
612 QFile file( fileName ); 612 QFile file( fileName );
613 if (!file.open( IO_ReadOnly ) ) { 613 if (!file.open( IO_ReadOnly ) ) {
614 return false; 614 return false;
615 615
616 } 616 }
617 QTextStream ts( &file ); 617 QTextStream ts( &file );
618 ts.setCodec( QTextCodec::codecForName("utf8") ); 618 ts.setCodec( QTextCodec::codecForName("utf8") );
619 answer = ts.read(); 619 answer = ts.read();
620 file.close(); 620 file.close();
621 //qDebug("answer \n%s ", answer.latin1()); 621 //qDebug("answer \n%s ", answer.latin1());
622 getNumFromRecord( answer, to ) ; 622 getNumFromRecord( answer, to ) ;
623 623
624 } 624 }
625 else { // change existing 625 else { // change existing
626 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 626 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
627 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 627 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
628 changeString += eString + "\n"; 628 changeString += eString + "\n";
629 changeEnt = true; 629 changeEnt = true;
630 630
631 } 631 }
632 } 632 }
633 633
634 to = tl.next(); 634 to = tl.next();
635 } 635 }
636 status.setText ( i18n("Changing todos ...") ); 636 status.setText ( i18n("Changing todos ...") );
637 qApp->processEvents(); 637 qApp->processEvents();
638 //qDebug("changing... "); 638 //qDebug("changing... ");
639 if ( changeEnt ) { 639 if ( changeEnt ) {
640 QFile file( fileName ); 640 QFile file( fileName );
641 if (!file.open( IO_WriteOnly ) ) { 641 if (!file.open( IO_WriteOnly ) ) {
642 return false; 642 return false;
643 643
644 } 644 }
645 QTextStream ts( &file ); 645 QTextStream ts( &file );
646 ts.setCodec( QTextCodec::codecForName("utf8") ); 646 ts.setCodec( QTextCodec::codecForName("utf8") );
647 ts << changeString ; 647 ts << changeString ;
648 file.close(); 648 file.close();
649 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 649 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
650 system ( command.latin1() ); 650 system ( command.latin1() );
651 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 651 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
652 652
653 } 653 }
654 status.setText ( i18n("Deleting todos ...") ); 654 status.setText ( i18n("Deleting todos ...") );
655 qApp->processEvents(); 655 qApp->processEvents();
656 //qDebug("deleting... "); 656 //qDebug("deleting... ");
657 if ( deleteEnt ) { 657 if ( deleteEnt ) {
658 QFile file( fileName ); 658 QFile file( fileName );
659 if (!file.open( IO_WriteOnly ) ) { 659 if (!file.open( IO_WriteOnly ) ) {
660 return false; 660 return false;
661 661
662 } 662 }
663 QTextStream ts( &file ); 663 QTextStream ts( &file );
664 ts.setCodec( QTextCodec::codecForName("utf8") ); 664 ts.setCodec( QTextCodec::codecForName("utf8") );
665 ts << deleteString; 665 ts << deleteString;
666 file.close(); 666 file.close();
667 command = "db2file todo -d -c " + codec+ " < "+ fileName; 667 command = "db2file todo -d -c " + codec+ " < "+ fileName;
668 system ( command.latin1() ); 668 system ( command.latin1() );
669 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 669 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
670 } 670 }
671 671
672 return true; 672 return true;
673} 673}
674QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 674QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
675{ 675{
676 QString datestr; 676 QString datestr;
677 QString timestr; 677 QString timestr;
678 int offset = KGlobal::locale()->localTimeOffset( dti ); 678 int offset = KGlobal::locale()->localTimeOffset( dti );
679 QDateTime dt; 679 QDateTime dt;
680 if (useTZ) 680 if (useTZ)
681 dt = dti.addSecs ( -(offset*60)); 681 dt = dti.addSecs ( -(offset*60));
682 else 682 else
683 dt = dti; 683 dt = dti;
684 if(dt.date().isValid()){ 684 if(dt.date().isValid()){
685 const QDate& date = dt.date(); 685 const QDate& date = dt.date();
686 datestr.sprintf("%04d%02d%02d", 686 datestr.sprintf("%04d%02d%02d",
687 date.year(), date.month(), date.day()); 687 date.year(), date.month(), date.day());
688 } 688 }
689 if(dt.time().isValid()){ 689 if(dt.time().isValid()){
690 const QTime& time = dt.time(); 690 const QTime& time = dt.time();
691 timestr.sprintf("T%02d%02d%02d", 691 timestr.sprintf("T%02d%02d%02d",
692 time.hour(), time.minute(), time.second()); 692 time.hour(), time.minute(), time.second());
693 } 693 }
694 return datestr + timestr; 694 return datestr + timestr;
695} 695}
696QString SharpFormat::getEventString( Event* event ) 696QString SharpFormat::getEventString( Event* event )
697{ 697{
698 QStringList list; 698 QStringList list;
699 list.append( QString::number(event->zaurusId() ) ); 699 list.append( QString::number(event->zaurusId() ) );
700 list.append( event->categories().join(",") ); 700 list.append( event->categories().join(",") );
701 if ( !event->summary().isEmpty() ) 701 if ( !event->summary().isEmpty() )
702 list.append( event->summary() ); 702 list.append( event->summary() );
703 else 703 else
704 list.append("" ); 704 list.append("" );
705 if ( !event->location().isEmpty() ) 705 if ( !event->location().isEmpty() )
706 list.append( event->location() ); 706 list.append( event->location() );
707 else 707 else
708 list.append("" ); 708 list.append("" );
709 if ( !event->description().isEmpty() ) 709 if ( !event->description().isEmpty() )
710 list.append( event->description() ); 710 list.append( event->description() );
711 else 711 else
712 list.append( "" ); 712 list.append( "" );
713 if ( event->doesFloat () ) { 713 if ( event->doesFloat () ) {
714 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 714 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
715 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 715 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
716 list.append( "1" ); 716 list.append( "1" );
717 717
718 } 718 }
719 else { 719 else {
720 list.append( dtToString( event->dtStart()) ); 720 list.append( dtToString( event->dtStart()) );
721 list.append( dtToString( event->dtEnd()) ); //6 721 list.append( dtToString( event->dtEnd()) ); //6
722 list.append( "0" ); 722 list.append( "0" );
723 } 723 }
724 bool noAlarm = true; 724 bool noAlarm = true;
725 if ( event->alarms().count() > 0 ) { 725 if ( event->alarms().count() > 0 ) {
726 Alarm * al = event->alarms().first(); 726 Alarm * al = event->alarms().first();
727 if ( al->enabled() ) { 727 if ( al->enabled() ) {
728 noAlarm = false; 728 noAlarm = false;
729 list.append( "0" ); // yes, 0 == alarm 729 list.append( "0" ); // yes, 0 == alarm
730 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 730 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
731 if ( al->type() == Alarm::Audio ) 731 if ( al->type() == Alarm::Audio )
732 list.append( "1" ); // type audio 732 list.append( "1" ); // type audio
733 else 733 else
734 list.append( "0" ); // type silent 734 list.append( "0" ); // type silent
735 } 735 }
736 } 736 }
737 if ( noAlarm ) { 737 if ( noAlarm ) {
738 list.append( "1" ); // yes, 1 == no alarm 738 list.append( "1" ); // yes, 1 == no alarm
739 list.append( "0" ); // no alarm offset 739 list.append( "0" ); // no alarm offset
740 list.append( "1" ); // type 740 list.append( "1" ); // type
741 } 741 }
742 // next is: 11 742 // next is: 11
743 // next is: 11-16 are recurrence 743 // next is: 11-16 are recurrence
744 Recurrence* rec = event->recurrence(); 744 Recurrence* rec = event->recurrence();
745 745
746 bool writeEndDate = false; 746 bool writeEndDate = false;
747 switch ( rec->doesRecur() ) 747 switch ( rec->doesRecur() )
748 { 748 {
749 case Recurrence::rDaily: // 0 749 case Recurrence::rDaily: // 0
750 list.append( "0" ); 750 list.append( "0" );
751 list.append( QString::number( rec->frequency() ));//12 751 list.append( QString::number( rec->frequency() ));//12
752 list.append( "0" ); 752 list.append( "0" );
753 list.append( "0" ); 753 list.append( "0" );
754 writeEndDate = true; 754 writeEndDate = true;
755 break; 755 break;
756 case Recurrence::rWeekly:// 1 756 case Recurrence::rWeekly:// 1
757 list.append( "1" ); 757 list.append( "1" );
758 list.append( QString::number( rec->frequency()) );//12 758 list.append( QString::number( rec->frequency()) );//12
759 list.append( "0" ); 759 list.append( "0" );
760 { 760 {
761 int days = 0; 761 int days = 0;
762 QBitArray weekDays = rec->days(); 762 QBitArray weekDays = rec->days();
763 int i; 763 int i;
764 for( i = 1; i <= 7; ++i ) { 764 for( i = 1; i <= 7; ++i ) {
765 if ( weekDays[i-1] ) { 765 if ( weekDays[i-1] ) {
766 days += 1 << (i-1); 766 days += 1 << (i-1);
767 } 767 }
768 } 768 }
769 list.append( QString::number( days ) ); 769 list.append( QString::number( days ) );
770 } 770 }
771 //pending weekdays 771 //pending weekdays
772 writeEndDate = true; 772 writeEndDate = true;
773 773
774 break; 774 break;
775 case Recurrence::rMonthlyPos:// 2 775 case Recurrence::rMonthlyPos:// 2
776 list.append( "2" ); 776 list.append( "2" );
777 list.append( QString::number( rec->frequency()) );//12 777 list.append( QString::number( rec->frequency()) );//12
778 778
779 writeEndDate = true; 779 writeEndDate = true;
780 { 780 {
781 int count = 1; 781 int count = 1;
782 QPtrList<Recurrence::rMonthPos> rmp; 782 QPtrList<Recurrence::rMonthPos> rmp;
783 rmp = rec->monthPositions(); 783 rmp = rec->monthPositions();
784 if ( rmp.first()->negative ) 784 if ( rmp.first()->negative )
785 count = 5 - rmp.first()->rPos - 1; 785 count = 5 - rmp.first()->rPos - 1;
786 else 786 else
787 count = rmp.first()->rPos - 1; 787 count = rmp.first()->rPos - 1;
788 list.append( QString::number( count ) ); 788 list.append( QString::number( count ) );
789 789
790 } 790 }
791 791
792 list.append( "0" ); 792 list.append( "0" );