summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index e8fa37c..5a8038b 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -8,49 +8,53 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abtable.h" 25#include "abtable.h"
26#include "addresssettings.h" 26#include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/contact.h> 31#include <qpe/contact.h>
32
33#ifndef MAKE_FOR_SHARP_ROM
32#include <qpe/finddialog.h> 34#include <qpe/finddialog.h>
35#endif
36
33#include <qpe/global.h> 37#include <qpe/global.h>
34#include <qpe/resource.h> 38#include <qpe/resource.h>
35#include <qpe/ir.h> 39#include <qpe/ir.h>
36#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
38 42
39#include <qaction.h> 43#include <qaction.h>
40#include <qdialog.h> 44#include <qdialog.h>
41#include <qdir.h> 45#include <qdir.h>
42#include <qfile.h> 46#include <qfile.h>
43#include <qimage.h> 47#include <qimage.h>
44#include <qlayout.h> 48#include <qlayout.h>
45#include <qpe/qpemenubar.h> 49#include <qpe/qpemenubar.h>
46#include <qmessagebox.h> 50#include <qmessagebox.h>
47#include <qpixmap.h> 51#include <qpixmap.h>
48#include <qpopupmenu.h> 52#include <qpopupmenu.h>
49#include <qpe/qpetoolbar.h> 53#include <qpe/qpetoolbar.h>
50#include <qstringlist.h> 54#include <qstringlist.h>
51#include <qtoolbutton.h> 55#include <qtoolbutton.h>
52#include <qwhatsthis.h> 56#include <qwhatsthis.h>
53 57
54#include <stdlib.h> 58#include <stdlib.h>
55#include <sys/stat.h> 59#include <sys/stat.h>
56#include <sys/types.h> 60#include <sys/types.h>
@@ -108,54 +112,56 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
108 listTools = new QPEToolBar( this, "list operations" ); 112 listTools = new QPEToolBar( this, "list operations" );
109 113
110 114
111 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 115 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
112 0, this, 0 ); 116 0, this, 0 );
113 actionNew = a; 117 actionNew = a;
114 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 118 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
115 a->addTo( edit ); 119 a->addTo( edit );
116 a->addTo( listTools ); 120 a->addTo( listTools );
117 121
118 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 122 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
119 0, this, 0 ); 123 0, this, 0 );
120 actionEdit = a; 124 actionEdit = a;
121 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
122 a->addTo( edit ); 126 a->addTo( edit );
123 a->addTo( listTools ); 127 a->addTo( listTools );
124 128
125 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 129 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
126 0, this, 0 ); 130 0, this, 0 );
127 actionTrash = a; 131 actionTrash = a;
128 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
129 a->addTo( edit ); 133 a->addTo( edit );
130 a->addTo( listTools ); 134 a->addTo( listTools );
131 135
136#ifndef MAKE_FOR_SHARP_ROM
132 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 137 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
133 QString::null, 0, this, 0 ); 138 QString::null, 0, this, 0 );
134 actionFind = a; 139 actionFind = a;
135 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 140 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
136 a->addTo( edit ); 141 a->addTo( edit );
137 a->addTo( listTools ); 142 a->addTo( listTools );
143#endif
138 144
139 145
140 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 146 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
141 QString::null, 0, this, 0 ); 147 QString::null, 0, this, 0 );
142 //a->setEnabled( FALSE ); we got support for it now :) zecke 148 //a->setEnabled( FALSE ); we got support for it now :) zecke
143 actionMail = a; 149 actionMail = a;
144 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 150 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
145 a->addTo( edit ); 151 a->addTo( edit );
146 a->addTo( listTools ); 152 a->addTo( listTools );
147 153
148 154
149 155
150 if ( Ir::supported() ) { 156 if ( Ir::supported() ) {
151 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 157 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
152 0, this, 0 ); 158 0, this, 0 );
153 actionBeam = a; 159 actionBeam = a;
154 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 160 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
155 a->addTo( edit ); 161 a->addTo( edit );
156 a->addTo( listTools ); 162 a->addTo( listTools );
157 } 163 }
158 164
159 edit->insertSeparator(); 165 edit->insertSeparator();
160 166
161 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 167 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
@@ -489,58 +495,62 @@ void AddressbookWindow::editPersonal()
489 495
490 abEditor->setCaption(tr("Edit My Personal Details")); 496 abEditor->setCaption(tr("Edit My Personal Details"));
491 abEditor->showMaximized(); 497 abEditor->showMaximized();
492 498
493 // fix the foxus... 499 // fix the foxus...
494 abEditor->setNameFocus(); 500 abEditor->setNameFocus();
495 if ( abEditor->exec() ) { 501 if ( abEditor->exec() ) {
496 setFocus(); 502 setFocus();
497 Contact new_personal = abEditor->entry(); 503 Contact new_personal = abEditor->entry();
498 QString fname = addressbookPersonalVCardName(); 504 QString fname = addressbookPersonalVCardName();
499 Contact::writeVCard( fname, new_personal ); 505 Contact::writeVCard( fname, new_personal );
500 abView()->init(new_personal); 506 abView()->init(new_personal);
501 abView()->sync(); 507 abView()->sync();
502 } 508 }
503 abEditor->setCaption( tr("Edit Address") ); 509 abEditor->setCaption( tr("Edit Address") );
504} 510}
505 511
506void AddressbookWindow::slotPersonalView() 512void AddressbookWindow::slotPersonalView()
507{ 513{
508 if (!actionPersonal->isOn()) { 514 if (!actionPersonal->isOn()) {
509 // we just turned it off 515 // we just turned it off
510 setCaption( tr("Contacts") ); 516 setCaption( tr("Contacts") );
511 actionNew->setEnabled(TRUE); 517 actionNew->setEnabled(TRUE);
512 actionTrash->setEnabled(TRUE); 518 actionTrash->setEnabled(TRUE);
519#ifndef MAKE_FOR_SHARP_ROM
513 actionFind->setEnabled(TRUE); 520 actionFind->setEnabled(TRUE);
521#endif
514 slotUpdateToolbar(); // maybe some of the above could be moved there 522 slotUpdateToolbar(); // maybe some of the above could be moved there
515 showList(); 523 showList();
516 return; 524 return;
517 } 525 }
518 526
519 // XXX need to disable some QActions. 527 // XXX need to disable some QActions.
520 actionNew->setEnabled(FALSE); 528 actionNew->setEnabled(FALSE);
521 actionTrash->setEnabled(FALSE); 529 actionTrash->setEnabled(FALSE);
530#ifndef MAKE_FOR_SHARP_ROM
522 actionFind->setEnabled(FALSE); 531 actionFind->setEnabled(FALSE);
532#endif
523 actionMail->setEnabled(FALSE); 533 actionMail->setEnabled(FALSE);
524 534
525 setCaption( tr("Contacts - My Personal Details") ); 535 setCaption( tr("Contacts - My Personal Details") );
526 QString filename = addressbookPersonalVCardName(); 536 QString filename = addressbookPersonalVCardName();
527 Contact me; 537 Contact me;
528 if (QFile::exists(filename)) 538 if (QFile::exists(filename))
529 me = Contact::readVCard( filename )[0]; 539 me = Contact::readVCard( filename )[0];
530 540
531 abView()->init( me ); 541 abView()->init( me );
532 abView()->sync(); 542 abView()->sync();
533 abList->hide(); 543 abList->hide();
534 setCentralWidget( abView() ); 544 setCentralWidget( abView() );
535 mView->show(); 545 mView->show();
536 mView->setFocus(); 546 mView->setFocus();
537} 547}
538 548
539void AddressbookWindow::editEntry( EntryMode entryMode ) 549void AddressbookWindow::editEntry( EntryMode entryMode )
540{ 550{
541 Contact entry; 551 Contact entry;
542 if ( bAbEditFirstTime ) { 552 if ( bAbEditFirstTime ) {
543 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, 553 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
544 this, "editor" ); 554 this, "editor" );
545 bAbEditFirstTime = FALSE; 555 bAbEditFirstTime = FALSE;
546 if ( entryMode == EditEntry ) 556 if ( entryMode == EditEntry )
@@ -755,58 +765,64 @@ void AddressbookWindow::initFields()
755 slOrderedFields.remove( tr("Name Title") ); 765 slOrderedFields.remove( tr("Name Title") );
756 slOrderedFields.remove( tr("First Name") ); 766 slOrderedFields.remove( tr("First Name") );
757 slOrderedFields.remove( tr("Last Name") ); 767 slOrderedFields.remove( tr("Last Name") );
758 slOrderedFields.remove( tr("File As") ); 768 slOrderedFields.remove( tr("File As") );
759 slOrderedFields.remove( tr("Default Email") ); 769 slOrderedFields.remove( tr("Default Email") );
760 slOrderedFields.remove( tr("Notes") ); 770 slOrderedFields.remove( tr("Notes") );
761 slOrderedFields.remove( tr("Gender") ); 771 slOrderedFields.remove( tr("Gender") );
762 772
763 } 773 }
764} 774}
765 775
766 776
767AbLabel *AddressbookWindow::abView() 777AbLabel *AddressbookWindow::abView()
768{ 778{
769 if ( !mView ) { 779 if ( !mView ) {
770 mView = new AbLabel( this, "viewer" ); 780 mView = new AbLabel( this, "viewer" );
771 mView->init( Contact() ); 781 mView->init( Contact() );
772 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); 782 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
773 } 783 }
774 return mView; 784 return mView;
775} 785}
776 786
777void AddressbookWindow::slotFind() 787void AddressbookWindow::slotFind()
778{ 788{
789#ifndef MAKE_FOR_SHARP_ROM
779 if ( centralWidget() == abView() ) 790 if ( centralWidget() == abView() )
780 showList(); 791 showList();
792
781 FindDialog frmFind( "Contacts", this ); 793 FindDialog frmFind( "Contacts", this );
782 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); 794 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int)));
783 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); 795 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
784 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); 796 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
797
785 frmFind.exec(); 798 frmFind.exec();
799
786 if ( abList->numSelections() ) 800 if ( abList->numSelections() )
787 abList->clearSelection(); 801 abList->clearSelection();
802
788 abList->clearFindRow(); 803 abList->clearFindRow();
804#endif
789} 805}
790 806
791void AddressbookWindow::slotSetCategory( int c ) 807void AddressbookWindow::slotSetCategory( int c )
792{ 808{
793 if ( c <= 0 ) 809 if ( c <= 0 )
794 return; 810 return;
795 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 811 for ( unsigned int i = 1; i < catMenu->count(); i++ )
796 catMenu->setItemChecked( i, c == (int)i ); 812 catMenu->setItemChecked( i, c == (int)i );
797 if ( c == 1 ) { 813 if ( c == 1 ) {
798 abList->setShowCategory( QString::null ); 814 abList->setShowCategory( QString::null );
799 setCaption( tr("Contacts") + " - " + tr ( "All" ) ); 815 setCaption( tr("Contacts") + " - " + tr ( "All" ) );
800 } else if ( c == (int)catMenu->count() ) { 816 } else if ( c == (int)catMenu->count() ) {
801 abList->setShowCategory( tr( "Unfiled" ) ); 817 abList->setShowCategory( tr( "Unfiled" ) );
802 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); 818 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
803 } else { 819 } else {
804 QString cat = abList->categories()[c - 2]; 820 QString cat = abList->categories()[c - 2];
805 abList->setShowCategory( cat ); 821 abList->setShowCategory( cat );
806 setCaption( tr("Contacts") + " - " + cat ); 822 setCaption( tr("Contacts") + " - " + cat );
807 } 823 }
808} 824}
809 825
810void AddressbookWindow::populateCategories() 826void AddressbookWindow::populateCategories()
811{ 827{
812 catMenu->clear(); 828 catMenu->clear();