author | zautrix <zautrix> | 2005-06-26 08:17:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 08:17:08 (UTC) |
commit | f27e8c6cc8abbd27f10167334d608c7e0af7f711 (patch) (unidiff) | |
tree | b516d5512178f98d105a5d77f96aff29dfe09c02 /libkcal | |
parent | 6d8fdbda8cb12b768932a80ccd25d275bc4b30f9 (diff) | |
download | kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.zip kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.tar.gz kdepimpi-f27e8c6cc8abbd27f10167334d608c7e0af7f711.tar.bz2 |
rec fix
-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 c2ee2c9..9b757f7 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -634,379 +634,379 @@ bool SharpFormat::save( Calendar *calendar) | |||
634 | 634 | ||
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | to = tl.next(); | 638 | to = tl.next(); |
639 | } | 639 | } |
640 | status.setText ( i18n("Changing todos ...") ); | 640 | status.setText ( i18n("Changing todos ...") ); |
641 | qApp->processEvents(); | 641 | qApp->processEvents(); |
642 | //qDebug("changing... "); | 642 | //qDebug("changing... "); |
643 | if ( changeEnt ) { | 643 | if ( changeEnt ) { |
644 | QFile file( fileName ); | 644 | QFile file( fileName ); |
645 | if (!file.open( IO_WriteOnly ) ) { | 645 | if (!file.open( IO_WriteOnly ) ) { |
646 | return false; | 646 | return false; |
647 | 647 | ||
648 | } | 648 | } |
649 | QTextStream ts( &file ); | 649 | QTextStream ts( &file ); |
650 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 650 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
651 | ts << changeString ; | 651 | ts << changeString ; |
652 | file.close(); | 652 | file.close(); |
653 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; | 653 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; |
654 | system ( command.latin1() ); | 654 | system ( command.latin1() ); |
655 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 655 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
656 | 656 | ||
657 | } | 657 | } |
658 | status.setText ( i18n("Deleting todos ...") ); | 658 | status.setText ( i18n("Deleting todos ...") ); |
659 | qApp->processEvents(); | 659 | qApp->processEvents(); |
660 | //qDebug("deleting... "); | 660 | //qDebug("deleting... "); |
661 | if ( deleteEnt ) { | 661 | if ( deleteEnt ) { |
662 | QFile file( fileName ); | 662 | QFile file( fileName ); |
663 | if (!file.open( IO_WriteOnly ) ) { | 663 | if (!file.open( IO_WriteOnly ) ) { |
664 | return false; | 664 | return false; |
665 | 665 | ||
666 | } | 666 | } |
667 | QTextStream ts( &file ); | 667 | QTextStream ts( &file ); |
668 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 668 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
669 | ts << deleteString; | 669 | ts << deleteString; |
670 | file.close(); | 670 | file.close(); |
671 | command = "db2file todo -d -c " + codec+ " < "+ fileName; | 671 | command = "db2file todo -d -c " + codec+ " < "+ fileName; |
672 | system ( command.latin1() ); | 672 | system ( command.latin1() ); |
673 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 673 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
674 | } | 674 | } |
675 | 675 | ||
676 | return true; | 676 | return true; |
677 | } | 677 | } |
678 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) | 678 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) |
679 | { | 679 | { |
680 | QString datestr; | 680 | QString datestr; |
681 | QString timestr; | 681 | QString timestr; |
682 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 682 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
683 | QDateTime dt; | 683 | QDateTime dt; |
684 | if (useTZ) | 684 | if (useTZ) |
685 | dt = dti.addSecs ( -(offset*60)); | 685 | dt = dti.addSecs ( -(offset*60)); |
686 | else | 686 | else |
687 | dt = dti; | 687 | dt = dti; |
688 | if(dt.date().isValid()){ | 688 | if(dt.date().isValid()){ |
689 | const QDate& date = dt.date(); | 689 | const QDate& date = dt.date(); |
690 | datestr.sprintf("%04d%02d%02d", | 690 | datestr.sprintf("%04d%02d%02d", |
691 | date.year(), date.month(), date.day()); | 691 | date.year(), date.month(), date.day()); |
692 | } | 692 | } |
693 | if(dt.time().isValid()){ | 693 | if(dt.time().isValid()){ |
694 | const QTime& time = dt.time(); | 694 | const QTime& time = dt.time(); |
695 | timestr.sprintf("T%02d%02d%02d", | 695 | timestr.sprintf("T%02d%02d%02d", |
696 | time.hour(), time.minute(), time.second()); | 696 | time.hour(), time.minute(), time.second()); |
697 | } | 697 | } |
698 | return datestr + timestr; | 698 | return datestr + timestr; |
699 | } | 699 | } |
700 | QString SharpFormat::getEventString( Event* event ) | 700 | QString SharpFormat::getEventString( Event* event ) |
701 | { | 701 | { |
702 | QStringList list; | 702 | QStringList list; |
703 | list.append( event->getID("Sharp_DTM") ); | 703 | list.append( event->getID("Sharp_DTM") ); |
704 | list.append( event->categories().join(",") ); | 704 | list.append( event->categories().join(",") ); |
705 | if ( !event->summary().isEmpty() ) | 705 | if ( !event->summary().isEmpty() ) |
706 | list.append( event->summary() ); | 706 | list.append( event->summary() ); |
707 | else | 707 | else |
708 | list.append("" ); | 708 | list.append("" ); |
709 | if ( !event->location().isEmpty() ) | 709 | if ( !event->location().isEmpty() ) |
710 | list.append( event->location() ); | 710 | list.append( event->location() ); |
711 | else | 711 | else |
712 | list.append("" ); | 712 | list.append("" ); |
713 | if ( !event->description().isEmpty() ) | 713 | if ( !event->description().isEmpty() ) |
714 | list.append( event->description() ); | 714 | list.append( event->description() ); |
715 | else | 715 | else |
716 | list.append( "" ); | 716 | list.append( "" ); |
717 | if ( event->doesFloat () ) { | 717 | if ( event->doesFloat () ) { |
718 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 718 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
719 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 719 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
720 | list.append( "1" ); | 720 | list.append( "1" ); |
721 | 721 | ||
722 | } | 722 | } |
723 | else { | 723 | else { |
724 | list.append( dtToString( event->dtStart()) ); | 724 | list.append( dtToString( event->dtStart()) ); |
725 | list.append( dtToString( event->dtEnd()) ); //6 | 725 | list.append( dtToString( event->dtEnd()) ); //6 |
726 | list.append( "0" ); | 726 | list.append( "0" ); |
727 | } | 727 | } |
728 | bool noAlarm = true; | 728 | bool noAlarm = true; |
729 | if ( event->alarms().count() > 0 ) { | 729 | if ( event->alarms().count() > 0 ) { |
730 | Alarm * al = event->alarms().first(); | 730 | Alarm * al = event->alarms().first(); |
731 | if ( al->enabled() ) { | 731 | if ( al->enabled() ) { |
732 | noAlarm = false; | 732 | noAlarm = false; |
733 | list.append( "0" ); // yes, 0 == alarm | 733 | list.append( "0" ); // yes, 0 == alarm |
734 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 734 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
735 | if ( al->type() == Alarm::Audio ) | 735 | if ( al->type() == Alarm::Audio ) |
736 | list.append( "1" ); // type audio | 736 | list.append( "1" ); // type audio |
737 | else | 737 | else |
738 | list.append( "0" ); // type silent | 738 | list.append( "0" ); // type silent |
739 | } | 739 | } |
740 | } | 740 | } |
741 | if ( noAlarm ) { | 741 | if ( noAlarm ) { |
742 | list.append( "1" ); // yes, 1 == no alarm | 742 | list.append( "1" ); // yes, 1 == no alarm |
743 | list.append( "0" ); // no alarm offset | 743 | list.append( "0" ); // no alarm offset |
744 | list.append( "1" ); // type | 744 | list.append( "1" ); // type |
745 | } | 745 | } |
746 | // next is: 11 | 746 | // next is: 11 |
747 | // next is: 11-16 are recurrence | 747 | // next is: 11-16 are recurrence |
748 | Recurrence* rec = event->recurrence(); | 748 | Recurrence* rec = event->recurrence(); |
749 | 749 | ||
750 | bool writeEndDate = false; | 750 | bool writeEndDate = false; |
751 | switch ( rec->doesRecur() ) | 751 | switch ( rec->doesRecur() ) |
752 | { | 752 | { |
753 | case Recurrence::rDaily: // 0 | 753 | case Recurrence::rDaily: // 0 |
754 | list.append( "0" ); | 754 | list.append( "0" ); |
755 | list.append( QString::number( rec->frequency() ));//12 | 755 | list.append( QString::number( rec->frequency() ));//12 |
756 | list.append( "0" ); | 756 | list.append( "0" ); |
757 | list.append( "0" ); | 757 | list.append( "0" ); |
758 | writeEndDate = true; | 758 | writeEndDate = true; |
759 | break; | 759 | break; |
760 | case Recurrence::rWeekly:// 1 | 760 | case Recurrence::rWeekly:// 1 |
761 | list.append( "1" ); | 761 | list.append( "1" ); |
762 | list.append( QString::number( rec->frequency()) );//12 | 762 | list.append( QString::number( rec->frequency()) );//12 |
763 | list.append( "0" ); | 763 | list.append( "0" ); |
764 | { | 764 | { |
765 | int days = 0; | 765 | int days = 0; |
766 | QBitArray weekDays = rec->days(); | 766 | QBitArray weekDays = rec->days(); |
767 | int i; | 767 | int i; |
768 | for( i = 1; i <= 7; ++i ) { | 768 | for( i = 1; i <= 7; ++i ) { |
769 | if ( weekDays[i-1] ) { | 769 | if ( weekDays[i-1] ) { |
770 | days += 1 << (i-1); | 770 | days += 1 << (i-1); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | list.append( QString::number( days ) ); | 773 | list.append( QString::number( days ) ); |
774 | } | 774 | } |
775 | //pending weekdays | 775 | //pending weekdays |
776 | writeEndDate = true; | 776 | writeEndDate = true; |
777 | 777 | ||
778 | break; | 778 | break; |
779 | case Recurrence::rMonthlyPos:// 2 | 779 | case Recurrence::rMonthlyPos:// 2 |
780 | list.append( "2" ); | 780 | list.append( "2" ); |
781 | list.append( QString::number( rec->frequency()) );//12 | 781 | list.append( QString::number( rec->frequency()) );//12 |
782 | 782 | ||
783 | writeEndDate = true; | 783 | writeEndDate = true; |
784 | { | 784 | { |
785 | int count = 1; | 785 | int count = 1; |
786 | QPtrList<Recurrence::rMonthPos> rmp; | 786 | QPtrList<Recurrence::rMonthPos> rmp; |
787 | rmp = rec->monthPositions(); | 787 | rmp = rec->monthPositions(); |
788 | if ( rmp.first()->negative ) | 788 | if ( rmp.first()->negative ) |
789 | count = 5 - rmp.first()->rPos - 1; | 789 | count = 5 - rmp.first()->rPos - 1; |
790 | else | 790 | else |
791 | count = rmp.first()->rPos - 1; | 791 | count = rmp.first()->rPos - 1; |
792 | list.append( QString::number( count ) ); | 792 | list.append( QString::number( count ) ); |
793 | 793 | ||
794 | } | 794 | } |
795 | 795 | ||
796 | list.append( "0" ); | 796 | list.append( "0" ); |
797 | break; | 797 | break; |
798 | case Recurrence::rMonthlyDay:// 3 | 798 | case Recurrence::rMonthlyDay:// 3 |
799 | list.append( "3" ); | 799 | list.append( "3" ); |
800 | list.append( QString::number( rec->frequency()) );//12 | 800 | list.append( QString::number( rec->frequency()) );//12 |
801 | list.append( "0" ); | 801 | list.append( "0" ); |
802 | list.append( "0" ); | 802 | list.append( "0" ); |
803 | writeEndDate = true; | 803 | writeEndDate = true; |
804 | break; | 804 | break; |
805 | case Recurrence::rYearlyMonth://4 | 805 | case Recurrence::rYearlyMonth://4 |
806 | list.append( "4" ); | 806 | list.append( "4" ); |
807 | list.append( QString::number( rec->frequency()) );//12 | 807 | list.append( QString::number( rec->frequency()) );//12 |
808 | list.append( "0" ); | 808 | list.append( "0" ); |
809 | list.append( "0" ); | 809 | list.append( "0" ); |
810 | writeEndDate = true; | 810 | writeEndDate = true; |
811 | break; | 811 | break; |
812 | 812 | ||
813 | default: | 813 | default: |
814 | list.append( "255" ); | 814 | list.append( "255" ); |
815 | list.append( QString() ); | 815 | list.append( QString() ); |
816 | list.append( "0" ); | 816 | list.append( "0" ); |
817 | list.append( QString() ); | 817 | list.append( QString() ); |
818 | list.append( "0" ); | 818 | list.append( "0" ); |
819 | list.append( "20991231T000000" ); | 819 | list.append( "20991231T000000" ); |
820 | break; | 820 | break; |
821 | } | 821 | } |
822 | if ( writeEndDate ) { | 822 | if ( writeEndDate ) { |
823 | 823 | ||
824 | if ( rec->endDate().isValid() ) { // 15 + 16 | 824 | if ( rec->endDate().isValid() ) { // 15 + 16 |
825 | list.append( "1" ); | 825 | list.append( "1" ); |
826 | list.append( dtToString( rec->endDate()) ); | 826 | list.append( dtToString( rec->endDate(), false ) ); |
827 | } else { | 827 | } else { |
828 | list.append( "0" ); | 828 | list.append( "0" ); |
829 | list.append( "20991231T000000" ); | 829 | list.append( "20991231T000000" ); |
830 | } | 830 | } |
831 | 831 | ||
832 | } | 832 | } |
833 | if ( event->doesFloat () ) { | 833 | if ( event->doesFloat () ) { |
834 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | 834 | list.append( dtToString( event->dtStart(), false ).left( 8 )); |
835 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | 835 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 |
836 | 836 | ||
837 | } | 837 | } |
838 | else { | 838 | else { |
839 | list.append( QString() ); | 839 | list.append( QString() ); |
840 | list.append( QString() ); | 840 | list.append( QString() ); |
841 | 841 | ||
842 | } | 842 | } |
843 | if (event->dtStart().date() == event->dtEnd().date() ) | 843 | if (event->dtStart().date() == event->dtEnd().date() ) |
844 | list.append( "0" ); | 844 | list.append( "0" ); |
845 | else | 845 | else |
846 | list.append( "1" ); | 846 | list.append( "1" ); |
847 | 847 | ||
848 | 848 | ||
849 | for(QStringList::Iterator it=list.begin(); | 849 | for(QStringList::Iterator it=list.begin(); |
850 | it!=list.end(); ++it){ | 850 | it!=list.end(); ++it){ |
851 | QString& s = (*it); | 851 | QString& s = (*it); |
852 | s.replace(QRegExp("\""), "\"\""); | 852 | s.replace(QRegExp("\""), "\"\""); |
853 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 853 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
854 | s.prepend('\"'); | 854 | s.prepend('\"'); |
855 | s.append('\"'); | 855 | s.append('\"'); |
856 | } else if(s.isEmpty() && !s.isNull()){ | 856 | } else if(s.isEmpty() && !s.isNull()){ |
857 | s = "\"\""; | 857 | s = "\"\""; |
858 | } | 858 | } |
859 | } | 859 | } |
860 | return list.join(","); | 860 | return list.join(","); |
861 | 861 | ||
862 | 862 | ||
863 | } | 863 | } |
864 | QString SharpFormat::getTodoString( Todo* todo ) | 864 | QString SharpFormat::getTodoString( Todo* todo ) |
865 | { | 865 | { |
866 | QStringList list; | 866 | QStringList list; |
867 | list.append( todo->getID("Sharp_DTM") ); | 867 | list.append( todo->getID("Sharp_DTM") ); |
868 | list.append( todo->categories().join(",") ); | 868 | list.append( todo->categories().join(",") ); |
869 | 869 | ||
870 | if ( todo->hasStartDate() ) { | 870 | if ( todo->hasStartDate() ) { |
871 | list.append( dtToString( todo->dtStart()) ); | 871 | list.append( dtToString( todo->dtStart()) ); |
872 | } else | 872 | } else |
873 | list.append( QString() ); | 873 | list.append( QString() ); |
874 | 874 | ||
875 | if ( todo->hasDueDate() ) { | 875 | if ( todo->hasDueDate() ) { |
876 | QTime tim; | 876 | QTime tim; |
877 | if ( todo->doesFloat()) { | 877 | if ( todo->doesFloat()) { |
878 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 878 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
879 | } else { | 879 | } else { |
880 | list.append( dtToString(todo->dtDue() ) ); | 880 | list.append( dtToString(todo->dtDue() ) ); |
881 | } | 881 | } |
882 | } else | 882 | } else |
883 | list.append( QString() ); | 883 | list.append( QString() ); |
884 | 884 | ||
885 | if ( todo->isCompleted() ) { | 885 | if ( todo->isCompleted() ) { |
886 | list.append( dtToString( todo->completed()) ); | 886 | list.append( dtToString( todo->completed()) ); |
887 | list.append( "0" ); // yes 0 == completed | 887 | list.append( "0" ); // yes 0 == completed |
888 | } else { | 888 | } else { |
889 | list.append( dtToString( todo->completed()) ); | 889 | list.append( dtToString( todo->completed()) ); |
890 | list.append( "1" ); | 890 | list.append( "1" ); |
891 | } | 891 | } |
892 | list.append( QString::number( todo->priority() )); | 892 | list.append( QString::number( todo->priority() )); |
893 | if( ! todo->summary().isEmpty() ) | 893 | if( ! todo->summary().isEmpty() ) |
894 | list.append( todo->summary() ); | 894 | list.append( todo->summary() ); |
895 | else | 895 | else |
896 | list.append( "" ); | 896 | list.append( "" ); |
897 | if (! todo->description().isEmpty() ) | 897 | if (! todo->description().isEmpty() ) |
898 | list.append( todo->description() ); | 898 | list.append( todo->description() ); |
899 | else | 899 | else |
900 | list.append( "" ); | 900 | list.append( "" ); |
901 | for(QStringList::Iterator it=list.begin(); | 901 | for(QStringList::Iterator it=list.begin(); |
902 | it!=list.end(); ++it){ | 902 | it!=list.end(); ++it){ |
903 | QString& s = (*it); | 903 | QString& s = (*it); |
904 | s.replace(QRegExp("\""), "\"\""); | 904 | s.replace(QRegExp("\""), "\"\""); |
905 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 905 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
906 | s.prepend('\"'); | 906 | s.prepend('\"'); |
907 | s.append('\"'); | 907 | s.append('\"'); |
908 | } else if(s.isEmpty() && !s.isNull()){ | 908 | } else if(s.isEmpty() && !s.isNull()){ |
909 | s = "\"\""; | 909 | s = "\"\""; |
910 | } | 910 | } |
911 | } | 911 | } |
912 | return list.join(","); | 912 | return list.join(","); |
913 | } | 913 | } |
914 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | 914 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) |
915 | { | 915 | { |
916 | //qDebug("start %d ", start); | 916 | //qDebug("start %d ", start); |
917 | 917 | ||
918 | QString retval =""; | 918 | QString retval =""; |
919 | if ( text.at(start) == '"' ) { | 919 | if ( text.at(start) == '"' ) { |
920 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | 920 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { |
921 | start = start +2; | 921 | start = start +2; |
922 | if ( text.mid( start,1) == "," ) { | 922 | if ( text.mid( start,1) == "," ) { |
923 | start += 1; | 923 | start += 1; |
924 | } | 924 | } |
925 | retval = ""; | 925 | retval = ""; |
926 | if ( text.mid( start,1) == "\n" ) { | 926 | if ( text.mid( start,1) == "\n" ) { |
927 | start += 1; | 927 | start += 1; |
928 | ok = false; | 928 | ok = false; |
929 | } | 929 | } |
930 | return retval; | 930 | return retval; |
931 | } | 931 | } |
932 | int hk = start+1; | 932 | int hk = start+1; |
933 | hk = text.find ('"',hk); | 933 | hk = text.find ('"',hk); |
934 | while ( text.at(hk+1) == '"' ) | 934 | while ( text.at(hk+1) == '"' ) |
935 | hk = text.find ('"',hk+2); | 935 | hk = text.find ('"',hk+2); |
936 | retval = text.mid( start+1, hk-start-1); | 936 | retval = text.mid( start+1, hk-start-1); |
937 | start = hk+1; | 937 | start = hk+1; |
938 | retval.replace( QRegExp("\"\""), "\""); | 938 | retval.replace( QRegExp("\"\""), "\""); |
939 | if ( text.mid( start,1) == "," ) { | 939 | if ( text.mid( start,1) == "," ) { |
940 | start += 1; | 940 | start += 1; |
941 | } | 941 | } |
942 | if ( text.mid( start,1) == "\n" ) { | 942 | if ( text.mid( start,1) == "\n" ) { |
943 | start += 1; | 943 | start += 1; |
944 | ok = false; | 944 | ok = false; |
945 | } | 945 | } |
946 | //qDebug("retval***%s*** ",retval.latin1() ); | 946 | //qDebug("retval***%s*** ",retval.latin1() ); |
947 | return retval; | 947 | return retval; |
948 | 948 | ||
949 | } else { | 949 | } else { |
950 | int nl = text.find ("\n",start); | 950 | int nl = text.find ("\n",start); |
951 | int kom = text.find (',',start); | 951 | int kom = text.find (',',start); |
952 | if ( kom < nl ) { | 952 | if ( kom < nl ) { |
953 | // qDebug("kom < nl %d ", kom); | 953 | // qDebug("kom < nl %d ", kom); |
954 | retval = text.mid(start, kom-start); | 954 | retval = text.mid(start, kom-start); |
955 | start = kom+1; | 955 | start = kom+1; |
956 | return retval; | 956 | return retval; |
957 | } else { | 957 | } else { |
958 | if ( nl == kom ) { | 958 | if ( nl == kom ) { |
959 | // qDebug(" nl == kom "); | 959 | // qDebug(" nl == kom "); |
960 | start = 0; | 960 | start = 0; |
961 | ok = false; | 961 | ok = false; |
962 | return "0"; | 962 | return "0"; |
963 | } | 963 | } |
964 | // qDebug(" nl < kom ", nl); | 964 | // qDebug(" nl < kom ", nl); |
965 | retval = text.mid( start, nl-start); | 965 | retval = text.mid( start, nl-start); |
966 | ok = false; | 966 | ok = false; |
967 | start = nl+1; | 967 | start = nl+1; |
968 | return retval; | 968 | return retval; |
969 | } | 969 | } |
970 | } | 970 | } |
971 | } | 971 | } |
972 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) | 972 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) |
973 | { | 973 | { |
974 | return false; | 974 | return false; |
975 | } | 975 | } |
976 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) | 976 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) |
977 | { | 977 | { |
978 | // qDebug("test %s ", text.latin1()); | 978 | // qDebug("test %s ", text.latin1()); |
979 | QStringList templist; | 979 | QStringList templist; |
980 | QString tempString; | 980 | QString tempString; |
981 | int start = 0; | 981 | int start = 0; |
982 | int len = text.length(); | 982 | int len = text.length(); |
983 | int end = text.find ("\n",start)+1; | 983 | int end = text.find ("\n",start)+1; |
984 | bool ok = true; | 984 | bool ok = true; |
985 | start = end; | 985 | start = end; |
986 | SharpParser handler( calendar ); | 986 | SharpParser handler( calendar ); |
987 | // handler.setCategoriesList( mCategories ); | 987 | // handler.setCategoriesList( mCategories ); |
988 | while ( start > 0 ) { | 988 | while ( start > 0 ) { |
989 | templist.clear(); | 989 | templist.clear(); |
990 | ok = true; | 990 | ok = true; |
991 | while ( ok ) { | 991 | while ( ok ) { |
992 | tempString = getPart( text, ok, start ); | 992 | tempString = getPart( text, ok, start ); |
993 | if ( start >= len || start == 0 ) { | 993 | if ( start >= len || start == 0 ) { |
994 | start = 0; | 994 | start = 0; |
995 | ok = false; | 995 | ok = false; |
996 | } | 996 | } |
997 | if ( tempString.right(1) =="\n" ) | 997 | if ( tempString.right(1) =="\n" ) |
998 | tempString = tempString.left( tempString.length()-1); | 998 | tempString = tempString.left( tempString.length()-1); |
999 | //if ( ok ) | 999 | //if ( ok ) |
1000 | templist.append( tempString ); | 1000 | templist.append( tempString ); |
1001 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | 1001 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); |
1002 | } | 1002 | } |
1003 | handler.startElement( existingCalendar, templist, type ); | 1003 | handler.startElement( existingCalendar, templist, type ); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | return false; | 1006 | return false; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | QString SharpFormat::toString( Calendar * ) | 1009 | QString SharpFormat::toString( Calendar * ) |
1010 | { | 1010 | { |
1011 | return QString::null; | 1011 | return QString::null; |
1012 | } | 1012 | } |