summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-09-14 03:13:52 (UTC)
committer zautrix <zautrix>2004-09-14 03:13:52 (UTC)
commitf1f43030eefa765950cb501aece6cc71fb4e9859 (patch) (unidiff)
treed7396ac13ab052ee38e2e8e139854cc88a289a43 /korganizer
parent5060b0737c0c279859cac3bcfb73d2ac21c6a79e (diff)
downloadkdepimpi-f1f43030eefa765950cb501aece6cc71fb4e9859.zip
kdepimpi-f1f43030eefa765950cb501aece6cc71fb4e9859.tar.gz
kdepimpi-f1f43030eefa765950cb501aece6cc71fb4e9859.tar.bz2
More fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 5a6d615..369c7a0 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -684,106 +684,105 @@ void CalendarView::createPrinter()
684#endif 684#endif
685} 685}
686 686
687void CalendarView::confSync() 687void CalendarView::confSync()
688{ 688{
689 static KSyncPrefsDialog* sp = 0; 689 static KSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 690 if ( ! sp ) {
691 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KSyncPrefsDialog( this, "syncprefs", true );
692 } 692 }
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 702}
703 703
704 704
705//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
707 707
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 714
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 716{
717 717
718 //void setZaurusId(int id); 718 //void setZaurusId(int id);
719 // int zaurusId() const; 719 // int zaurusId() const;
720 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
721 // int zaurusUid() const; 721 // int zaurusUid() const;
722 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
723 // int zaurusStat() const; 723 // int zaurusStat() const;
724 // 0 equal 724 // 0 equal
725 // 1 take local 725 // 1 take local
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 730 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 if ( remCh ) 732 //if ( remCh )
733 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 733 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
734 locCh = ( local->lastModified() > mLastCalendarSync ); 734 locCh = ( local->lastModified() > mLastCalendarSync );
735 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
736 if ( !remCh && ! locCh ) { 735 if ( !remCh && ! locCh ) {
737 //qDebug("both not changed "); 736 //qDebug("both not changed ");
738 lastSync = local->lastModified().addDays(1); 737 lastSync = local->lastModified().addDays(1);
739 } else { 738 } else {
740 if ( locCh ) { 739 if ( locCh ) {
741 // qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); 740 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1());
742 lastSync = local->lastModified().addDays( -1 ); 741 lastSync = local->lastModified().addDays( -1 );
743 if ( !remCh ) 742 if ( !remCh )
744 remote->setLastModified( lastSync.addDays( -1 ) ); 743 remote->setLastModified( lastSync.addDays( -1 ) );
745 } else { 744 } else {
746 //qDebug(" not loc changed "); 745 //qDebug(" not loc changed ");
747 lastSync = local->lastModified().addDays( 1 ); 746 lastSync = local->lastModified().addDays( 1 );
748 if ( remCh ) 747 if ( remCh )
749 remote->setLastModified( lastSync.addDays( 1 ) ); 748 remote->setLastModified( lastSync.addDays( 1 ) );
750 749
751 } 750 }
752 } 751 }
753 full = true; 752 full = true;
754 if ( mode < SYNC_PREF_ASK ) 753 if ( mode < SYNC_PREF_ASK )
755 mode = SYNC_PREF_ASK; 754 mode = SYNC_PREF_ASK;
756 } else { 755 } else {
757 if ( local->lastModified() == remote->lastModified() ) 756 if ( local->lastModified() == remote->lastModified() )
758 if ( local->revision() == remote->revision() ) 757 if ( local->revision() == remote->revision() )
759 return 0; 758 return 0;
760 759
761 } 760 }
762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
763 762
764 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
765 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
766 //full = true; //debug only 765 //full = true; //debug only
767 if ( full ) { 766 if ( full ) {
768 bool equ = false; 767 bool equ = false;
769 if ( local->type() == "Event" ) { 768 if ( local->type() == "Event" ) {
770 equ = (*((Event*) local) == *((Event*) remote)); 769 equ = (*((Event*) local) == *((Event*) remote));
771 } 770 }
772 else if ( local->type() =="Todo" ) 771 else if ( local->type() =="Todo" )
773 equ = (*((Todo*) local) == (*(Todo*) remote)); 772 equ = (*((Todo*) local) == (*(Todo*) remote));
774 else if ( local->type() =="Journal" ) 773 else if ( local->type() =="Journal" )
775 equ = (*((Journal*) local) == *((Journal*) remote)); 774 equ = (*((Journal*) local) == *((Journal*) remote));
776 if ( equ ) { 775 if ( equ ) {
777 //qDebug("equal "); 776 //qDebug("equal ");
778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 778 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
780 } 779 }
781 if ( mode < SYNC_PREF_FORCE_LOCAL ) 780 if ( mode < SYNC_PREF_FORCE_LOCAL )
782 return 0; 781 return 0;
783 782
784 }//else //debug only 783 }//else //debug only
785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
786 } 785 }
787 int result; 786 int result;
788 bool localIsNew; 787 bool localIsNew;
789 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 788 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
@@ -1070,97 +1069,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1070 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1071 inR->setLastModified( modifiedCalendar ); 1070 inR->setLastModified( modifiedCalendar );
1072 local->addIncidence( inR->clone() ); 1071 local->addIncidence( inR->clone() );
1073 ++addedEvent; 1072 ++addedEvent;
1074 } else { 1073 } else {
1075 checkExternSyncEvent(eventRSyncSharp, inR); 1074 checkExternSyncEvent(eventRSyncSharp, inR);
1076 remote->deleteIncidence( inR ); 1075 remote->deleteIncidence( inR );
1077 ++deletedEventR; 1076 ++deletedEventR;
1078 } 1077 }
1079 } 1078 }
1080 } 1079 }
1081 } 1080 }
1082 inR = er.next(); 1081 inR = er.next();
1083 } 1082 }
1084 QPtrList<Incidence> el = local->rawIncidences(); 1083 QPtrList<Incidence> el = local->rawIncidences();
1085 inL = el.first(); 1084 inL = el.first();
1086 modulo = (el.count()/10)+1; 1085 modulo = (el.count()/10)+1;
1087 bar.setCaption (i18n("Add / remove events") ); 1086 bar.setCaption (i18n("Add / remove events") );
1088 bar.setTotalSteps ( el.count() ) ; 1087 bar.setTotalSteps ( el.count() ) ;
1089 bar.show(); 1088 bar.show();
1090 incCounter = 0; 1089 incCounter = 0;
1091 1090
1092 while ( inL ) { 1091 while ( inL ) {
1093 1092
1094 qApp->processEvents(); 1093 qApp->processEvents();
1095 if ( ! bar.isVisible() ) 1094 if ( ! bar.isVisible() )
1096 return false; 1095 return false;
1097 if ( incCounter % modulo == 0 ) 1096 if ( incCounter % modulo == 0 )
1098 bar.setProgress( incCounter ); 1097 bar.setProgress( incCounter );
1099 ++incCounter; 1098 ++incCounter;
1100 uid = inL->uid(); 1099 uid = inL->uid();
1101 bool skipIncidence = false; 1100 bool skipIncidence = false;
1102 if ( uid.left(15) == QString("last-syncEvent-") ) 1101 if ( uid.left(15) == QString("last-syncEvent-") )
1103 skipIncidence = true; 1102 skipIncidence = true;
1104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1105 skipIncidence = true; 1104 skipIncidence = true;
1106 if ( !skipIncidence ) { 1105 if ( !skipIncidence ) {
1107 inR = remote->incidence( uid ); 1106 inR = remote->incidence( uid );
1108 if ( ! inR ) { 1107 if ( ! inR ) {
1109 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1110 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1111 checkExternSyncEvent(eventLSyncSharp, inL); 1110 checkExternSyncEvent(eventLSyncSharp, inL);
1112 local->deleteIncidence( inL ); 1111 local->deleteIncidence( inL );
1113 ++deletedEventL; 1112 ++deletedEventL;
1114 } else { 1113 } else {
1115 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1114 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1116 inL->removeID(mCurrentSyncDevice ); 1115 inL->removeID(mCurrentSyncDevice );
1117 ++addedEventR; 1116 ++addedEventR;
1118 qDebug("remote added Incidence %s ", inL->summary().latin1()); 1117 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1119 inL->setLastModified( modifiedCalendar ); 1118 inL->setLastModified( modifiedCalendar );
1120 inR = inL->clone(); 1119 inR = inL->clone();
1121 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1120 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1122 remote->addIncidence( inR ); 1121 remote->addIncidence( inR );
1123 } 1122 }
1124 } 1123 }
1125 } else { 1124 } else {
1126 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1125 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1127 checkExternSyncEvent(eventLSyncSharp, inL); 1126 checkExternSyncEvent(eventLSyncSharp, inL);
1128 local->deleteIncidence( inL ); 1127 local->deleteIncidence( inL );
1129 ++deletedEventL; 1128 ++deletedEventL;
1130 } else { 1129 } else {
1131 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1130 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1132 ++addedEventR; 1131 ++addedEventR;
1133 inL->setLastModified( modifiedCalendar ); 1132 inL->setLastModified( modifiedCalendar );
1134 remote->addIncidence( inL->clone() ); 1133 remote->addIncidence( inL->clone() );
1135 } 1134 }
1136 } 1135 }
1137 } 1136 }
1138 } 1137 }
1139 } 1138 }
1140 inL = el.next(); 1139 inL = el.next();
1141 } 1140 }
1142 int delFut = 0; 1141 int delFut = 0;
1143 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1142 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1144 er = remote->rawIncidences(); 1143 er = remote->rawIncidences();
1145 inR = er.first(); 1144 inR = er.first();
1146 QDateTime dt; 1145 QDateTime dt;
1147 QDateTime cur = QDateTime::currentDateTime(); 1146 QDateTime cur = QDateTime::currentDateTime();
1148 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); 1147 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
1149 while ( inR ) { 1148 while ( inR ) {
1150 if ( inR->type() == "Todo" ) { 1149 if ( inR->type() == "Todo" ) {
1151 Todo * t = (Todo*)inR; 1150 Todo * t = (Todo*)inR;
1152 if ( t->hasDueDate() ) 1151 if ( t->hasDueDate() )
1153 dt = t->dtDue(); 1152 dt = t->dtDue();
1154 else 1153 else
1155 dt = cur.addSecs( 62 ); 1154 dt = cur.addSecs( 62 );
1156 } 1155 }
1157 else if (inR->type() == "Event" ) { 1156 else if (inR->type() == "Event" ) {
1158 bool ok; 1157 bool ok;
1159 dt = inR->getNextOccurence( cur, &ok ); 1158 dt = inR->getNextOccurence( cur, &ok );
1160 if ( !ok ) 1159 if ( !ok )
1161 dt = cur.addSecs( -62 ); 1160 dt = cur.addSecs( -62 );
1162 } 1161 }
1163 else 1162 else
1164 dt = inR->dtStart(); 1163 dt = inR->dtStart();
1165 if ( dt < cur || dt > end ) { 1164 if ( dt < cur || dt > end ) {
1166 remote->deleteIncidence( inR ); 1165 remote->deleteIncidence( inR );