-rw-r--r-- | kabc/vcard21parser.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index 60d02b8..e24a9dc 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp | |||
@@ -27,6 +27,8 @@ $Id$ | |||
27 | 27 | ||
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | //Added by qt3to4: | ||
31 | #include <Q3ValueList> | ||
30 | #include <kmdcodec.h> | 32 | #include <kmdcodec.h> |
31 | 33 | ||
32 | #include "vcard21parser.h" | 34 | #include "vcard21parser.h" |
@@ -45,7 +47,7 @@ bool VCardLineX::isValid() const | |||
45 | 47 | ||
46 | // This is long but it makes it a bit faster (and saves me from using | 48 | // This is long but it makes it a bit faster (and saves me from using |
47 | // a tree which is probably the ideal situation, but a bit memory heavy) | 49 | // a tree which is probably the ideal situation, but a bit memory heavy) |
48 | switch( name[0] ) { | 50 | switch( name[0].unicode() ) { |
49 | case 'a': | 51 | case 'a': |
50 | if ( name == VCARD_ADR && qualified && | 52 | if ( name == VCARD_ADR && qualified && |
51 | (qualifiers.contains(VCARD_ADR_DOM) || | 53 | (qualifiers.contains(VCARD_ADR_DOM) || |
@@ -269,7 +271,7 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) | |||
269 | addressee.setBirthday(VCardStringToDate(tmpStr)); | 271 | addressee.setBirthday(VCardStringToDate(tmpStr)); |
270 | 272 | ||
271 | //set the addressee's phone numbers | 273 | //set the addressee's phone numbers |
272 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 274 | for ( Q3ValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
273 | if ( (*i).name == VCARD_TEL ) { | 275 | if ( (*i).name == VCARD_TEL ) { |
274 | int type = 0; | 276 | int type = 0; |
275 | if ( (*i).qualified ) { | 277 | if ( (*i).qualified ) { |
@@ -308,7 +310,7 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) | |||
308 | } | 310 | } |
309 | addressee.makePhoneNumbersOLcompatible(); | 311 | addressee.makePhoneNumbersOLcompatible(); |
310 | //set the addressee's addresses | 312 | //set the addressee's addresses |
311 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 313 | for ( Q3ValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
312 | if ( (*i).name == VCARD_ADR ) { | 314 | if ( (*i).name == VCARD_ADR ) { |
313 | int type = 0; | 315 | int type = 0; |
314 | if ( (*i).qualified ) { | 316 | if ( (*i).qualified ) { |
@@ -327,7 +329,10 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) | |||
327 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) | 329 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) |
328 | type |= Address::Pref; | 330 | type |= Address::Pref; |
329 | } | 331 | } |
330 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); | 332 | QStringList tmp; |
333 | for(Q3ValueList<QString>::const_iterator ii=(*i).parameters.begin();ii!=(*i).parameters.end();++ii) | ||
334 | tmp.push_back(*ii); | ||
335 | addressee.insertAddress( readAddressFromQStringList( tmp, type ) ); | ||
331 | } | 336 | } |
332 | } | 337 | } |
333 | 338 | ||
@@ -408,10 +413,10 @@ VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) | |||
408 | int _err = 0; | 413 | int _err = 0; |
409 | int _state = VC_STATE_BEGIN; | 414 | int _state = VC_STATE_BEGIN; |
410 | 415 | ||
411 | QValueList<VCardLineX> *_vcdata; | 416 | Q3ValueList<VCardLineX> *_vcdata; |
412 | QValueList<QString> lines; | 417 | QStringList lines; |
413 | 418 | ||
414 | _vcdata = new QValueList<VCardLineX>; | 419 | _vcdata = new Q3ValueList<VCardLineX>; |
415 | 420 | ||
416 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); | 421 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); |
417 | 422 | ||
@@ -501,8 +506,8 @@ VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) | |||
501 | } | 506 | } |
502 | _vcl.parameters = QStringList::split( ';', value, true ); | 507 | _vcl.parameters = QStringList::split( ';', value, true ); |
503 | if ( qp ) { // decode the quoted printable | 508 | if ( qp ) { // decode the quoted printable |
504 | for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) | 509 | for ( QLinkedList<QString>::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) |
505 | *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); | 510 | *z = KCodecs::quotedPrintableDecode( (Q3CString)(*z).latin1() ); |
506 | } | 511 | } |
507 | } | 512 | } |
508 | } else { | 513 | } else { |
@@ -543,7 +548,7 @@ VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) | |||
543 | return new VCard21ParserImpl( _vcdata ); | 548 | return new VCard21ParserImpl( _vcdata ); |
544 | } | 549 | } |
545 | 550 | ||
546 | VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) | 551 | VCard21ParserImpl::VCard21ParserImpl(Q3ValueList<VCardLineX> *_vcd) : _vcdata(_vcd) |
547 | { | 552 | { |
548 | } | 553 | } |
549 | 554 | ||
@@ -554,7 +559,7 @@ QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifie | |||
554 | const QString lowname = name.lower(); | 559 | const QString lowname = name.lower(); |
555 | const QString lowqualifier = qualifier.lower(); | 560 | const QString lowqualifier = qualifier.lower(); |
556 | 561 | ||
557 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 562 | for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
558 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { | 563 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { |
559 | if ((*i).parameters.count() > 0) | 564 | if ((*i).parameters.count() > 0) |
560 | return (*i).parameters[0]; | 565 | return (*i).parameters[0]; |
@@ -570,7 +575,7 @@ QString VCard21ParserImpl::getValue(const QString& name) | |||
570 | QString failed; | 575 | QString failed; |
571 | const QString lowname = name.lower(); | 576 | const QString lowname = name.lower(); |
572 | 577 | ||
573 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 578 | for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
574 | if ((*i).name == lowname && !(*i).qualified) { | 579 | if ((*i).name == lowname && !(*i).qualified) { |
575 | if ((*i).parameters.count() > 0) | 580 | if ((*i).parameters.count() > 0) |
576 | return (*i).parameters[0]; | 581 | return (*i).parameters[0]; |
@@ -584,9 +589,10 @@ QString VCard21ParserImpl::getValue(const QString& name) | |||
584 | QStringList VCard21ParserImpl::getValues(const QString& name) | 589 | QStringList VCard21ParserImpl::getValues(const QString& name) |
585 | { | 590 | { |
586 | const QString lowname = name.lower(); | 591 | const QString lowname = name.lower(); |
587 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 592 | for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
588 | if ((*i).name == lowname && !(*i).qualified) | 593 | if ((*i).name == lowname && !(*i).qualified) { |
589 | return (*i).parameters; | 594 | return QStringList( (*i).parameters ); |
595 | } | ||
590 | } | 596 | } |
591 | // failed. | 597 | // failed. |
592 | return QStringList(); | 598 | return QStringList(); |
@@ -596,9 +602,9 @@ QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qua | |||
596 | { | 602 | { |
597 | const QString lowname = name.lower(); | 603 | const QString lowname = name.lower(); |
598 | const QString lowqualifier = qualifier.lower(); | 604 | const QString lowqualifier = qualifier.lower(); |
599 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 605 | for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
600 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) | 606 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) |
601 | return (*i).parameters; | 607 | return QStringList( (*i).parameters ); |
602 | } | 608 | } |
603 | // failed. | 609 | // failed. |
604 | return QStringList(); | 610 | return QStringList(); |