author | zautrix <zautrix> | 2004-08-01 11:37:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 11:37:35 (UTC) |
commit | e954cc1e29b129982e4d07c4f490d7e881597374 (patch) (side-by-side diff) | |
tree | 29e7bdcf20952b813637083596102f7e7b080567 /korganizer | |
parent | 8a394f316feb828954d69480553f85c9c0f4b353 (diff) | |
download | kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.zip kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.gz kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.bz2 |
Made sync code more readable by using defines
-rw-r--r-- | korganizer/calendarview.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 58b3d70..fd68dc4 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -126,15 +126,13 @@ #endif using namespace KOrg; using namespace KCal; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; -#define SYNC_MODE_NORMAL 0 -#define SYNC_MODE_SHARP 1 -#define SYNC_MODE_QTOPIA 2 + class KOBeamPrefs : public QDialog { public: KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) @@ -724,16 +722,16 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b // int zaurusStat() const; // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastCalendarSync; - if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->zaurusUid() != local->zaurusUid() ); - locCh = ( local->zaurusStat() != local->revision() ); + locCh = ( local->lastModified() > mLastCalendarSync ); //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); if ( !remCh && ! locCh ) { //qDebug("both not changed "); lastSync = local->lastModified().addDays(1); } else { if ( locCh ) { @@ -747,14 +745,14 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b if ( remCh ) remote->setLastModified( lastSync.addDays( 1 ) ); } } full = true; - if ( mode < 3 ) - mode = 3; + if ( mode < SYNC_PREF_ASK ) + mode = SYNC_PREF_ASK; } else { if ( local->lastModified() == remote->lastModified() ) if ( local->revision() == remote->revision() ) return 0; } @@ -771,48 +769,48 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b else if ( local->type() =="Todo" ) equ = (*((Todo*) local) == (*(Todo*) remote)); else if ( local->type() =="Journal" ) equ = (*((Journal*) local) == *((Journal*) remote)); if ( equ ) { //qDebug("equal "); - if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setZaurusUid( remote->zaurusUid() ); } - if ( mode < 4 ) + if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; - if ( full && mode < 2 ) - mode = 3; + if ( full && mode < SYNC_PREF_NEWEST ) + mode = SYNC_PREF_ASK; switch( mode ) { - case 0: + case SYNC_PREF_LOCAL: if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; return 1; break; - case 1: + case SYNC_PREF_REMOTE: if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; return 2; break; - case 2: + case SYNC_PREF_NEWEST: if ( local->lastModified() > remote->lastModified() ) return 1; else return 2; break; - case 3: + case SYNC_PREF_ASK: //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); @@ -832,20 +830,21 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); getEventViewerDialog()->showMe(); result = getEventViewerDialog()->executeS( localIsNew ); return result; break; - case 4: + case SYNC_PREF_FORCE_LOCAL: return 1; break; - case 5: + case SYNC_PREF_FORCE_REMOTE: return 2; break; default: + // SYNC_PREF_TAKE_BOTH not implemented break; } return 0; } Event* CalendarView::getLastSyncEvent() { @@ -993,19 +992,19 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int local->deleteIncidence( inL ); local->addIncidence( inR->clone() ); ++changedLocal; } } } else { // no conflict - if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = eventLSync->description(); QString pref = "e"; if ( inR->type() == "Todo" ) pref = "t"; if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it - inR->setZaurusStat( -3 ); + inR->setZaurusStat( SYNC_TEMPSTATE_DELETE ); //remote->deleteIncidence( inR ); ++deletedEventR; } else { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; @@ -1042,18 +1041,18 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; if ( uid.left(21) == QString("last-syncEvent-device") ) skipIncidence = true; - if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); if ( ! inR ) { - if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( inL->zaurusId() >= 0 && mode != 4 ) { local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { inL->setZaurusId( -1 ); @@ -1138,13 +1137,13 @@ bool CalendarView::syncCalendar(QString filename, int mode) updateView(); return syncOK; } void CalendarView::syncSharp() { #ifndef DESKTOP_VERSION - mGlobalSyncMode = SYNC_MODE_SHARP; + mGlobalSyncMode = SYNC_MODE_EXTERNAL; //mCurrentSyncDevice = "sharp-DTM"; if ( KOPrefs::instance()->mAskForPreferences ) edit_sync_options(); qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); @@ -1157,23 +1156,25 @@ void CalendarView::syncSharp() qApp->processEvents(); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); + /* obsolete while ( inc ) { inc->setZaurusStat( inc->revision () ); inc = iL.next(); } + */ // pending: clean last sync event description sharpFormat.save(calendar); iL = calendar->rawIncidences(); inc = iL.first(); Incidence* loc; while ( inc ) { - if ( inc->zaurusStat() == -4 ) { + if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) { loc = mCalendar->incidence(inc->uid() ); if ( loc ) { loc->setZaurusId( inc->zaurusId() ); loc->setZaurusUid( inc->zaurusUid() ); } } |