author | zautrix <zautrix> | 2005-01-17 12:47:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 12:47:46 (UTC) |
commit | 214b82c86bd5365d7a5fc786c8c9c7231ec6dc77 (patch) (side-by-side diff) | |
tree | 9b6052411933ccd1a15428c8f747f0143db4690d | |
parent | ba5e5a22ad492f798b2626026cc1838b731e055b (diff) | |
download | kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.zip kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.tar.gz kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.tar.bz2 |
small cal fix
-rw-r--r-- | korganizer/calendarview.cpp | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 685bb60..da1edea 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -903,48 +903,50 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t eve->setReadOnly( false ); eve->setDescription( des ); //qDebug("setdes %s ", des.latin1()); eve->setReadOnly( true ); } eve = lastSync.next(); } } void CalendarView::checkExternalId( Incidence * inc ) { QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; checkExternSyncEvent( lastSync, inc ); } bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; int addedEvent = 0; int addedEventR = 0; int deletedEventR = 0; int deletedEventL = 0; int changedLocal = 0; int changedRemote = 0; + int filteredIN = 0; + int filteredOUT = 0; //QPtrList<Event> el = local->rawEvents(); Event* eventR; QString uid; int take; Event* eventL; Event* eventRSync; Event* eventLSync; QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; local->resetTempSyncStat(); mLastCalendarSync = QDateTime::currentDateTime(); if ( mSyncManager->syncWithDesktop() ) { remote->resetPilotStat(1); if ( KSyncManager::mRequestedSyncEvent.isValid() ) { mLastCalendarSync = KSyncManager::mRequestedSyncEvent; qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); } else { qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); } } QDateTime modifiedCalendar = mLastCalendarSync; eventLSync = getLastSyncEvent(); eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); @@ -1080,112 +1082,116 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } else { inR->setLastModified( modifiedCalendar ); inL = inR->clone(); inL->setIDStr( ":" ); inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); local->addIncidence( inL ); ++addedEvent; } } else { if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { inR->setLastModified( modifiedCalendar ); inL = inR->clone(); inL->setIDStr( ":" ); local->addIncidence( inL ); ++addedEvent; } else { checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; } } + } else { + ++filteredIN; } } } inR = er.next(); } QPtrList<Incidence> el = local->rawIncidences(); inL = el.first(); modulo = (el.count()/10)+1; bar.setCaption (i18n("Add / remove events") ); bar.setTotalSteps ( el.count() ) ; bar.show(); incCounter = 0; while ( inL ) { qApp->processEvents(); if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) skipIncidence = true; - if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){ - skipIncidence = true; - } if ( !skipIncidence ) { inR = remote->incidence( uid ); - if ( ! inR ) { // no conflict ********** add or delete local - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { - checkExternSyncEvent(eventLSyncSharp, inL); - local->deleteIncidence( inL ); - ++deletedEventL; - } else { - if ( ! mSyncManager->mWriteBackExistingOnly ) { - inL->removeID(mCurrentSyncDevice ); - ++addedEventR; - //qDebug("remote added Incidence %s ", inL->summary().latin1()); - inL->setLastModified( modifiedCalendar ); - inR = inL->clone(); - inR->setIDStr( ":" ); - inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); - remote->addIncidence( inR ); + if ( ! inR ) { + if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ + // no conflict ********** add or delete local + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { + checkExternSyncEvent(eventLSyncSharp, inL); + local->deleteIncidence( inL ); + ++deletedEventL; + } else { + if ( ! mSyncManager->mWriteBackExistingOnly ) { + inL->removeID(mCurrentSyncDevice ); + ++addedEventR; + //qDebug("remote added Incidence %s ", inL->summary().latin1()); + inL->setLastModified( modifiedCalendar ); + inR = inL->clone(); + inR->setIDStr( ":" ); + inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + remote->addIncidence( inR ); + } } - } - } else { - if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { - checkExternSyncEvent(eventLSyncSharp, inL); - local->deleteIncidence( inL ); - ++deletedEventL; } else { - if ( ! mSyncManager->mWriteBackExistingOnly ) { - ++addedEventR; - inL->setLastModified( modifiedCalendar ); - inR = inL->clone(); - inR->setIDStr( ":" ); - remote->addIncidence( inR ); + if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { + checkExternSyncEvent(eventLSyncSharp, inL); + local->deleteIncidence( inL ); + ++deletedEventL; + } else { + if ( ! mSyncManager->mWriteBackExistingOnly ) { + ++addedEventR; + inL->setLastModified( modifiedCalendar ); + inR = inL->clone(); + inR->setIDStr( ":" ); + remote->addIncidence( inR ); + } } } + } else { + ++filteredOUT; } } } inL = el.next(); } int delFut = 0; int remRem = 0; if ( mSyncManager->mWriteBackInFuture ) { er = remote->rawIncidences(); remRem = er.count(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); while ( inR ) { if ( inR->type() == "Todo" ) { Todo * t = (Todo*)inR; if ( t->hasDueDate() ) dt = t->dtDue(); else dt = cur.addSecs( 62 ); } else if (inR->type() == "Event" ) { bool ok; @@ -1197,49 +1203,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int dt = inR->dtStart(); if ( dt < cur || dt > end ) { remote->deleteIncidence( inR ); ++delFut; } inR = er.next(); } } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... remote->addEvent( eventRSync ); else delete eventRSync; QString mes; - 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 ); + 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); QString delmess; if ( delFut ) { delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); mes += delmess; } mes = i18n("Local calendar changed!\n") +mes; mCalendar->checkAlarmForIncidence( 0, true ); qDebug( mes ); if ( mSyncManager->mShowSyncSummary ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, i18n("KO/Pi Synchronization"),i18n("Write back"))) { qDebug("cancelled "); return false; } } return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { |