summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-08 20:03:23 (UTC)
committer zautrix <zautrix>2004-10-08 20:03:23 (UTC)
commit10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (unidiff)
tree3105b985a9dbedd31dff52e14fe667eeff4f9ff4 /kaddressbook
parent13bd085e06b76228321f5a004759fcdf19cca711 (diff)
downloadkdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2
added contact phone support
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c5406bf..939296f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -318,789 +318,804 @@ KABCore::~KABCore()
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325} 325}
326 326
327void KABCore::restoreSettings() 327void KABCore::restoreSettings()
328{ 328{
329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
330 330
331 bool state; 331 bool state;
332 332
333 if (mMultipleViewsAtOnce) 333 if (mMultipleViewsAtOnce)
334 state = KABPrefs::instance()->mDetailsPageVisible; 334 state = KABPrefs::instance()->mDetailsPageVisible;
335 else 335 else
336 state = false; 336 state = false;
337 337
338 mActionDetails->setChecked( state ); 338 mActionDetails->setChecked( state );
339 setDetailsVisible( state ); 339 setDetailsVisible( state );
340 340
341 state = KABPrefs::instance()->mJumpButtonBarVisible; 341 state = KABPrefs::instance()->mJumpButtonBarVisible;
342 342
343 mActionJumpBar->setChecked( state ); 343 mActionJumpBar->setChecked( state );
344 setJumpButtonBarVisible( state ); 344 setJumpButtonBarVisible( state );
345/*US 345/*US
346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
347 if ( splitterSize.count() == 0 ) { 347 if ( splitterSize.count() == 0 ) {
348 splitterSize.append( width() / 2 ); 348 splitterSize.append( width() / 2 );
349 splitterSize.append( width() / 2 ); 349 splitterSize.append( width() / 2 );
350 } 350 }
351 mMiniSplitter->setSizes( splitterSize ); 351 mMiniSplitter->setSizes( splitterSize );
352 if ( mExtensionBarSplitter ) { 352 if ( mExtensionBarSplitter ) {
353 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 353 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
354 if ( splitterSize.count() == 0 ) { 354 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 355 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
357 } 357 }
358 mExtensionBarSplitter->setSizes( splitterSize ); 358 mExtensionBarSplitter->setSizes( splitterSize );
359 359
360 } 360 }
361*/ 361*/
362 mViewManager->restoreSettings(); 362 mViewManager->restoreSettings();
363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
364 mExtensionManager->restoreSettings(); 364 mExtensionManager->restoreSettings();
365#ifdef DESKTOP_VERSION 365#ifdef DESKTOP_VERSION
366 int wid = width(); 366 int wid = width();
367 if ( wid < 10 ) 367 if ( wid < 10 )
368 wid = 400; 368 wid = 400;
369#else 369#else
370 int wid = QApplication::desktop()->width(); 370 int wid = QApplication::desktop()->width();
371 if ( wid < 640 ) 371 if ( wid < 640 )
372 wid = QApplication::desktop()->height(); 372 wid = QApplication::desktop()->height();
373#endif 373#endif
374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
375 if ( true /*splitterSize.count() == 0*/ ) { 375 if ( true /*splitterSize.count() == 0*/ ) {
376 splitterSize.append( wid / 2 ); 376 splitterSize.append( wid / 2 );
377 splitterSize.append( wid / 2 ); 377 splitterSize.append( wid / 2 );
378 } 378 }
379 mMiniSplitter->setSizes( splitterSize ); 379 mMiniSplitter->setSizes( splitterSize );
380 if ( mExtensionBarSplitter ) { 380 if ( mExtensionBarSplitter ) {
381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 382 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 383 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
385 } 385 }
386 mExtensionBarSplitter->setSizes( splitterSize ); 386 mExtensionBarSplitter->setSizes( splitterSize );
387 387
388 } 388 }
389 389
390 390
391} 391}
392 392
393void KABCore::saveSettings() 393void KABCore::saveSettings()
394{ 394{
395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
396 if ( mExtensionBarSplitter ) 396 if ( mExtensionBarSplitter )
397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
400#ifndef KAB_EMBEDDED 400#ifndef KAB_EMBEDDED
401 401
402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
404#endif //KAB_EMBEDDED 404#endif //KAB_EMBEDDED
405 mExtensionManager->saveSettings(); 405 mExtensionManager->saveSettings();
406 mViewManager->saveSettings(); 406 mViewManager->saveSettings();
407 407
408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
409} 409}
410 410
411KABC::AddressBook *KABCore::addressBook() const 411KABC::AddressBook *KABCore::addressBook() const
412{ 412{
413 return mAddressBook; 413 return mAddressBook;
414} 414}
415 415
416KConfig *KABCore::config() 416KConfig *KABCore::config()
417{ 417{
418#ifndef KAB_EMBEDDED 418#ifndef KAB_EMBEDDED
419 return KABPrefs::instance()->config(); 419 return KABPrefs::instance()->config();
420#else //KAB_EMBEDDED 420#else //KAB_EMBEDDED
421 return KABPrefs::instance()->getConfig(); 421 return KABPrefs::instance()->getConfig();
422#endif //KAB_EMBEDDED 422#endif //KAB_EMBEDDED
423} 423}
424 424
425KActionCollection *KABCore::actionCollection() const 425KActionCollection *KABCore::actionCollection() const
426{ 426{
427 return mGUIClient->actionCollection(); 427 return mGUIClient->actionCollection();
428} 428}
429 429
430KABC::Field *KABCore::currentSearchField() const 430KABC::Field *KABCore::currentSearchField() const
431{ 431{
432 if (mIncSearchWidget) 432 if (mIncSearchWidget)
433 return mIncSearchWidget->currentField(); 433 return mIncSearchWidget->currentField();
434 else 434 else
435 return 0; 435 return 0;
436} 436}
437 437
438QStringList KABCore::selectedUIDs() const 438QStringList KABCore::selectedUIDs() const
439{ 439{
440 return mViewManager->selectedUids(); 440 return mViewManager->selectedUids();
441} 441}
442 442
443KABC::Resource *KABCore::requestResource( QWidget *parent ) 443KABC::Resource *KABCore::requestResource( QWidget *parent )
444{ 444{
445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
446 446
447 QPtrList<KRES::Resource> kresResources; 447 QPtrList<KRES::Resource> kresResources;
448 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 448 QPtrListIterator<KABC::Resource> resIt( kabcResources );
449 KABC::Resource *resource; 449 KABC::Resource *resource;
450 while ( ( resource = resIt.current() ) != 0 ) { 450 while ( ( resource = resIt.current() ) != 0 ) {
451 ++resIt; 451 ++resIt;
452 if ( !resource->readOnly() ) { 452 if ( !resource->readOnly() ) {
453 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 453 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
454 if ( res ) 454 if ( res )
455 kresResources.append( res ); 455 kresResources.append( res );
456 } 456 }
457 } 457 }
458 458
459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
460 return static_cast<KABC::Resource*>( res ); 460 return static_cast<KABC::Resource*>( res );
461} 461}
462 462
463#ifndef KAB_EMBEDDED 463#ifndef KAB_EMBEDDED
464KAboutData *KABCore::createAboutData() 464KAboutData *KABCore::createAboutData()
465#else //KAB_EMBEDDED 465#else //KAB_EMBEDDED
466void KABCore::createAboutData() 466void KABCore::createAboutData()
467#endif //KAB_EMBEDDED 467#endif //KAB_EMBEDDED
468{ 468{
469#ifndef KAB_EMBEDDED 469#ifndef KAB_EMBEDDED
470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
471 "3.1", I18N_NOOP( "The KDE Address Book" ), 471 "3.1", I18N_NOOP( "The KDE Address Book" ),
472 KAboutData::License_GPL_V2, 472 KAboutData::License_GPL_V2,
473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
476 about->addAuthor( "Cornelius Schumacher", 476 about->addAuthor( "Cornelius Schumacher",
477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
478 "schumacher@kde.org" ); 478 "schumacher@kde.org" );
479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
480 "mpilone@slac.com" ); 480 "mpilone@slac.com" );
481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
484 "michel@klaralvdalens-datakonsult.se" ); 484 "michel@klaralvdalens-datakonsult.se" );
485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
486 "hansen@kde.org" ); 486 "hansen@kde.org" );
487 487
488 return about; 488 return about;
489#endif //KAB_EMBEDDED 489#endif //KAB_EMBEDDED
490 490
491 QString version; 491 QString version;
492#include <../version> 492#include <../version>
493 QMessageBox::about( this, "About KAddressbook/Pi", 493 QMessageBox::about( this, "About KAddressbook/Pi",
494 "KAddressbook/Platform-independent\n" 494 "KAddressbook/Platform-independent\n"
495 "(KA/Pi) " +version + " - " + 495 "(KA/Pi) " +version + " - " +
496#ifdef DESKTOP_VERSION 496#ifdef DESKTOP_VERSION
497 "Desktop Edition\n" 497 "Desktop Edition\n"
498#else 498#else
499 "PDA-Edition\n" 499 "PDA-Edition\n"
500 "for: Zaurus 5500 / 7x0 / 8x0\n" 500 "for: Zaurus 5500 / 7x0 / 8x0\n"
501#endif 501#endif
502 502
503 "(c) 2004 Ulf Schenk\n" 503 "(c) 2004 Ulf Schenk\n"
504 "(c) 2004 Lutz Rogowski\n" 504 "(c) 2004 Lutz Rogowski\n"
505 "(c) 1997-2003, The KDE PIM Team\n" 505 "(c) 1997-2003, The KDE PIM Team\n"
506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
507 "Don Sanders Original author\n" 507 "Don Sanders Original author\n"
508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
510 "Greg Stern DCOP interface\n" 510 "Greg Stern DCOP interface\n"
511 "Mark Westcot Contact pinning\n" 511 "Mark Westcot Contact pinning\n"
512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
514#ifdef _WIN32_ 514#ifdef _WIN32_
515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
516#endif 516#endif
517 ); 517 );
518} 518}
519 519
520void KABCore::setContactSelected( const QString &uid ) 520void KABCore::setContactSelected( const QString &uid )
521{ 521{
522 KABC::Addressee addr = mAddressBook->findByUid( uid ); 522 KABC::Addressee addr = mAddressBook->findByUid( uid );
523 if ( !mDetails->isHidden() ) 523 if ( !mDetails->isHidden() )
524 mDetails->setAddressee( addr ); 524 mDetails->setAddressee( addr );
525 525
526 if ( !addr.isEmpty() ) { 526 if ( !addr.isEmpty() ) {
527 emit contactSelected( addr.formattedName() ); 527 emit contactSelected( addr.formattedName() );
528 KABC::Picture pic = addr.photo(); 528 KABC::Picture pic = addr.photo();
529 if ( pic.isIntern() ) { 529 if ( pic.isIntern() ) {
530//US emit contactSelected( pic.data() ); 530//US emit contactSelected( pic.data() );
531//US instead use: 531//US instead use:
532 QPixmap px; 532 QPixmap px;
533 if (pic.data().isNull() != true) 533 if (pic.data().isNull() != true)
534 { 534 {
535 px.convertFromImage(pic.data()); 535 px.convertFromImage(pic.data());
536 } 536 }
537 537
538 emit contactSelected( px ); 538 emit contactSelected( px );
539 } 539 }
540 } 540 }
541 541
542 542
543 mExtensionManager->setSelectionChanged(); 543 mExtensionManager->setSelectionChanged();
544 544
545 // update the actions 545 // update the actions
546 bool selected = !uid.isEmpty(); 546 bool selected = !uid.isEmpty();
547 547
548 if ( mReadWrite ) { 548 if ( mReadWrite ) {
549 mActionCut->setEnabled( selected ); 549 mActionCut->setEnabled( selected );
550 mActionPaste->setEnabled( selected ); 550 mActionPaste->setEnabled( selected );
551 } 551 }
552 552
553 mActionCopy->setEnabled( selected ); 553 mActionCopy->setEnabled( selected );
554 mActionDelete->setEnabled( selected ); 554 mActionDelete->setEnabled( selected );
555 mActionEditAddressee->setEnabled( selected ); 555 mActionEditAddressee->setEnabled( selected );
556 mActionMail->setEnabled( selected ); 556 mActionMail->setEnabled( selected );
557 mActionMailVCard->setEnabled( selected ); 557 mActionMailVCard->setEnabled( selected );
558 //if (mActionBeam) 558 //if (mActionBeam)
559 //mActionBeam->setEnabled( selected ); 559 //mActionBeam->setEnabled( selected );
560 560
561 if (mActionBeamVCard) 561 if (mActionBeamVCard)
562 mActionBeamVCard->setEnabled( selected ); 562 mActionBeamVCard->setEnabled( selected );
563 563
564 mActionExport2phone->setEnabled( selected ); 564 mActionExport2phone->setEnabled( selected );
565 mActionWhoAmI->setEnabled( selected ); 565 mActionWhoAmI->setEnabled( selected );
566 mActionCategories->setEnabled( selected ); 566 mActionCategories->setEnabled( selected );
567} 567}
568 568
569void KABCore::sendMail() 569void KABCore::sendMail()
570{ 570{
571 sendMail( mViewManager->selectedEmails().join( ", " ) ); 571 sendMail( mViewManager->selectedEmails().join( ", " ) );
572} 572}
573 573
574void KABCore::sendMail( const QString& emaillist ) 574void KABCore::sendMail( const QString& emaillist )
575{ 575{
576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
577 if (emaillist.contains(",") > 0) 577 if (emaillist.contains(",") > 0)
578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
579 else 579 else
580 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 580 ExternalAppHandler::instance()->mailToOneContact( emaillist );
581} 581}
582 582
583 583
584 584
585void KABCore::mailVCard() 585void KABCore::mailVCard()
586{ 586{
587 QStringList uids = mViewManager->selectedUids(); 587 QStringList uids = mViewManager->selectedUids();
588 if ( !uids.isEmpty() ) 588 if ( !uids.isEmpty() )
589 mailVCard( uids ); 589 mailVCard( uids );
590} 590}
591 591
592void KABCore::mailVCard( const QStringList& uids ) 592void KABCore::mailVCard( const QStringList& uids )
593{ 593{
594 QStringList urls; 594 QStringList urls;
595 595
596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
597 597
598 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 598 QString dirName = "/tmp/" + KApplication::randomString( 8 );
599 599
600 600
601 601
602 QDir().mkdir( dirName, true ); 602 QDir().mkdir( dirName, true );
603 603
604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
605 KABC::Addressee a = mAddressBook->findByUid( *it ); 605 KABC::Addressee a = mAddressBook->findByUid( *it );
606 606
607 if ( a.isEmpty() ) 607 if ( a.isEmpty() )
608 continue; 608 continue;
609 609
610 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 610 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
611 611
612 QString fileName = dirName + "/" + name; 612 QString fileName = dirName + "/" + name;
613 613
614 QFile outFile(fileName); 614 QFile outFile(fileName);
615 615
616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
617 KABC::VCardConverter converter; 617 KABC::VCardConverter converter;
618 QString vcard; 618 QString vcard;
619 619
620 converter.addresseeToVCard( a, vcard ); 620 converter.addresseeToVCard( a, vcard );
621 621
622 QTextStream t( &outFile ); // use a text stream 622 QTextStream t( &outFile ); // use a text stream
623 t.setEncoding( QTextStream::UnicodeUTF8 ); 623 t.setEncoding( QTextStream::UnicodeUTF8 );
624 t << vcard; 624 t << vcard;
625 625
626 outFile.close(); 626 outFile.close();
627 627
628 urls.append( fileName ); 628 urls.append( fileName );
629 } 629 }
630 } 630 }
631 631
632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
633 633
634 634
635/*US 635/*US
636 kapp->invokeMailer( QString::null, QString::null, QString::null, 636 kapp->invokeMailer( QString::null, QString::null, QString::null,
637 QString::null, // subject 637 QString::null, // subject
638 QString::null, // body 638 QString::null, // body
639 QString::null, 639 QString::null,
640 urls ); // attachments 640 urls ); // attachments
641*/ 641*/
642 642
643} 643}
644 644
645/** 645/**
646 Beams the "WhoAmI contact. 646 Beams the "WhoAmI contact.
647*/ 647*/
648void KABCore::beamMySelf() 648void KABCore::beamMySelf()
649{ 649{
650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
651 if (!a.isEmpty()) 651 if (!a.isEmpty())
652 { 652 {
653 QStringList uids; 653 QStringList uids;
654 uids << a.uid(); 654 uids << a.uid();
655 655
656 beamVCard(uids); 656 beamVCard(uids);
657 } else { 657 } else {
658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
659 659
660 660
661 } 661 }
662} 662}
663 663
664void KABCore::export2phone() 664void KABCore::export2phone()
665{ 665{
666 666
667 KAex2phonePrefs ex2phone; 667 KAex2phonePrefs ex2phone;
668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
671 671
672 if ( !ex2phone.exec() ) { 672 if ( !ex2phone.exec() ) {
673 return; 673 return;
674 } 674 }
675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
678 678
679 679
680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
681 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 681 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
682 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 682 KPimGlobalPrefs::instance()->mEx2PhoneModel );
683 683
684 QStringList uids = mViewManager->selectedUids(); 684 QStringList uids = mViewManager->selectedUids();
685 if ( uids.isEmpty() ) 685 if ( uids.isEmpty() )
686 return; 686 return;
687 687
688#ifdef _WIN32_ 688#ifdef _WIN32_
689 QString fileName = locateLocal("tmp", "tempfile.vcf"); 689 QString fileName = locateLocal("tmp", "tempfile.vcf");
690#else 690#else
691 QString fileName = "/tmp/kdepimtemp.vcf"; 691 QString fileName = "/tmp/kdepimtemp.vcf";
692#endif 692#endif
693 693
694 KABC::VCardConverter converter; 694 KABC::VCardConverter converter;
695 QString description; 695 QString description;
696 QString datastream; 696 QString datastream;
697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
698 KABC::Addressee a = mAddressBook->findByUid( *it ); 698 KABC::Addressee a = mAddressBook->findByUid( *it );
699 699
700 if ( a.isEmpty() ) 700 if ( a.isEmpty() )
701 continue; 701 continue;
702 a.simplifyEmails();
703 a.simplifyPhoneNumbers();
704 a.simplifyPhoneNumberTypes();
702 705
703 if (description.isEmpty()) 706 if (description.isEmpty())
704 description = a.formattedName(); 707 description = a.formattedName();
705
706 QString vcard; 708 QString vcard;
709 QString vcardnew;
707 converter.addresseeToVCard( a, vcard ); 710 converter.addresseeToVCard( a, vcard );
708 int start = 0; 711 int start = 0;
709 int next; 712 int next;
710 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 713 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
711 int semi = vcard.find(";", next); 714 int semi = vcard.find(";", next);
712 int dopp = vcard.find(":", next); 715 int dopp = vcard.find(":", next);
713 int sep; 716 int sep;
714 if ( semi < dopp && semi >= 0 ) 717 if ( semi < dopp && semi >= 0 )
715 sep = semi ; 718 sep = semi ;
716 else 719 else
717 sep = dopp; 720 sep = dopp;
718 datastream +=vcard.mid( start, next - start); 721 vcardnew +=vcard.mid( start, next - start);
719 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 722 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
720 start = sep; 723 start = sep;
721 } 724 }
722 datastream += vcard.mid( start,vcard.length() ); 725 vcardnew += vcard.mid( start,vcard.length() );
726 vcard = "";
727 start = 0;
728 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
729 int sep = vcardnew.find(":", next);
730 vcard +=vcardnew.mid( start, next - start+3);
731 start = sep;
732 }
733 vcard += vcardnew.mid( start,vcardnew.length() );
734 vcard.replace ( QRegExp(";;;") , "" );
735 vcard.replace ( QRegExp(";;") , "" );
736 datastream += vcard;
737
723 } 738 }
724 QFile outFile(fileName); 739 QFile outFile(fileName);
725 if ( outFile.open(IO_WriteOnly) ) { 740 if ( outFile.open(IO_WriteOnly) ) {
726 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 741 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
727 QTextStream t( &outFile ); // use a text stream 742 QTextStream t( &outFile ); // use a text stream
728 t.setEncoding( QTextStream::UnicodeUTF8 ); 743 t.setEncoding( QTextStream::UnicodeUTF8 );
729 t <<datastream; 744 t <<datastream;
730 outFile.close(); 745 outFile.close();
731 if ( PhoneAccess::writeToPhone( fileName ) ) 746 if ( PhoneAccess::writeToPhone( fileName ) )
732 qDebug("Export okay "); 747 qDebug("Export okay ");
733 else 748 else
734 qDebug("Error export contacts "); 749 qDebug("Error export contacts ");
735 750
736 } else { 751 } else {
737 qDebug("Error open temp file "); 752 qDebug("Error open temp file ");
738 return; 753 return;
739 } 754 }
740 755
741 756
742#if 0 757#if 0
743 758
744 setCaption( i18n("Writing to phone...")); 759 setCaption( i18n("Writing to phone..."));
745 if ( PhoneFormat::writeToPhone( cal ) ) 760 if ( PhoneFormat::writeToPhone( cal ) )
746 setCaption( i18n("Export to phone successful!")); 761 setCaption( i18n("Export to phone successful!"));
747 else 762 else
748 setCaption( i18n("Error exporting to phone!")); 763 setCaption( i18n("Error exporting to phone!"));
749#endif 764#endif
750 765
751 766
752} 767}
753void KABCore::beamVCard() 768void KABCore::beamVCard()
754{ 769{
755 QStringList uids = mViewManager->selectedUids(); 770 QStringList uids = mViewManager->selectedUids();
756 if ( !uids.isEmpty() ) 771 if ( !uids.isEmpty() )
757 beamVCard( uids ); 772 beamVCard( uids );
758} 773}
759 774
760 775
761void KABCore::beamVCard(const QStringList& uids) 776void KABCore::beamVCard(const QStringList& uids)
762{ 777{
763/*US 778/*US
764 QString beamFilename; 779 QString beamFilename;
765 Opie::OPimContact c; 780 Opie::OPimContact c;
766 if ( actionPersonal->isOn() ) { 781 if ( actionPersonal->isOn() ) {
767 beamFilename = addressbookPersonalVCardName(); 782 beamFilename = addressbookPersonalVCardName();
768 if ( !QFile::exists( beamFilename ) ) 783 if ( !QFile::exists( beamFilename ) )
769 return; // can't beam a non-existent file 784 return; // can't beam a non-existent file
770 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 785 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
771 beamFilename ); 786 beamFilename );
772 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 787 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
773 Opie::OPimContactAccess::List allList = access->allRecords(); 788 Opie::OPimContactAccess::List allList = access->allRecords();
774 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 789 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
775 c = *it; 790 c = *it;
776 791
777 delete access; 792 delete access;
778 } else { 793 } else {
779 unlink( beamfile ); // delete if exists 794 unlink( beamfile ); // delete if exists
780 mkdir("/tmp/obex/", 0755); 795 mkdir("/tmp/obex/", 0755);
781 c = m_abView -> currentEntry(); 796 c = m_abView -> currentEntry();
782 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 797 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
783 beamfile ); 798 beamfile );
784 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 799 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
785 access->add( c ); 800 access->add( c );
786 access->save(); 801 access->save();
787 delete access; 802 delete access;
788 803
789 beamFilename = beamfile; 804 beamFilename = beamfile;
790 } 805 }
791 806
792 owarn << "Beaming: " << beamFilename << oendl; 807 owarn << "Beaming: " << beamFilename << oendl;
793*/ 808*/
794 809
795#if 0 810#if 0
796 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 811 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
797 812
798 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 813 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
799 814
800 QString name = "contact.vcf"; 815 QString name = "contact.vcf";
801 816
802 QString fileName = dirName + "/" + name; 817 QString fileName = dirName + "/" + name;
803#endif 818#endif
804 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 819 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
805 // 820 //
806 QString fileName = "/tmp/kapibeamfile.vcf"; 821 QString fileName = "/tmp/kapibeamfile.vcf";
807 822
808 823
809 //QDir().mkdir( dirName, true ); 824 //QDir().mkdir( dirName, true );
810 825
811 826
812 KABC::VCardConverter converter; 827 KABC::VCardConverter converter;
813 QString description; 828 QString description;
814 QString datastream; 829 QString datastream;
815 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 830 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
816 KABC::Addressee a = mAddressBook->findByUid( *it ); 831 KABC::Addressee a = mAddressBook->findByUid( *it );
817 832
818 if ( a.isEmpty() ) 833 if ( a.isEmpty() )
819 continue; 834 continue;
820 835
821 if (description.isEmpty()) 836 if (description.isEmpty())
822 description = a.formattedName(); 837 description = a.formattedName();
823 838
824 QString vcard; 839 QString vcard;
825 converter.addresseeToVCard( a, vcard ); 840 converter.addresseeToVCard( a, vcard );
826 int start = 0; 841 int start = 0;
827 int next; 842 int next;
828 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 843 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
829 int semi = vcard.find(";", next); 844 int semi = vcard.find(";", next);
830 int dopp = vcard.find(":", next); 845 int dopp = vcard.find(":", next);
831 int sep; 846 int sep;
832 if ( semi < dopp && semi >= 0 ) 847 if ( semi < dopp && semi >= 0 )
833 sep = semi ; 848 sep = semi ;
834 else 849 else
835 sep = dopp; 850 sep = dopp;
836 datastream +=vcard.mid( start, next - start); 851 datastream +=vcard.mid( start, next - start);
837 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 852 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
838 start = sep; 853 start = sep;
839 } 854 }
840 datastream += vcard.mid( start,vcard.length() ); 855 datastream += vcard.mid( start,vcard.length() );
841 } 856 }
842#ifndef DESKTOP_VERSION 857#ifndef DESKTOP_VERSION
843 QFile outFile(fileName); 858 QFile outFile(fileName);
844 if ( outFile.open(IO_WriteOnly) ) { 859 if ( outFile.open(IO_WriteOnly) ) {
845 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 860 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
846 QTextStream t( &outFile ); // use a text stream 861 QTextStream t( &outFile ); // use a text stream
847 t.setEncoding( QTextStream::UnicodeUTF8 ); 862 t.setEncoding( QTextStream::UnicodeUTF8 );
848 t <<datastream; 863 t <<datastream;
849 outFile.close(); 864 outFile.close();
850 Ir *ir = new Ir( this ); 865 Ir *ir = new Ir( this );
851 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 866 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
852 ir->send( fileName, description, "text/x-vCard" ); 867 ir->send( fileName, description, "text/x-vCard" );
853 } else { 868 } else {
854 qDebug("Error open temp beam file "); 869 qDebug("Error open temp beam file ");
855 return; 870 return;
856 } 871 }
857#endif 872#endif
858 873
859} 874}
860 875
861void KABCore::beamDone( Ir *ir ) 876void KABCore::beamDone( Ir *ir )
862{ 877{
863#ifndef DESKTOP_VERSION 878#ifndef DESKTOP_VERSION
864 delete ir; 879 delete ir;
865#endif 880#endif
866} 881}
867 882
868 883
869void KABCore::browse( const QString& url ) 884void KABCore::browse( const QString& url )
870{ 885{
871#ifndef KAB_EMBEDDED 886#ifndef KAB_EMBEDDED
872 kapp->invokeBrowser( url ); 887 kapp->invokeBrowser( url );
873#else //KAB_EMBEDDED 888#else //KAB_EMBEDDED
874 qDebug("KABCore::browse must be fixed"); 889 qDebug("KABCore::browse must be fixed");
875#endif //KAB_EMBEDDED 890#endif //KAB_EMBEDDED
876} 891}
877 892
878void KABCore::selectAllContacts() 893void KABCore::selectAllContacts()
879{ 894{
880 mViewManager->setSelected( QString::null, true ); 895 mViewManager->setSelected( QString::null, true );
881} 896}
882 897
883void KABCore::deleteContacts() 898void KABCore::deleteContacts()
884{ 899{
885 QStringList uidList = mViewManager->selectedUids(); 900 QStringList uidList = mViewManager->selectedUids();
886 deleteContacts( uidList ); 901 deleteContacts( uidList );
887} 902}
888 903
889void KABCore::deleteContacts( const QStringList &uids ) 904void KABCore::deleteContacts( const QStringList &uids )
890{ 905{
891 if ( uids.count() > 0 ) { 906 if ( uids.count() > 0 ) {
892 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 907 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
893 UndoStack::instance()->push( command ); 908 UndoStack::instance()->push( command );
894 RedoStack::instance()->clear(); 909 RedoStack::instance()->clear();
895 910
896 // now if we deleted anything, refresh 911 // now if we deleted anything, refresh
897 setContactSelected( QString::null ); 912 setContactSelected( QString::null );
898 setModified( true ); 913 setModified( true );
899 } 914 }
900} 915}
901 916
902void KABCore::copyContacts() 917void KABCore::copyContacts()
903{ 918{
904 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 919 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
905 920
906 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 921 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
907 922
908 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 923 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
909 924
910 QClipboard *cb = QApplication::clipboard(); 925 QClipboard *cb = QApplication::clipboard();
911 cb->setText( clipText ); 926 cb->setText( clipText );
912} 927}
913 928
914void KABCore::cutContacts() 929void KABCore::cutContacts()
915{ 930{
916 QStringList uidList = mViewManager->selectedUids(); 931 QStringList uidList = mViewManager->selectedUids();
917 932
918//US if ( uidList.size() > 0 ) { 933//US if ( uidList.size() > 0 ) {
919 if ( uidList.count() > 0 ) { 934 if ( uidList.count() > 0 ) {
920 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 935 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
921 UndoStack::instance()->push( command ); 936 UndoStack::instance()->push( command );
922 RedoStack::instance()->clear(); 937 RedoStack::instance()->clear();
923 938
924 setModified( true ); 939 setModified( true );
925 } 940 }
926} 941}
927 942
928void KABCore::pasteContacts() 943void KABCore::pasteContacts()
929{ 944{
930 QClipboard *cb = QApplication::clipboard(); 945 QClipboard *cb = QApplication::clipboard();
931 946
932 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 947 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
933 948
934 pasteContacts( list ); 949 pasteContacts( list );
935} 950}
936 951
937void KABCore::pasteContacts( KABC::Addressee::List &list ) 952void KABCore::pasteContacts( KABC::Addressee::List &list )
938{ 953{
939 KABC::Resource *resource = requestResource( this ); 954 KABC::Resource *resource = requestResource( this );
940 KABC::Addressee::List::Iterator it; 955 KABC::Addressee::List::Iterator it;
941 for ( it = list.begin(); it != list.end(); ++it ) 956 for ( it = list.begin(); it != list.end(); ++it )
942 (*it).setResource( resource ); 957 (*it).setResource( resource );
943 958
944 PwPasteCommand *command = new PwPasteCommand( this, list ); 959 PwPasteCommand *command = new PwPasteCommand( this, list );
945 UndoStack::instance()->push( command ); 960 UndoStack::instance()->push( command );
946 RedoStack::instance()->clear(); 961 RedoStack::instance()->clear();
947 962
948 setModified( true ); 963 setModified( true );
949} 964}
950 965
951void KABCore::setWhoAmI() 966void KABCore::setWhoAmI()
952{ 967{
953 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 968 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
954 969
955 if ( addrList.count() > 1 ) { 970 if ( addrList.count() > 1 ) {
956 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 971 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
957 return; 972 return;
958 } 973 }
959 974
960 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 975 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
961 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 976 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
962 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 977 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
963} 978}
964 979
965void KABCore::setCategories() 980void KABCore::setCategories()
966{ 981{
967 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 982 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
968 if ( !dlg.exec() ) 983 if ( !dlg.exec() )
969 return; 984 return;
970 985
971 bool merge = false; 986 bool merge = false;
972 QString msg = i18n( "Merge with existing categories?" ); 987 QString msg = i18n( "Merge with existing categories?" );
973 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 988 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
974 merge = true; 989 merge = true;
975 990
976 QStringList categories = dlg.selectedCategories(); 991 QStringList categories = dlg.selectedCategories();
977 992
978 QStringList uids = mViewManager->selectedUids(); 993 QStringList uids = mViewManager->selectedUids();
979 QStringList::Iterator it; 994 QStringList::Iterator it;
980 for ( it = uids.begin(); it != uids.end(); ++it ) { 995 for ( it = uids.begin(); it != uids.end(); ++it ) {
981 KABC::Addressee addr = mAddressBook->findByUid( *it ); 996 KABC::Addressee addr = mAddressBook->findByUid( *it );
982 if ( !addr.isEmpty() ) { 997 if ( !addr.isEmpty() ) {
983 if ( !merge ) 998 if ( !merge )
984 addr.setCategories( categories ); 999 addr.setCategories( categories );
985 else { 1000 else {
986 QStringList addrCategories = addr.categories(); 1001 QStringList addrCategories = addr.categories();
987 QStringList::Iterator catIt; 1002 QStringList::Iterator catIt;
988 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1003 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
989 if ( !addrCategories.contains( *catIt ) ) 1004 if ( !addrCategories.contains( *catIt ) )
990 addrCategories.append( *catIt ); 1005 addrCategories.append( *catIt );
991 } 1006 }
992 addr.setCategories( addrCategories ); 1007 addr.setCategories( addrCategories );
993 } 1008 }
994 1009
995 mAddressBook->insertAddressee( addr ); 1010 mAddressBook->insertAddressee( addr );
996 } 1011 }
997 } 1012 }
998 1013
999 if ( uids.count() > 0 ) 1014 if ( uids.count() > 0 )
1000 setModified( true ); 1015 setModified( true );
1001} 1016}
1002 1017
1003void KABCore::setSearchFields( const KABC::Field::List &fields ) 1018void KABCore::setSearchFields( const KABC::Field::List &fields )
1004{ 1019{
1005 mIncSearchWidget->setFields( fields ); 1020 mIncSearchWidget->setFields( fields );
1006} 1021}
1007 1022
1008void KABCore::incrementalSearch( const QString& text ) 1023void KABCore::incrementalSearch( const QString& text )
1009{ 1024{
1010 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1025 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1011} 1026}
1012 1027
1013void KABCore::setModified() 1028void KABCore::setModified()
1014{ 1029{
1015 setModified( true ); 1030 setModified( true );
1016} 1031}
1017 1032
1018void KABCore::setModifiedWOrefresh() 1033void KABCore::setModifiedWOrefresh()
1019{ 1034{
1020 // qDebug("KABCore::setModifiedWOrefresh() "); 1035 // qDebug("KABCore::setModifiedWOrefresh() ");
1021 mModified = true; 1036 mModified = true;
1022 mActionSave->setEnabled( mModified ); 1037 mActionSave->setEnabled( mModified );
1023#ifdef DESKTOP_VERSION 1038#ifdef DESKTOP_VERSION
1024 mDetails->refreshView(); 1039 mDetails->refreshView();
1025#endif 1040#endif
1026 1041
1027} 1042}
1028void KABCore::setModified( bool modified ) 1043void KABCore::setModified( bool modified )
1029{ 1044{
1030 mModified = modified; 1045 mModified = modified;
1031 mActionSave->setEnabled( mModified ); 1046 mActionSave->setEnabled( mModified );
1032 1047
1033 if ( modified ) 1048 if ( modified )
1034 mJumpButtonBar->recreateButtons(); 1049 mJumpButtonBar->recreateButtons();
1035 1050
1036 mViewManager->refreshView(); 1051 mViewManager->refreshView();
1037 mDetails->refreshView(); 1052 mDetails->refreshView();
1038 1053
1039} 1054}
1040 1055
1041bool KABCore::modified() const 1056bool KABCore::modified() const
1042{ 1057{
1043 return mModified; 1058 return mModified;
1044} 1059}
1045 1060
1046void KABCore::contactModified( const KABC::Addressee &addr ) 1061void KABCore::contactModified( const KABC::Addressee &addr )
1047{ 1062{
1048 1063
1049 Command *command = 0; 1064 Command *command = 0;
1050 QString uid; 1065 QString uid;
1051 1066
1052 // check if it exists already 1067 // check if it exists already
1053 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1068 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1054 if ( origAddr.isEmpty() ) 1069 if ( origAddr.isEmpty() )
1055 command = new PwNewCommand( mAddressBook, addr ); 1070 command = new PwNewCommand( mAddressBook, addr );
1056 else { 1071 else {
1057 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1072 command = new PwEditCommand( mAddressBook, origAddr, addr );
1058 uid = addr.uid(); 1073 uid = addr.uid();
1059 } 1074 }
1060 1075
1061 UndoStack::instance()->push( command ); 1076 UndoStack::instance()->push( command );
1062 RedoStack::instance()->clear(); 1077 RedoStack::instance()->clear();
1063 1078
1064 setModified( true ); 1079 setModified( true );
1065} 1080}
1066 1081
1067void KABCore::newContact() 1082void KABCore::newContact()
1068{ 1083{
1069 1084
1070 1085
1071 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1086 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1072 1087
1073 QPtrList<KRES::Resource> kresResources; 1088 QPtrList<KRES::Resource> kresResources;
1074 QPtrListIterator<KABC::Resource> it( kabcResources ); 1089 QPtrListIterator<KABC::Resource> it( kabcResources );
1075 KABC::Resource *resource; 1090 KABC::Resource *resource;
1076 while ( ( resource = it.current() ) != 0 ) { 1091 while ( ( resource = it.current() ) != 0 ) {
1077 ++it; 1092 ++it;
1078 if ( !resource->readOnly() ) { 1093 if ( !resource->readOnly() ) {
1079 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1094 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1080 if ( res ) 1095 if ( res )
1081 kresResources.append( res ); 1096 kresResources.append( res );
1082 } 1097 }
1083 } 1098 }
1084 1099
1085 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1100 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1086 resource = static_cast<KABC::Resource*>( res ); 1101 resource = static_cast<KABC::Resource*>( res );
1087 1102
1088 if ( resource ) { 1103 if ( resource ) {
1089 KABC::Addressee addr; 1104 KABC::Addressee addr;
1090 addr.setResource( resource ); 1105 addr.setResource( resource );
1091 mEditorDialog->setAddressee( addr ); 1106 mEditorDialog->setAddressee( addr );
1092 KApplication::execDialog ( mEditorDialog ); 1107 KApplication::execDialog ( mEditorDialog );
1093 1108
1094 } else 1109 } else
1095 return; 1110 return;
1096 1111
1097 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1112 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1098 1113
1099 1114
1100} 1115}
1101 1116
1102void KABCore::addEmail( QString aStr ) 1117void KABCore::addEmail( QString aStr )
1103{ 1118{
1104#ifndef KAB_EMBEDDED 1119#ifndef KAB_EMBEDDED
1105 QString fullName, email; 1120 QString fullName, email;
1106 1121