-rw-r--r-- | kabc/addressee.cpp | 28 | ||||
-rw-r--r-- | kabc/addressee.h | 2 |
2 files changed, 17 insertions, 13 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 711c261..0157721 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -244,78 +244,82 @@ void Addressee::computeCsum(const QString &dev) for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); t.sort(); uint iii; for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->emails; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->categories; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->custom; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); KABC::Address::List::Iterator addressIter; for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); ++addressIter ) { t = (*addressIter).asList(); t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); } uint cs = getCsum4List(l); // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); setCsum( dev, QString::number (cs )); } -void Addressee::mergeContact( Addressee ad ) +void Addressee::mergeContact( const Addressee& ad ) { + + detach(); + if ( mData->name.isEmpty() ) mData->name = ad.mData->name; + if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; + if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; + if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; + if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; + if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; + if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; + if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; + if ( !mData->birthday.isValid() ) + if ( ad.mData->birthday.isValid()) + mData->birthday = ad.mData->birthday; + if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; #if 0 - if ( !mData->name.isEmpty() ) l.append(mData->name); - if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); - if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); - if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); - if ( !mData->additionalName ) l.append( mData->additionalName ); - if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); - if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); - if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); - if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); - if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); - if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); + if ( !mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); if ( !mData->title .isEmpty() ) l.append( mData->title ); if ( !mData->role.isEmpty() ) l.append( mData->role ); if ( !mData->organization.isEmpty() ) l.append( mData->organization ); if ( !mData->note.isEmpty() ) l.append( mData->note ); if ( !mData->productId.isEmpty() ) l.append(mData->productId ); if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); #endif } void Addressee::removeID(const QString &prof) { detach(); mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); } void Addressee::setTempSyncStat( int id ) { if ( mData->mTempSyncStat == id ) return; detach(); mData->mTempSyncStat = id; } int Addressee::tempSyncStat() const { return mData->mTempSyncStat; diff --git a/kabc/addressee.h b/kabc/addressee.h index 59fcbd8..3ba7777 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -85,65 +85,65 @@ class Addressee public: typedef QValueList<Addressee> List; /** Construct an empty address book entry. */ Addressee(); ~Addressee(); Addressee( const Addressee & ); Addressee &operator=( const Addressee & ); bool operator==( const Addressee & ) const; bool operator!=( const Addressee & ) const; // sync stuff void setTempSyncStat(int id); int tempSyncStat() const; void setIDStr( const QString & ); QString IDStr() const; void setID( const QString &, const QString & ); QString getID( const QString & ); void setCsum( const QString &, const QString & ); QString getCsum( const QString & ); void removeID(const QString &); void computeCsum(const QString &dev); ulong getCsum4List( const QStringList & attList); /** Return, if the address book entry is empty. */ bool isEmpty() const; void setExternalUID( const QString &id ); QString externalUID() const; - void mergeContact( Addressee ad ); + void mergeContact( const Addressee& ad ); /** Set unique identifier. */ void setUid( const QString &uid ); /** Return unique identifier. */ QString uid() const; /** Return translated label for uid field. */ static QString uidLabel(); /** Set name. */ void setName( const QString &name ); /** Return name. */ QString name() const; /** Return translated label for name field. */ static QString nameLabel(); /** Set formatted name. */ void setFormattedName( const QString &formattedName ); /** Return formatted name. |