-rw-r--r-- | korganizer/calendarview.cpp | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfc6b10..9160e1d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -851,9 +851,12 @@ Event* CalendarView::getLastSyncEvent() Event* lse; //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); - lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); + lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); if (!lse) { lse = new Event(); - lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); - lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); + lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); + QString sum = ""; + if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) + sum = "E: "; + lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); @@ -866,20 +869,43 @@ Event* CalendarView::getLastSyncEvent() } -void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) +void CalendarView::setupExternSyncProfiles() { - if ( ! lastSync ) - return; - if ( toDelete->zaurusId() < 0 ) + Event* lse; + mExternLastSyncEvent.clear(); + int i; + for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { + lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); + if ( lse ) + mExternLastSyncEvent.append( lse ); + else + qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); + } + +} +// we check, if the to delete event has a id for a profile +// if yes, we set this id in the profile to delete +void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) +{ + if ( ! lastSync.count() == 0 ) return; if ( toDelete->type() == "Journal" ) return; - QString des = lastSync->description(); - QString pref = "e"; - if ( toDelete->type() == "Todo" ) - pref = "t"; - des += pref+ QString::number ( toDelete->zaurusId() ) + ","; - lastSync->setReadOnly( false ); - lastSync->setDescription( des ); - lastSync->setReadOnly( true ); + + Event* eve = lastSync.first(); + + while ( eve ) { + int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name + if ( id >= 0 ) { + QString des = eve->description(); + QString pref = "e"; + if ( toDelete->type() == "Todo" ) + pref = "t"; + des += pref+ QString::number ( id ) + ","; + eve->setReadOnly( false ); + eve->setDescription( des ); + eve->setReadOnly( true ); + } + eve = lastSync.next(); + } } @@ -900,10 +926,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int Event* eventRSync; Event* eventLSync; - Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); - Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); + QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); + QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; - eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); + eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); if ( eventR ) { eventRSync = (Event*) eventR->clone(); @@ -914,5 +940,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int eventRSync = new Event(); eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); - eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); + eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); eventRSync->setDtStart( mLastCalendarSync ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); @@ -966,5 +992,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int uid = inR->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; @@ -1016,5 +1042,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++addedEvent; } else { - checkSharpEvent(eventRSyncSharp, inR); + checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; @@ -1043,5 +1069,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int uid = inL->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) @@ -1064,5 +1090,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { - checkSharpEvent(eventLSyncSharp, inL); + checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; @@ -1343,5 +1369,5 @@ void CalendarView::setSyncEventsReadOnly() ev = eL.first(); while ( ev ) { - if ( ev->uid().left(21) == QString("last-syncEvent-device") ) + if ( ev->uid().left(15) == QString("last-syncEvent-") ) ev->setReadOnly( true ); ev = eL.next(); @@ -1807,5 +1833,5 @@ void CalendarView::checkZaurusId( int id, bool todo ) { if ( id >= 0 ) { - Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); + Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM"); if ( lse ) { QString des = lse->description(); |