Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 34bf7f1..6819085 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,29 +1,28 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | ||
3 | ** | 4 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
5 | ** | 6 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** OContact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | 17 | ** |
19 | **********************************************************************/ | 18 | **********************************************************************/ |
20 | 19 | ||
21 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
22 | 21 | ||
23 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 23 | #include "ablabel.h" |
25 | #include "abview.h" | 24 | #include "abview.h" |
26 | #include "abtable.h" | 25 | #include "abtable.h" |
27 | // #include "addresssettings.h" | 26 | // #include "addresssettings.h" |
28 | #include "addressbook.h" | 27 | #include "addressbook.h" |
29 | 28 | ||
@@ -104,30 +103,30 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
104 | catMenu = new QPopupMenu( this ); | 103 | catMenu = new QPopupMenu( this ); |
105 | catMenu->setCheckable( TRUE ); | 104 | catMenu->setCheckable( TRUE ); |
106 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
107 | mbList->insertItem( tr("View"), catMenu ); | 106 | mbList->insertItem( tr("View"), catMenu ); |
108 | 107 | ||
109 | // Create Toolbar | 108 | // Create Toolbar |
110 | listTools = new QPEToolBar( this, "list operations" ); | 109 | listTools = new QPEToolBar( this, "list operations" ); |
111 | listTools->setHorizontalStretchable( true ); | 110 | listTools->setHorizontalStretchable( true ); |
112 | addToolBar( listTools ); | 111 | addToolBar( listTools ); |
113 | moveToolBar( listTools, m_config.getToolBarPos() ); | 112 | moveToolBar( listTools, m_config.getToolBarPos() ); |
114 | 113 | ||
115 | // View Icons | 114 | // View Icons |
116 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ), | 115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
117 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
118 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
119 | m_tableViewButton->setToggleAction( true ); | 118 | m_tableViewButton->setToggleAction( true ); |
120 | m_tableViewButton->addTo( listTools ); | 119 | m_tableViewButton->addTo( listTools ); |
121 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); | 120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
122 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
123 | m_cardViewButton->setToggleAction( true ); | 122 | m_cardViewButton->setToggleAction( true ); |
124 | m_cardViewButton->addTo( listTools ); | 123 | m_cardViewButton->addTo( listTools ); |
125 | 124 | ||
126 | listTools->addSeparator(); | 125 | listTools->addSeparator(); |
127 | 126 | ||
128 | // Other Buttons | 127 | // Other Buttons |
129 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
130 | 0, this, 0 ); | 129 | 0, this, 0 ); |
131 | actionNew = a; | 130 | actionNew = a; |
132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
133 | a->addTo( edit ); | 132 | a->addTo( edit ); |
@@ -643,25 +642,27 @@ static void parseName( const QString& name, QString *first, QString *middle, | |||
643 | if ( space <= 0 ) { | 642 | if ( space <= 0 ) { |
644 | *first = rest; | 643 | *first = rest; |
645 | } else { | 644 | } else { |
646 | *first = rest.left( space ); | 645 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 646 | *middle = rest.mid( space+1 ); |
648 | } | 647 | } |
649 | 648 | ||
650 | } | 649 | } |
651 | 650 | ||
652 | 651 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 652 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 653 | { |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 654 | bool needShow = FALSE; |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | ||
656 | |||
656 | 657 | ||
657 | if (msg == "editPersonal()") { | 658 | if (msg == "editPersonal()") { |
658 | editPersonal(); | 659 | editPersonal(); |
659 | } else if (msg == "editPersonalAndClose()") { | 660 | } else if (msg == "editPersonalAndClose()") { |
660 | editPersonal(); | 661 | editPersonal(); |
661 | close(); | 662 | close(); |
662 | } else if ( msg == "addContact(QString,QString)" ) { | 663 | } else if ( msg == "addContact(QString,QString)" ) { |
663 | QDataStream stream(data,IO_ReadOnly); | 664 | QDataStream stream(data,IO_ReadOnly); |
664 | QString name, email; | 665 | QString name, email; |
665 | stream >> name >> email; | 666 | stream >> name >> email; |
666 | 667 | ||
667 | OContact cnt; | 668 | OContact cnt; |
@@ -680,60 +681,64 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
680 | // :SXm_abView()->init( cnt ); | 681 | // :SXm_abView()->init( cnt ); |
681 | editEntry( EditEntry ); | 682 | editEntry( EditEntry ); |
682 | } else if ( msg == "beamBusinessCard()" ) { | 683 | } else if ( msg == "beamBusinessCard()" ) { |
683 | QString beamFilename = addressbookPersonalVCardName(); | 684 | QString beamFilename = addressbookPersonalVCardName(); |
684 | if ( !QFile::exists( beamFilename ) ) | 685 | if ( !QFile::exists( beamFilename ) ) |
685 | return; // can't beam a non-existent file | 686 | return; // can't beam a non-existent file |
686 | 687 | ||
687 | Ir *ir = new Ir( this ); | 688 | Ir *ir = new Ir( this ); |
688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 689 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
689 | QString description = "mycard.vcf"; | 690 | QString description = "mycard.vcf"; |
690 | ir->send( beamFilename, description, "text/x-vCard" ); | 691 | ir->send( beamFilename, description, "text/x-vCard" ); |
691 | } else if ( msg == "show(int)" ) { | 692 | } else if ( msg == "show(int)" ) { |
693 | raise(); | ||
692 | QDataStream stream(data,IO_ReadOnly); | 694 | QDataStream stream(data,IO_ReadOnly); |
693 | int uid; | 695 | int uid; |
694 | stream >> uid; | 696 | stream >> uid; |
695 | 697 | ||
696 | qWarning( "Showing uid: %d" , uid ); | 698 | qWarning( "Showing uid: %d" , uid ); |
697 | 699 | ||
698 | // Deactivate Personal View.. | 700 | // Deactivate Personal View.. |
699 | if ( actionPersonal->isOn() ){ | 701 | if ( actionPersonal->isOn() ){ |
700 | actionPersonal->setOn( false ); | 702 | actionPersonal->setOn( false ); |
701 | slotPersonalView(); | 703 | slotPersonalView(); |
702 | } | 704 | } |
703 | 705 | ||
704 | // Reset category and show as card.. | 706 | // Reset category and show as card.. |
705 | m_abView -> setShowByCategory( QString::null ); | 707 | m_abView -> setShowByCategory( QString::null ); |
706 | m_abView -> setCurrentUid( uid ); | 708 | m_abView -> setCurrentUid( uid ); |
707 | slotViewSwitched ( AbView::CardView ); | 709 | slotViewSwitched ( AbView::CardView ); |
708 | 710 | ||
709 | showMaximized(); | 711 | needShow = true; |
710 | qApp->exec(); | 712 | |
711 | 713 | ||
712 | } else if ( msg == "edit(int)" ) { | 714 | } else if ( msg == "edit(int)" ) { |
713 | QDataStream stream(data,IO_ReadOnly); | 715 | QDataStream stream(data,IO_ReadOnly); |
714 | int uid; | 716 | int uid; |
715 | stream >> uid; | 717 | stream >> uid; |
716 | 718 | ||
717 | // Deactivate Personal View.. | 719 | // Deactivate Personal View.. |
718 | if ( actionPersonal->isOn() ){ | 720 | if ( actionPersonal->isOn() ){ |
719 | actionPersonal->setOn( false ); | 721 | actionPersonal->setOn( false ); |
720 | slotPersonalView(); | 722 | slotPersonalView(); |
721 | } | 723 | } |
722 | 724 | ||
723 | // Reset category and edit.. | 725 | // Reset category and edit.. |
724 | m_abView -> setShowByCategory( QString::null ); | 726 | m_abView -> setShowByCategory( QString::null ); |
725 | m_abView -> setCurrentUid( uid ); | 727 | m_abView -> setCurrentUid( uid ); |
726 | slotViewEdit(); | 728 | slotViewEdit(); |
727 | } | 729 | } |
730 | |||
731 | if (needShow) | ||
732 | QPEApplication::setKeepRunning(); | ||
728 | 733 | ||
729 | } | 734 | } |
730 | 735 | ||
731 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 736 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
732 | { | 737 | { |
733 | OContact entry; | 738 | OContact entry; |
734 | if ( !abEditor ) { | 739 | if ( !abEditor ) { |
735 | abEditor = new ContactEditor( entry, this, "editor" ); | 740 | abEditor = new ContactEditor( entry, this, "editor" ); |
736 | } | 741 | } |
737 | if ( entryMode == EditEntry ) | 742 | if ( entryMode == EditEntry ) |
738 | abEditor->setEntry( m_abView -> currentEntry() ); | 743 | abEditor->setEntry( m_abView -> currentEntry() ); |
739 | else if ( entryMode == NewEntry ) | 744 | else if ( entryMode == NewEntry ) |
@@ -891,25 +896,25 @@ bool AddressbookWindow::save() | |||
891 | #ifdef __DEBUG_RELEASE | 896 | #ifdef __DEBUG_RELEASE |
892 | void AddressbookWindow::slotSave() | 897 | void AddressbookWindow::slotSave() |
893 | { | 898 | { |
894 | save(); | 899 | save(); |
895 | } | 900 | } |
896 | #endif | 901 | #endif |
897 | 902 | ||
898 | 903 | ||
899 | void AddressbookWindow::slotNotFound() | 904 | void AddressbookWindow::slotNotFound() |
900 | { | 905 | { |
901 | qWarning("Got notfound signal!"); | 906 | qWarning("Got notfound signal!"); |
902 | QMessageBox::information( this, tr( "Not Found" ), | 907 | QMessageBox::information( this, tr( "Not Found" ), |
903 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 908 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
904 | 909 | ||
905 | 910 | ||
906 | } | 911 | } |
907 | void AddressbookWindow::slotWrapAround() | 912 | void AddressbookWindow::slotWrapAround() |
908 | { | 913 | { |
909 | qWarning("Got wrap signal!"); | 914 | qWarning("Got wrap signal!"); |
910 | // if ( doNotifyWrapAround ) | 915 | // if ( doNotifyWrapAround ) |
911 | // QMessageBox::information( this, tr( "End of list" ), | 916 | // QMessageBox::information( this, tr( "End of list" ), |
912 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 917 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
913 | 918 | ||
914 | } | 919 | } |
915 | 920 | ||
@@ -941,25 +946,25 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
941 | book = QString::null; | 946 | book = QString::null; |
942 | view = AbView::TableView; | 947 | view = AbView::TableView; |
943 | }else if ( i == 2 ){ | 948 | }else if ( i == 2 ){ |
944 | book = tr( "Cards" ); | 949 | book = tr( "Cards" ); |
945 | view = AbView::CardView; | 950 | view = AbView::CardView; |
946 | // }else if ( i == 3 ){ | 951 | // }else if ( i == 3 ){ |
947 | // book = tr( "Personal" ); | 952 | // book = tr( "Personal" ); |
948 | // view = AbView:: PersonalView; | 953 | // view = AbView:: PersonalView; |
949 | }else if ( i == 3 ){ // default All Categories | 954 | }else if ( i == 3 ){ // default All Categories |
950 | cat = QString::null; | 955 | cat = QString::null; |
951 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 956 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
952 | cat = "Unfiled"; | 957 | cat = "Unfiled"; |
953 | qWarning ("Unfiled selected!!!"); | 958 | qWarning ("Unfiled selected!"); |
954 | }else{ | 959 | }else{ |
955 | cat = m_abView->categories()[i - 4]; | 960 | cat = m_abView->categories()[i - 4]; |
956 | } | 961 | } |
957 | } | 962 | } |
958 | } | 963 | } |
959 | 964 | ||
960 | // Switch to the selected View | 965 | // Switch to the selected View |
961 | slotViewSwitched( view ); | 966 | slotViewSwitched( view ); |
962 | 967 | ||
963 | // Tell the view about the selected category | 968 | // Tell the view about the selected category |
964 | m_abView -> setShowByCategory( cat ); | 969 | m_abView -> setShowByCategory( cat ); |
965 | 970 | ||