author | eilers <eilers> | 2003-05-09 13:41:06 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-05-09 13:41:06 (UTC) |
commit | ddadf9f70cbcd7c6b8addcc8c1f6ede0283f765d (patch) (unidiff) | |
tree | 3471c2ecec1ec034fb2855da230f05fef5e7b3b1 | |
parent | 98196030da571da62ecb2fdd67e77a1e941d175a (diff) | |
download | opie-ddadf9f70cbcd7c6b8addcc8c1f6ede0283f765d.zip opie-ddadf9f70cbcd7c6b8addcc8c1f6ede0283f765d.tar.gz opie-ddadf9f70cbcd7c6b8addcc8c1f6ede0283f765d.tar.bz2 |
No it jumps into the front if show(int) is used.. Thanks tille !
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 975911e..25c6f3a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -581,256 +581,257 @@ void AddressbookWindow::slotBeam() | |||
581 | QString beamFilename; | 581 | QString beamFilename; |
582 | OContact c; | 582 | OContact c; |
583 | if ( actionPersonal->isOn() ) { | 583 | if ( actionPersonal->isOn() ) { |
584 | beamFilename = addressbookPersonalVCardName(); | 584 | beamFilename = addressbookPersonalVCardName(); |
585 | if ( !QFile::exists( beamFilename ) ) | 585 | if ( !QFile::exists( beamFilename ) ) |
586 | return; // can't beam a non-existent file | 586 | return; // can't beam a non-existent file |
587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
588 | beamFilename ); | 588 | beamFilename ); |
589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
590 | OContactAccess::List allList = access->allRecords(); | 590 | OContactAccess::List allList = access->allRecords(); |
591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
592 | c = *it; | 592 | c = *it; |
593 | 593 | ||
594 | delete access; | 594 | delete access; |
595 | } else { | 595 | } else { |
596 | unlink( beamfile ); // delete if exists | 596 | unlink( beamfile ); // delete if exists |
597 | mkdir("/tmp/obex/", 0755); | 597 | mkdir("/tmp/obex/", 0755); |
598 | c = m_abView -> currentEntry(); | 598 | c = m_abView -> currentEntry(); |
599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
600 | beamfile ); | 600 | beamfile ); |
601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
602 | access->add( c ); | 602 | access->add( c ); |
603 | access->save(); | 603 | access->save(); |
604 | delete access; | 604 | delete access; |
605 | 605 | ||
606 | beamFilename = beamfile; | 606 | beamFilename = beamfile; |
607 | } | 607 | } |
608 | 608 | ||
609 | qWarning("Beaming: %s", beamFilename.latin1() ); | 609 | qWarning("Beaming: %s", beamFilename.latin1() ); |
610 | 610 | ||
611 | Ir *ir = new Ir( this ); | 611 | Ir *ir = new Ir( this ); |
612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
613 | QString description = c.fullName(); | 613 | QString description = c.fullName(); |
614 | ir->send( beamFilename, description, "text/x-vCard" ); | 614 | ir->send( beamFilename, description, "text/x-vCard" ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 617 | void AddressbookWindow::beamDone( Ir *ir ) |
618 | { | 618 | { |
619 | 619 | ||
620 | delete ir; | 620 | delete ir; |
621 | unlink( beamfile ); | 621 | unlink( beamfile ); |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 625 | static void parseName( const QString& name, QString *first, QString *middle, |
626 | QString * last ) | 626 | QString * last ) |
627 | { | 627 | { |
628 | 628 | ||
629 | int comma = name.find ( "," ); | 629 | int comma = name.find ( "," ); |
630 | QString rest; | 630 | QString rest; |
631 | if ( comma > 0 ) { | 631 | if ( comma > 0 ) { |
632 | *last = name.left( comma ); | 632 | *last = name.left( comma ); |
633 | comma++; | 633 | comma++; |
634 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 634 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
635 | comma++; | 635 | comma++; |
636 | rest = name.mid( comma ); | 636 | rest = name.mid( comma ); |
637 | } else { | 637 | } else { |
638 | int space = name.findRev( ' ' ); | 638 | int space = name.findRev( ' ' ); |
639 | *last = name.mid( space+1 ); | 639 | *last = name.mid( space+1 ); |
640 | rest = name.left( space ); | 640 | rest = name.left( space ); |
641 | } | 641 | } |
642 | int space = rest.find( ' ' ); | 642 | int space = rest.find( ' ' ); |
643 | if ( space <= 0 ) { | 643 | if ( space <= 0 ) { |
644 | *first = rest; | 644 | *first = rest; |
645 | } else { | 645 | } else { |
646 | *first = rest.left( space ); | 646 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 647 | *middle = rest.mid( space+1 ); |
648 | } | 648 | } |
649 | 649 | ||
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 654 | { |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); |
656 | 656 | ||
657 | if (msg == "editPersonal()") { | 657 | if (msg == "editPersonal()") { |
658 | editPersonal(); | 658 | editPersonal(); |
659 | } else if (msg == "editPersonalAndClose()") { | 659 | } else if (msg == "editPersonalAndClose()") { |
660 | editPersonal(); | 660 | editPersonal(); |
661 | close(); | 661 | close(); |
662 | } else if ( msg == "addContact(QString,QString)" ) { | 662 | } else if ( msg == "addContact(QString,QString)" ) { |
663 | QDataStream stream(data,IO_ReadOnly); | 663 | QDataStream stream(data,IO_ReadOnly); |
664 | QString name, email; | 664 | QString name, email; |
665 | stream >> name >> email; | 665 | stream >> name >> email; |
666 | 666 | ||
667 | OContact cnt; | 667 | OContact cnt; |
668 | QString fn, mn, ln; | 668 | QString fn, mn, ln; |
669 | parseName( name, &fn, &mn, &ln ); | 669 | parseName( name, &fn, &mn, &ln ); |
670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
671 | cnt.setFirstName( fn ); | 671 | cnt.setFirstName( fn ); |
672 | cnt.setMiddleName( mn ); | 672 | cnt.setMiddleName( mn ); |
673 | cnt.setLastName( ln ); | 673 | cnt.setLastName( ln ); |
674 | cnt.insertEmails( email ); | 674 | cnt.insertEmails( email ); |
675 | cnt.setDefaultEmail( email ); | 675 | cnt.setDefaultEmail( email ); |
676 | cnt.setFileAs(); | 676 | cnt.setFileAs(); |
677 | 677 | ||
678 | m_abView -> addEntry( cnt ); | 678 | m_abView -> addEntry( cnt ); |
679 | 679 | ||
680 | // :SXm_abView()->init( cnt ); | 680 | // :SXm_abView()->init( cnt ); |
681 | editEntry( EditEntry ); | 681 | editEntry( EditEntry ); |
682 | } else if ( msg == "beamBusinessCard()" ) { | 682 | } else if ( msg == "beamBusinessCard()" ) { |
683 | QString beamFilename = addressbookPersonalVCardName(); | 683 | QString beamFilename = addressbookPersonalVCardName(); |
684 | if ( !QFile::exists( beamFilename ) ) | 684 | if ( !QFile::exists( beamFilename ) ) |
685 | return; // can't beam a non-existent file | 685 | return; // can't beam a non-existent file |
686 | 686 | ||
687 | Ir *ir = new Ir( this ); | 687 | Ir *ir = new Ir( this ); |
688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
689 | QString description = "mycard.vcf"; | 689 | QString description = "mycard.vcf"; |
690 | ir->send( beamFilename, description, "text/x-vCard" ); | 690 | ir->send( beamFilename, description, "text/x-vCard" ); |
691 | } else if ( msg == "show(int)" ) { | 691 | } else if ( msg == "show(int)" ) { |
692 | QDataStream stream(data,IO_ReadOnly); | 692 | QDataStream stream(data,IO_ReadOnly); |
693 | int uid; | 693 | int uid; |
694 | stream >> uid; | 694 | stream >> uid; |
695 | 695 | ||
696 | qWarning( "Showing uid: %d" , uid ); | 696 | qWarning( "Showing uid: %d" , uid ); |
697 | 697 | ||
698 | // Deactivate Personal View.. | 698 | // Deactivate Personal View.. |
699 | if ( actionPersonal->isOn() ){ | 699 | if ( actionPersonal->isOn() ){ |
700 | actionPersonal->setOn( false ); | 700 | actionPersonal->setOn( false ); |
701 | slotPersonalView(); | 701 | slotPersonalView(); |
702 | } | 702 | } |
703 | 703 | ||
704 | // Reset category and show as card.. | 704 | // Reset category and show as card.. |
705 | m_abView -> setShowByCategory( QString::null ); | 705 | m_abView -> setShowByCategory( QString::null ); |
706 | m_abView -> setCurrentUid( uid ); | 706 | m_abView -> setCurrentUid( uid ); |
707 | slotViewSwitched ( AbView::CardView ); | 707 | slotViewSwitched ( AbView::CardView ); |
708 | 708 | ||
709 | showMaximized(); | ||
709 | qApp->exec(); | 710 | qApp->exec(); |
710 | 711 | ||
711 | } else if ( msg == "edit(int)" ) { | 712 | } else if ( msg == "edit(int)" ) { |
712 | QDataStream stream(data,IO_ReadOnly); | 713 | QDataStream stream(data,IO_ReadOnly); |
713 | int uid; | 714 | int uid; |
714 | stream >> uid; | 715 | stream >> uid; |
715 | 716 | ||
716 | // Deactivate Personal View.. | 717 | // Deactivate Personal View.. |
717 | if ( actionPersonal->isOn() ){ | 718 | if ( actionPersonal->isOn() ){ |
718 | actionPersonal->setOn( false ); | 719 | actionPersonal->setOn( false ); |
719 | slotPersonalView(); | 720 | slotPersonalView(); |
720 | } | 721 | } |
721 | 722 | ||
722 | // Reset category and edit.. | 723 | // Reset category and edit.. |
723 | m_abView -> setShowByCategory( QString::null ); | 724 | m_abView -> setShowByCategory( QString::null ); |
724 | m_abView -> setCurrentUid( uid ); | 725 | m_abView -> setCurrentUid( uid ); |
725 | slotViewEdit(); | 726 | slotViewEdit(); |
726 | } | 727 | } |
727 | 728 | ||
728 | } | 729 | } |
729 | 730 | ||
730 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 731 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
731 | { | 732 | { |
732 | OContact entry; | 733 | OContact entry; |
733 | if ( !abEditor ) { | 734 | if ( !abEditor ) { |
734 | abEditor = new ContactEditor( entry, this, "editor" ); | 735 | abEditor = new ContactEditor( entry, this, "editor" ); |
735 | } | 736 | } |
736 | if ( entryMode == EditEntry ) | 737 | if ( entryMode == EditEntry ) |
737 | abEditor->setEntry( m_abView -> currentEntry() ); | 738 | abEditor->setEntry( m_abView -> currentEntry() ); |
738 | else if ( entryMode == NewEntry ) | 739 | else if ( entryMode == NewEntry ) |
739 | abEditor->setEntry( entry ); | 740 | abEditor->setEntry( entry ); |
740 | // other things may change the caption. | 741 | // other things may change the caption. |
741 | abEditor->setCaption( tr("Edit Address") ); | 742 | abEditor->setCaption( tr("Edit Address") ); |
742 | 743 | ||
743 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 744 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
744 | abEditor->showMaximized(); | 745 | abEditor->showMaximized(); |
745 | #endif | 746 | #endif |
746 | // fix the foxus... | 747 | // fix the foxus... |
747 | abEditor->setNameFocus(); | 748 | abEditor->setNameFocus(); |
748 | if ( abEditor->exec() ) { | 749 | if ( abEditor->exec() ) { |
749 | setFocus(); | 750 | setFocus(); |
750 | if ( entryMode == NewEntry ) { | 751 | if ( entryMode == NewEntry ) { |
751 | OContact insertEntry = abEditor->entry(); | 752 | OContact insertEntry = abEditor->entry(); |
752 | insertEntry.assignUid(); | 753 | insertEntry.assignUid(); |
753 | m_abView -> addEntry( insertEntry ); | 754 | m_abView -> addEntry( insertEntry ); |
754 | } else { | 755 | } else { |
755 | OContact replEntry = abEditor->entry(); | 756 | OContact replEntry = abEditor->entry(); |
756 | 757 | ||
757 | if ( !replEntry.isValidUid() ) | 758 | if ( !replEntry.isValidUid() ) |
758 | replEntry.assignUid(); | 759 | replEntry.assignUid(); |
759 | 760 | ||
760 | m_abView -> replaceEntry( replEntry ); | 761 | m_abView -> replaceEntry( replEntry ); |
761 | } | 762 | } |
762 | } | 763 | } |
763 | // populateCategories(); | 764 | // populateCategories(); |
764 | 765 | ||
765 | } | 766 | } |
766 | 767 | ||
767 | void AddressbookWindow::editPersonal() | 768 | void AddressbookWindow::editPersonal() |
768 | { | 769 | { |
769 | OContact entry; | 770 | OContact entry; |
770 | 771 | ||
771 | // Switch to personal view if not selected | 772 | // Switch to personal view if not selected |
772 | // but take care of the menu, too | 773 | // but take care of the menu, too |
773 | if ( ! actionPersonal->isOn() ){ | 774 | if ( ! actionPersonal->isOn() ){ |
774 | qWarning("*** ++++"); | 775 | qWarning("*** ++++"); |
775 | actionPersonal->setOn( true ); | 776 | actionPersonal->setOn( true ); |
776 | slotPersonalView(); | 777 | slotPersonalView(); |
777 | } | 778 | } |
778 | 779 | ||
779 | if ( !abEditor ) { | 780 | if ( !abEditor ) { |
780 | abEditor = new ContactEditor( entry, this, "editor" ); | 781 | abEditor = new ContactEditor( entry, this, "editor" ); |
781 | } | 782 | } |
782 | 783 | ||
783 | abEditor->setCaption(tr("Edit My Personal Details")); | 784 | abEditor->setCaption(tr("Edit My Personal Details")); |
784 | abEditor->setPersonalView( true ); | 785 | abEditor->setPersonalView( true ); |
785 | editEntry( EditEntry ); | 786 | editEntry( EditEntry ); |
786 | abEditor->setPersonalView( false ); | 787 | abEditor->setPersonalView( false ); |
787 | 788 | ||
788 | } | 789 | } |
789 | 790 | ||
790 | 791 | ||
791 | void AddressbookWindow::slotPersonalView() | 792 | void AddressbookWindow::slotPersonalView() |
792 | { | 793 | { |
793 | qWarning("slotPersonalView()"); | 794 | qWarning("slotPersonalView()"); |
794 | if (!actionPersonal->isOn()) { | 795 | if (!actionPersonal->isOn()) { |
795 | // we just turned it off | 796 | // we just turned it off |
796 | qWarning("slotPersonalView()-> OFF"); | 797 | qWarning("slotPersonalView()-> OFF"); |
797 | setCaption( tr("Contacts") ); | 798 | setCaption( tr("Contacts") ); |
798 | actionNew->setEnabled(TRUE); | 799 | actionNew->setEnabled(TRUE); |
799 | actionTrash->setEnabled(TRUE); | 800 | actionTrash->setEnabled(TRUE); |
800 | actionFind->setEnabled(TRUE); | 801 | actionFind->setEnabled(TRUE); |
801 | actionMail->setEnabled(TRUE); | 802 | actionMail->setEnabled(TRUE); |
802 | // slotUpdateToolbar(); | 803 | // slotUpdateToolbar(); |
803 | 804 | ||
804 | m_abView->showPersonal( false ); | 805 | m_abView->showPersonal( false ); |
805 | 806 | ||
806 | return; | 807 | return; |
807 | } | 808 | } |
808 | 809 | ||
809 | qWarning("slotPersonalView()-> ON"); | 810 | qWarning("slotPersonalView()-> ON"); |
810 | // XXX need to disable some QActions. | 811 | // XXX need to disable some QActions. |
811 | actionNew->setEnabled(FALSE); | 812 | actionNew->setEnabled(FALSE); |
812 | actionTrash->setEnabled(FALSE); | 813 | actionTrash->setEnabled(FALSE); |
813 | actionFind->setEnabled(FALSE); | 814 | actionFind->setEnabled(FALSE); |
814 | actionMail->setEnabled(FALSE); | 815 | actionMail->setEnabled(FALSE); |
815 | 816 | ||
816 | setCaption( tr("Contacts - My Personal Details") ); | 817 | setCaption( tr("Contacts - My Personal Details") ); |
817 | 818 | ||
818 | m_abView->showPersonal( true ); | 819 | m_abView->showPersonal( true ); |
819 | 820 | ||
820 | } | 821 | } |
821 | 822 | ||
822 | 823 | ||
823 | void AddressbookWindow::listIsEmpty( bool empty ) | 824 | void AddressbookWindow::listIsEmpty( bool empty ) |
824 | { | 825 | { |
825 | if ( !empty ) { | 826 | if ( !empty ) { |
826 | deleteButton->setEnabled( TRUE ); | 827 | deleteButton->setEnabled( TRUE ); |
827 | } | 828 | } |
828 | } | 829 | } |
829 | 830 | ||
830 | void AddressbookWindow::reload() | 831 | void AddressbookWindow::reload() |
831 | { | 832 | { |
832 | syncing = FALSE; | 833 | syncing = FALSE; |
833 | m_abView->clear(); | 834 | m_abView->clear(); |
834 | m_abView->reload(); | 835 | m_abView->reload(); |
835 | } | 836 | } |
836 | 837 | ||