summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-08-01 11:37:35 (UTC)
committer zautrix <zautrix>2004-08-01 11:37:35 (UTC)
commite954cc1e29b129982e4d07c4f490d7e881597374 (patch) (side-by-side diff)
tree29e7bdcf20952b813637083596102f7e7b080567 /korganizer
parent8a394f316feb828954d69480553f85c9c0f4b353 (diff)
downloadkdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.zip
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.gz
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.bz2
Made sync code more readable by using defines
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp47
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
@@ -129,9 +129,7 @@ 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
{
@@ -727,10 +725,10 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
// 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 ");
@@ -750,8 +748,8 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
}
}
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() )
@@ -774,10 +772,10 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
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
@@ -785,31 +783,31 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
}
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;
@@ -835,14 +833,15 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
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;
@@ -996,13 +995,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
}
} 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 {
@@ -1045,12 +1044,12 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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;
@@ -1141,7 +1140,7 @@ bool CalendarView::syncCalendar(QString filename, int mode)
void CalendarView::syncSharp()
{
#ifndef DESKTOP_VERSION
- mGlobalSyncMode = SYNC_MODE_SHARP;
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
//mCurrentSyncDevice = "sharp-DTM";
if ( KOPrefs::instance()->mAskForPreferences )
edit_sync_options();
@@ -1160,17 +1159,19 @@ void CalendarView::syncSharp()
{
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() );