author | zautrix <zautrix> | 2005-08-23 21:48:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-23 21:48:53 (UTC) |
commit | 2acca9aff5bd651923b5d728712a0fd80b3d54e9 (patch) (unidiff) | |
tree | c2113d441908520d86902a8a9fade08eb05ee0d0 /kaddressbook | |
parent | 6f5464760f5fb1e4c13027464cfe4943b85d29a0 (diff) | |
download | kdepimpi-2acca9aff5bd651923b5d728712a0fd80b3d54e9.zip kdepimpi-2acca9aff5bd651923b5d728712a0fd80b3d54e9.tar.gz kdepimpi-2acca9aff5bd651923b5d728712a0fd80b3d54e9.tar.bz2 |
fastload fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 22 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index af12f2b..4e2523e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -423,658 +423,668 @@ void KABCore::loadDataAfterStart() | |||
423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); | 423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); |
424 | 424 | ||
425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
426 | if ( !mCStringMess.isEmpty() ) | 426 | if ( !mCStringMess.isEmpty() ) |
427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); | 427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); |
428 | #endif | 428 | #endif |
429 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 429 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
430 | setCaptionBack(); | 430 | setCaptionBack(); |
431 | } | 431 | } |
432 | void KABCore::updateToolBar() | 432 | void KABCore::updateToolBar() |
433 | { | 433 | { |
434 | static int iii = 0; | 434 | static int iii = 0; |
435 | ++iii; | 435 | ++iii; |
436 | mMainWindow->toolBar()->repaintMe(); | 436 | mMainWindow->toolBar()->repaintMe(); |
437 | if ( iii < 4 ) | 437 | if ( iii < 4 ) |
438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
439 | } | 439 | } |
440 | KABCore::~KABCore() | 440 | KABCore::~KABCore() |
441 | { | 441 | { |
442 | // save(); | 442 | // save(); |
443 | //saveSettings(); | 443 | //saveSettings(); |
444 | //KABPrefs::instance()->writeConfig(); | 444 | //KABPrefs::instance()->writeConfig(); |
445 | delete AddresseeConfig::instance(); | 445 | delete AddresseeConfig::instance(); |
446 | mAddressBook = 0; | 446 | mAddressBook = 0; |
447 | KABC::StdAddressBook::close(); | 447 | KABC::StdAddressBook::close(); |
448 | 448 | ||
449 | delete syncManager; | 449 | delete syncManager; |
450 | #ifndef DESKTOP_VERSION | 450 | #ifndef DESKTOP_VERSION |
451 | if ( infrared ) | 451 | if ( infrared ) |
452 | delete infrared; | 452 | delete infrared; |
453 | #endif | 453 | #endif |
454 | } | 454 | } |
455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
456 | { | 456 | { |
457 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 457 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
458 | if ( cmsg == "setDocument(QString)" ) { | 458 | if ( cmsg == "setDocument(QString)" ) { |
459 | QDataStream stream( data, IO_ReadOnly ); | 459 | QDataStream stream( data, IO_ReadOnly ); |
460 | QString fileName; | 460 | QString fileName; |
461 | stream >> fileName; | 461 | stream >> fileName; |
462 | recieve( fileName ); | 462 | recieve( fileName ); |
463 | return; | 463 | return; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | void KABCore::toggleBeamReceive( ) | 466 | void KABCore::toggleBeamReceive( ) |
467 | { | 467 | { |
468 | if ( mBRdisabled ) | 468 | if ( mBRdisabled ) |
469 | return; | 469 | return; |
470 | #ifndef DESKTOP_VERSION | 470 | #ifndef DESKTOP_VERSION |
471 | if ( infrared ) { | 471 | if ( infrared ) { |
472 | qDebug("KA: AB disable BeamReceive "); | 472 | qDebug("KA: AB disable BeamReceive "); |
473 | delete infrared; | 473 | delete infrared; |
474 | infrared = 0; | 474 | infrared = 0; |
475 | mActionBR->setChecked(false); | 475 | mActionBR->setChecked(false); |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | qDebug("KA: AB enable BeamReceive "); | 478 | qDebug("KA: AB enable BeamReceive "); |
479 | mActionBR->setChecked(true); | 479 | mActionBR->setChecked(true); |
480 | 480 | ||
481 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 481 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
482 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 482 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
483 | #endif | 483 | #endif |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | void KABCore::disableBR(bool b) | 487 | void KABCore::disableBR(bool b) |
488 | { | 488 | { |
489 | #ifndef DESKTOP_VERSION | 489 | #ifndef DESKTOP_VERSION |
490 | if ( b ) { | 490 | if ( b ) { |
491 | if ( infrared ) { | 491 | if ( infrared ) { |
492 | toggleBeamReceive( ); | 492 | toggleBeamReceive( ); |
493 | } | 493 | } |
494 | mBRdisabled = true; | 494 | mBRdisabled = true; |
495 | } else { | 495 | } else { |
496 | if ( mBRdisabled ) { | 496 | if ( mBRdisabled ) { |
497 | mBRdisabled = false; | 497 | mBRdisabled = false; |
498 | //toggleBeamReceive( ); | 498 | //toggleBeamReceive( ); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | #endif | 501 | #endif |
502 | 502 | ||
503 | } | 503 | } |
504 | void KABCore::recieve( QString fn ) | 504 | void KABCore::recieve( QString fn ) |
505 | { | 505 | { |
506 | //qDebug("KABCore::recieve "); | 506 | //qDebug("KABCore::recieve "); |
507 | int count = mAddressBook->importFromFile( fn, true ); | 507 | int count = mAddressBook->importFromFile( fn, true ); |
508 | if ( count ) | 508 | if ( count ) |
509 | setModified( true ); | 509 | setModified( true ); |
510 | mViewManager->refreshView(); | 510 | mViewManager->refreshView(); |
511 | message(i18n("%1 contact(s) received!").arg( count )); | 511 | message(i18n("%1 contact(s) received!").arg( count )); |
512 | topLevelWidget()->showMaximized(); | 512 | topLevelWidget()->showMaximized(); |
513 | topLevelWidget()->raise(); | 513 | topLevelWidget()->raise(); |
514 | } | 514 | } |
515 | void KABCore::restoreSettings() | 515 | void KABCore::restoreSettings() |
516 | { | 516 | { |
517 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 517 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
518 | 518 | ||
519 | bool state; | 519 | bool state; |
520 | 520 | ||
521 | if (mMultipleViewsAtOnce) | 521 | if (mMultipleViewsAtOnce) |
522 | state = KABPrefs::instance()->mDetailsPageVisible; | 522 | state = KABPrefs::instance()->mDetailsPageVisible; |
523 | else | 523 | else |
524 | state = false; | 524 | state = false; |
525 | 525 | ||
526 | mActionDetails->setChecked( state ); | 526 | mActionDetails->setChecked( state ); |
527 | setDetailsVisible( state ); | 527 | setDetailsVisible( state ); |
528 | 528 | ||
529 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 529 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
530 | 530 | ||
531 | mActionJumpBar->setChecked( state ); | 531 | mActionJumpBar->setChecked( state ); |
532 | setJumpButtonBarVisible( state ); | 532 | setJumpButtonBarVisible( state ); |
533 | /*US | 533 | /*US |
534 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 534 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
535 | if ( splitterSize.count() == 0 ) { | 535 | if ( splitterSize.count() == 0 ) { |
536 | splitterSize.append( width() / 2 ); | 536 | splitterSize.append( width() / 2 ); |
537 | splitterSize.append( width() / 2 ); | 537 | splitterSize.append( width() / 2 ); |
538 | } | 538 | } |
539 | mMiniSplitter->setSizes( splitterSize ); | 539 | mMiniSplitter->setSizes( splitterSize ); |
540 | if ( mExtensionBarSplitter ) { | 540 | if ( mExtensionBarSplitter ) { |
541 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 541 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
542 | if ( splitterSize.count() == 0 ) { | 542 | if ( splitterSize.count() == 0 ) { |
543 | splitterSize.append( width() / 2 ); | 543 | splitterSize.append( width() / 2 ); |
544 | splitterSize.append( width() / 2 ); | 544 | splitterSize.append( width() / 2 ); |
545 | } | 545 | } |
546 | mExtensionBarSplitter->setSizes( splitterSize ); | 546 | mExtensionBarSplitter->setSizes( splitterSize ); |
547 | 547 | ||
548 | } | 548 | } |
549 | */ | 549 | */ |
550 | mViewManager->restoreSettings(); | 550 | mViewManager->restoreSettings(); |
551 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 551 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
552 | mExtensionManager->restoreSettings(); | 552 | mExtensionManager->restoreSettings(); |
553 | #ifdef DESKTOP_VERSION | 553 | #ifdef DESKTOP_VERSION |
554 | int wid = width(); | 554 | int wid = width(); |
555 | if ( wid < 10 ) | 555 | if ( wid < 10 ) |
556 | wid = 400; | 556 | wid = 400; |
557 | #else | 557 | #else |
558 | int wid = QApplication::desktop()->width(); | 558 | int wid = QApplication::desktop()->width(); |
559 | if ( wid < 640 ) | 559 | if ( wid < 640 ) |
560 | wid = QApplication::desktop()->height(); | 560 | wid = QApplication::desktop()->height(); |
561 | #endif | 561 | #endif |
562 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 562 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
563 | if ( true /*splitterSize.count() == 0*/ ) { | 563 | if ( true /*splitterSize.count() == 0*/ ) { |
564 | splitterSize.append( wid / 2 ); | 564 | splitterSize.append( wid / 2 ); |
565 | splitterSize.append( wid / 2 ); | 565 | splitterSize.append( wid / 2 ); |
566 | } | 566 | } |
567 | mMiniSplitter->setSizes( splitterSize ); | 567 | mMiniSplitter->setSizes( splitterSize ); |
568 | if ( mExtensionBarSplitter ) { | 568 | if ( mExtensionBarSplitter ) { |
569 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 569 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
570 | if ( true /*splitterSize.count() == 0*/ ) { | 570 | if ( true /*splitterSize.count() == 0*/ ) { |
571 | splitterSize.append( wid / 2 ); | 571 | splitterSize.append( wid / 2 ); |
572 | splitterSize.append( wid / 2 ); | 572 | splitterSize.append( wid / 2 ); |
573 | } | 573 | } |
574 | mExtensionBarSplitter->setSizes( splitterSize ); | 574 | mExtensionBarSplitter->setSizes( splitterSize ); |
575 | 575 | ||
576 | } | 576 | } |
577 | #ifdef DESKTOP_VERSION | 577 | #ifdef DESKTOP_VERSION |
578 | KConfig *config = KABPrefs::instance()->getConfig(); | 578 | KConfig *config = KABPrefs::instance()->getConfig(); |
579 | config->setGroup("WidgetLayout"); | 579 | config->setGroup("WidgetLayout"); |
580 | QStringList list; | 580 | QStringList list; |
581 | list = config->readListEntry("MainLayout"); | 581 | list = config->readListEntry("MainLayout"); |
582 | int x,y,w,h; | 582 | int x,y,w,h; |
583 | if ( ! list.isEmpty() ) { | 583 | if ( ! list.isEmpty() ) { |
584 | x = list[0].toInt(); | 584 | x = list[0].toInt(); |
585 | y = list[1].toInt(); | 585 | y = list[1].toInt(); |
586 | w = list[2].toInt(); | 586 | w = list[2].toInt(); |
587 | h = list[3].toInt(); | 587 | h = list[3].toInt(); |
588 | KApplication::testCoords( &x,&y,&w,&h ); | 588 | KApplication::testCoords( &x,&y,&w,&h ); |
589 | topLevelWidget()->setGeometry(x,y,w,h); | 589 | topLevelWidget()->setGeometry(x,y,w,h); |
590 | 590 | ||
591 | } else { | 591 | } else { |
592 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 592 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
593 | } | 593 | } |
594 | #endif | 594 | #endif |
595 | } | 595 | } |
596 | 596 | ||
597 | void KABCore::saveSettings() | 597 | void KABCore::saveSettings() |
598 | { | 598 | { |
599 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 599 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
600 | if ( mExtensionBarSplitter ) | 600 | if ( mExtensionBarSplitter ) |
601 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 601 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
602 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 602 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
603 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 603 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
604 | #ifndef KAB_EMBEDDED | 604 | #ifndef KAB_EMBEDDED |
605 | 605 | ||
606 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 606 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
607 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 607 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
608 | #endif //KAB_EMBEDDED | 608 | #endif //KAB_EMBEDDED |
609 | mExtensionManager->saveSettings(); | 609 | mExtensionManager->saveSettings(); |
610 | mViewManager->saveSettings(); | 610 | mViewManager->saveSettings(); |
611 | 611 | ||
612 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 612 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
613 | 613 | ||
614 | KABPrefs::instance()->writeConfig(); | 614 | KABPrefs::instance()->writeConfig(); |
615 | qDebug("KA: KABCore::saveSettings() "); | 615 | //qDebug("KA: KABCore::saveSettings() "); |
616 | } | 616 | } |
617 | 617 | ||
618 | KABC::AddressBook *KABCore::addressBook() const | 618 | KABC::AddressBook *KABCore::addressBook() const |
619 | { | 619 | { |
620 | return mAddressBook; | 620 | return mAddressBook; |
621 | } | 621 | } |
622 | 622 | ||
623 | KConfig *KABCore::config() | 623 | KConfig *KABCore::config() |
624 | { | 624 | { |
625 | #ifndef KAB_EMBEDDED | 625 | #ifndef KAB_EMBEDDED |
626 | return KABPrefs::instance()->config(); | 626 | return KABPrefs::instance()->config(); |
627 | #else //KAB_EMBEDDED | 627 | #else //KAB_EMBEDDED |
628 | return KABPrefs::instance()->getConfig(); | 628 | return KABPrefs::instance()->getConfig(); |
629 | #endif //KAB_EMBEDDED | 629 | #endif //KAB_EMBEDDED |
630 | } | 630 | } |
631 | 631 | ||
632 | KActionCollection *KABCore::actionCollection() const | 632 | KActionCollection *KABCore::actionCollection() const |
633 | { | 633 | { |
634 | return mGUIClient->actionCollection(); | 634 | return mGUIClient->actionCollection(); |
635 | } | 635 | } |
636 | 636 | ||
637 | KABC::Field *KABCore::currentSearchField() const | 637 | KABC::Field *KABCore::currentSearchField() const |
638 | { | 638 | { |
639 | if (mIncSearchWidget) | 639 | if (mIncSearchWidget) |
640 | return mIncSearchWidget->currentField(); | 640 | return mIncSearchWidget->currentField(); |
641 | else | 641 | else |
642 | return 0; | 642 | return 0; |
643 | } | 643 | } |
644 | 644 | ||
645 | QStringList KABCore::selectedUIDs() const | 645 | QStringList KABCore::selectedUIDs() const |
646 | { | 646 | { |
647 | return mViewManager->selectedUids(); | 647 | return mViewManager->selectedUids(); |
648 | } | 648 | } |
649 | 649 | ||
650 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 650 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
651 | { | 651 | { |
652 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 652 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
653 | 653 | ||
654 | QPtrList<KRES::Resource> kresResources; | 654 | QPtrList<KRES::Resource> kresResources; |
655 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 655 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
656 | KABC::Resource *resource; | 656 | KABC::Resource *resource; |
657 | while ( ( resource = resIt.current() ) != 0 ) { | 657 | while ( ( resource = resIt.current() ) != 0 ) { |
658 | ++resIt; | 658 | ++resIt; |
659 | if ( !resource->readOnly() ) { | 659 | if ( !resource->readOnly() ) { |
660 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 660 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
661 | if ( res ) | 661 | if ( res ) |
662 | kresResources.append( res ); | 662 | kresResources.append( res ); |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 666 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
667 | return static_cast<KABC::Resource*>( res ); | 667 | return static_cast<KABC::Resource*>( res ); |
668 | } | 668 | } |
669 | 669 | ||
670 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
671 | KAboutData *KABCore::createAboutData() | 671 | KAboutData *KABCore::createAboutData() |
672 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
673 | void KABCore::createAboutData() | 673 | void KABCore::createAboutData() |
674 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
675 | { | 675 | { |
676 | 676 | ||
677 | 677 | ||
678 | QString version; | 678 | QString version; |
679 | #include <../version> | 679 | #include <../version> |
680 | QMessageBox::about( this, "About KAddressbook/Pi", | 680 | QMessageBox::about( this, "About KAddressbook/Pi", |
681 | "KAddressbook/Platform-independent\n" | 681 | "KAddressbook/Platform-independent\n" |
682 | "(KA/Pi) " +version + " - " + | 682 | "(KA/Pi) " +version + " - " + |
683 | #ifdef DESKTOP_VERSION | 683 | #ifdef DESKTOP_VERSION |
684 | "Desktop Edition\n" | 684 | "Desktop Edition\n" |
685 | #else | 685 | #else |
686 | "PDA-Edition\n" | 686 | "PDA-Edition\n" |
687 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 687 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
688 | #endif | 688 | #endif |
689 | 689 | ||
690 | "(c) 2004 Ulf Schenk\n" | 690 | "(c) 2004 Ulf Schenk\n" |
691 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" | 691 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
692 | "(c) 1997-2003, The KDE PIM Team\n" | 692 | "(c) 1997-2003, The KDE PIM Team\n" |
693 | "Tobias Koenig Maintainer\n" | 693 | "Tobias Koenig Maintainer\n" |
694 | "Don Sanders Original author\n" | 694 | "Don Sanders Original author\n" |
695 | "Cornelius Schumacher Co-maintainer\n" | 695 | "Cornelius Schumacher Co-maintainer\n" |
696 | "Mike Pilone GUI and framework redesign\n" | 696 | "Mike Pilone GUI and framework redesign\n" |
697 | "Greg Stern DCOP interface\n" | 697 | "Greg Stern DCOP interface\n" |
698 | "Mark Westcot Contact pinning\n" | 698 | "Mark Westcot Contact pinning\n" |
699 | "Michel Boyer de la Giroday LDAP Lookup\n" | 699 | "Michel Boyer de la Giroday LDAP Lookup\n" |
700 | "Steffen Hansen LDAP Lookup" | 700 | "Steffen Hansen LDAP Lookup" |
701 | #ifdef _WIN32_ | 701 | #ifdef _WIN32_ |
702 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 702 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
703 | #endif | 703 | #endif |
704 | ); | 704 | ); |
705 | } | 705 | } |
706 | 706 | ||
707 | void KABCore::setContactSelected( const QString &uid ) | 707 | void KABCore::setContactSelected( const QString &uid ) |
708 | { | 708 | { |
709 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 709 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
710 | if ( !mDetails->isHidden() ) | 710 | if ( !mDetails->isHidden() ) |
711 | mDetails->setAddressee( addr ); | 711 | mDetails->setAddressee( addr ); |
712 | 712 | ||
713 | if ( !addr.isEmpty() ) { | 713 | if ( !addr.isEmpty() ) { |
714 | emit contactSelected( addr.formattedName() ); | 714 | emit contactSelected( addr.formattedName() ); |
715 | KABC::Picture pic = addr.photo(); | 715 | KABC::Picture pic = addr.photo(); |
716 | if ( pic.isIntern() ) { | 716 | if ( pic.isIntern() ) { |
717 | //US emit contactSelected( pic.data() ); | 717 | //US emit contactSelected( pic.data() ); |
718 | //US instead use: | 718 | //US instead use: |
719 | QPixmap px; | 719 | QPixmap px; |
720 | if (pic.data().isNull() != true) | 720 | if (pic.data().isNull() != true) |
721 | { | 721 | { |
722 | px.convertFromImage(pic.data()); | 722 | px.convertFromImage(pic.data()); |
723 | } | 723 | } |
724 | 724 | ||
725 | emit contactSelected( px ); | 725 | emit contactSelected( px ); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | 729 | ||
730 | mExtensionManager->setSelectionChanged(); | 730 | mExtensionManager->setSelectionChanged(); |
731 | 731 | ||
732 | // update the actions | 732 | // update the actions |
733 | bool selected = !uid.isEmpty(); | 733 | bool selected = !uid.isEmpty(); |
734 | 734 | ||
735 | if ( mReadWrite ) { | 735 | if ( mReadWrite ) { |
736 | mActionCut->setEnabled( selected ); | 736 | mActionCut->setEnabled( selected ); |
737 | mActionPaste->setEnabled( selected ); | 737 | mActionPaste->setEnabled( selected ); |
738 | } | 738 | } |
739 | 739 | ||
740 | mActionCopy->setEnabled( selected ); | 740 | mActionCopy->setEnabled( selected ); |
741 | mActionDelete->setEnabled( selected ); | 741 | mActionDelete->setEnabled( selected ); |
742 | mActionEditAddressee->setEnabled( selected ); | 742 | mActionEditAddressee->setEnabled( selected ); |
743 | mActionMail->setEnabled( selected ); | 743 | mActionMail->setEnabled( selected ); |
744 | mActionMailVCard->setEnabled( selected ); | 744 | mActionMailVCard->setEnabled( selected ); |
745 | //if (mActionBeam) | 745 | //if (mActionBeam) |
746 | //mActionBeam->setEnabled( selected ); | 746 | //mActionBeam->setEnabled( selected ); |
747 | mActionWhoAmI->setEnabled( selected ); | 747 | mActionWhoAmI->setEnabled( selected ); |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::sendMail() | 750 | void KABCore::sendMail() |
751 | { | 751 | { |
752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
753 | } | 753 | } |
754 | 754 | ||
755 | void KABCore::sendMail( const QString& emaillist ) | 755 | void KABCore::sendMail( const QString& emaillist ) |
756 | { | 756 | { |
757 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 757 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
758 | if (emaillist.contains(",") > 0) | 758 | if (emaillist.contains(",") > 0) |
759 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 759 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
760 | else | 760 | else |
761 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 761 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
762 | } | 762 | } |
763 | 763 | ||
764 | 764 | ||
765 | 765 | ||
766 | void KABCore::mailVCard() | 766 | void KABCore::mailVCard() |
767 | { | 767 | { |
768 | QStringList uids = mViewManager->selectedUids(); | 768 | QStringList uids = mViewManager->selectedUids(); |
769 | if ( !uids.isEmpty() ) | 769 | if ( !uids.isEmpty() ) |
770 | mailVCard( uids ); | 770 | mailVCard( uids ); |
771 | } | 771 | } |
772 | 772 | ||
773 | void KABCore::mailVCard( const QStringList& uids ) | 773 | void KABCore::mailVCard( const QStringList& uids ) |
774 | { | 774 | { |
775 | QStringList urls; | 775 | QStringList urls; |
776 | 776 | ||
777 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 777 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
778 | 778 | ||
779 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 779 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
780 | 780 | ||
781 | 781 | ||
782 | 782 | ||
783 | QDir().mkdir( dirName, true ); | 783 | QDir().mkdir( dirName, true ); |
784 | 784 | ||
785 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 785 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
786 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 786 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
787 | 787 | ||
788 | if ( a.isEmpty() ) | 788 | if ( a.isEmpty() ) |
789 | continue; | 789 | continue; |
790 | 790 | ||
791 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 791 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
792 | 792 | ||
793 | QString fileName = dirName + "/" + name; | 793 | QString fileName = dirName + "/" + name; |
794 | 794 | ||
795 | QFile outFile(fileName); | 795 | QFile outFile(fileName); |
796 | 796 | ||
797 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 797 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
798 | KABC::VCardConverter converter; | 798 | KABC::VCardConverter converter; |
799 | QString vcard; | 799 | QString vcard; |
800 | 800 | ||
801 | converter.addresseeToVCard( a, vcard ); | 801 | converter.addresseeToVCard( a, vcard ); |
802 | 802 | ||
803 | QTextStream t( &outFile ); // use a text stream | 803 | QTextStream t( &outFile ); // use a text stream |
804 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 804 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
805 | t << vcard; | 805 | t << vcard; |
806 | 806 | ||
807 | outFile.close(); | 807 | outFile.close(); |
808 | 808 | ||
809 | urls.append( fileName ); | 809 | urls.append( fileName ); |
810 | } | 810 | } |
811 | } | 811 | } |
812 | 812 | ||
813 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 813 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
814 | 814 | ||
815 | 815 | ||
816 | /*US | 816 | /*US |
817 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 817 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
818 | QString::null, // subject | 818 | QString::null, // subject |
819 | QString::null, // body | 819 | QString::null, // body |
820 | QString::null, | 820 | QString::null, |
821 | urls ); // attachments | 821 | urls ); // attachments |
822 | */ | 822 | */ |
823 | 823 | ||
824 | } | 824 | } |
825 | 825 | ||
826 | /** | 826 | /** |
827 | Beams the "WhoAmI contact. | 827 | Beams the "WhoAmI contact. |
828 | */ | 828 | */ |
829 | void KABCore::beamMySelf() | 829 | void KABCore::beamMySelf() |
830 | { | 830 | { |
831 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 831 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
832 | if (!a.isEmpty()) | 832 | if (!a.isEmpty()) |
833 | { | 833 | { |
834 | QStringList uids; | 834 | QStringList uids; |
835 | uids << a.uid(); | 835 | uids << a.uid(); |
836 | 836 | ||
837 | beamVCard(uids); | 837 | beamVCard(uids); |
838 | } else { | 838 | } else { |
839 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 839 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
840 | 840 | ||
841 | 841 | ||
842 | } | 842 | } |
843 | } | 843 | } |
844 | void KABCore::updateMainWindow() | 844 | void KABCore::updateMainWindow() |
845 | { | 845 | { |
846 | mMainWindow->showMaximized(); | 846 | mMainWindow->showMaximized(); |
847 | mMainWindow->update(); | 847 | //mMainWindow->repaint(); |
848 | } | 848 | } |
849 | void KABCore::resizeEvent(QResizeEvent* e ) | 849 | void KABCore::resizeEvent(QResizeEvent* e ) |
850 | { | 850 | { |
851 | if ( !mMiniSplitter ) | 851 | if ( !mMiniSplitter ) |
852 | return; | 852 | return; |
853 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 853 | static int desktop_width = 0; |
854 | if ( e->oldSize().width() != e->size().width() ) | 854 | //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); |
855 | if ( desktop_width != QApplication::desktop()->width() ) | ||
855 | if ( QApplication::desktop()->width() >= 480 ) { | 856 | if ( QApplication::desktop()->width() >= 480 ) { |
856 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 857 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
858 | //qDebug("640 "); | ||
857 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 859 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
860 | //qDebug("switch V->H "); | ||
858 | mMiniSplitter->setOrientation( Qt::Horizontal); | 861 | mMiniSplitter->setOrientation( Qt::Horizontal); |
859 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 862 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
860 | } | 863 | } |
861 | if ( QApplication::desktop()->width() <= 640 ) { | 864 | if ( QApplication::desktop()->width() <= 640 ) { |
865 | bool shot = mMainWindow->isVisible(); | ||
862 | mMainWindow->showMinimized(); | 866 | mMainWindow->showMinimized(); |
863 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 867 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
864 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 868 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
865 | if ( mIncSearchWidget ) | 869 | if ( mIncSearchWidget ) |
866 | mIncSearchWidget->setSize(); | 870 | mIncSearchWidget->setSize(); |
867 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 871 | if ( shot ) |
872 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
868 | } | 873 | } |
869 | 874 | ||
870 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 875 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
876 | //qDebug("480 "); | ||
871 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 877 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
878 | //qDebug("switch H->V "); | ||
872 | mMiniSplitter->setOrientation( Qt::Vertical ); | 879 | mMiniSplitter->setOrientation( Qt::Vertical ); |
873 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 880 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
874 | } | 881 | } |
875 | if ( QApplication::desktop()->width() <= 640 ) { | 882 | if ( QApplication::desktop()->width() <= 640 ) { |
876 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 883 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
884 | bool shot = mMainWindow->isVisible(); | ||
877 | mMainWindow->showMinimized(); | 885 | mMainWindow->showMinimized(); |
878 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 886 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
879 | if ( mIncSearchWidget ) { | 887 | if ( mIncSearchWidget ) { |
880 | mIncSearchWidget->setSize(); | 888 | mIncSearchWidget->setSize(); |
881 | } | 889 | } |
882 | } else { | 890 | } else { |
883 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 891 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
884 | } | 892 | } |
885 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 893 | if ( shot ) |
894 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
886 | } | 895 | } |
887 | } | 896 | } |
888 | } | 897 | } |
898 | desktop_width = QApplication::desktop()->width(); | ||
889 | QWidget::resizeEvent( e ); | 899 | QWidget::resizeEvent( e ); |
890 | 900 | ||
891 | } | 901 | } |
892 | void KABCore::export2phone() | 902 | void KABCore::export2phone() |
893 | { | 903 | { |
894 | 904 | ||
895 | QStringList uids; | 905 | QStringList uids; |
896 | XXPortSelectDialog dlg( this, false, this ); | 906 | XXPortSelectDialog dlg( this, false, this ); |
897 | if ( dlg.exec() ) | 907 | if ( dlg.exec() ) |
898 | uids = dlg.uids(); | 908 | uids = dlg.uids(); |
899 | else | 909 | else |
900 | return; | 910 | return; |
901 | if ( uids.isEmpty() ) | 911 | if ( uids.isEmpty() ) |
902 | return; | 912 | return; |
903 | // qDebug("count %d ", uids.count()); | 913 | // qDebug("count %d ", uids.count()); |
904 | 914 | ||
905 | KAex2phonePrefs ex2phone; | 915 | KAex2phonePrefs ex2phone; |
906 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 916 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
907 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 917 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
908 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 918 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
909 | 919 | ||
910 | if ( !ex2phone.exec() ) { | 920 | if ( !ex2phone.exec() ) { |
911 | return; | 921 | return; |
912 | } | 922 | } |
913 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 923 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
914 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 924 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
915 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 925 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
916 | 926 | ||
917 | 927 | ||
918 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 928 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
919 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 929 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
920 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 930 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
921 | 931 | ||
922 | QString fileName = getPhoneFile(); | 932 | QString fileName = getPhoneFile(); |
923 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 933 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
924 | return; | 934 | return; |
925 | 935 | ||
926 | message(i18n("Exporting to phone...")); | 936 | message(i18n("Exporting to phone...")); |
927 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 937 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
928 | 938 | ||
929 | } | 939 | } |
930 | QString KABCore::getPhoneFile() | 940 | QString KABCore::getPhoneFile() |
931 | { | 941 | { |
932 | #ifdef DESKTOP_VERSION | 942 | #ifdef DESKTOP_VERSION |
933 | return locateLocal("tmp", "phonefile.vcf"); | 943 | return locateLocal("tmp", "phonefile.vcf"); |
934 | #else | 944 | #else |
935 | return "/tmp/phonefile.vcf"; | 945 | return "/tmp/phonefile.vcf"; |
936 | #endif | 946 | #endif |
937 | 947 | ||
938 | } | 948 | } |
939 | void KABCore::writeToPhone( ) | 949 | void KABCore::writeToPhone( ) |
940 | { | 950 | { |
941 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 951 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
942 | message(i18n("Export to phone finished!")); | 952 | message(i18n("Export to phone finished!")); |
943 | else | 953 | else |
944 | qDebug(i18n("KA: Error exporting to phone")); | 954 | qDebug(i18n("KA: Error exporting to phone")); |
945 | } | 955 | } |
946 | void KABCore::beamVCard() | 956 | void KABCore::beamVCard() |
947 | { | 957 | { |
948 | QStringList uids; | 958 | QStringList uids; |
949 | XXPortSelectDialog dlg( this, false, this ); | 959 | XXPortSelectDialog dlg( this, false, this ); |
950 | if ( dlg.exec() ) | 960 | if ( dlg.exec() ) |
951 | uids = dlg.uids(); | 961 | uids = dlg.uids(); |
952 | else | 962 | else |
953 | return; | 963 | return; |
954 | if ( uids.isEmpty() ) | 964 | if ( uids.isEmpty() ) |
955 | return; | 965 | return; |
956 | beamVCard( uids ); | 966 | beamVCard( uids ); |
957 | } | 967 | } |
958 | 968 | ||
959 | 969 | ||
960 | void KABCore::beamVCard(const QStringList& uids) | 970 | void KABCore::beamVCard(const QStringList& uids) |
961 | { | 971 | { |
962 | 972 | ||
963 | // LR: we should use the /tmp dir on the Zaurus, | 973 | // LR: we should use the /tmp dir on the Zaurus, |
964 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 974 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
965 | 975 | ||
966 | #ifdef DESKTOP_VERSION | 976 | #ifdef DESKTOP_VERSION |
967 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 977 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
968 | #else | 978 | #else |
969 | QString fileName = "/tmp/kapibeamfile.vcf"; | 979 | QString fileName = "/tmp/kapibeamfile.vcf"; |
970 | #endif | 980 | #endif |
971 | 981 | ||
972 | KABC::VCardConverter converter; | 982 | KABC::VCardConverter converter; |
973 | QString description; | 983 | QString description; |
974 | QString datastream; | 984 | QString datastream; |
975 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 985 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
976 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 986 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
977 | 987 | ||
978 | if ( a.isEmpty() ) | 988 | if ( a.isEmpty() ) |
979 | continue; | 989 | continue; |
980 | 990 | ||
981 | if (description.isEmpty()) | 991 | if (description.isEmpty()) |
982 | description = a.formattedName(); | 992 | description = a.formattedName(); |
983 | 993 | ||
984 | QString vcard; | 994 | QString vcard; |
985 | converter.addresseeToVCard( a, vcard ); | 995 | converter.addresseeToVCard( a, vcard ); |
986 | int start = 0; | 996 | int start = 0; |
987 | int next; | 997 | int next; |
988 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 998 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
989 | int semi = vcard.find(";", next); | 999 | int semi = vcard.find(";", next); |
990 | int dopp = vcard.find(":", next); | 1000 | int dopp = vcard.find(":", next); |
991 | int sep; | 1001 | int sep; |
992 | if ( semi < dopp && semi >= 0 ) | 1002 | if ( semi < dopp && semi >= 0 ) |
993 | sep = semi ; | 1003 | sep = semi ; |
994 | else | 1004 | else |
995 | sep = dopp; | 1005 | sep = dopp; |
996 | datastream +=vcard.mid( start, next - start); | 1006 | datastream +=vcard.mid( start, next - start); |
997 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 1007 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
998 | start = sep; | 1008 | start = sep; |
999 | } | 1009 | } |
1000 | datastream += vcard.mid( start,vcard.length() ); | 1010 | datastream += vcard.mid( start,vcard.length() ); |
1001 | } | 1011 | } |
1002 | #ifndef DESKTOP_VERSION | 1012 | #ifndef DESKTOP_VERSION |
1003 | QFile outFile(fileName); | 1013 | QFile outFile(fileName); |
1004 | if ( outFile.open(IO_WriteOnly) ) { | 1014 | if ( outFile.open(IO_WriteOnly) ) { |
1005 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 1015 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
1006 | QTextStream t( &outFile ); // use a text stream | 1016 | QTextStream t( &outFile ); // use a text stream |
1007 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 1017 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
1008 | t.setEncoding( QTextStream::Latin1 ); | 1018 | t.setEncoding( QTextStream::Latin1 ); |
1009 | t <<datastream.latin1(); | 1019 | t <<datastream.latin1(); |
1010 | outFile.close(); | 1020 | outFile.close(); |
1011 | Ir *ir = new Ir( this ); | 1021 | Ir *ir = new Ir( this ); |
1012 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 1022 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
1013 | ir->send( fileName, description, "text/x-vCard" ); | 1023 | ir->send( fileName, description, "text/x-vCard" ); |
1014 | } else { | 1024 | } else { |
1015 | qDebug("KA: Error open temp beam file "); | 1025 | qDebug("KA: Error open temp beam file "); |
1016 | return; | 1026 | return; |
1017 | } | 1027 | } |
1018 | #endif | 1028 | #endif |
1019 | 1029 | ||
1020 | } | 1030 | } |
1021 | 1031 | ||
1022 | void KABCore::beamDone( Ir *ir ) | 1032 | void KABCore::beamDone( Ir *ir ) |
1023 | { | 1033 | { |
1024 | #ifndef DESKTOP_VERSION | 1034 | #ifndef DESKTOP_VERSION |
1025 | delete ir; | 1035 | delete ir; |
1026 | #endif | 1036 | #endif |
1027 | topLevelWidget()->raise(); | 1037 | topLevelWidget()->raise(); |
1028 | message( i18n("Beaming finished!") ); | 1038 | message( i18n("Beaming finished!") ); |
1029 | } | 1039 | } |
1030 | 1040 | ||
1031 | 1041 | ||
1032 | void KABCore::browse( const QString& url ) | 1042 | void KABCore::browse( const QString& url ) |
1033 | { | 1043 | { |
1034 | #ifndef KAB_EMBEDDED | 1044 | #ifndef KAB_EMBEDDED |
1035 | kapp->invokeBrowser( url ); | 1045 | kapp->invokeBrowser( url ); |
1036 | #else //KAB_EMBEDDED | 1046 | #else //KAB_EMBEDDED |
1037 | qDebug("KABCore::browse must be fixed"); | 1047 | qDebug("KABCore::browse must be fixed"); |
1038 | #endif //KAB_EMBEDDED | 1048 | #endif //KAB_EMBEDDED |
1039 | } | 1049 | } |
1040 | 1050 | ||
1041 | void KABCore::selectAllContacts() | 1051 | void KABCore::selectAllContacts() |
1042 | { | 1052 | { |
1043 | mViewManager->setSelected( QString::null, true ); | 1053 | mViewManager->setSelected( QString::null, true ); |
1044 | } | 1054 | } |
1045 | 1055 | ||
1046 | void KABCore::deleteContacts() | 1056 | void KABCore::deleteContacts() |
1047 | { | 1057 | { |
1048 | QStringList uidList = mViewManager->selectedUids(); | 1058 | QStringList uidList = mViewManager->selectedUids(); |
1049 | deleteContacts( uidList ); | 1059 | deleteContacts( uidList ); |
1050 | } | 1060 | } |
1051 | 1061 | ||
1052 | void KABCore::deleteContacts( const QStringList &uids ) | 1062 | void KABCore::deleteContacts( const QStringList &uids ) |
1053 | { | 1063 | { |
1054 | 1064 | ||
1055 | if ( uids.count() > 0 ) { | 1065 | if ( uids.count() > 0 ) { |
1056 | 1066 | ||
1057 | if ( KABPrefs::instance()->mAskForDelete ) { | 1067 | if ( KABPrefs::instance()->mAskForDelete ) { |
1058 | int count = uids.count(); | 1068 | int count = uids.count(); |
1059 | if ( count > 5 ) count = 5; | 1069 | if ( count > 5 ) count = 5; |
1060 | QString cNames; | 1070 | QString cNames; |
1061 | int i; | 1071 | int i; |
1062 | for ( i = 0; i < count ; ++i ) { | 1072 | for ( i = 0; i < count ; ++i ) { |
1063 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; | 1073 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; |
1064 | } | 1074 | } |
1065 | if ( uids.count() > 5 ) | 1075 | if ( uids.count() > 5 ) |
1066 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); | 1076 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); |
1067 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; | 1077 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; |
1068 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) | 1078 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) |
1069 | return; | 1079 | return; |
1070 | } | 1080 | } |
1071 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1081 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1072 | UndoStack::instance()->push( command ); | 1082 | UndoStack::instance()->push( command ); |
1073 | RedoStack::instance()->clear(); | 1083 | RedoStack::instance()->clear(); |
1074 | 1084 | ||
1075 | // now if we deleted anything, refresh | 1085 | // now if we deleted anything, refresh |
1076 | setContactSelected( QString::null ); | 1086 | setContactSelected( QString::null ); |
1077 | setModified( true ); | 1087 | setModified( true ); |
1078 | } | 1088 | } |
1079 | } | 1089 | } |
1080 | 1090 | ||
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 02fc40a..272f2eb 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -145,346 +145,348 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | |||
145 | mListView->clear(); | 145 | mListView->clear(); |
146 | if ( s.isEmpty() || s == "*" ) { | 146 | if ( s.isEmpty() || s == "*" ) { |
147 | refresh(); | 147 | refresh(); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | QRegExp re = getRegExp( s ); | 150 | QRegExp re = getRegExp( s ); |
151 | if (!re.isValid()) | 151 | if (!re.isValid()) |
152 | return; | 152 | return; |
153 | KABC::Addressee::List addresseeList = addressees(); | 153 | KABC::Addressee::List addresseeList = addressees(); |
154 | KABC::Addressee::List::Iterator it; | 154 | KABC::Addressee::List::Iterator it; |
155 | if ( field ) { | 155 | if ( field ) { |
156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
158 | continue; | 158 | continue; |
159 | #if QT_VERSION >= 0x030000 | 159 | #if QT_VERSION >= 0x030000 |
160 | if (re.search(field->value( *it ).lower()) == 0) | 160 | if (re.search(field->value( *it ).lower()) == 0) |
161 | #else | 161 | #else |
162 | if (re.match(field->value( *it ).lower()) == 0) | 162 | if (re.match(field->value( *it ).lower()) == 0) |
163 | #endif | 163 | #endif |
164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
165 | 165 | ||
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | KABC::Field::List fieldList = allFields(); | 168 | KABC::Field::List fieldList = allFields(); |
169 | KABC::Field::List::ConstIterator fieldIt; | 169 | KABC::Field::List::ConstIterator fieldIt; |
170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
172 | continue; | 172 | continue; |
173 | bool match = false; | 173 | bool match = false; |
174 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 174 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
175 | #if QT_VERSION >= 0x030000 | 175 | #if QT_VERSION >= 0x030000 |
176 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) | 176 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) |
177 | #else | 177 | #else |
178 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) | 178 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) |
179 | #endif | 179 | #endif |
180 | { | 180 | { |
181 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); | 181 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); |
182 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 182 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
183 | match = true; | 183 | match = true; |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | if ( ! match ) { | 187 | if ( ! match ) { |
188 | if ( (*it).matchPhoneNumber( &re ) ) { | 188 | if ( (*it).matchPhoneNumber( &re ) ) { |
189 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 189 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
190 | match = true; | 190 | match = true; |
191 | break; | 191 | break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | if ( ! match ) { | 194 | if ( ! match ) { |
195 | if ( (*it).matchAddress( &re ) ) { | 195 | if ( (*it).matchAddress( &re ) ) { |
196 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 196 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
197 | match = true; | 197 | match = true; |
198 | break; | 198 | break; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | // Sometimes the background pixmap gets messed up when we add lots | 203 | // Sometimes the background pixmap gets messed up when we add lots |
204 | // of items. | 204 | // of items. |
205 | //mListView->repaint(); | 205 | //mListView->repaint(); |
206 | if ( mListView->firstChild() ) { | 206 | if ( mListView->firstChild() ) { |
207 | mListView->setCurrentItem ( mListView->firstChild() ); | 207 | mListView->setCurrentItem ( mListView->firstChild() ); |
208 | mListView->setSelected ( mListView->firstChild(), true ); | 208 | mListView->setSelected ( mListView->firstChild(), true ); |
209 | } | 209 | } |
210 | else | 210 | else |
211 | emit selected(QString::null); | 211 | emit selected(QString::null); |
212 | 212 | ||
213 | } | 213 | } |
214 | void KAddressBookTableView::writeConfig(KConfig *config) | 214 | void KAddressBookTableView::writeConfig(KConfig *config) |
215 | { | 215 | { |
216 | KAddressBookView::writeConfig(config); | 216 | KAddressBookView::writeConfig(config); |
217 | 217 | ||
218 | mListView->saveLayout(config, config->group()); | 218 | mListView->saveLayout(config, config->group()); |
219 | } | 219 | } |
220 | 220 | ||
221 | void KAddressBookTableView::readConfig(KConfig *config) | 221 | void KAddressBookTableView::readConfig(KConfig *config) |
222 | { | 222 | { |
223 | KAddressBookView::readConfig( config ); | 223 | KAddressBookView::readConfig( config ); |
224 | // The config could have changed the fields, so we need to reconstruct | 224 | // The config could have changed the fields, so we need to reconstruct |
225 | // the listview. | 225 | // the listview. |
226 | reconstructListView(); | 226 | reconstructListView(); |
227 | 227 | ||
228 | // costum colors? | 228 | // costum colors? |
229 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 229 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
230 | { | 230 | { |
231 | QPalette p( mListView->palette() ); | 231 | QPalette p( mListView->palette() ); |
232 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 232 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
233 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 233 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
234 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 234 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
235 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 235 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
236 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 236 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
237 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 237 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
238 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 238 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
239 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 239 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
240 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 240 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
241 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 241 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
242 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 242 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
243 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 243 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
244 | #ifndef KAB_EMBEDDED | 244 | #ifndef KAB_EMBEDDED |
245 | c = KGlobalSettings::alternateBackgroundColor(); | 245 | c = KGlobalSettings::alternateBackgroundColor(); |
246 | #else //KAB_EMBEDDED | 246 | #else //KAB_EMBEDDED |
247 | c = QColor(240, 240, 240); | 247 | c = QColor(240, 240, 240); |
248 | #endif //KAB_EMBEDDED | 248 | #endif //KAB_EMBEDDED |
249 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 249 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
250 | mListView->setAlternateColor(c); | 250 | mListView->setAlternateColor(c); |
251 | 251 | ||
252 | 252 | ||
253 | //US mListView->viewport()->setPalette( p ); | 253 | //US mListView->viewport()->setPalette( p ); |
254 | mListView->setPalette( p ); | 254 | mListView->setPalette( p ); |
255 | } | 255 | } |
256 | else | 256 | else |
257 | { | 257 | { |
258 | // needed if turned off during a session. | 258 | // needed if turned off during a session. |
259 | //US mListView->viewport()->setPalette( mListView->palette() ); | 259 | //US mListView->viewport()->setPalette( mListView->palette() ); |
260 | mListView->setPalette( mListView->palette() ); | 260 | mListView->setPalette( mListView->palette() ); |
261 | } | 261 | } |
262 | 262 | ||
263 | //custom fonts? | 263 | //custom fonts? |
264 | QFont f( font() ); | 264 | QFont f( font() ); |
265 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 265 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
266 | { | 266 | { |
267 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 267 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
268 | f.setBold( true ); | 268 | f.setBold( true ); |
269 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 269 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
270 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 270 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
271 | } | 271 | } |
272 | else | 272 | else |
273 | { | 273 | { |
274 | mListView->setFont( f ); | 274 | mListView->setFont( f ); |
275 | f.setBold( true ); | 275 | f.setBold( true ); |
276 | //US mListView->setHeaderFont( f ); | 276 | //US mListView->setHeaderFont( f ); |
277 | mListView->header()->setFont( f ); | 277 | mListView->header()->setFont( f ); |
278 | } | 278 | } |
279 | 279 | ||
280 | // Set the list view options | 280 | // Set the list view options |
281 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 281 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
282 | true)); | 282 | true)); |
283 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 283 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
284 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 284 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
285 | 285 | ||
286 | if (config->readBoolEntry("Background", false)) | 286 | if (config->readBoolEntry("Background", false)) |
287 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 287 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
288 | 288 | ||
289 | // Restore the layout of the listview | 289 | // Restore the layout of the listview |
290 | mListView->restoreLayout(config, config->group()); | 290 | mListView->restoreLayout(config, config->group()); |
291 | } | 291 | } |
292 | 292 | ||
293 | void KAddressBookTableView::refresh(QString uid) | 293 | void KAddressBookTableView::refresh(QString uid) |
294 | { | 294 | { |
295 | // For now just repopulate. In reality this method should | 295 | // For now just repopulate. In reality this method should |
296 | // check the value of uid, and if valid iterate through | 296 | // check the value of uid, and if valid iterate through |
297 | // the listview to find the entry, then tell it to refresh. | 297 | // the listview to find the entry, then tell it to refresh. |
298 | 298 | ||
299 | if (uid.isNull()) { | 299 | if (uid.isNull()) { |
300 | // Clear the list view | 300 | // Clear the list view |
301 | QString currentUID, nextUID; | 301 | QString currentUID, nextUID; |
302 | #ifndef KAB_EMBEDDED | 302 | #ifndef KAB_EMBEDDED |
303 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 303 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
304 | #else //KAB_EMBEDDED | 304 | #else //KAB_EMBEDDED |
305 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 305 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
306 | #endif //KAB_EMBEDDED | 306 | #endif //KAB_EMBEDDED |
307 | 307 | ||
308 | if ( currentItem ) { | 308 | if ( currentItem ) { |
309 | #ifndef KAB_EMBEDDED | 309 | #ifndef KAB_EMBEDDED |
310 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 310 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
311 | #else //KAB_EMBEDDED | 311 | #else //KAB_EMBEDDED |
312 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 312 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
313 | #endif //KAB_EMBEDDED | 313 | #endif //KAB_EMBEDDED |
314 | if ( nextItem ) | 314 | if ( nextItem ) |
315 | nextUID = nextItem->addressee().uid(); | 315 | nextUID = nextItem->addressee().uid(); |
316 | currentUID = currentItem->addressee().uid(); | 316 | currentUID = currentItem->addressee().uid(); |
317 | } | 317 | } |
318 | 318 | ||
319 | mListView->clear(); | 319 | mListView->clear(); |
320 | 320 | ||
321 | currentItem = 0; | 321 | currentItem = 0; |
322 | KABC::Addressee::List addresseeList = addressees(); | 322 | KABC::Addressee::List addresseeList = addressees(); |
323 | KABC::Addressee::List::Iterator it; | 323 | KABC::Addressee::List::Iterator it; |
324 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 324 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
325 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 325 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
326 | continue; | 326 | continue; |
327 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 327 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
328 | if ( (*it).uid() == currentUID ) | 328 | if ( (*it).uid() == currentUID ) |
329 | currentItem = item; | 329 | currentItem = item; |
330 | else if ( (*it).uid() == nextUID && !currentItem ) | 330 | else if ( (*it).uid() == nextUID && !currentItem ) |
331 | currentItem = item; | 331 | currentItem = item; |
332 | } | 332 | } |
333 | 333 | ||
334 | // Sometimes the background pixmap gets messed up when we add lots | 334 | // Sometimes the background pixmap gets messed up when we add lots |
335 | // of items. | 335 | // of items. |
336 | mListView->repaint(); | 336 | mListView->repaint(); |
337 | 337 | if ( !currentItem ) | |
338 | currentItem = (ContactListViewItem *)mListView->firstChild(); | ||
338 | if ( currentItem ) { | 339 | if ( currentItem ) { |
339 | mListView->setCurrentItem( currentItem ); | 340 | mListView->setCurrentItem( currentItem ); |
340 | mListView->ensureItemVisible( currentItem ); | 341 | mListView->ensureItemVisible( currentItem ); |
342 | mListView->setSelected( currentItem, true ); | ||
341 | } | 343 | } |
342 | } else { | 344 | } else { |
343 | // Only need to update on entry. Iterate through and try to find it | 345 | // Only need to update on entry. Iterate through and try to find it |
344 | ContactListViewItem *ceItem; | 346 | ContactListViewItem *ceItem; |
345 | QListViewItemIterator it( mListView ); | 347 | QListViewItemIterator it( mListView ); |
346 | while ( it.current() ) { | 348 | while ( it.current() ) { |
347 | #ifndef KAB_EMBEDDED | 349 | #ifndef KAB_EMBEDDED |
348 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 350 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
349 | #else //KAB_EMBEDDED | 351 | #else //KAB_EMBEDDED |
350 | ceItem = (ContactListViewItem*)( it.current() ); | 352 | ceItem = (ContactListViewItem*)( it.current() ); |
351 | #endif //KAB_EMBEDDED | 353 | #endif //KAB_EMBEDDED |
352 | 354 | ||
353 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 355 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
354 | ceItem->refresh(); | 356 | ceItem->refresh(); |
355 | return; | 357 | return; |
356 | } | 358 | } |
357 | ++it; | 359 | ++it; |
358 | } | 360 | } |
359 | 361 | ||
360 | refresh( QString::null ); | 362 | refresh( QString::null ); |
361 | } | 363 | } |
362 | } | 364 | } |
363 | 365 | ||
364 | QStringList KAddressBookTableView::selectedUids() | 366 | QStringList KAddressBookTableView::selectedUids() |
365 | { | 367 | { |
366 | QStringList uidList; | 368 | QStringList uidList; |
367 | QListViewItem *item; | 369 | QListViewItem *item; |
368 | ContactListViewItem *ceItem; | 370 | ContactListViewItem *ceItem; |
369 | 371 | ||
370 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 372 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
371 | { | 373 | { |
372 | if (mListView->isSelected( item )) | 374 | if (mListView->isSelected( item )) |
373 | { | 375 | { |
374 | #ifndef KAB_EMBEDDED | 376 | #ifndef KAB_EMBEDDED |
375 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 377 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
376 | #else //KAB_EMBEDDED | 378 | #else //KAB_EMBEDDED |
377 | ceItem = (ContactListViewItem*)(item); | 379 | ceItem = (ContactListViewItem*)(item); |
378 | #endif //KAB_EMBEDDED | 380 | #endif //KAB_EMBEDDED |
379 | 381 | ||
380 | if (ceItem != 0L) | 382 | if (ceItem != 0L) |
381 | uidList << ceItem->addressee().uid(); | 383 | uidList << ceItem->addressee().uid(); |
382 | } | 384 | } |
383 | } | 385 | } |
384 | if ( uidList.count() == 0 ) | 386 | if ( uidList.count() == 0 ) |
385 | if ( mListView->currentItem() ) { | 387 | if ( mListView->currentItem() ) { |
386 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 388 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
387 | uidList << ceItem->addressee().uid(); | 389 | uidList << ceItem->addressee().uid(); |
388 | } | 390 | } |
389 | 391 | ||
390 | return uidList; | 392 | return uidList; |
391 | } | 393 | } |
392 | 394 | ||
393 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 395 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
394 | { | 396 | { |
395 | QListViewItem *item; | 397 | QListViewItem *item; |
396 | ContactListViewItem *ceItem; | 398 | ContactListViewItem *ceItem; |
397 | 399 | ||
398 | if (uid.isNull()) | 400 | if (uid.isNull()) |
399 | { | 401 | { |
400 | mListView->selectAll(selected); | 402 | mListView->selectAll(selected); |
401 | } | 403 | } |
402 | else | 404 | else |
403 | { | 405 | { |
404 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 406 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
405 | { | 407 | { |
406 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
407 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 409 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
408 | #else //KAB_EMBEDDED | 410 | #else //KAB_EMBEDDED |
409 | ceItem = (ContactListViewItem*)(item); | 411 | ceItem = (ContactListViewItem*)(item); |
410 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
411 | 413 | ||
412 | 414 | ||
413 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 415 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
414 | { | 416 | { |
415 | mListView->setSelected(item, selected); | 417 | mListView->setSelected(item, selected); |
416 | 418 | ||
417 | if (selected) | 419 | if (selected) |
418 | mListView->ensureItemVisible(item); | 420 | mListView->ensureItemVisible(item); |
419 | } | 421 | } |
420 | } | 422 | } |
421 | } | 423 | } |
422 | } | 424 | } |
423 | 425 | ||
424 | void KAddressBookTableView::addresseeSelected() | 426 | void KAddressBookTableView::addresseeSelected() |
425 | { | 427 | { |
426 | // We need to try to find the first selected item. This might not be the | 428 | // We need to try to find the first selected item. This might not be the |
427 | // last selected item, but when QListView is in multiselection mode, | 429 | // last selected item, but when QListView is in multiselection mode, |
428 | // there is no way to figure out which one was | 430 | // there is no way to figure out which one was |
429 | // selected last. | 431 | // selected last. |
430 | QListViewItem *item; | 432 | QListViewItem *item; |
431 | bool found =false; | 433 | bool found =false; |
432 | for (item = mListView->firstChild(); item && !found; | 434 | for (item = mListView->firstChild(); item && !found; |
433 | item = item->nextSibling()) | 435 | item = item->nextSibling()) |
434 | { | 436 | { |
435 | if (item->isSelected()) | 437 | if (item->isSelected()) |
436 | { | 438 | { |
437 | found = true; | 439 | found = true; |
438 | #ifndef KAB_EMBEDDED | 440 | #ifndef KAB_EMBEDDED |
439 | ContactListViewItem *ceItem | 441 | ContactListViewItem *ceItem |
440 | = dynamic_cast<ContactListViewItem*>(item); | 442 | = dynamic_cast<ContactListViewItem*>(item); |
441 | #else //KAB_EMBEDDED | 443 | #else //KAB_EMBEDDED |
442 | ContactListViewItem *ceItem | 444 | ContactListViewItem *ceItem |
443 | = (ContactListViewItem*)(item); | 445 | = (ContactListViewItem*)(item); |
444 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
445 | 447 | ||
446 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 448 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
447 | } | 449 | } |
448 | } | 450 | } |
449 | 451 | ||
450 | if (!found) | 452 | if (!found) |
451 | emit selected(QString::null); | 453 | emit selected(QString::null); |
452 | } | 454 | } |
453 | 455 | ||
454 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 456 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
455 | { | 457 | { |
456 | if (item) | 458 | if (item) |
457 | { | 459 | { |
458 | #ifndef KAB_EMBEDDED | 460 | #ifndef KAB_EMBEDDED |
459 | ContactListViewItem *ceItem | 461 | ContactListViewItem *ceItem |
460 | = dynamic_cast<ContactListViewItem*>(item); | 462 | = dynamic_cast<ContactListViewItem*>(item); |
461 | #else //KAB_EMBEDDED | 463 | #else //KAB_EMBEDDED |
462 | ContactListViewItem *ceItem | 464 | ContactListViewItem *ceItem |
463 | = (ContactListViewItem*)(item); | 465 | = (ContactListViewItem*)(item); |
464 | #endif //KAB_EMBEDDED | 466 | #endif //KAB_EMBEDDED |
465 | 467 | ||
466 | if (ceItem) | 468 | if (ceItem) |
467 | { | 469 | { |
468 | emit executed(ceItem->addressee().uid()); | 470 | emit executed(ceItem->addressee().uid()); |
469 | } | 471 | } |
470 | } | 472 | } |
471 | else | 473 | else |
472 | { | 474 | { |
473 | emit executed(QString::null); | 475 | emit executed(QString::null); |
474 | } | 476 | } |
475 | } | 477 | } |
476 | 478 | ||
477 | void KAddressBookTableView::addresseeDeleted() | 479 | void KAddressBookTableView::addresseeDeleted() |
478 | { | 480 | { |
479 | 481 | ||
480 | emit deleteRequest(); | 482 | emit deleteRequest(); |
481 | 483 | ||
482 | } | 484 | } |
483 | 485 | ||
484 | 486 | ||
485 | 487 | ||
486 | 488 | ||
487 | 489 | ||
488 | #ifndef KAB_EMBEDDED | 490 | #ifndef KAB_EMBEDDED |
489 | #include "kaddressbooktableview.moc" | 491 | #include "kaddressbooktableview.moc" |
490 | #endif //KAB_EMBEDDED | 492 | #endif //KAB_EMBEDDED |