-rw-r--r-- | korganizer/calendarview.cpp | 53 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 |
3 files changed, 47 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index db07713..cfd9290 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -730,17 +730,19 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
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 ) | ||
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | ||
732 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
734 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
735 | //qDebug("both not changed "); | 737 | qDebug("both not changed "); |
736 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
737 | } else { | 739 | } else { |
738 | if ( locCh ) { | 740 | if ( locCh ) { |
739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 741 | qDebug("loc changed %d", local->revision() ); |
740 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
741 | if ( !remCh ) | 743 | if ( !remCh ) |
742 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
743 | } else { | 745 | } else { |
744 | //qDebug(" not loc changed "); | 746 | qDebug(" not loc changed "); |
745 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
746 | if ( remCh ) | 748 | if ( remCh ) |
@@ -785,4 +787,6 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
785 | int result; | 787 | int result; |
786 | bool localIsNew; | 788 | bool localIsNew; |
789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | ||
790 | |||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
@@ -816,5 +820,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
816 | return 2; | 820 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
818 | localIsNew = local->lastModified() > remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
819 | if ( localIsNew ) | 823 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
@@ -943,4 +947,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
943 | mLastCalendarSync = QDateTime::currentDateTime(); | 947 | mLastCalendarSync = QDateTime::currentDateTime(); |
944 | QDateTime modifiedCalendar = mLastCalendarSync;; | 948 | QDateTime modifiedCalendar = mLastCalendarSync;; |
949 | eventLSync = getLastSyncEvent(); | ||
945 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
946 | if ( eventR ) { | 951 | if ( eventR ) { |
@@ -949,13 +954,16 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
949 | 954 | ||
950 | } else { | 955 | } else { |
951 | fullDateRange = true; | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
952 | eventRSync = new Event(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
953 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 958 | } else { |
954 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 959 | fullDateRange = true; |
955 | eventRSync->setDtStart( mLastCalendarSync ); | 960 | eventRSync = new Event(); |
956 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
957 | eventRSync->setCategories( i18n("SyncEvent") ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | ||
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | ||
965 | eventRSync->setCategories( i18n("SyncEvent") ); | ||
966 | } | ||
958 | } | 967 | } |
959 | eventLSync = getLastSyncEvent(); | ||
960 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
961 | fullDateRange = true; | 969 | fullDateRange = true; |
@@ -1117,5 +1125,24 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1117 | inL = el.next(); | 1125 | inL = el.next(); |
1118 | } | 1126 | } |
1119 | 1127 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | |
1128 | er = remote->rawIncidences(); | ||
1129 | inR = er.first(); | ||
1130 | QDateTime dt; | ||
1131 | QDateTime cur = QDateTime::currentDateTime(); | ||
1132 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | ||
1133 | while ( inR ) { | ||
1134 | if ( inR->type() == "Todo" ) { | ||
1135 | Todo * t = (Todo*)inR; | ||
1136 | if ( t->hasDueDate() ) | ||
1137 | dt = t->dtDue(); | ||
1138 | else | ||
1139 | dt = cur.addSecs( 62 ); | ||
1140 | } | ||
1141 | else dt = inR->dtStart(); | ||
1142 | if ( dt < cur || dt > end ) | ||
1143 | remote->deleteIncidence( inR ); | ||
1144 | inR = er.next(); | ||
1145 | } | ||
1146 | } | ||
1120 | bar.hide(); | 1147 | bar.hide(); |
1121 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1148 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 446fe2e..a9ac52f 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -200,4 +200,5 @@ class KOPrefs : public KPimPrefs | |||
200 | bool mUsePassWd; | 200 | bool mUsePassWd; |
201 | bool mWriteBackFile; | 201 | bool mWriteBackFile; |
202 | int mWriteBackInFuture; | ||
202 | bool mAskForPreferences; | 203 | bool mAskForPreferences; |
203 | bool mShowSyncSummary; | 204 | bool mShowSyncSummary; |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d8aa43a..aa30b52 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -915,4 +915,7 @@ int MainWindow::ringSync() | |||
915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
917 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
918 | if ( temp->getWriteBackFuture() ) | ||
919 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
917 | KOPrefs::instance()->mShowSyncSummary = false; | 920 | KOPrefs::instance()->mShowSyncSummary = false; |
918 | mView->setSyncDevice(syncProfileNames[i] ); | 921 | mView->setSyncDevice(syncProfileNames[i] ); |
@@ -1018,4 +1021,7 @@ void MainWindow::slotSyncMenu( int action ) | |||
1018 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1021 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1019 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1022 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1023 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1024 | if ( temp->getWriteBackFuture() ) | ||
1025 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1020 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1026 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1021 | if ( action == 1000 ) { | 1027 | if ( action == 1000 ) { |