-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 9 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index 0cd2086..5fca3bc 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp @@ -24,99 +24,106 @@ #include <qregexp.h> #include <VCardDefines.h> #include <VCardVCardEntity.h> using namespace VCARD; VCardEntity::VCardEntity() : Entity() { cardList_.setAutoDelete( TRUE ); } VCardEntity::VCardEntity(const VCardEntity & x) : Entity(x) { cardList_.setAutoDelete( TRUE ); } VCardEntity::VCardEntity(const QCString & s) : Entity(s) { cardList_.setAutoDelete( TRUE ); } VCardEntity & VCardEntity::operator = (VCardEntity & x) { if (*this == x) return *this; Entity::operator = (x); return *this; } VCardEntity & VCardEntity::operator = (const QCString & s) { Entity::operator = (s); return *this; } bool VCardEntity::operator == (VCardEntity & x) { x.parse(); return false; } VCardEntity::~VCardEntity() { } void VCardEntity::_parse() { vDebug("parse"); QCString s(strRep_); int i = s.find(QRegExp("BEGIN:VCARD", false)); while (i != -1) { i = s.find(QRegExp("BEGIN:VCARD", false), 11); QCString cardStr(s.left(i)); VCard * v = new VCard(cardStr); cardList_.append(v); v->parse(); s.remove(0, i); } } void VCardEntity::_assemble() { VCardListIterator it(cardList_); for (; it.current(); ++it) strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. } VCardList & VCardEntity::cardList() { parse(); return cardList_; } void VCardEntity::setCardList(const VCardList & l) { parse(); - cardList_ = l; +//US cardList_ = l; + VCardListIterator it(l); + + for (; it.current(); ++it) { + VCard* v = new VCard(*it.current()); + cardList_.append(v); + } + } diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index bd9a57b..bffaa64 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp @@ -190,194 +190,194 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) case EntityNote: addressee.setNote( readTextValue( cl ) ); break; case EntityProductID: addressee.setProductId( readTextValue( cl ) ); break; case EntitySortString: addressee.setSortString( readTextValue( cl ) ); break; case EntityN: readNValue( cl, addressee ); break; case EntityAddress: addressee.insertAddress( readAddressValue( cl ) ); break; case EntityTelephone: addressee.insertPhoneNumber( readTelephoneValue( cl ) ); break; case EntityCategories: addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); break; case EntityBirthday: addressee.setBirthday( readDateValue( cl ) ); break; case EntityRevision: addressee.setRevision( readDateTimeValue( cl ) ); break; case EntityGeo: addressee.setGeo( readGeoValue( cl ) ); break; case EntityTimeZone: addressee.setTimeZone( readUTCValue( cl ) ); break; case EntityVersion: break; case EntityClass: addressee.setSecrecy( readClassValue( cl ) ); break; case EntityKey: addressee.insertKey( readKeyValue( cl ) ); break; case EntityPhoto: addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); break; case EntityLogo: addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); break; case EntityAgent: addressee.setAgent( readAgentValue( cl ) ); break; case EntitySound: addressee.setSound( readSoundValue( cl, addressee ) ); break; default: kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " << int( type ) << ": " << cl->asString() << endl; break; } } for( cl = contentLines.first(); cl; cl = contentLines.next() ) { EntityType type = cl->entityType(); if ( type == EntityLabel ) { int type = readAddressParam( cl ); Address address = addressee.address( type ); if ( address.isEmpty() ) address.setType( type ); address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); addressee.insertAddress( address ); } } return true; } void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) { - ContentLine cl; - QString value; +//US ContentLine cl; +//US QString value; addTextValue( v, EntityName, addressee.name() ); addTextValue( v, EntityUID, addressee.uid() ); addTextValue( v, EntityFullName, addressee.formattedName() ); QStringList emails = addressee.emails(); QStringList::ConstIterator it4; for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { addTextValue( v, EntityEmail, *it4 ); } QStringList customs = addressee.customs(); QStringList::ConstIterator it5; for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { addCustomValue( v, *it5 ); } addTextValue( v, EntityURL, addressee.url().url() ); addNValue( v, addressee ); addTextValue( v, EntityNickname, addressee.nickName() ); addTextValue( v, EntityMailer, addressee.mailer() ); addTextValue( v, EntityTitle, addressee.title() ); addTextValue( v, EntityRole, addressee.role() ); addTextValue( v, EntityOrganisation, addressee.organization() ); addTextValue( v, EntityNote, addressee.note() ); addTextValue( v, EntityProductID, addressee.productId() ); addTextValue( v, EntitySortString, addressee.sortString() ); Address::List addresses = addressee.addresses(); Address::List::ConstIterator it3; for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { addAddressValue( v, *it3 ); addLabelValue( v, *it3 ); } PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); PhoneNumber::List::ConstIterator it2; for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { addTelephoneValue( v, *it2 ); } Key::List keys = addressee.keys(); Key::List::ConstIterator it6; for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { addKeyValue( v, *it6 ); } addTextValue( v, EntityCategories, addressee.categories().join(",") ); addDateValue( v, EntityBirthday, addressee.birthday().date() ); addDateTimeValue( v, EntityRevision, addressee.revision() ); addGeoValue( v, addressee.geo() ); addUTCValue( v, addressee.timeZone() ); addClassValue( v, addressee.secrecy() ); addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); addAgentValue( v, addressee.agent() ); addSoundValue( v, addressee.sound(), addressee, intern ); } void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) { if ( txt.isEmpty() ) return; ContentLine cl; cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); QString value = txt.mid( txt.find( ":" ) + 1 ); if ( value.isEmpty() ) return; cl.setValue( new TextValue( value.utf8() ) ); v->add(cl); } void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) { if ( txt.isEmpty() ) return; ContentLine cl; cl.setName( EntityTypeToParamName( type ) ); cl.setValue( new TextValue( txt.utf8() ) ); v->add(cl); } void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, const QDate &date ) { if ( !date.isValid() ) return; ContentLine cl; cl.setName( EntityTypeToParamName( type ) ); |