summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-10-07 22:37:40 (UTC)
committer zautrix <zautrix>2004-10-07 22:37:40 (UTC)
commit21ec296f7f2832920dac336bb9f9476c80d746f5 (patch) (unidiff)
tree69b2897665d70ad45da249b1cf374a01d3be6dc4 /kabc/addressbook.cpp
parent4a01915314201cbe2461ce68cdf9c556c687d727 (diff)
downloadkdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.zip
kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.gz
kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.bz2
ab view fixes
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index ed5e9c2..dc3cda1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -354,96 +354,97 @@ bool AddressBook::load()
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool 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}
378void AddressBook::export2File( QString fileName ) 378void 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 outFile.close(); 403 outFile.close();
403} 404}
404void AddressBook::importFromFile( QString fileName ) 405void AddressBook::importFromFile( QString fileName )
405{ 406{
406 407
407 KABC::Addressee::List list; 408 KABC::Addressee::List list;
408 QFile file( fileName ); 409 QFile file( fileName );
409 410
410 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
412 file.close(); 413 file.close();
413 414
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 415 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool; 416 KABC::VCardTool tool;
416 list = tool.parseVCards( data ); 417 list = tool.parseVCards( data );
417 KABC::Addressee::List::Iterator it; 418 KABC::Addressee::List::Iterator it;
418 for ( it = list.begin(); it != list.end(); ++it ) { 419 for ( it = list.begin(); it != list.end(); ++it ) {
419 (*it).setResource( 0 ); 420 (*it).setResource( 0 );
420 insertAddressee( (*it), false, true ); 421 insertAddressee( (*it), false, true );
421 } 422 }
422 423
423} 424}
424 425
425bool AddressBook::saveAB() 426bool AddressBook::saveAB()
426{ 427{
427 bool ok = true; 428 bool ok = true;
428 429
429 deleteRemovedAddressees(); 430 deleteRemovedAddressees();
430 Iterator ait; 431 Iterator ait;
431 for ( ait = begin(); ait != end(); ++ait ) { 432 for ( ait = begin(); ait != end(); ++ait ) {
432 if ( !(*ait).IDStr().isEmpty() ) { 433 if ( !(*ait).IDStr().isEmpty() ) {
433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
434 } 435 }
435 } 436 }
436 KRES::Manager<Resource>::ActiveIterator it; 437 KRES::Manager<Resource>::ActiveIterator it;
437 KRES::Manager<Resource> *manager = d->mManager; 438 KRES::Manager<Resource> *manager = d->mManager;
438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
439 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 440 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
440 Ticket *ticket = requestSaveTicket( *it ); 441 Ticket *ticket = requestSaveTicket( *it );
441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
442 if ( !ticket ) { 443 if ( !ticket ) {
443 error( i18n( "Unable to save to resource '%1'. It is locked." ) 444 error( i18n( "Unable to save to resource '%1'. It is locked." )
444 .arg( (*it)->resourceName() ) ); 445 .arg( (*it)->resourceName() ) );
445 return false; 446 return false;
446 } 447 }
447 448
448 //if ( !save( ticket ) ) 449 //if ( !save( ticket ) )
449 if ( ticket->resource() ) { 450 if ( ticket->resource() ) {