author | zautrix <zautrix> | 2004-08-01 11:37:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 11:37:35 (UTC) |
commit | e954cc1e29b129982e4d07c4f490d7e881597374 (patch) (unidiff) | |
tree | 29e7bdcf20952b813637083596102f7e7b080567 /libkcal | |
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-- | libkcal/sharpformat.cpp | 15 | ||||
-rw-r--r-- | libkcal/syncdefines.h | 22 |
2 files changed, 30 insertions, 7 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index f83f72e..973f19d 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -37,16 +37,17 @@ | |||
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | ||
45 | 46 | ||
46 | using namespace KCal; | 47 | using namespace KCal; |
47 | 48 | ||
48 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
49 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
50 | 51 | ||
51 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
52 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
@@ -86,17 +87,17 @@ class SharpParser : public QObject | |||
86 | Event *event; | 87 | Event *event; |
87 | event = existingCalendar->event( attList[0].toInt() ); | 88 | event = existingCalendar->event( attList[0].toInt() ); |
88 | if ( event ) | 89 | if ( event ) |
89 | event = (Event*)event->clone(); | 90 | event = (Event*)event->clone(); |
90 | else | 91 | else |
91 | event = new Event; | 92 | event = new Event; |
92 | event->setZaurusId( attList[0].toInt() ); | 93 | event->setZaurusId( attList[0].toInt() ); |
93 | event->setZaurusUid( cSum ); | 94 | event->setZaurusUid( cSum ); |
94 | event->setZaurusStat( -2 ); | 95 | event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
95 | 96 | ||
96 | event->setSummary( attList[2] ); | 97 | event->setSummary( attList[2] ); |
97 | event->setLocation( attList[3] ); | 98 | event->setLocation( attList[3] ); |
98 | event->setDescription( attList[4] ); | 99 | event->setDescription( attList[4] ); |
99 | if ( attList[7] == "1" ) { | 100 | if ( attList[7] == "1" ) { |
100 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); | 101 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); |
101 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); | 102 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); |
102 | event->setFloats( true ); | 103 | event->setFloats( true ); |
@@ -197,17 +198,17 @@ class SharpParser : public QObject | |||
197 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 198 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
198 | // 0 1 2 3 4 5 6 7 8 | 199 | // 0 1 2 3 4 5 6 7 8 |
199 | //1,,,,,1,4,Loch zumachen,"" | 200 | //1,,,,,1,4,Loch zumachen,"" |
200 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 201 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
201 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 202 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
202 | 203 | ||
203 | todo->setZaurusId( attList[0].toInt() ); | 204 | todo->setZaurusId( attList[0].toInt() ); |
204 | todo->setZaurusUid( cSum ); | 205 | todo->setZaurusUid( cSum ); |
205 | todo->setZaurusStat( -2 ); | 206 | todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
206 | 207 | ||
207 | todo->setSummary( attList[7] ); | 208 | todo->setSummary( attList[7] ); |
208 | todo->setDescription( attList[8]); | 209 | todo->setDescription( attList[8]); |
209 | 210 | ||
210 | int priority = attList[6].toInt(); | 211 | int priority = attList[6].toInt(); |
211 | if ( priority == 0 ) priority = 3; | 212 | if ( priority == 0 ) priority = 3; |
212 | todo->setPriority( priority ); | 213 | todo->setPriority( priority ); |
213 | 214 | ||
@@ -462,17 +463,17 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | |||
462 | if ( ccc == 2 && loopCount < 25 ) { | 463 | if ( ccc == 2 && loopCount < 25 ) { |
463 | start = 0; | 464 | start = 0; |
464 | bool ok; | 465 | bool ok; |
465 | int newnum = templist[0].toInt( &ok ); | 466 | int newnum = templist[0].toInt( &ok ); |
466 | if ( ok && newnum > 0) { | 467 | if ( ok && newnum > 0) { |
467 | retval = newnum; | 468 | retval = newnum; |
468 | inc->setZaurusId( newnum ); | 469 | inc->setZaurusId( newnum ); |
469 | inc->setZaurusUid( getCsum( templist ) ); | 470 | inc->setZaurusUid( getCsum( templist ) ); |
470 | inc->setZaurusStat( -4 ); | 471 | inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID ); |
471 | } | 472 | } |
472 | } | 473 | } |
473 | } | 474 | } |
474 | //qDebug("getNumFromRecord returning : %d ", retval); | 475 | //qDebug("getNumFromRecord returning : %d ", retval); |
475 | return retval; | 476 | return retval; |
476 | } | 477 | } |
477 | bool SharpFormat::save( Calendar *calendar) | 478 | bool SharpFormat::save( Calendar *calendar) |
478 | { | 479 | { |
@@ -501,21 +502,21 @@ bool SharpFormat::save( Calendar *calendar) | |||
501 | QString changeString = ePrefix; | 502 | QString changeString = ePrefix; |
502 | QString deleteString = ePrefix; | 503 | QString deleteString = ePrefix; |
503 | bool deleteEnt = false; | 504 | bool deleteEnt = false; |
504 | bool changeEnt = false; | 505 | bool changeEnt = false; |
505 | QString message = i18n("Processing event # "); | 506 | QString message = i18n("Processing event # "); |
506 | int procCount = 0; | 507 | int procCount = 0; |
507 | while ( ev ) { | 508 | while ( ev ) { |
508 | //qDebug("i %d ", ++i); | 509 | //qDebug("i %d ", ++i); |
509 | if ( ev->zaurusStat() != -2 ) { | 510 | if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
510 | status.setText ( message + QString::number ( ++procCount ) ); | 511 | status.setText ( message + QString::number ( ++procCount ) ); |
511 | qApp->processEvents(); | 512 | qApp->processEvents(); |
512 | QString eString = getEventString( ev ); | 513 | QString eString = getEventString( ev ); |
513 | if ( ev->zaurusStat() == -3 ) { // delete | 514 | if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
514 | // deleting empty strings does not work. | 515 | // deleting empty strings does not work. |
515 | // we write first and x and then delete the record with the x | 516 | // we write first and x and then delete the record with the x |
516 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 517 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
517 | changeString += eString + "\n"; | 518 | changeString += eString + "\n"; |
518 | deleteString += eString + "\n"; | 519 | deleteString += eString + "\n"; |
519 | deleteEnt = true; | 520 | deleteEnt = true; |
520 | changeEnt = true; | 521 | changeEnt = true; |
521 | } | 522 | } |
@@ -587,21 +588,21 @@ bool SharpFormat::save( Calendar *calendar) | |||
587 | status.setText ( i18n("Processing todos ...") ); | 588 | status.setText ( i18n("Processing todos ...") ); |
588 | qApp->processEvents(); | 589 | qApp->processEvents(); |
589 | QPtrList<Todo> tl = calendar->rawTodos(); | 590 | QPtrList<Todo> tl = calendar->rawTodos(); |
590 | Todo* to = tl.first(); | 591 | Todo* to = tl.first(); |
591 | i = 0; | 592 | i = 0; |
592 | message = i18n("Processing todo # "); | 593 | message = i18n("Processing todo # "); |
593 | procCount = 0; | 594 | procCount = 0; |
594 | while ( to ) { | 595 | while ( to ) { |
595 | if ( to->zaurusStat() != -2 ) { | 596 | if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
596 | status.setText ( message + QString::number ( ++procCount ) ); | 597 | status.setText ( message + QString::number ( ++procCount ) ); |
597 | qApp->processEvents(); | 598 | qApp->processEvents(); |
598 | QString eString = getTodoString( to ); | 599 | QString eString = getTodoString( to ); |
599 | if ( to->zaurusStat() == -3 ) { // delete | 600 | if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
600 | // deleting empty strings does not work. | 601 | // deleting empty strings does not work. |
601 | // we write first and x and then delete the record with the x | 602 | // we write first and x and then delete the record with the x |
602 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 603 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
603 | changeString += eString + "\n"; | 604 | changeString += eString + "\n"; |
604 | deleteString += eString + "\n"; | 605 | deleteString += eString + "\n"; |
605 | deleteEnt = true; | 606 | deleteEnt = true; |
606 | changeEnt = true; | 607 | changeEnt = true; |
607 | } | 608 | } |
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h new file mode 100644 index 0000000..57642ec --- a/dev/null +++ b/libkcal/syncdefines.h | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | #ifndef _KSYNC_DEFINES_H_ | ||
3 | #define _KSYNC_DEFINES_H_ | ||
4 | |||
5 | #define SYNC_PREF_LOCAL 0 | ||
6 | #define SYNC_PREF_REMOTE 1 | ||
7 | #define SYNC_PREF_NEWEST 2 | ||
8 | #define SYNC_PREF_ASK 3 | ||
9 | #define SYNC_PREF_FORCE_LOCAL 4 | ||
10 | #define SYNC_PREF_FORCE_REMOTE 5 | ||
11 | #define SYNC_PREF_TAKE_BOTH 6 | ||
12 | |||
13 | #define SYNC_MODE_NORMAL 0 | ||
14 | #define SYNC_MODE_EXTERNAL 1 | ||
15 | |||
16 | #define SYNC_TEMPSTATE_INITIAL 0 | ||
17 | #define SYNC_TEMPSTATE_NEW_EXTERNAL -2 | ||
18 | #define SYNC_TEMPSTATE_DELETE -3 | ||
19 | #define SYNC_TEMPSTATE_NEW_ID -4 | ||
20 | |||
21 | |||
22 | #endif | ||