author | zautrix <zautrix> | 2004-10-09 02:22:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 02:22:11 (UTC) |
commit | 69af2ac56474e3a1e3e59be318caf53f5d357f94 (patch) (unidiff) | |
tree | 05e8a657c6f2526f5d1d628e93e0f16e8ffbf11e /kabc | |
parent | c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (diff) | |
download | kdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.zip kdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.tar.gz kdepimpi-69af2ac56474e3a1e3e59be318caf53f5d357f94.tar.bz2 |
more ir fixes
-rw-r--r-- | kabc/addressbook.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index bf6d053..1a06956 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -366,97 +366,96 @@ bool AddressBook::load() | |||
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | t << "\r\n\r\n"; | 402 | t << "\r\n\r\n"; |
403 | outFile.close(); | 403 | outFile.close(); |
404 | } | 404 | } |
405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | 405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) |
406 | { | 406 | { |
407 | 407 | ||
408 | KABC::Addressee::List list; | 408 | KABC::Addressee::List list; |
409 | QFile file( fileName ); | 409 | QFile file( fileName ); |
410 | 410 | ||
411 | file.open( IO_ReadOnly ); | 411 | file.open( IO_ReadOnly ); |
412 | QByteArray rawData = file.readAll(); | 412 | QByteArray rawData = file.readAll(); |
413 | file.close(); | 413 | file.close(); |
414 | qDebug("AddressBook::importFromFile "); | ||
415 | QString data; | 414 | QString data; |
416 | if ( replaceLabel ) { | 415 | if ( replaceLabel ) { |
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 416 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | 417 | data.replace ( QRegExp("LABEL") , "ADR" ); |
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 418 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
420 | } else | 419 | } else |
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 420 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
422 | KABC::VCardTool tool; | 421 | KABC::VCardTool tool; |
423 | list = tool.parseVCards( data ); | 422 | list = tool.parseVCards( data ); |
424 | KABC::Addressee::List::Iterator it; | 423 | KABC::Addressee::List::Iterator it; |
425 | for ( it = list.begin(); it != list.end(); ++it ) { | 424 | for ( it = list.begin(); it != list.end(); ++it ) { |
426 | (*it).setResource( 0 ); | 425 | (*it).setResource( 0 ); |
427 | if ( replaceLabel ) | 426 | if ( replaceLabel ) |
428 | (*it).removeVoice(); | 427 | (*it).removeVoice(); |
429 | insertAddressee( (*it), false, true ); | 428 | insertAddressee( (*it), false, true ); |
430 | } | 429 | } |
431 | 430 | ||
432 | } | 431 | } |
433 | 432 | ||
434 | bool AddressBook::saveAB() | 433 | bool AddressBook::saveAB() |
435 | { | 434 | { |
436 | bool ok = true; | 435 | bool ok = true; |
437 | 436 | ||
438 | deleteRemovedAddressees(); | 437 | deleteRemovedAddressees(); |
439 | Iterator ait; | 438 | Iterator ait; |
440 | for ( ait = begin(); ait != end(); ++ait ) { | 439 | for ( ait = begin(); ait != end(); ++ait ) { |
441 | if ( !(*ait).IDStr().isEmpty() ) { | 440 | if ( !(*ait).IDStr().isEmpty() ) { |
442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 441 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
443 | } | 442 | } |
444 | } | 443 | } |
445 | KRES::Manager<Resource>::ActiveIterator it; | 444 | KRES::Manager<Resource>::ActiveIterator it; |
446 | KRES::Manager<Resource> *manager = d->mManager; | 445 | KRES::Manager<Resource> *manager = d->mManager; |
447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 446 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 447 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
449 | Ticket *ticket = requestSaveTicket( *it ); | 448 | Ticket *ticket = requestSaveTicket( *it ); |
450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 449 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
451 | if ( !ticket ) { | 450 | if ( !ticket ) { |
452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 451 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
453 | .arg( (*it)->resourceName() ) ); | 452 | .arg( (*it)->resourceName() ) ); |
454 | return false; | 453 | return false; |
455 | } | 454 | } |
456 | 455 | ||
457 | //if ( !save( ticket ) ) | 456 | //if ( !save( ticket ) ) |
458 | if ( ticket->resource() ) { | 457 | if ( ticket->resource() ) { |
459 | if ( ! ticket->resource()->save( ticket ) ) | 458 | if ( ! ticket->resource()->save( ticket ) ) |
460 | ok = false; | 459 | ok = false; |
461 | } else | 460 | } else |
462 | ok = false; | 461 | ok = false; |