Diffstat (limited to 'kabc/vcardparser/vcardtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 01c5b3e..71f29d7 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp @@ -82,51 +82,62 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) address.append( (*it).extended().replace( ';', "\\;" ) ); address.append( (*it).street().replace( ';', "\\;" ) ); address.append( (*it).locality().replace( ';', "\\;" ) ); address.append( (*it).region().replace( ';', "\\;" ) ); address.append( (*it).postalCode().replace( ';', "\\;" ) ); address.append( (*it).country().replace( ';', "\\;" ) ); */ //US using the old implementation instead //qDebug("VCardTool::createVCards has to be verified"); address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); VCardLine adrLine( "ADR", address.join( ";" ) ); VCardLine labelLine( "LABEL", (*it).label() ); bool hasLabel = !(*it).label().isEmpty(); QMap<QString, int>::Iterator typeIt; for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { if ( typeIt.data() & (*it).type() ) { - adrLine.addParameter( "TYPE", typeIt.key() ); - if ( hasLabel ) - labelLine.addParameter( "TYPE", typeIt.key() ); + if ( version == VCard::v3_0 ) { + adrLine.addParameter( "TYPE", typeIt.key().lower() ); + } + else { + adrLine.addParameter( "TYPE", typeIt.key() ); + } + if ( hasLabel ) { + if ( version == VCard::v3_0 ) { + labelLine.addParameter( "TYPE", typeIt.key().lower() ); + } + else { + labelLine.addParameter( "TYPE", typeIt.key() ); + } + } } } card.addLine( adrLine ); if ( hasLabel ) card.addLine( labelLine ); } // AGENT card.addLine( createAgent( version, (*addrIt).agent() ) ); // BDAY card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); // CATEGORIES if ( version == VCard::v3_0 ) { QStringList categories = (*addrIt).categories(); QStringList::Iterator catIt; for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { //US using the old implementation instead // qDebug("VCardTool::createVCards has to be verified"); //US (*catIt).replace( ',', "\\," ); (*catIt).replace( QRegExp(","), "\\," ); @@ -212,49 +223,52 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); // REV card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); // ROLE card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); // SORT-STRING if ( version == VCard::v3_0 ) card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); // SOUND card.addLine( createSound( (*addrIt).sound() ) ); // TEL PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); PhoneNumber::List::ConstIterator phoneIt; for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { VCardLine line( "TEL", (*phoneIt).number() ); QMap<QString, int>::Iterator typeIt; for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { if ( typeIt.data() & (*phoneIt).type() ) - line.addParameter( "TYPE", typeIt.key() ); + if ( version == VCard::v3_0 ) + line.addParameter( "TYPE", typeIt.key().lower() ); + else + line.addParameter( "TYPE", typeIt.key() ); } card.addLine( line ); } // TITLE card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); // TZ TimeZone timeZone = (*addrIt).timeZone(); if ( timeZone.isValid() ) { QString str; int neg = 1; if ( timeZone.offset() < 0 ) neg = -1; str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), ( timeZone.offset() / 60 ) * neg, ( timeZone.offset() % 60 ) * neg ); card.addLine( VCardLine( "TZ", str ) ); } |