author | zautrix <zautrix> | 2004-08-20 04:35:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-20 04:35:46 (UTC) |
commit | b42c4af4200c67802ee0cc57e10e1464903736b7 (patch) (unidiff) | |
tree | 59f35319f3223892e2353bb8a2c72cb9e87ca0f9 /libkcal | |
parent | 93decd4185adc7197008e8397cf753a5ab674d99 (diff) | |
download | kdepimpi-b42c4af4200c67802ee0cc57e10e1464903736b7.zip kdepimpi-b42c4af4200c67802ee0cc57e10e1464903736b7.tar.gz kdepimpi-b42c4af4200c67802ee0cc57e10e1464903736b7.tar.bz2 |
change reverted
-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 820d068..defdb09 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -414,193 +414,193 @@ bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | |||
414 | status.setText( i18n("Reading todos ...") ); | 414 | status.setText( i18n("Reading todos ...") ); |
415 | qApp->processEvents(); | 415 | qApp->processEvents(); |
416 | if ( ! debug ) { | 416 | if ( ! debug ) { |
417 | fileName = "/tmp/kopitempout"; | 417 | fileName = "/tmp/kopitempout"; |
418 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 418 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
419 | system ( command.latin1() ); | 419 | system ( command.latin1() ); |
420 | } else { | 420 | } else { |
421 | fileName = "/tmp/todo.txt"; | 421 | fileName = "/tmp/todo.txt"; |
422 | } | 422 | } |
423 | file.setName( fileName ); | 423 | file.setName( fileName ); |
424 | if (!file.open( IO_ReadOnly ) ) { | 424 | if (!file.open( IO_ReadOnly ) ) { |
425 | return false; | 425 | return false; |
426 | 426 | ||
427 | } | 427 | } |
428 | ts.setDevice( &file ); | 428 | ts.setDevice( &file ); |
429 | text = ts.read(); | 429 | text = ts.read(); |
430 | file.close(); | 430 | file.close(); |
431 | 431 | ||
432 | status.setText( i18n("Processing todos ...") ); | 432 | status.setText( i18n("Processing todos ...") ); |
433 | status.raise(); | 433 | status.raise(); |
434 | qApp->processEvents(); | 434 | qApp->processEvents(); |
435 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 435 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
436 | return true; | 436 | return true; |
437 | } | 437 | } |
438 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 438 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
439 | { | 439 | { |
440 | int retval = -1; | 440 | int retval = -1; |
441 | QStringList templist; | 441 | QStringList templist; |
442 | QString tempString; | 442 | QString tempString; |
443 | int start = 0; | 443 | int start = 0; |
444 | int len = answer.length(); | 444 | int len = answer.length(); |
445 | int end = answer.find ("\n",start)+1; | 445 | int end = answer.find ("\n",start)+1; |
446 | bool ok = true; | 446 | bool ok = true; |
447 | start = end; | 447 | start = end; |
448 | int ccc = 0; | 448 | int ccc = 0; |
449 | while ( start > 0 ) { | 449 | while ( start > 0 ) { |
450 | templist.clear(); | 450 | templist.clear(); |
451 | ok = true; | 451 | ok = true; |
452 | int loopCount = 0; | 452 | int loopCount = 0; |
453 | while ( ok ) { | 453 | while ( ok ) { |
454 | ++loopCount; | 454 | ++loopCount; |
455 | if ( loopCount > 25 ) { | 455 | if ( loopCount > 25 ) { |
456 | qDebug("KO: Error in while loop"); | 456 | qDebug("KO: Error in while loop"); |
457 | ok = false; | 457 | ok = false; |
458 | start = 0; | 458 | start = 0; |
459 | break; | 459 | break; |
460 | } | 460 | } |
461 | if ( ok ) | 461 | if ( ok ) |
462 | tempString = getPart( answer, ok, start ); | 462 | tempString = getPart( answer, ok, start ); |
463 | if ( start >= len || start == 0 ) { | 463 | if ( start >= len || start == 0 ) { |
464 | start = 0; | 464 | start = 0; |
465 | ok = false; | 465 | ok = false; |
466 | } | 466 | } |
467 | if ( tempString.right(1) =="\n" ) | 467 | if ( tempString.right(1) =="\n" ) |
468 | tempString = tempString.left( tempString.length()-1); | 468 | tempString = tempString.left( tempString.length()-1); |
469 | 469 | ||
470 | templist.append( tempString ); | 470 | templist.append( tempString ); |
471 | } | 471 | } |
472 | ++ccc; | 472 | ++ccc; |
473 | if ( ccc == 2 && loopCount < 25 ) { | 473 | if ( ccc == 2 && loopCount < 25 ) { |
474 | start = 0; | 474 | start = 0; |
475 | bool ok; | 475 | bool ok; |
476 | int newnum = templist[0].toInt( &ok ); | 476 | int newnum = templist[0].toInt( &ok ); |
477 | if ( ok && newnum > 0) { | 477 | if ( ok && newnum > 0) { |
478 | retval = newnum; | 478 | retval = newnum; |
479 | inc->setID( "Sharp_DTM",templist[0] ); | 479 | inc->setID( "Sharp_DTM",templist[0] ); |
480 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); | 480 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); |
481 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 481 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | //qDebug("getNumFromRecord returning : %d ", retval); | 485 | //qDebug("getNumFromRecord returning : %d ", retval); |
486 | return retval; | 486 | return retval; |
487 | } | 487 | } |
488 | bool SharpFormat::save( Calendar *calendar) | 488 | bool SharpFormat::save( Calendar *calendar) |
489 | { | 489 | { |
490 | 490 | ||
491 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 491 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
492 | int w = status.sizeHint().width()+20 ; | 492 | int w = status.sizeHint().width()+20 ; |
493 | if ( w < 200 ) w = 200; | 493 | if ( w < 200 ) w = 200; |
494 | int h = status.sizeHint().height()+20 ; | 494 | int h = status.sizeHint().height()+20 ; |
495 | int dw = QApplication::desktop()->width(); | 495 | int dw = QApplication::desktop()->width(); |
496 | int dh = QApplication::desktop()->height(); | 496 | int dh = QApplication::desktop()->height(); |
497 | status.setCaption(i18n("Writing DTM Data") ); | 497 | status.setCaption(i18n("Writing DTM Data") ); |
498 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 498 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
499 | status.show(); | 499 | status.show(); |
500 | status.raise(); | 500 | status.raise(); |
501 | qApp->processEvents(); | 501 | qApp->processEvents(); |
502 | bool debug = DEBUGMODE; | 502 | bool debug = DEBUGMODE; |
503 | QString codec = "utf8"; | 503 | QString codec = "utf8"; |
504 | QString answer; | 504 | QString answer; |
505 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 505 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
506 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 506 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
507 | QString command; | 507 | QString command; |
508 | QPtrList<Event> er = calendar->rawEvents(); | 508 | QPtrList<Event> er = calendar->rawEvents(); |
509 | Event* ev = er.first(); | 509 | Event* ev = er.first(); |
510 | QString fileName = "/tmp/kdepimtempfile"; | 510 | QString fileName = "/tmp/kopitempout"; |
511 | int i = 0; | 511 | int i = 0; |
512 | QString changeString = ePrefix; | 512 | QString changeString = ePrefix; |
513 | QString deleteString = ePrefix; | 513 | QString deleteString = ePrefix; |
514 | bool deleteEnt = false; | 514 | bool deleteEnt = false; |
515 | bool changeEnt = false; | 515 | bool changeEnt = false; |
516 | QString message = i18n("Processing event # "); | 516 | QString message = i18n("Processing event # "); |
517 | int procCount = 0; | 517 | int procCount = 0; |
518 | while ( ev ) { | 518 | while ( ev ) { |
519 | //qDebug("i %d ", ++i); | 519 | //qDebug("i %d ", ++i); |
520 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 520 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
521 | status.setText ( message + QString::number ( ++procCount ) ); | 521 | status.setText ( message + QString::number ( ++procCount ) ); |
522 | qApp->processEvents(); | 522 | qApp->processEvents(); |
523 | QString eString = getEventString( ev ); | 523 | QString eString = getEventString( ev ); |
524 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 524 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
525 | // deleting empty strings does not work. | 525 | // deleting empty strings does not work. |
526 | // we write first and x and then delete the record with the x | 526 | // we write first and x and then delete the record with the x |
527 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 527 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
528 | changeString += eString + "\n"; | 528 | changeString += eString + "\n"; |
529 | deleteString += eString + "\n"; | 529 | deleteString += eString + "\n"; |
530 | deleteEnt = true; | 530 | deleteEnt = true; |
531 | changeEnt = true; | 531 | changeEnt = true; |
532 | } | 532 | } |
533 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 533 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
534 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 534 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
535 | system ( command.utf8() ); | 535 | system ( command.utf8() ); |
536 | QFile file( fileName ); | 536 | QFile file( fileName ); |
537 | if (!file.open( IO_ReadOnly ) ) { | 537 | if (!file.open( IO_ReadOnly ) ) { |
538 | return false; | 538 | return false; |
539 | 539 | ||
540 | } | 540 | } |
541 | QTextStream ts( &file ); | 541 | QTextStream ts( &file ); |
542 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 542 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
543 | answer = ts.read(); | 543 | answer = ts.read(); |
544 | file.close(); | 544 | file.close(); |
545 | //qDebug("answer \n%s ", answer.latin1()); | 545 | //qDebug("answer \n%s ", answer.latin1()); |
546 | getNumFromRecord( answer, ev ) ; | 546 | getNumFromRecord( answer, ev ) ; |
547 | 547 | ||
548 | } | 548 | } |
549 | else { // change existing | 549 | else { // change existing |
550 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 550 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
551 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 551 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
552 | changeString += eString + "\n"; | 552 | changeString += eString + "\n"; |
553 | changeEnt = true; | 553 | changeEnt = true; |
554 | 554 | ||
555 | } | 555 | } |
556 | } | 556 | } |
557 | ev = er.next(); | 557 | ev = er.next(); |
558 | } | 558 | } |
559 | status.setText ( i18n("Changing events ...") ); | 559 | status.setText ( i18n("Changing events ...") ); |
560 | qApp->processEvents(); | 560 | qApp->processEvents(); |
561 | //qDebug("changing... "); | 561 | //qDebug("changing... "); |
562 | if ( changeEnt ) { | 562 | if ( changeEnt ) { |
563 | QFile file( fileName ); | 563 | QFile file( fileName ); |
564 | if (!file.open( IO_WriteOnly ) ) { | 564 | if (!file.open( IO_WriteOnly ) ) { |
565 | return false; | 565 | return false; |
566 | 566 | ||
567 | } | 567 | } |
568 | QTextStream ts( &file ); | 568 | QTextStream ts( &file ); |
569 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 569 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
570 | ts << changeString ; | 570 | ts << changeString ; |
571 | file.close(); | 571 | file.close(); |
572 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 572 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
573 | system ( command.latin1() ); | 573 | system ( command.latin1() ); |
574 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 574 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
575 | 575 | ||
576 | } | 576 | } |
577 | status.setText ( i18n("Deleting events ...") ); | 577 | status.setText ( i18n("Deleting events ...") ); |
578 | qApp->processEvents(); | 578 | qApp->processEvents(); |
579 | //qDebug("deleting... "); | 579 | //qDebug("deleting... "); |
580 | if ( deleteEnt ) { | 580 | if ( deleteEnt ) { |
581 | QFile file( fileName ); | 581 | QFile file( fileName ); |
582 | if (!file.open( IO_WriteOnly ) ) { | 582 | if (!file.open( IO_WriteOnly ) ) { |
583 | return false; | 583 | return false; |
584 | 584 | ||
585 | } | 585 | } |
586 | QTextStream ts( &file ); | 586 | QTextStream ts( &file ); |
587 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 587 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
588 | ts << deleteString; | 588 | ts << deleteString; |
589 | file.close(); | 589 | file.close(); |
590 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 590 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
591 | system ( command.latin1() ); | 591 | system ( command.latin1() ); |
592 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 592 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
593 | } | 593 | } |
594 | 594 | ||
595 | 595 | ||
596 | changeString = tPrefix; | 596 | changeString = tPrefix; |
597 | deleteString = tPrefix; | 597 | deleteString = tPrefix; |
598 | status.setText ( i18n("Processing todos ...") ); | 598 | status.setText ( i18n("Processing todos ...") ); |
599 | qApp->processEvents(); | 599 | qApp->processEvents(); |
600 | QPtrList<Todo> tl = calendar->rawTodos(); | 600 | QPtrList<Todo> tl = calendar->rawTodos(); |
601 | Todo* to = tl.first(); | 601 | Todo* to = tl.first(); |
602 | i = 0; | 602 | i = 0; |
603 | message = i18n("Processing todo # "); | 603 | message = i18n("Processing todo # "); |
604 | procCount = 0; | 604 | procCount = 0; |
605 | while ( to ) { | 605 | while ( to ) { |
606 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 606 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |