summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-04-08 22:05:03 (UTC)
committer zautrix <zautrix>2005-04-08 22:05:03 (UTC)
commit9667e6f2589d5b2080cca928814f382761f8dda6 (patch) (unidiff)
tree438bcb5c041de0804284cf457cbc97a367dadf37 /kabc
parentc0f1d38e29ee0d0a1d1dcb5bda08089923926b41 (diff)
downloadkdepimpi-9667e6f2589d5b2080cca928814f382761f8dda6.zip
kdepimpi-9667e6f2589d5b2080cca928814f382761f8dda6.tar.gz
kdepimpi-9667e6f2589d5b2080cca928814f382761f8dda6.tar.bz2
utf8 kapi import fix
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcard.cpp2
-rw-r--r--kabc/vcardparser/vcardline.cpp14
-rw-r--r--kabc/vcardparser/vcardline.h7
-rw-r--r--kabc/vcardparser/vcardparser.cpp8
-rw-r--r--kabc/vcardparser/vcardtool.cpp86
5 files changed, 61 insertions, 56 deletions
diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp
index 24fd498..bc9f208 100644
--- a/kabc/vcardparser/vcard.cpp
+++ b/kabc/vcardparser/vcard.cpp
@@ -113,3 +113,3 @@ VCard::Version VCard::version() const
113 VCardLine line = ( *versionEntry )[ 0 ]; 113 VCardLine line = ( *versionEntry )[ 0 ];
114 if ( line.value() == "2.1" ) 114 if ( line.valueString() == "2.1" )
115 return v2_1; 115 return v2_1;
diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp
index 0972a35..8df2d32 100644
--- a/kabc/vcardparser/vcardline.cpp
+++ b/kabc/vcardparser/vcardline.cpp
@@ -84,8 +84,12 @@ QString VCardLine::identifier() const
84 84
85void VCardLine::setValue( const QString& value ) 85void VCardLine::setValueString( const QString& value )
86{ 86{
87 mValue.duplicate( value.data(), value.length() ); 87 setValueCString( value.utf8() );
88}
89void VCardLine::setValueCString( const QCString& value )
90{
91 mValue.duplicate( value.data(), value.length() );
88} 92}
89 93
90void VCardLine::setValue( const QByteArray& value ) 94void VCardLine::setValueBytes( const QByteArray& value )
91{ 95{
@@ -94,5 +98,5 @@ void VCardLine::setValue( const QByteArray& value )
94 98
95QVariant VCardLine::value() const 99QString VCardLine::valueString() const
96{ 100{
97 return QVariant( QCString( mValue.data(), mValue.size()+1 ) ); 101 return QString::fromUtf8( mValue.data(), mValue.size() );
98} 102}
diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h
index 6e74b38..8dc9322 100644
--- a/kabc/vcardparser/vcardline.h
+++ b/kabc/vcardparser/vcardline.h
@@ -60,4 +60,5 @@ class VCardLine
60 */ 60 */
61 void setValue( const QString& value ); 61 void setValueString( const QString& value );
62 void setValue( const QByteArray& value ); 62 void setValueCString( const QCString& value );
63 void setValueBytes( const QByteArray& value );
63 64
@@ -66,3 +67,3 @@ class VCardLine
66 */ 67 */
67 QVariant value() const; 68 QString valueString() const;
68 QByteArray valueBytes() const; 69 QByteArray valueBytes() const;
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
index 7fae011..11622a0 100644
--- a/kabc/vcardparser/vcardparser.cpp
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -128,3 +128,3 @@ VCard::List VCardParser::parseVCards( const QString& text )
128// } else 128// } else
129 vCardLine.setValue( output ); 129 vCardLine.setValueBytes( output );
130//PP our vcards are *supposed* to be in UTF-8 130//PP our vcards are *supposed* to be in UTF-8
@@ -133,3 +133,3 @@ VCard::List VCardParser::parseVCards( const QString& text )
133 } else 133 } else
134 vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) ); 134 vCardLine.setValueString( value.replace( QRegExp("\\\\n"), "\n" ) );
135 135
@@ -190,3 +190,3 @@ QString VCardParser::createVCards( const VCard::List& list )
190 for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { 190 for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
191 if ( !(*lineIt).value().asString().isEmpty() ) { 191 if ( !(*lineIt).valueString().isEmpty() ) {
192 if ( (*lineIt).hasGroup() ) 192 if ( (*lineIt).hasGroup() )
@@ -223,3 +223,3 @@ QString VCardParser::createVCards( const VCard::List& list )
223 } else 223 } else
224 textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) ); 224 textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) );
225 225
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 0cf72c0..c3d92b6 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -369,3 +369,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
369 Address address; 369 Address address;
370 const QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); 370 const QStringList addrParts = splitString( semicolonSep, (*lineIt).valueString() );
371 if ( addrParts.count() > 0 ) 371 if ( addrParts.count() > 0 )
@@ -401,3 +401,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
401 else if ( identifier == "bday" ) 401 else if ( identifier == "bday" )
402 addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); 402 addr.setBirthday( parseDateTime( (*lineIt).valueString() ) );
403 403
@@ -405,3 +405,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
405 else if ( identifier == "categories" ) { 405 else if ( identifier == "categories" ) {
406 const QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); 406 const QStringList categories = splitString( commaSep, (*lineIt).valueString() );
407 addr.setCategories( categories ); 407 addr.setCategories( categories );
@@ -416,3 +416,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
416 const QStringList types = (*lineIt).parameters( "type" ); 416 const QStringList types = (*lineIt).parameters( "type" );
417 addr.insertEmail( (*lineIt).value().asString(), types.findIndex( "PREF" ) != -1 ); 417 addr.insertEmail( (*lineIt).valueString(), types.findIndex( "PREF" ) != -1 );
418 } 418 }
@@ -421,3 +421,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
421 else if ( identifier == "fn" ) 421 else if ( identifier == "fn" )
422 addr.setFormattedName( (*lineIt).value().asString() ); 422 addr.setFormattedName( (*lineIt).valueString() );
423 423
@@ -427,3 +427,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
427 427
428 const QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); 428 const QStringList geoParts = QStringList::split( ';', (*lineIt).valueString(), true );
429 geo.setLatitude( geoParts[ 0 ].toFloat() ); 429 geo.setLatitude( geoParts[ 0 ].toFloat() );
@@ -451,3 +451,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
451 if ( (*it).type() == type ) { 451 if ( (*it).type() == type ) {
452 (*it).setLabel( (*lineIt).value().asString() ); 452 (*it).setLabel( (*lineIt).valueString() );
453 addr.insertAddress( *it ); 453 addr.insertAddress( *it );
@@ -460,3 +460,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
460 KABC::Address address( type ); 460 KABC::Address address( type );
461 address.setLabel( (*lineIt).value().asString() ); 461 address.setLabel( (*lineIt).valueString() );
462 addr.insertAddress( address ); 462 addr.insertAddress( address );
@@ -471,3 +471,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
471 else if ( identifier == "mailer" ) 471 else if ( identifier == "mailer" )
472 addr.setMailer( (*lineIt).value().asString() ); 472 addr.setMailer( (*lineIt).valueString() );
473 473
@@ -475,3 +475,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
475 else if ( identifier == "n" ) { 475 else if ( identifier == "n" ) {
476 const QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); 476 const QStringList nameParts = splitString( semicolonSep, (*lineIt).valueString() );
477 if ( nameParts.count() > 0 ) 477 if ( nameParts.count() > 0 )
@@ -490,3 +490,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
490 else if ( identifier == "name" ) 490 else if ( identifier == "name" )
491 addr.setName( (*lineIt).value().asString() ); 491 addr.setName( (*lineIt).valueString() );
492 492
@@ -494,3 +494,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
494 else if ( identifier == "nickname" ) 494 else if ( identifier == "nickname" )
495 addr.setNickName( (*lineIt).value().asString() ); 495 addr.setNickName( (*lineIt).valueString() );
496 496
@@ -498,3 +498,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
498 else if ( identifier == "note" ) 498 else if ( identifier == "note" )
499 addr.setNote( (*lineIt).value().asString() ); 499 addr.setNote( (*lineIt).valueString() );
500 500
@@ -502,3 +502,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
502 else if ( identifier == "org" ) 502 else if ( identifier == "org" )
503 addr.setOrganization( (*lineIt).value().asString() ); 503 addr.setOrganization( (*lineIt).valueString() );
504 504
@@ -510,3 +510,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
510 else if ( identifier == "prodid" ) 510 else if ( identifier == "prodid" )
511 addr.setProductId( (*lineIt).value().asString() ); 511 addr.setProductId( (*lineIt).valueString() );
512 512
@@ -514,3 +514,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
514 else if ( identifier == "rev" ) 514 else if ( identifier == "rev" )
515 addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); 515 addr.setRevision( parseDateTime( (*lineIt).valueString() ) );
516 516
@@ -518,3 +518,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
518 else if ( identifier == "role" ) 518 else if ( identifier == "role" )
519 addr.setRole( (*lineIt).value().asString() ); 519 addr.setRole( (*lineIt).valueString() );
520 520
@@ -522,3 +522,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
522 else if ( identifier == "sort-string" ) 522 else if ( identifier == "sort-string" )
523 addr.setSortString( (*lineIt).value().asString() ); 523 addr.setSortString( (*lineIt).valueString() );
524 524
@@ -531,3 +531,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
531 PhoneNumber phone; 531 PhoneNumber phone;
532 phone.setNumber( (*lineIt).value().asString() ); 532 phone.setNumber( (*lineIt).valueString() );
533 533
@@ -546,3 +546,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
546 else if ( identifier == "title" ) 546 else if ( identifier == "title" )
547 addr.setTitle( (*lineIt).value().asString() ); 547 addr.setTitle( (*lineIt).valueString() );
548 548
@@ -551,3 +551,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
551 TimeZone tz; 551 TimeZone tz;
552 const QString date = (*lineIt).value().asString(); 552 const QString date = (*lineIt).valueString();
553 553
@@ -564,3 +564,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
564 else if ( identifier == "uid" ) 564 else if ( identifier == "uid" )
565 addr.setUid( (*lineIt).value().asString() ); 565 addr.setUid( (*lineIt).valueString() );
566 566
@@ -568,3 +568,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
568 else if ( identifier == "url" ) 568 else if ( identifier == "url" )
569 addr.setUrl( KURL( (*lineIt).value().asString() ) ); 569 addr.setUrl( KURL( (*lineIt).valueString() ) );
570 570
@@ -574,3 +574,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
574 int dash = key.find( "-" ); 574 int dash = key.find( "-" );
575 addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() ); 575 addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).valueString() );
576 } 576 }
@@ -638,3 +638,3 @@ Picture VCardTool::parsePicture( const VCardLine &line )
638 if ( line.parameter( "value" ).lower() == "uri" ) 638 if ( line.parameter( "value" ).lower() == "uri" )
639 pic.setUrl( line.value().asString() ); 639 pic.setUrl( line.valueString() );
640 } 640 }
@@ -657,3 +657,3 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi
657 s << pic.data(); 657 s << pic.data();
658 line.setValue( input ); 658 line.setValueBytes( input );
659 line.addParameter( "encoding", "b" ); 659 line.addParameter( "encoding", "b" );
@@ -663,3 +663,3 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi
663 QByteArray ba; 663 QByteArray ba;
664 line.setValue( pic.url() ); 664 line.setValueString( pic.url() );
665 line.addParameter( "value", "URI" ); 665 line.addParameter( "value", "URI" );
@@ -679,3 +679,3 @@ Sound VCardTool::parseSound( const VCardLine &line )
679 if ( line.parameter( "value" ).lower() == "uri" ) 679 if ( line.parameter( "value" ).lower() == "uri" )
680 snd.setUrl( line.value().asString() ); 680 snd.setUrl( line.valueString() );
681 } 681 }
@@ -696,3 +696,3 @@ VCardLine VCardTool::createSound( const Sound &snd )
696 if ( !snd.data().isEmpty() ) { 696 if ( !snd.data().isEmpty() ) {
697 line.setValue( snd.data() ); 697 line.setValueBytes( snd.data() );
698 line.addParameter( "encoding", "b" ); 698 line.addParameter( "encoding", "b" );
@@ -701,3 +701,3 @@ VCardLine VCardTool::createSound( const Sound &snd )
701 } else if ( !snd.url().isEmpty() ) { 701 } else if ( !snd.url().isEmpty() ) {
702 line.setValue( snd.url() ); 702 line.setValueString( snd.url() );
703 line.addParameter( "value", "URI" ); 703 line.addParameter( "value", "URI" );
@@ -716,3 +716,3 @@ Key VCardTool::parseKey( const VCardLine &line )
716 else 716 else
717 key.setTextData( line.value().asString() ); 717 key.setTextData( line.valueString() );
718 718
@@ -738,3 +738,3 @@ VCardLine VCardTool::createKey( const Key &key )
738 if ( !key.binaryData().isEmpty() ) { 738 if ( !key.binaryData().isEmpty() ) {
739 line.setValue( key.binaryData() ); 739 line.setValueBytes( key.binaryData() );
740 line.addParameter( "encoding", "b" ); 740 line.addParameter( "encoding", "b" );
@@ -742,3 +742,3 @@ VCardLine VCardTool::createKey( const Key &key )
742 } else if ( !key.textData().isEmpty() ) 742 } else if ( !key.textData().isEmpty() )
743 line.setValue( key.textData() ); 743 line.setValueString( key.textData() );
744 744
@@ -758,7 +758,7 @@ Secrecy VCardTool::parseSecrecy( const VCardLine &line )
758 758
759 if ( line.value().asString().lower() == "public" ) 759 if ( line.valueString().lower() == "public" )
760 secrecy.setType( Secrecy::Public ); 760 secrecy.setType( Secrecy::Public );
761 if ( line.value().asString().lower() == "private" ) 761 if ( line.valueString().lower() == "private" )
762 secrecy.setType( Secrecy::Private ); 762 secrecy.setType( Secrecy::Private );
763 if ( line.value().asString().lower() == "confidential" ) 763 if ( line.valueString().lower() == "confidential" )
764 secrecy.setType( Secrecy::Confidential ); 764 secrecy.setType( Secrecy::Confidential );
@@ -775,7 +775,7 @@ VCardLine VCardTool::createSecrecy( const Secrecy &secrecy )
775 if ( type == Secrecy::Public ) 775 if ( type == Secrecy::Public )
776 line.setValue( "PUBLIC" ); 776 line.setValueString( "PUBLIC" );
777 else if ( type == Secrecy::Private ) 777 else if ( type == Secrecy::Private )
778 line.setValue( "PRIVATE" ); 778 line.setValueString( "PRIVATE" );
779 else if ( type == Secrecy::Confidential ) 779 else if ( type == Secrecy::Confidential )
780 line.setValue( "CONFIDENTIAL" ); 780 line.setValueString( "CONFIDENTIAL" );
781 781
@@ -791,5 +791,5 @@ Agent VCardTool::parseAgent( const VCardLine &line )
791 if ( line.parameter( "value" ).lower() == "uri" ) 791 if ( line.parameter( "value" ).lower() == "uri" )
792 agent.setUrl( line.value().asString() ); 792 agent.setUrl( line.valueString() );
793 } else { 793 } else {
794 QString str = line.value().asString(); 794 QString str = line.valueString();
795 str.replace( QRegExp("\\\\n"), "\r\n" ); 795 str.replace( QRegExp("\\\\n"), "\r\n" );
@@ -825,6 +825,6 @@ VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent )
825 str.replace( QRegExp(","), "\\," ); 825 str.replace( QRegExp(","), "\\," );
826 line.setValue( str ); 826 line.setValueString( str );
827 } 827 }
828 } else if ( !agent.url().isEmpty() ) { 828 } else if ( !agent.url().isEmpty() ) {
829 line.setValue( agent.url() ); 829 line.setValueString( agent.url() );
830 line.addParameter( "value", "URI" ); 830 line.addParameter( "value", "URI" );