author | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
commit | c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff) | |
tree | b83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /kabc/addressee.cpp | |
parent | 07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff) | |
download | kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2 |
import ir fixes
-rw-r--r-- | kabc/addressee.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 19a1845..3f3d5c0 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -222,192 +222,209 @@ void Addressee::computeCsum(const QString &dev) | |||
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
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 | bool Addressee::removeVoice() | ||
319 | { | ||
320 | PhoneNumber::List phoneN = phoneNumbers(); | ||
321 | PhoneNumber::List::Iterator phoneIt; | ||
322 | bool found = false; | ||
323 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | ||
324 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | ||
325 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | ||
326 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | ||
327 | insertPhoneNumber( (*phoneIt) ); | ||
328 | found = true; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | } | ||
333 | return found; | ||
334 | } | ||
318 | void Addressee::simplifyAddresses() | 335 | void Addressee::simplifyAddresses() |
319 | { | 336 | { |
320 | if ( mData->addresses.count() < 3 ) return ; | 337 | if ( mData->addresses.count() < 3 ) return ; |
321 | int count = 0; | 338 | int count = 0; |
322 | Address::List list; | 339 | Address::List list; |
323 | Address::List::Iterator it; | 340 | Address::List::Iterator it; |
324 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
325 | if ( count > 1 ) | 342 | if ( count > 1 ) |
326 | list.append( *it ); | 343 | list.append( *it ); |
327 | ++count; | 344 | ++count; |
328 | } | 345 | } |
329 | for( it = list.begin(); it != list.end(); ++it ) { | 346 | for( it = list.begin(); it != list.end(); ++it ) { |
330 | removeAddress( (*it) ); | 347 | removeAddress( (*it) ); |
331 | } | 348 | } |
332 | } | 349 | } |
333 | 350 | ||
334 | // removes all emails but the first | 351 | // removes all emails but the first |
335 | // needed by phone sync | 352 | // needed by phone sync |
336 | void Addressee::simplifyEmails() | 353 | void Addressee::simplifyEmails() |
337 | { | 354 | { |
338 | if ( mData->emails.count() == 0 ) return ; | 355 | if ( mData->emails.count() == 0 ) return ; |
339 | QString email = mData->emails.first(); | 356 | QString email = mData->emails.first(); |
340 | detach(); | 357 | detach(); |
341 | mData->emails.clear(); | 358 | mData->emails.clear(); |
342 | mData->emails.append( email ); | 359 | mData->emails.append( email ); |
343 | } | 360 | } |
344 | 361 | ||
345 | void Addressee::simplifyPhoneNumbers() | 362 | void Addressee::simplifyPhoneNumbers() |
346 | { | 363 | { |
347 | KABC::PhoneNumber::List removeNumbers; | 364 | KABC::PhoneNumber::List removeNumbers; |
348 | KABC::PhoneNumber::List::Iterator phoneIter; | 365 | KABC::PhoneNumber::List::Iterator phoneIter; |
349 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 366 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
350 | ++phoneIter ) { | 367 | ++phoneIter ) { |
351 | if ( ! ( *phoneIter ).simplifyNumber() ) | 368 | if ( ! ( *phoneIter ).simplifyNumber() ) |
352 | removeNumbers.append( ( *phoneIter ) ); | 369 | removeNumbers.append( ( *phoneIter ) ); |
353 | } | 370 | } |
354 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 371 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
355 | ++phoneIter ) { | 372 | ++phoneIter ) { |
356 | removePhoneNumber(( *phoneIter )); | 373 | removePhoneNumber(( *phoneIter )); |
357 | } | 374 | } |
358 | } | 375 | } |
359 | void Addressee::simplifyPhoneNumberTypes() | 376 | void Addressee::simplifyPhoneNumberTypes() |
360 | { | 377 | { |
361 | KABC::PhoneNumber::List::Iterator phoneIter; | 378 | KABC::PhoneNumber::List::Iterator phoneIter; |
362 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 379 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
363 | ++phoneIter ) | 380 | ++phoneIter ) |
364 | ( *phoneIter ).simplifyType(); | 381 | ( *phoneIter ).simplifyType(); |
365 | } | 382 | } |
366 | void Addressee::removeID(const QString &prof) | 383 | void Addressee::removeID(const QString &prof) |
367 | { | 384 | { |
368 | detach(); | 385 | detach(); |
369 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 386 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
370 | 387 | ||
371 | } | 388 | } |
372 | void Addressee::setID( const QString & prof , const QString & id ) | 389 | void Addressee::setID( const QString & prof , const QString & id ) |
373 | { | 390 | { |
374 | detach(); | 391 | detach(); |
375 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 392 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
376 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 393 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
377 | } | 394 | } |
378 | void Addressee::setTempSyncStat( int id ) | 395 | void Addressee::setTempSyncStat( int id ) |
379 | { | 396 | { |
380 | if ( mData->mTempSyncStat == id ) return; | 397 | if ( mData->mTempSyncStat == id ) return; |
381 | detach(); | 398 | detach(); |
382 | mData->mTempSyncStat = id; | 399 | mData->mTempSyncStat = id; |
383 | } | 400 | } |
384 | int Addressee::tempSyncStat() const | 401 | int Addressee::tempSyncStat() const |
385 | { | 402 | { |
386 | return mData->mTempSyncStat; | 403 | return mData->mTempSyncStat; |
387 | } | 404 | } |
388 | 405 | ||
389 | QString Addressee::getID( const QString & prof) | 406 | QString Addressee::getID( const QString & prof) |
390 | { | 407 | { |
391 | return KIdManager::getId ( mData->mExternalId, prof ); | 408 | return KIdManager::getId ( mData->mExternalId, prof ); |
392 | } | 409 | } |
393 | 410 | ||
394 | void Addressee::setCsum( const QString & prof , const QString & id ) | 411 | void Addressee::setCsum( const QString & prof , const QString & id ) |
395 | { | 412 | { |
396 | detach(); | 413 | detach(); |
397 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 414 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
398 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 415 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
399 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 416 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
400 | } | 417 | } |
401 | 418 | ||
402 | QString Addressee::getCsum( const QString & prof) | 419 | QString Addressee::getCsum( const QString & prof) |
403 | { | 420 | { |
404 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 421 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
405 | } | 422 | } |
406 | 423 | ||
407 | void Addressee::setIDStr( const QString & s ) | 424 | void Addressee::setIDStr( const QString & s ) |
408 | { | 425 | { |
409 | detach(); | 426 | detach(); |
410 | mData->mExternalId = s; | 427 | mData->mExternalId = s; |
411 | } | 428 | } |
412 | 429 | ||
413 | QString Addressee::IDStr() const | 430 | QString Addressee::IDStr() const |