-rw-r--r-- | kabc/addressee.cpp | 16 | ||||
-rw-r--r-- | kabc/addressee.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index e571980..19a1845 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -302,32 +302,48 @@ void Addressee::mergeContact( const Addressee& ad ) | |||
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Addressee::simplifyAddresses() | ||
319 | { | ||
320 | if ( mData->addresses.count() < 3 ) return ; | ||
321 | int count = 0; | ||
322 | Address::List list; | ||
323 | Address::List::Iterator it; | ||
324 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
325 | if ( count > 1 ) | ||
326 | list.append( *it ); | ||
327 | ++count; | ||
328 | } | ||
329 | for( it = list.begin(); it != list.end(); ++it ) { | ||
330 | removeAddress( (*it) ); | ||
331 | } | ||
332 | } | ||
333 | |||
318 | // removes all emails but the first | 334 | // removes all emails but the first |
319 | // needed by phone sync | 335 | // needed by phone sync |
320 | void Addressee::simplifyEmails() | 336 | void Addressee::simplifyEmails() |
321 | { | 337 | { |
322 | if ( mData->emails.count() == 0 ) return ; | 338 | if ( mData->emails.count() == 0 ) return ; |
323 | QString email = mData->emails.first(); | 339 | QString email = mData->emails.first(); |
324 | detach(); | 340 | detach(); |
325 | mData->emails.clear(); | 341 | mData->emails.clear(); |
326 | mData->emails.append( email ); | 342 | mData->emails.append( email ); |
327 | } | 343 | } |
328 | 344 | ||
329 | void Addressee::simplifyPhoneNumbers() | 345 | void Addressee::simplifyPhoneNumbers() |
330 | { | 346 | { |
331 | KABC::PhoneNumber::List removeNumbers; | 347 | KABC::PhoneNumber::List removeNumbers; |
332 | KABC::PhoneNumber::List::Iterator phoneIter; | 348 | KABC::PhoneNumber::List::Iterator phoneIter; |
333 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 349 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 4cafa86..44f0629 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -105,32 +105,33 @@ class Addressee | |||
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | ||
121 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
122 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
123 | 124 | ||
124 | /** | 125 | /** |
125 | Set unique identifier. | 126 | Set unique identifier. |
126 | */ | 127 | */ |
127 | void setUid( const QString &uid ); | 128 | void setUid( const QString &uid ); |
128 | /** | 129 | /** |
129 | Return unique identifier. | 130 | Return unique identifier. |
130 | */ | 131 | */ |
131 | QString uid() const; | 132 | QString uid() const; |
132 | /** | 133 | /** |
133 | Return translated label for uid field. | 134 | Return translated label for uid field. |
134 | */ | 135 | */ |
135 | static QString uidLabel(); | 136 | static QString uidLabel(); |
136 | 137 | ||