summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/sharpformat.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index d56eab6..b88e729 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -573,134 +573,145 @@ bool SharpFormat::save( Calendar *calendar)
573 } 573 }
574 ev = er.next(); 574 ev = er.next();
575 } 575 }
576 status.setText ( i18n("Changing events ...") ); 576 status.setText ( i18n("Changing events ...") );
577 qApp->processEvents(); 577 qApp->processEvents();
578 //qDebug("changing... "); 578 //qDebug("changing... ");
579 if ( changeEnt ) { 579 if ( changeEnt ) {
580 QFile file( fileName ); 580 QFile file( fileName );
581 if (!file.open( IO_WriteOnly ) ) { 581 if (!file.open( IO_WriteOnly ) ) {
582 return false; 582 return false;
583 583
584 } 584 }
585 QTextStream ts( &file ); 585 QTextStream ts( &file );
586 ts.setCodec( QTextCodec::codecForName("utf8") ); 586 ts.setCodec( QTextCodec::codecForName("utf8") );
587 ts << changeString ; 587 ts << changeString ;
588 file.close(); 588 file.close();
589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
590 system ( command.latin1() ); 590 system ( command.latin1() );
591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
592 592
593 } 593 }
594 status.setText ( i18n("Deleting events ...") ); 594 status.setText ( i18n("Deleting events ...") );
595 qApp->processEvents(); 595 qApp->processEvents();
596 //qDebug("deleting... "); 596 //qDebug("deleting... ");
597 if ( deleteEnt ) { 597 if ( deleteEnt ) {
598 QFile file( fileName ); 598 QFile file( fileName );
599 if (!file.open( IO_WriteOnly ) ) { 599 if (!file.open( IO_WriteOnly ) ) {
600 return false; 600 return false;
601 601
602 } 602 }
603 QTextStream ts( &file ); 603 QTextStream ts( &file );
604 ts.setCodec( QTextCodec::codecForName("utf8") ); 604 ts.setCodec( QTextCodec::codecForName("utf8") );
605 ts << deleteString; 605 ts << deleteString;
606 file.close(); 606 file.close();
607 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 607 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
608 system ( command.latin1() ); 608 system ( command.latin1() );
609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
610 } 610 }
611 611
612 612
613 changeString = tPrefix; 613 changeString = tPrefix;
614 deleteString = tPrefix; 614 deleteString = tPrefix;
615 status.setText ( i18n("Processing todos ...") ); 615 status.setText ( i18n("Processing todos ...") );
616 qApp->processEvents(); 616 qApp->processEvents();
617 QPtrList<Todo> tl = calendar->rawTodos(); 617 QPtrList<Todo> tl = calendar->rawTodos();
618 Todo* to = tl.first(); 618 Todo* to = tl.first();
619 i = 0; 619 i = 0;
620 message = i18n("Processing todo # "); 620 message = i18n("Processing todo # ");
621 procCount = 0; 621 procCount = 0;
622 while ( to ) { 622 while ( to ) {
623 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 623 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
624 status.setText ( message + QString::number ( ++procCount ) ); 624 status.setText ( message + QString::number ( ++procCount ) );
625 qApp->processEvents(); 625 qApp->processEvents();
626 QString eString = getTodoString( to ); 626 QString eString = getTodoString( to );
627 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 627 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
628 // deleting empty strings does not work. 628 // deleting empty strings does not work.
629 // we write first and x and then delete the record with the x 629 // we write first and x and then delete the record with the x
630 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 630 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
631 changeString += eString + "\n"; 631 changeString += eString + "\n";
632 deleteString += eString + "\n"; 632 deleteString += eString + "\n";
633 deleteEnt = true; 633 deleteEnt = true;
634 changeEnt = true; 634 changeEnt = true;
635 } 635 }
636 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 636 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
637 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 637
638
639
640 QString fileNameIn = "/tmp/kopitempin";
641 QFile fileIn( fileNameIn );
642 if (!fileIn.open( IO_WriteOnly ) ) {
643 return false;
644 }
645 QTextStream tsIn( &fileIn );
646 tsIn.setCodec( QTextCodec::codecForName("utf8") );
647 tsIn << tPrefix << eString ;
648 fileIn.close();
649 command = "(cat /tmp/kopitempin | db2file todo -w -g -c " + codec+ ") > "+ fileName;
638 system ( command.utf8() ); 650 system ( command.utf8() );
639 QFile file( fileName ); 651 QFile file( fileName );
640 if (!file.open( IO_ReadOnly ) ) { 652 if (!file.open( IO_ReadOnly ) ) {
641 return false; 653 return false;
642
643 } 654 }
644 QTextStream ts( &file ); 655 QTextStream ts( &file );
645 ts.setCodec( QTextCodec::codecForName("utf8") ); 656 ts.setCodec( QTextCodec::codecForName("utf8") );
646 answer = ts.read(); 657 answer = ts.read();
647 file.close(); 658 file.close();
648 //qDebug("answer \n%s ", answer.latin1()); 659 //qDebug("answer \n%s ", answer.latin1());
649 getNumFromRecord( answer, to ) ; 660 getNumFromRecord( answer, to ) ;
650 661
651 } 662 }
652 else { // change existing 663 else { // change existing
653 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 664 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
654 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 665 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
655 changeString += eString + "\n"; 666 changeString += eString + "\n";
656 changeEnt = true; 667 changeEnt = true;
657 668
658 } 669 }
659 } 670 }
660 671
661 to = tl.next(); 672 to = tl.next();
662 } 673 }
663 status.setText ( i18n("Changing todos ...") ); 674 status.setText ( i18n("Changing todos ...") );
664 qApp->processEvents(); 675 qApp->processEvents();
665 //qDebug("changing... "); 676 //qDebug("changing... ");
666 if ( changeEnt ) { 677 if ( changeEnt ) {
667 QFile file( fileName ); 678 QFile file( fileName );
668 if (!file.open( IO_WriteOnly ) ) { 679 if (!file.open( IO_WriteOnly ) ) {
669 return false; 680 return false;
670 681
671 } 682 }
672 QTextStream ts( &file ); 683 QTextStream ts( &file );
673 ts.setCodec( QTextCodec::codecForName("utf8") ); 684 ts.setCodec( QTextCodec::codecForName("utf8") );
674 ts << changeString ; 685 ts << changeString ;
675 file.close(); 686 file.close();
676 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 687 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
677 system ( command.latin1() ); 688 system ( command.latin1() );
678 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 689 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
679 690
680 } 691 }
681 status.setText ( i18n("Deleting todos ...") ); 692 status.setText ( i18n("Deleting todos ...") );
682 qApp->processEvents(); 693 qApp->processEvents();
683 //qDebug("deleting... "); 694 //qDebug("deleting... ");
684 if ( deleteEnt ) { 695 if ( deleteEnt ) {
685 QFile file( fileName ); 696 QFile file( fileName );
686 if (!file.open( IO_WriteOnly ) ) { 697 if (!file.open( IO_WriteOnly ) ) {
687 return false; 698 return false;
688 699
689 } 700 }
690 QTextStream ts( &file ); 701 QTextStream ts( &file );
691 ts.setCodec( QTextCodec::codecForName("utf8") ); 702 ts.setCodec( QTextCodec::codecForName("utf8") );
692 ts << deleteString; 703 ts << deleteString;
693 file.close(); 704 file.close();
694 command = "db2file todo -d -c " + codec+ " < "+ fileName; 705 command = "db2file todo -d -c " + codec+ " < "+ fileName;
695 system ( command.latin1() ); 706 system ( command.latin1() );
696 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 707 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
697 } 708 }
698 709
699 return true; 710 return true;
700} 711}
701QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 712QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
702{ 713{
703 QString datestr; 714 QString datestr;
704 QString timestr; 715 QString timestr;
705 int offset = KGlobal::locale()->localTimeOffset( dti ); 716 int offset = KGlobal::locale()->localTimeOffset( dti );
706 QDateTime dt; 717 QDateTime dt;