-rw-r--r-- | kabc/addressee.cpp | 75 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 32 | ||||
-rw-r--r-- | kabc/phonenumber.h | 1 |
3 files changed, 62 insertions, 46 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index cb10160..2aca559 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -294,34 +294,35 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | if ( isSubSet ) { | 302 | if ( isSubSet ) { |
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( (*it) == ( *phoneItAD ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | ||
312 | break; | 313 | break; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | if ( ! found ) | 316 | if ( ! found ) |
316 | mData->phoneNumbers.append( *phoneItAD ); | 317 | mData->phoneNumbers.append( *phoneItAD ); |
317 | } | 318 | } |
318 | // ************* emails; | 319 | // ************* emails; |
319 | t = mData->emails; | 320 | t = mData->emails; |
320 | tAD = ad.mData->emails; | 321 | tAD = ad.mData->emails; |
321 | for ( iii = 0; iii < tAD.count(); ++iii) | 322 | for ( iii = 0; iii < tAD.count(); ++iii) |
322 | if ( !t.contains(tAD[iii] ) ) | 323 | if ( !t.contains(tAD[iii] ) ) |
323 | mData->emails.append( tAD[iii] ); | 324 | mData->emails.append( tAD[iii] ); |
324 | // ************* categories; | 325 | // ************* categories; |
325 | t = mData->categories; | 326 | t = mData->categories; |
326 | tAD = ad.mData->categories; | 327 | tAD = ad.mData->categories; |
327 | for ( iii = 0; iii < tAD.count(); ++iii) | 328 | for ( iii = 0; iii < tAD.count(); ++iii) |
@@ -345,74 +346,66 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
345 | if ( ! found ) { | 346 | if ( ! found ) { |
346 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
351 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
352 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
353 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
354 | } | 355 | } |
355 | } | 356 | } |
356 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
357 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
358 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | 362 | { | |
362 | #if 0 | 363 | Key::List::Iterator itA; |
363 | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | |
364 | if ( mData->url.isValid() ) | 365 | bool found = false; |
365 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 366 | Key::List::Iterator it; |
366 | KABC::PhoneNumber::List phoneNumbers; | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
367 | KABC::PhoneNumber::List::Iterator phoneIter; | 368 | if ( (*it) == (*itA)) { |
368 | 369 | found = true; | |
369 | QStringList t; | 370 | break; |
370 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 371 | |
371 | ++phoneIter ) | 372 | } |
372 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 373 | } |
373 | t.sort(); | 374 | if ( ! found ) { |
374 | uint iii; | 375 | mData->keys.append( *itA ); |
375 | for ( iii = 0; iii < t.count(); ++iii) | 376 | } |
376 | l.append( t[iii] ); | 377 | } |
377 | t = mData->emails; | ||
378 | t.sort(); | ||
379 | for ( iii = 0; iii < t.count(); ++iii) | ||
380 | l.append( t[iii] ); | ||
381 | t = mData->categories; | ||
382 | t.sort(); | ||
383 | for ( iii = 0; iii < t.count(); ++iii) | ||
384 | l.append( t[iii] ); | ||
385 | t = mData->custom; | ||
386 | t.sort(); | ||
387 | for ( iii = 0; iii < t.count(); ++iii) | ||
388 | l.append( t[iii] ); | ||
389 | KABC::Address::List::Iterator addressIter; | ||
390 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
391 | ++addressIter ) { | ||
392 | t = (*addressIter).asList(); | ||
393 | t.sort(); | ||
394 | for ( iii = 0; iii < t.count(); ++iii) | ||
395 | l.append( t[iii] ); | ||
396 | } | 378 | } |
379 | KABC::Address::List::Iterator addressIterA; | ||
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | ||
381 | bool found = false; | ||
382 | KABC::Address::List::Iterator addressIter; | ||
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
384 | ++addressIter ) { | ||
385 | if ( (*addressIter) == (*addressIterA)) { | ||
386 | found = true; | ||
387 | (*addressIter).setType( (*addressIterA).type() ); | ||
388 | break; | ||
389 | } | ||
397 | 390 | ||
398 | #endif | 391 | } |
399 | 392 | if ( ! found ) { | |
400 | // pending: | 393 | mData->addresses.append( *addressIterA ); |
401 | // merging addresses | 394 | } |
402 | // merging keys | 395 | } |
403 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
404 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
405 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
406 | } | 399 | } |
407 | 400 | ||
408 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
409 | { | 402 | { |
410 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
411 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
412 | bool found = false; | 405 | bool found = false; |
413 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
414 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
415 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
416 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
417 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
418 | found = true; | 411 | found = true; |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index d7e3925..3d82553 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -68,38 +68,60 @@ bool PhoneNumber::operator!=( const PhoneNumber &p ) const | |||
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | 69 | bool PhoneNumber::simplifyNumber() |
70 | { | 70 | { |
71 | QString Number; | 71 | QString Number; |
72 | int i; | 72 | int i; |
73 | Number = mNumber.stripWhiteSpace (); | 73 | Number = mNumber.stripWhiteSpace (); |
74 | mNumber = ""; | 74 | mNumber = ""; |
75 | for ( i = 0; i < Number.length(); ++i) { | 75 | for ( i = 0; i < Number.length(); ++i) { |
76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | 76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) |
77 | mNumber += Number.at(i); | 77 | mNumber += Number.at(i); |
78 | } | 78 | } |
79 | return ( mNumber.length() > 0 ); | 79 | return ( mNumber.length() > 0 ); |
80 | } | 80 | } |
81 | // make cellphone compatible | 81 | // make cellphone compatible |
82 | void PhoneNumber::simplifyType() | 82 | void PhoneNumber::simplifyType() |
83 | { | 83 | { |
84 | if ( mType & Fax ) mType = Fax; | 84 | if ( mType & Fax ) mType = Fax; |
85 | else if ( mType & Cell ) mType = Cell; | 85 | else if ( mType & Cell ) mType = Cell; |
86 | else if ( mType & Work ) mType = Work ; | 86 | else if ( mType & Work ) mType = Work ; |
87 | else if ( mType & Home ) mType = Home; | 87 | else if ( mType & Home ) mType = Home; |
88 | else mType = Pref; | 88 | else mType = Pref; |
89 | } | 89 | } |
90 | bool PhoneNumber::contains( const PhoneNumber &p ) | ||
91 | { | ||
92 | QString Number; | ||
93 | QString Num; | ||
94 | uint i; | ||
95 | Number = mNumber.stripWhiteSpace (); | ||
96 | Num = ""; | ||
97 | for ( i = 0; i < Number.length(); ++i) { | ||
98 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | ||
99 | Num += Number.at(i); | ||
100 | } | ||
101 | QString NumberR; | ||
102 | QString NumR; | ||
103 | NumberR = p.mNumber.stripWhiteSpace (); | ||
104 | NumR = ""; | ||
105 | for ( i = 0; i < NumberR.length(); ++i) { | ||
106 | if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' ) | ||
107 | NumR += NumberR.at(i); | ||
108 | } | ||
109 | return (Num == NumR); | ||
110 | } | ||
111 | |||
90 | void PhoneNumber::setId( const QString &id ) | 112 | void PhoneNumber::setId( const QString &id ) |
91 | { | 113 | { |
92 | mId = id; | 114 | mId = id; |
93 | } | 115 | } |
94 | 116 | ||
95 | QString PhoneNumber::id() const | 117 | QString PhoneNumber::id() const |
96 | { | 118 | { |
97 | return mId; | 119 | return mId; |
98 | } | 120 | } |
99 | 121 | ||
100 | void PhoneNumber::setNumber( const QString &number ) | 122 | void PhoneNumber::setNumber( const QString &number ) |
101 | { | 123 | { |
102 | mNumber = number; | 124 | mNumber = number; |
103 | } | 125 | } |
104 | 126 | ||
105 | QString PhoneNumber::number() const | 127 | QString PhoneNumber::number() const |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 410a52f..2d4d3e0 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -79,32 +79,33 @@ class PhoneNumber | |||
79 | Create a phonenumber object. | 79 | Create a phonenumber object. |
80 | 80 | ||
81 | @param number Number | 81 | @param number Number |
82 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
83 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
84 | */ | 84 | */ |
85 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
91 | 91 | ||
92 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
93 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
94 | 94 | ||
95 | bool contains( const PhoneNumber &p ); | ||
95 | /** | 96 | /** |
96 | Sets the unique identifier. | 97 | Sets the unique identifier. |
97 | */ | 98 | */ |
98 | void setId( const QString &id ); | 99 | void setId( const QString &id ); |
99 | 100 | ||
100 | /** | 101 | /** |
101 | Returns the unique identifier. | 102 | Returns the unique identifier. |
102 | */ | 103 | */ |
103 | QString id() const; | 104 | QString id() const; |
104 | 105 | ||
105 | /** | 106 | /** |
106 | Sets the number. | 107 | Sets the number. |
107 | */ | 108 | */ |
108 | void setNumber( const QString & ); | 109 | void setNumber( const QString & ); |
109 | 110 | ||
110 | /** | 111 | /** |