summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp69
1 files changed, 49 insertions, 20 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 8335d8b..84e66fb 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -24,28 +24,24 @@
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 29
30#include <opie/ofileselector.h> 30#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 31#include <opie/ofiledialog.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <opie/ocontact.h> 34#include <opie/ocontact.h>
35 35
36#ifndef MAKE_FOR_SHARP_ROM
37#include <qpe/finddialog.h>
38#endif
39
40#include <qpe/global.h> 36#include <qpe/global.h>
41#include <qpe/resource.h> 37#include <qpe/resource.h>
42#include <qpe/ir.h> 38#include <qpe/ir.h>
43#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
44#include <qpe/qcopenvelope_qws.h> 40#include <qpe/qcopenvelope_qws.h>
45 41
46#include <qaction.h> 42#include <qaction.h>
47#include <qdialog.h> 43#include <qdialog.h>
48#include <qdir.h> 44#include <qdir.h>
49#include <qfile.h> 45#include <qfile.h>
50#include <qimage.h> 46#include <qimage.h>
51#include <qlayout.h> 47#include <qlayout.h>
@@ -58,37 +54,41 @@
58#include <qtoolbutton.h> 54#include <qtoolbutton.h>
59#include <qwhatsthis.h> 55#include <qwhatsthis.h>
60 56
61#include <stdlib.h> 57#include <stdlib.h>
62#include <sys/stat.h> 58#include <sys/stat.h>
63#include <sys/types.h> 59#include <sys/types.h>
64#include <fcntl.h> 60#include <fcntl.h>
65#include <unistd.h> 61#include <unistd.h>
66 62
67#include <qdatetime.h> 63#include <qdatetime.h>
68 64
69#include "picker.h" 65#include "picker.h"
66#include "configdlg.h"
70 67
71static QString addressbookPersonalVCardName() 68static QString addressbookPersonalVCardName()
72{ 69{
73 QString filename = Global::applicationFileName("addressbook", 70 QString filename = Global::applicationFileName("addressbook",
74 "businesscard.vcf"); 71 "businesscard.vcf");
75 return filename; 72 return filename;
76} 73}
77 74
78 75
79AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
80 WFlags f ) 77 WFlags f )
81 : QMainWindow( parent, name, f ), 78 : QMainWindow( parent, name, f ),
82 abEditor(0), 79 abEditor(0),
80 useRegExp(false),
81 DoSignalWrapAround(false),
82 caseSensitive(false),
83 bAbEditFirstTime(TRUE), 83 bAbEditFirstTime(TRUE),
84 syncing(FALSE) 84 syncing(FALSE)
85{ 85{
86 isLoading = true; 86 isLoading = true;
87 87
88 initFields(); 88 initFields();
89 89
90 setCaption( tr("Contacts") ); 90 setCaption( tr("Contacts") );
91 setIcon( Resource::loadPixmap( "AddressBook" ) ); 91 setIcon( Resource::loadPixmap( "AddressBook" ) );
92 92
93 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
94 94
@@ -199,24 +199,28 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
199 // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 199 // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
200 // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 200 // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
201 // a->addTo( edit ); 201 // a->addTo( edit );
202 202
203 203
204#ifdef __DEBUG_RELEASE 204#ifdef __DEBUG_RELEASE
205 // Remove this function for public Release ! This is only 205 // Remove this function for public Release ! This is only
206 // for debug purposes .. 206 // for debug purposes ..
207 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 207 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
208 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 208 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
209 a->addTo( edit ); 209 a->addTo( edit );
210#endif 210#endif
211 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null,
212 0, this, 0 );
213 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
214 a->addTo( edit );
211 215
212 // Create Views 216 // Create Views
213 listContainer = new QWidget( this ); 217 listContainer = new QWidget( this );
214 218
215 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 219 QVBoxLayout *vb = new QVBoxLayout( listContainer );
216 220
217 abList = new AbTable( &orderedFields, listContainer, "table" ); 221 abList = new AbTable( &orderedFields, listContainer, "table" );
218 vb->addWidget(abList); 222 vb->addWidget(abList);
219 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 223 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
220 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 224 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
221 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 225 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
222 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); 226 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) );
@@ -246,28 +250,53 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
246 250
247 defaultFont = new QFont( abList->font() ); 251 defaultFont = new QFont( abList->font() );
248 252
249 slotSetFont(startFontSize); 253 slotSetFont(startFontSize);
250 254
251 mbList->insertItem( tr("Font"), fontMenu); 255 mbList->insertItem( tr("Font"), fontMenu);
252 setCentralWidget(listContainer); 256 setCentralWidget(listContainer);
253 257
254 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 258 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
255 259
256 abList->setCurrentCell( 0, 0 ); 260 abList->setCurrentCell( 0, 0 );
257 261
262 // Read Config settings
263 Config cfg("AddressBook");
264 cfg.setGroup("Search");
265 useRegExp = cfg.readBoolEntry( "useRegExp" );
266 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
267 DoSignalWrapAround = cfg.readBoolEntry( "signalWrapAround" );
268
258 isLoading = false; 269 isLoading = false;
259} 270}
260 271
261 272
273void AddressbookWindow::slotConfig()
274{
275 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
276 dlg -> setUseRegExp ( useRegExp );
277 dlg -> setBeCaseSensitive( caseSensitive );
278 dlg -> setSignalWrapAround( DoSignalWrapAround );
279 dlg -> showMaximized();
280 if ( dlg -> exec() ) {
281 qWarning ("Config Dialog accepted !");
282 useRegExp = dlg -> useRegExp();
283 caseSensitive = dlg -> beCaseSensitive();
284 DoSignalWrapAround = dlg -> signalWrapAround();
285 }
286
287 delete dlg;
288}
289
290
262void AddressbookWindow::slotSetFont( int size ) { 291void AddressbookWindow::slotSetFont( int size ) {
263 292
264 if (size > 2 || size < 0) 293 if (size > 2 || size < 0)
265 size = 1; 294 size = 1;
266 295
267 startFontSize = size; 296 startFontSize = size;
268 297
269 QFont *currentFont; 298 QFont *currentFont;
270 299
271 switch (size) { 300 switch (size) {
272 case 0: 301 case 0:
273 fontMenu->setItemChecked(0, true); 302 fontMenu->setItemChecked(0, true);
@@ -331,24 +360,29 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
331 360
332 if ( centralWidget() == listContainer ) 361 if ( centralWidget() == listContainer )
333 showList(); 362 showList();
334 else if ( centralWidget() == mView ) 363 else if ( centralWidget() == mView )
335 showView(); 364 showView();
336} 365}
337 366
338AddressbookWindow::~AddressbookWindow() 367AddressbookWindow::~AddressbookWindow()
339{ 368{
340 Config cfg("AddressBook"); 369 Config cfg("AddressBook");
341 cfg.setGroup("Font"); 370 cfg.setGroup("Font");
342 cfg.writeEntry("fontSize", startFontSize); 371 cfg.writeEntry("fontSize", startFontSize);
372
373 cfg.setGroup("Search");
374 cfg.writeEntry("useRegExp", useRegExp);
375 cfg.writeEntry("caseSensitive", caseSensitive);
376 cfg.writeEntry("signalWrapAround", DoSignalWrapAround);
343} 377}
344 378
345void AddressbookWindow::slotUpdateToolbar() 379void AddressbookWindow::slotUpdateToolbar()
346{ 380{
347 OContact ce = abList->currentEntry(); 381 OContact ce = abList->currentEntry();
348 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 382 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
349} 383}
350 384
351void AddressbookWindow::showList() 385void AddressbookWindow::showList()
352{ 386{
353 bool visiblemView; 387 bool visiblemView;
354 388
@@ -885,70 +919,65 @@ AbLabel *AddressbookWindow::abView()
885{ 919{
886 if ( !mView ) { 920 if ( !mView ) {
887 mView = new AbLabel( this, "viewer" ); 921 mView = new AbLabel( this, "viewer" );
888 mView->init( OContact() ); 922 mView->init( OContact() );
889 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); 923 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
890 } 924 }
891 return mView; 925 return mView;
892} 926}
893 927
894void AddressbookWindow::slotFindOpen() 928void AddressbookWindow::slotFindOpen()
895{ 929{
896 searchBar->show(); 930 searchBar->show();
931 searchEdit->setFocus();
897} 932}
898void AddressbookWindow::slotFindClose() 933void AddressbookWindow::slotFindClose()
899{ 934{
900 searchBar->hide(); 935 searchBar->hide();
936 abList->setFocus();
901} 937}
902void AddressbookWindow::slotFindNext() 938void AddressbookWindow::slotFindNext()
903{ 939{
904}
905
906void AddressbookWindow::slotFind()
907{
908 if ( centralWidget() == abView() ) 940 if ( centralWidget() == abView() )
909 showList(); 941 showList();
910 942
911 // FindDialog frmFind( "Contacts", this ); 943 // Maybe we should react on Wraparound and notfound ?
912 // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); 944 // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
913 // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); 945 // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
914 // frmFind.exec();
915 946
916 // QStringList categories = abList->categories();
917 // abList->setShowCategory( book, cat );
918 abList->slotDoFind( searchEdit->text(), false, false); 947 abList->slotDoFind( searchEdit->text(), false, false);
919 948
920 949
921 if ( abList->numSelections() ) 950 if ( abList->numSelections() )
922 abList->clearSelection(); 951 abList->clearSelection();
923 952
953}
954
955void AddressbookWindow::slotFind()
956{
957
924 abList->clearFindRow(); 958 abList->clearFindRow();
959 slotFindNext();
925} 960}
926 961
927void AddressbookWindow::slotSetCategory( int c ) 962void AddressbookWindow::slotSetCategory( int c )
928{ 963{
929 964
930 QString cat, book; 965 QString cat, book;
931 966
932 if ( c <= 0 ) 967 if ( c <= 0 )
933 return; 968 return;
934 969
935 // Checkmark Book Menu Item Selected 970 // Set checkItem for selected one
936 if ( c < 6 ) 971 for ( unsigned int i = 1; i < catMenu->count(); i++ )
937 for ( unsigned int i = 1; i < 6; i++ )
938 catMenu->setItemChecked( i, c == (int)i );
939
940 // Checkmark Category Menu Item Selected
941 else
942 for ( unsigned int i = 6; i < catMenu->count(); i++ )
943 catMenu->setItemChecked( i, c == (int)i ); 972 catMenu->setItemChecked( i, c == (int)i );
944 973
945 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 974 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
946 if (catMenu->isItemChecked( i )) { 975 if (catMenu->isItemChecked( i )) {
947 if ( i == 1 ) // default List view 976 if ( i == 1 ) // default List view
948 book = QString::null; 977 book = QString::null;
949 else if ( i == 2 ) 978 else if ( i == 2 )
950 book = "Phone"; 979 book = "Phone";
951 else if ( i == 3 ) 980 else if ( i == 3 )
952 book = "Company"; 981 book = "Company";
953 else if ( i == 4 ) 982 else if ( i == 4 )
954 book = "Email"; 983 book = "Email";