author | zautrix <zautrix> | 2005-04-08 13:58:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-08 13:58:07 (UTC) |
commit | c0f1d38e29ee0d0a1d1dcb5bda08089923926b41 (patch) (unidiff) | |
tree | a235fdef5d4b8b519bfd8141247993ba778b39b2 /kaddressbook | |
parent | 19a95939a6469ab5469f6904f57263a792598f07 (diff) | |
download | kdepimpi-c0f1d38e29ee0d0a1d1dcb5bda08089923926b41.zip kdepimpi-c0f1d38e29ee0d0a1d1dcb5bda08089923926b41.tar.gz kdepimpi-c0f1d38e29ee0d0a1d1dcb5bda08089923926b41.tar.bz2 |
fix
-rw-r--r-- | kaddressbook/kabcore.cpp | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa9f130..9c40142 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -378,557 +378,537 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
378 | 378 | ||
379 | 379 | ||
380 | #ifndef KAB_EMBEDDED | 380 | #ifndef KAB_EMBEDDED |
381 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 381 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
382 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 382 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
383 | 383 | ||
384 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 384 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
385 | SLOT( browse( const QString& ) ) ); | 385 | SLOT( browse( const QString& ) ) ); |
386 | 386 | ||
387 | 387 | ||
388 | mAddressBookService = new KAddressBookService( this ); | 388 | mAddressBookService = new KAddressBookService( this ); |
389 | 389 | ||
390 | #endif //KAB_EMBEDDED | 390 | #endif //KAB_EMBEDDED |
391 | 391 | ||
392 | mMessageTimer = new QTimer( this ); | 392 | mMessageTimer = new QTimer( this ); |
393 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 393 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
394 | mEditorDialog = 0; | 394 | mEditorDialog = 0; |
395 | createAddresseeEditorDialog( this ); | 395 | createAddresseeEditorDialog( this ); |
396 | setModified( false ); | 396 | setModified( false ); |
397 | mBRdisabled = false; | 397 | mBRdisabled = false; |
398 | #ifndef DESKTOP_VERSION | 398 | #ifndef DESKTOP_VERSION |
399 | infrared = 0; | 399 | infrared = 0; |
400 | #endif | 400 | #endif |
401 | //toggleBeamReceive( ); | 401 | //toggleBeamReceive( ); |
402 | mMainWindow->toolBar()->show(); | 402 | mMainWindow->toolBar()->show(); |
403 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 403 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
404 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 404 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
405 | } | 405 | } |
406 | 406 | ||
407 | void KABCore::updateToolBar() | 407 | void KABCore::updateToolBar() |
408 | { | 408 | { |
409 | static int iii = 0; | 409 | static int iii = 0; |
410 | ++iii; | 410 | ++iii; |
411 | mMainWindow->toolBar()->repaintMe(); | 411 | mMainWindow->toolBar()->repaintMe(); |
412 | if ( iii < 4 ) | 412 | if ( iii < 4 ) |
413 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 413 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
414 | } | 414 | } |
415 | KABCore::~KABCore() | 415 | KABCore::~KABCore() |
416 | { | 416 | { |
417 | // save(); | 417 | // save(); |
418 | //saveSettings(); | 418 | //saveSettings(); |
419 | //KABPrefs::instance()->writeConfig(); | 419 | //KABPrefs::instance()->writeConfig(); |
420 | delete AddresseeConfig::instance(); | 420 | delete AddresseeConfig::instance(); |
421 | mAddressBook = 0; | 421 | mAddressBook = 0; |
422 | KABC::StdAddressBook::close(); | 422 | KABC::StdAddressBook::close(); |
423 | 423 | ||
424 | delete syncManager; | 424 | delete syncManager; |
425 | #ifndef DESKTOP_VERSION | 425 | #ifndef DESKTOP_VERSION |
426 | if ( infrared ) | 426 | if ( infrared ) |
427 | delete infrared; | 427 | delete infrared; |
428 | #endif | 428 | #endif |
429 | } | 429 | } |
430 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 430 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
431 | { | 431 | { |
432 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 432 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
433 | if ( cmsg == "setDocument(QString)" ) { | 433 | if ( cmsg == "setDocument(QString)" ) { |
434 | QDataStream stream( data, IO_ReadOnly ); | 434 | QDataStream stream( data, IO_ReadOnly ); |
435 | QString fileName; | 435 | QString fileName; |
436 | stream >> fileName; | 436 | stream >> fileName; |
437 | recieve( fileName ); | 437 | recieve( fileName ); |
438 | return; | 438 | return; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | void KABCore::toggleBeamReceive( ) | 441 | void KABCore::toggleBeamReceive( ) |
442 | { | 442 | { |
443 | if ( mBRdisabled ) | 443 | if ( mBRdisabled ) |
444 | return; | 444 | return; |
445 | #ifndef DESKTOP_VERSION | 445 | #ifndef DESKTOP_VERSION |
446 | if ( infrared ) { | 446 | if ( infrared ) { |
447 | qDebug("KA: AB disable BeamReceive "); | 447 | qDebug("KA: AB disable BeamReceive "); |
448 | delete infrared; | 448 | delete infrared; |
449 | infrared = 0; | 449 | infrared = 0; |
450 | mActionBR->setChecked(false); | 450 | mActionBR->setChecked(false); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | qDebug("KA: AB enable BeamReceive "); | 453 | qDebug("KA: AB enable BeamReceive "); |
454 | mActionBR->setChecked(true); | 454 | mActionBR->setChecked(true); |
455 | 455 | ||
456 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 456 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
457 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 457 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
458 | #endif | 458 | #endif |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | void KABCore::disableBR(bool b) | 462 | void KABCore::disableBR(bool b) |
463 | { | 463 | { |
464 | #ifndef DESKTOP_VERSION | 464 | #ifndef DESKTOP_VERSION |
465 | if ( b ) { | 465 | if ( b ) { |
466 | if ( infrared ) { | 466 | if ( infrared ) { |
467 | toggleBeamReceive( ); | 467 | toggleBeamReceive( ); |
468 | } | 468 | } |
469 | mBRdisabled = true; | 469 | mBRdisabled = true; |
470 | } else { | 470 | } else { |
471 | if ( mBRdisabled ) { | 471 | if ( mBRdisabled ) { |
472 | mBRdisabled = false; | 472 | mBRdisabled = false; |
473 | //toggleBeamReceive( ); | 473 | //toggleBeamReceive( ); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | #endif | 476 | #endif |
477 | 477 | ||
478 | } | 478 | } |
479 | void KABCore::recieve( QString fn ) | 479 | void KABCore::recieve( QString fn ) |
480 | { | 480 | { |
481 | //qDebug("KABCore::recieve "); | 481 | //qDebug("KABCore::recieve "); |
482 | int count = mAddressBook->importFromFile( fn, true ); | 482 | int count = mAddressBook->importFromFile( fn, true ); |
483 | if ( count ) | 483 | if ( count ) |
484 | setModified( true ); | 484 | setModified( true ); |
485 | mViewManager->refreshView(); | 485 | mViewManager->refreshView(); |
486 | message(i18n("%1 contact(s) received!").arg( count )); | 486 | message(i18n("%1 contact(s) received!").arg( count )); |
487 | topLevelWidget()->showMaximized(); | 487 | topLevelWidget()->showMaximized(); |
488 | topLevelWidget()->raise(); | 488 | topLevelWidget()->raise(); |
489 | } | 489 | } |
490 | void KABCore::restoreSettings() | 490 | void KABCore::restoreSettings() |
491 | { | 491 | { |
492 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 492 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
493 | 493 | ||
494 | bool state; | 494 | bool state; |
495 | 495 | ||
496 | if (mMultipleViewsAtOnce) | 496 | if (mMultipleViewsAtOnce) |
497 | state = KABPrefs::instance()->mDetailsPageVisible; | 497 | state = KABPrefs::instance()->mDetailsPageVisible; |
498 | else | 498 | else |
499 | state = false; | 499 | state = false; |
500 | 500 | ||
501 | mActionDetails->setChecked( state ); | 501 | mActionDetails->setChecked( state ); |
502 | setDetailsVisible( state ); | 502 | setDetailsVisible( state ); |
503 | 503 | ||
504 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 504 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
505 | 505 | ||
506 | mActionJumpBar->setChecked( state ); | 506 | mActionJumpBar->setChecked( state ); |
507 | setJumpButtonBarVisible( state ); | 507 | setJumpButtonBarVisible( state ); |
508 | /*US | 508 | /*US |
509 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 509 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
510 | if ( splitterSize.count() == 0 ) { | 510 | if ( splitterSize.count() == 0 ) { |
511 | splitterSize.append( width() / 2 ); | 511 | splitterSize.append( width() / 2 ); |
512 | splitterSize.append( width() / 2 ); | 512 | splitterSize.append( width() / 2 ); |
513 | } | 513 | } |
514 | mMiniSplitter->setSizes( splitterSize ); | 514 | mMiniSplitter->setSizes( splitterSize ); |
515 | if ( mExtensionBarSplitter ) { | 515 | if ( mExtensionBarSplitter ) { |
516 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 516 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
517 | if ( splitterSize.count() == 0 ) { | 517 | if ( splitterSize.count() == 0 ) { |
518 | splitterSize.append( width() / 2 ); | 518 | splitterSize.append( width() / 2 ); |
519 | splitterSize.append( width() / 2 ); | 519 | splitterSize.append( width() / 2 ); |
520 | } | 520 | } |
521 | mExtensionBarSplitter->setSizes( splitterSize ); | 521 | mExtensionBarSplitter->setSizes( splitterSize ); |
522 | 522 | ||
523 | } | 523 | } |
524 | */ | 524 | */ |
525 | mViewManager->restoreSettings(); | 525 | mViewManager->restoreSettings(); |
526 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 526 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
527 | mExtensionManager->restoreSettings(); | 527 | mExtensionManager->restoreSettings(); |
528 | #ifdef DESKTOP_VERSION | 528 | #ifdef DESKTOP_VERSION |
529 | int wid = width(); | 529 | int wid = width(); |
530 | if ( wid < 10 ) | 530 | if ( wid < 10 ) |
531 | wid = 400; | 531 | wid = 400; |
532 | #else | 532 | #else |
533 | int wid = QApplication::desktop()->width(); | 533 | int wid = QApplication::desktop()->width(); |
534 | if ( wid < 640 ) | 534 | if ( wid < 640 ) |
535 | wid = QApplication::desktop()->height(); | 535 | wid = QApplication::desktop()->height(); |
536 | #endif | 536 | #endif |
537 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 537 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
538 | if ( true /*splitterSize.count() == 0*/ ) { | 538 | if ( true /*splitterSize.count() == 0*/ ) { |
539 | splitterSize.append( wid / 2 ); | 539 | splitterSize.append( wid / 2 ); |
540 | splitterSize.append( wid / 2 ); | 540 | splitterSize.append( wid / 2 ); |
541 | } | 541 | } |
542 | mMiniSplitter->setSizes( splitterSize ); | 542 | mMiniSplitter->setSizes( splitterSize ); |
543 | if ( mExtensionBarSplitter ) { | 543 | if ( mExtensionBarSplitter ) { |
544 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 544 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
545 | if ( true /*splitterSize.count() == 0*/ ) { | 545 | if ( true /*splitterSize.count() == 0*/ ) { |
546 | splitterSize.append( wid / 2 ); | 546 | splitterSize.append( wid / 2 ); |
547 | splitterSize.append( wid / 2 ); | 547 | splitterSize.append( wid / 2 ); |
548 | } | 548 | } |
549 | mExtensionBarSplitter->setSizes( splitterSize ); | 549 | mExtensionBarSplitter->setSizes( splitterSize ); |
550 | 550 | ||
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | void KABCore::saveSettings() | 556 | void KABCore::saveSettings() |
557 | { | 557 | { |
558 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 558 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
559 | if ( mExtensionBarSplitter ) | 559 | if ( mExtensionBarSplitter ) |
560 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 560 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
561 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 561 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
562 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 562 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
563 | #ifndef KAB_EMBEDDED | 563 | #ifndef KAB_EMBEDDED |
564 | 564 | ||
565 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 565 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
566 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 566 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
567 | #endif //KAB_EMBEDDED | 567 | #endif //KAB_EMBEDDED |
568 | mExtensionManager->saveSettings(); | 568 | mExtensionManager->saveSettings(); |
569 | mViewManager->saveSettings(); | 569 | mViewManager->saveSettings(); |
570 | 570 | ||
571 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 571 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
572 | KABPrefs::instance()->writeConfig(); | 572 | KABPrefs::instance()->writeConfig(); |
573 | qDebug("KA: KABCore::saveSettings() "); | 573 | qDebug("KA: KABCore::saveSettings() "); |
574 | } | 574 | } |
575 | 575 | ||
576 | KABC::AddressBook *KABCore::addressBook() const | 576 | KABC::AddressBook *KABCore::addressBook() const |
577 | { | 577 | { |
578 | return mAddressBook; | 578 | return mAddressBook; |
579 | } | 579 | } |
580 | 580 | ||
581 | KConfig *KABCore::config() | 581 | KConfig *KABCore::config() |
582 | { | 582 | { |
583 | #ifndef KAB_EMBEDDED | 583 | #ifndef KAB_EMBEDDED |
584 | return KABPrefs::instance()->config(); | 584 | return KABPrefs::instance()->config(); |
585 | #else //KAB_EMBEDDED | 585 | #else //KAB_EMBEDDED |
586 | return KABPrefs::instance()->getConfig(); | 586 | return KABPrefs::instance()->getConfig(); |
587 | #endif //KAB_EMBEDDED | 587 | #endif //KAB_EMBEDDED |
588 | } | 588 | } |
589 | 589 | ||
590 | KActionCollection *KABCore::actionCollection() const | 590 | KActionCollection *KABCore::actionCollection() const |
591 | { | 591 | { |
592 | return mGUIClient->actionCollection(); | 592 | return mGUIClient->actionCollection(); |
593 | } | 593 | } |
594 | 594 | ||
595 | KABC::Field *KABCore::currentSearchField() const | 595 | KABC::Field *KABCore::currentSearchField() const |
596 | { | 596 | { |
597 | if (mIncSearchWidget) | 597 | if (mIncSearchWidget) |
598 | return mIncSearchWidget->currentField(); | 598 | return mIncSearchWidget->currentField(); |
599 | else | 599 | else |
600 | return 0; | 600 | return 0; |
601 | } | 601 | } |
602 | 602 | ||
603 | QStringList KABCore::selectedUIDs() const | 603 | QStringList KABCore::selectedUIDs() const |
604 | { | 604 | { |
605 | return mViewManager->selectedUids(); | 605 | return mViewManager->selectedUids(); |
606 | } | 606 | } |
607 | 607 | ||
608 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 608 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
609 | { | 609 | { |
610 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 610 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
611 | 611 | ||
612 | QPtrList<KRES::Resource> kresResources; | 612 | QPtrList<KRES::Resource> kresResources; |
613 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 613 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
614 | KABC::Resource *resource; | 614 | KABC::Resource *resource; |
615 | while ( ( resource = resIt.current() ) != 0 ) { | 615 | while ( ( resource = resIt.current() ) != 0 ) { |
616 | ++resIt; | 616 | ++resIt; |
617 | if ( !resource->readOnly() ) { | 617 | if ( !resource->readOnly() ) { |
618 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 618 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
619 | if ( res ) | 619 | if ( res ) |
620 | kresResources.append( res ); | 620 | kresResources.append( res ); |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 624 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
625 | return static_cast<KABC::Resource*>( res ); | 625 | return static_cast<KABC::Resource*>( res ); |
626 | } | 626 | } |
627 | 627 | ||
628 | #ifndef KAB_EMBEDDED | 628 | #ifndef KAB_EMBEDDED |
629 | KAboutData *KABCore::createAboutData() | 629 | KAboutData *KABCore::createAboutData() |
630 | #else //KAB_EMBEDDED | 630 | #else //KAB_EMBEDDED |
631 | void KABCore::createAboutData() | 631 | void KABCore::createAboutData() |
632 | #endif //KAB_EMBEDDED | 632 | #endif //KAB_EMBEDDED |
633 | { | 633 | { |
634 | #ifndef KAB_EMBEDDED | 634 | |
635 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | ||
636 | "3.1", I18N_NOOP( "The KDE Address Book" ), | ||
637 | KAboutData::License_GPL_V2, | ||
638 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | ||
639 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | ||
640 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | ||
641 | about->addAuthor( "Cornelius Schumacher", | ||
642 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | ||
643 | "schumacher@kde.org" ); | ||
644 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | ||
645 | "mpilone@slac.com" ); | ||
646 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | ||
647 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | ||
648 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | ||
649 | "michel@klaralvdalens-datakonsult.se" ); | ||
650 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | ||
651 | "hansen@kde.org" ); | ||
652 | |||
653 | return about; | ||
654 | #endif //KAB_EMBEDDED | ||
655 | 635 | ||
656 | QString version; | 636 | QString version; |
657 | #include <../version> | 637 | #include <../version> |
658 | QMessageBox::about( this, "About KAddressbook/Pi", | 638 | QMessageBox::about( this, "About KAddressbook/Pi", |
659 | "KAddressbook/Platform-independent\n" | 639 | "KAddressbook/Platform-independent\n" |
660 | "(KA/Pi) " +version + " - " + | 640 | "(KA/Pi) " +version + " - " + |
661 | #ifdef DESKTOP_VERSION | 641 | #ifdef DESKTOP_VERSION |
662 | "Desktop Edition\n" | 642 | "Desktop Edition\n" |
663 | #else | 643 | #else |
664 | "PDA-Edition\n" | 644 | "PDA-Edition\n" |
665 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 645 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
666 | #endif | 646 | #endif |
667 | 647 | ||
668 | "(c) 2004 Ulf Schenk\n" | 648 | "(c) 2004 Ulf Schenk\n" |
669 | "(c) 2004 Lutz Rogowski\n" | 649 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
670 | "(c) 1997-2003, The KDE PIM Team\n" | 650 | "(c) 1997-2003, The KDE PIM Team\n" |
671 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 651 | "Tobias Koenig Maintainer\n" |
672 | "Don Sanders Original author\n" | 652 | "Don Sanders Original author\n" |
673 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 653 | "Cornelius Schumacher Co-maintainer\n" |
674 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 654 | "Mike Pilone GUI and framework redesign\n" |
675 | "Greg Stern DCOP interface\n" | 655 | "Greg Stern DCOP interface\n" |
676 | "Mark Westcot Contact pinning\n" | 656 | "Mark Westcot Contact pinning\n" |
677 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 657 | "Michel Boyer de la Giroday LDAP Lookup\n" |
678 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 658 | "Steffen Hansen LDAP Lookup" |
679 | #ifdef _WIN32_ | 659 | #ifdef _WIN32_ |
680 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 660 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
681 | #endif | 661 | #endif |
682 | ); | 662 | ); |
683 | } | 663 | } |
684 | 664 | ||
685 | void KABCore::setContactSelected( const QString &uid ) | 665 | void KABCore::setContactSelected( const QString &uid ) |
686 | { | 666 | { |
687 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 667 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
688 | if ( !mDetails->isHidden() ) | 668 | if ( !mDetails->isHidden() ) |
689 | mDetails->setAddressee( addr ); | 669 | mDetails->setAddressee( addr ); |
690 | 670 | ||
691 | if ( !addr.isEmpty() ) { | 671 | if ( !addr.isEmpty() ) { |
692 | emit contactSelected( addr.formattedName() ); | 672 | emit contactSelected( addr.formattedName() ); |
693 | KABC::Picture pic = addr.photo(); | 673 | KABC::Picture pic = addr.photo(); |
694 | if ( pic.isIntern() ) { | 674 | if ( pic.isIntern() ) { |
695 | //US emit contactSelected( pic.data() ); | 675 | //US emit contactSelected( pic.data() ); |
696 | //US instead use: | 676 | //US instead use: |
697 | QPixmap px; | 677 | QPixmap px; |
698 | if (pic.data().isNull() != true) | 678 | if (pic.data().isNull() != true) |
699 | { | 679 | { |
700 | px.convertFromImage(pic.data()); | 680 | px.convertFromImage(pic.data()); |
701 | } | 681 | } |
702 | 682 | ||
703 | emit contactSelected( px ); | 683 | emit contactSelected( px ); |
704 | } | 684 | } |
705 | } | 685 | } |
706 | 686 | ||
707 | 687 | ||
708 | mExtensionManager->setSelectionChanged(); | 688 | mExtensionManager->setSelectionChanged(); |
709 | 689 | ||
710 | // update the actions | 690 | // update the actions |
711 | bool selected = !uid.isEmpty(); | 691 | bool selected = !uid.isEmpty(); |
712 | 692 | ||
713 | if ( mReadWrite ) { | 693 | if ( mReadWrite ) { |
714 | mActionCut->setEnabled( selected ); | 694 | mActionCut->setEnabled( selected ); |
715 | mActionPaste->setEnabled( selected ); | 695 | mActionPaste->setEnabled( selected ); |
716 | } | 696 | } |
717 | 697 | ||
718 | mActionCopy->setEnabled( selected ); | 698 | mActionCopy->setEnabled( selected ); |
719 | mActionDelete->setEnabled( selected ); | 699 | mActionDelete->setEnabled( selected ); |
720 | mActionEditAddressee->setEnabled( selected ); | 700 | mActionEditAddressee->setEnabled( selected ); |
721 | mActionMail->setEnabled( selected ); | 701 | mActionMail->setEnabled( selected ); |
722 | mActionMailVCard->setEnabled( selected ); | 702 | mActionMailVCard->setEnabled( selected ); |
723 | //if (mActionBeam) | 703 | //if (mActionBeam) |
724 | //mActionBeam->setEnabled( selected ); | 704 | //mActionBeam->setEnabled( selected ); |
725 | mActionWhoAmI->setEnabled( selected ); | 705 | mActionWhoAmI->setEnabled( selected ); |
726 | } | 706 | } |
727 | 707 | ||
728 | void KABCore::sendMail() | 708 | void KABCore::sendMail() |
729 | { | 709 | { |
730 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 710 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
731 | } | 711 | } |
732 | 712 | ||
733 | void KABCore::sendMail( const QString& emaillist ) | 713 | void KABCore::sendMail( const QString& emaillist ) |
734 | { | 714 | { |
735 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 715 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
736 | if (emaillist.contains(",") > 0) | 716 | if (emaillist.contains(",") > 0) |
737 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 717 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
738 | else | 718 | else |
739 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 719 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
740 | } | 720 | } |
741 | 721 | ||
742 | 722 | ||
743 | 723 | ||
744 | void KABCore::mailVCard() | 724 | void KABCore::mailVCard() |
745 | { | 725 | { |
746 | QStringList uids = mViewManager->selectedUids(); | 726 | QStringList uids = mViewManager->selectedUids(); |
747 | if ( !uids.isEmpty() ) | 727 | if ( !uids.isEmpty() ) |
748 | mailVCard( uids ); | 728 | mailVCard( uids ); |
749 | } | 729 | } |
750 | 730 | ||
751 | void KABCore::mailVCard( const QStringList& uids ) | 731 | void KABCore::mailVCard( const QStringList& uids ) |
752 | { | 732 | { |
753 | QStringList urls; | 733 | QStringList urls; |
754 | 734 | ||
755 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 735 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
756 | 736 | ||
757 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 737 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
758 | 738 | ||
759 | 739 | ||
760 | 740 | ||
761 | QDir().mkdir( dirName, true ); | 741 | QDir().mkdir( dirName, true ); |
762 | 742 | ||
763 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 743 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
764 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 744 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
765 | 745 | ||
766 | if ( a.isEmpty() ) | 746 | if ( a.isEmpty() ) |
767 | continue; | 747 | continue; |
768 | 748 | ||
769 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 749 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
770 | 750 | ||
771 | QString fileName = dirName + "/" + name; | 751 | QString fileName = dirName + "/" + name; |
772 | 752 | ||
773 | QFile outFile(fileName); | 753 | QFile outFile(fileName); |
774 | 754 | ||
775 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 755 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
776 | KABC::VCardConverter converter; | 756 | KABC::VCardConverter converter; |
777 | QString vcard; | 757 | QString vcard; |
778 | 758 | ||
779 | converter.addresseeToVCard( a, vcard ); | 759 | converter.addresseeToVCard( a, vcard ); |
780 | 760 | ||
781 | QTextStream t( &outFile ); // use a text stream | 761 | QTextStream t( &outFile ); // use a text stream |
782 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 762 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
783 | t << vcard; | 763 | t << vcard; |
784 | 764 | ||
785 | outFile.close(); | 765 | outFile.close(); |
786 | 766 | ||
787 | urls.append( fileName ); | 767 | urls.append( fileName ); |
788 | } | 768 | } |
789 | } | 769 | } |
790 | 770 | ||
791 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 771 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
792 | 772 | ||
793 | 773 | ||
794 | /*US | 774 | /*US |
795 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 775 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
796 | QString::null, // subject | 776 | QString::null, // subject |
797 | QString::null, // body | 777 | QString::null, // body |
798 | QString::null, | 778 | QString::null, |
799 | urls ); // attachments | 779 | urls ); // attachments |
800 | */ | 780 | */ |
801 | 781 | ||
802 | } | 782 | } |
803 | 783 | ||
804 | /** | 784 | /** |
805 | Beams the "WhoAmI contact. | 785 | Beams the "WhoAmI contact. |
806 | */ | 786 | */ |
807 | void KABCore::beamMySelf() | 787 | void KABCore::beamMySelf() |
808 | { | 788 | { |
809 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 789 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
810 | if (!a.isEmpty()) | 790 | if (!a.isEmpty()) |
811 | { | 791 | { |
812 | QStringList uids; | 792 | QStringList uids; |
813 | uids << a.uid(); | 793 | uids << a.uid(); |
814 | 794 | ||
815 | beamVCard(uids); | 795 | beamVCard(uids); |
816 | } else { | 796 | } else { |
817 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 797 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
818 | 798 | ||
819 | 799 | ||
820 | } | 800 | } |
821 | } | 801 | } |
822 | void KABCore::updateMainWindow() | 802 | void KABCore::updateMainWindow() |
823 | { | 803 | { |
824 | mMainWindow->showMaximized(); | 804 | mMainWindow->showMaximized(); |
825 | mMainWindow->update(); | 805 | mMainWindow->update(); |
826 | } | 806 | } |
827 | void KABCore::resizeEvent(QResizeEvent* e ) | 807 | void KABCore::resizeEvent(QResizeEvent* e ) |
828 | { | 808 | { |
829 | if ( !mMiniSplitter ) | 809 | if ( !mMiniSplitter ) |
830 | return; | 810 | return; |
831 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 811 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
832 | if ( QApplication::desktop()->width() >= 480 ) { | 812 | if ( QApplication::desktop()->width() >= 480 ) { |
833 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 813 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
834 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 814 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
835 | mMiniSplitter->setOrientation( Qt::Horizontal); | 815 | mMiniSplitter->setOrientation( Qt::Horizontal); |
836 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 816 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
837 | } | 817 | } |
838 | if ( QApplication::desktop()->width() <= 640 ) { | 818 | if ( QApplication::desktop()->width() <= 640 ) { |
839 | mMainWindow->showMinimized(); | 819 | mMainWindow->showMinimized(); |
840 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 820 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
841 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 821 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
842 | if ( mIncSearchWidget ) | 822 | if ( mIncSearchWidget ) |
843 | mIncSearchWidget->setSize(); | 823 | mIncSearchWidget->setSize(); |
844 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 824 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
845 | } | 825 | } |
846 | 826 | ||
847 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 827 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
848 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 828 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
849 | mMiniSplitter->setOrientation( Qt::Vertical ); | 829 | mMiniSplitter->setOrientation( Qt::Vertical ); |
850 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 830 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
851 | } | 831 | } |
852 | if ( QApplication::desktop()->width() <= 640 ) { | 832 | if ( QApplication::desktop()->width() <= 640 ) { |
853 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 833 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
854 | mMainWindow->showMinimized(); | 834 | mMainWindow->showMinimized(); |
855 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 835 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
856 | if ( mIncSearchWidget ) { | 836 | if ( mIncSearchWidget ) { |
857 | mIncSearchWidget->setSize(); | 837 | mIncSearchWidget->setSize(); |
858 | } | 838 | } |
859 | } else { | 839 | } else { |
860 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 840 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
861 | } | 841 | } |
862 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 842 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
863 | } | 843 | } |
864 | } | 844 | } |
865 | } | 845 | } |
866 | QWidget::resizeEvent( e ); | 846 | QWidget::resizeEvent( e ); |
867 | 847 | ||
868 | } | 848 | } |
869 | void KABCore::export2phone() | 849 | void KABCore::export2phone() |
870 | { | 850 | { |
871 | 851 | ||
872 | QStringList uids; | 852 | QStringList uids; |
873 | XXPortSelectDialog dlg( this, false, this ); | 853 | XXPortSelectDialog dlg( this, false, this ); |
874 | if ( dlg.exec() ) | 854 | if ( dlg.exec() ) |
875 | uids = dlg.uids(); | 855 | uids = dlg.uids(); |
876 | else | 856 | else |
877 | return; | 857 | return; |
878 | if ( uids.isEmpty() ) | 858 | if ( uids.isEmpty() ) |
879 | return; | 859 | return; |
880 | // qDebug("count %d ", uids.count()); | 860 | // qDebug("count %d ", uids.count()); |
881 | 861 | ||
882 | KAex2phonePrefs ex2phone; | 862 | KAex2phonePrefs ex2phone; |
883 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 863 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
884 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 864 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
885 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 865 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
886 | 866 | ||
887 | if ( !ex2phone.exec() ) { | 867 | if ( !ex2phone.exec() ) { |
888 | return; | 868 | return; |
889 | } | 869 | } |
890 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 870 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
891 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 871 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
892 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 872 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
893 | 873 | ||
894 | 874 | ||
895 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 875 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
896 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 876 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
897 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 877 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
898 | 878 | ||
899 | QString fileName = getPhoneFile(); | 879 | QString fileName = getPhoneFile(); |
900 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 880 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
901 | return; | 881 | return; |
902 | 882 | ||
903 | message(i18n("Exporting to phone...")); | 883 | message(i18n("Exporting to phone...")); |
904 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 884 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
905 | 885 | ||
906 | } | 886 | } |
907 | QString KABCore::getPhoneFile() | 887 | QString KABCore::getPhoneFile() |
908 | { | 888 | { |
909 | #ifdef DESKTOP_VERSION | 889 | #ifdef DESKTOP_VERSION |
910 | return locateLocal("tmp", "phonefile.vcf"); | 890 | return locateLocal("tmp", "phonefile.vcf"); |
911 | #else | 891 | #else |
912 | return "/tmp/phonefile.vcf"; | 892 | return "/tmp/phonefile.vcf"; |
913 | #endif | 893 | #endif |
914 | 894 | ||
915 | } | 895 | } |
916 | void KABCore::writeToPhone( ) | 896 | void KABCore::writeToPhone( ) |
917 | { | 897 | { |
918 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 898 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
919 | message(i18n("Export to phone finished!")); | 899 | message(i18n("Export to phone finished!")); |
920 | else | 900 | else |
921 | qDebug(i18n("KA: Error exporting to phone")); | 901 | qDebug(i18n("KA: Error exporting to phone")); |
922 | } | 902 | } |
923 | void KABCore::beamVCard() | 903 | void KABCore::beamVCard() |
924 | { | 904 | { |
925 | QStringList uids; | 905 | QStringList uids; |
926 | XXPortSelectDialog dlg( this, false, this ); | 906 | XXPortSelectDialog dlg( this, false, this ); |
927 | if ( dlg.exec() ) | 907 | if ( dlg.exec() ) |
928 | uids = dlg.uids(); | 908 | uids = dlg.uids(); |
929 | else | 909 | else |
930 | return; | 910 | return; |
931 | if ( uids.isEmpty() ) | 911 | if ( uids.isEmpty() ) |
932 | return; | 912 | return; |
933 | beamVCard( uids ); | 913 | beamVCard( uids ); |
934 | } | 914 | } |