-rw-r--r-- | kabc/addressee.cpp | 32 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 23 | ||||
-rw-r--r-- | kabc/phonenumber.h | 2 |
4 files changed, 61 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 25c77f6..e571980 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -314,8 +314,40 @@ void Addressee::mergeContact( const Addressee& ad ) | |||
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | // removes all emails but the first | ||
319 | // needed by phone sync | ||
320 | void Addressee::simplifyEmails() | ||
321 | { | ||
322 | if ( mData->emails.count() == 0 ) return ; | ||
323 | QString email = mData->emails.first(); | ||
324 | detach(); | ||
325 | mData->emails.clear(); | ||
326 | mData->emails.append( email ); | ||
327 | } | ||
328 | |||
329 | void Addressee::simplifyPhoneNumbers() | ||
330 | { | ||
331 | KABC::PhoneNumber::List removeNumbers; | ||
332 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
333 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
334 | ++phoneIter ) { | ||
335 | if ( ! ( *phoneIter ).simplifyNumber() ) | ||
336 | removeNumbers.append( ( *phoneIter ) ); | ||
337 | } | ||
338 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
339 | ++phoneIter ) { | ||
340 | removePhoneNumber(( *phoneIter )); | ||
341 | } | ||
342 | } | ||
343 | void Addressee::simplifyPhoneNumberTypes() | ||
344 | { | ||
345 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
346 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
347 | ++phoneIter ) | ||
348 | ( *phoneIter ).simplifyType(); | ||
349 | } | ||
318 | void Addressee::removeID(const QString &prof) | 350 | void Addressee::removeID(const QString &prof) |
319 | { | 351 | { |
320 | detach(); | 352 | detach(); |
321 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 353 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 8baa888..4cafa86 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -116,8 +116,12 @@ class Addressee | |||
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(); | ||
121 | void simplifyPhoneNumbers(); | ||
122 | void simplifyPhoneNumberTypes(); | ||
123 | |||
120 | /** | 124 | /** |
121 | Set unique identifier. | 125 | Set unique identifier. |
122 | */ | 126 | */ |
123 | void setUid( const QString &uid ); | 127 | void setUid( const QString &uid ); |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 7aeb2ee..e5abc0e 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -65,8 +65,31 @@ bool PhoneNumber::operator!=( const PhoneNumber &p ) const | |||
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | ||
70 | { | ||
71 | QString Number; | ||
72 | int i; | ||
73 | Number = mNumber.stripWhiteSpace (); | ||
74 | mNumber = ""; | ||
75 | if ( Number.at(0) == '+' ) | ||
76 | mNumber += "+"; | ||
77 | for ( i = 0; i < Number.length(); ++i) { | ||
78 | if ( Number.at(i).isDigit() ) | ||
79 | mNumber += Number.at(i); | ||
80 | } | ||
81 | return ( mNumber.length() > 0 ); | ||
82 | } | ||
83 | // make cellphone compatible | ||
84 | void PhoneNumber::simplifyType() | ||
85 | { | ||
86 | if ( mType & Fax ) mType = Fax; | ||
87 | else if ( mType & Cell ) mType = Cell; | ||
88 | else if ( mType & Work ) mType = Work ; | ||
89 | else if ( mType & Home ) mType = Home; | ||
90 | else mType = Pref; | ||
91 | } | ||
69 | void PhoneNumber::setId( const QString &id ) | 92 | void PhoneNumber::setId( const QString &id ) |
70 | { | 93 | { |
71 | mId = id; | 94 | mId = id; |
72 | } | 95 | } |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 1df344f..410a52f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -147,8 +147,10 @@ class PhoneNumber | |||
147 | Returns the translated label for phone number type. | 147 | Returns the translated label for phone number type. |
148 | @obsolete | 148 | @obsolete |
149 | */ | 149 | */ |
150 | static QString label( int type ); | 150 | static QString label( int type ); |
151 | bool simplifyNumber(); | ||
152 | void simplifyType(); | ||
151 | 153 | ||
152 | private: | 154 | private: |
153 | void init(); | 155 | void init(); |
154 | 156 | ||