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.cpp70
1 files changed, 51 insertions, 19 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index f7e4c95..3466801 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -75,19 +75,26 @@ static QString addressbookPersonalVCardName()
75 75
76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
77 WFlags f ) 77 WFlags f )
78 : QMainWindow( parent, name, f ), 78 : QMainWindow( parent, name, f ),
79 abEditor(0), 79 abEditor(0),
80 useRegExp(false), 80 useRegExp(false),
81 DoSignalWrapAround(false), 81 doNotifyWrapAround(true),
82 caseSensitive(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 // Read Config settings
89 Config cfg("AddressBook");
90 cfg.setGroup("Search");
91 useRegExp = cfg.readBoolEntry( "useRegExp" );
92 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
93 doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
94
88 initFields(); 95 initFields();
89 96
90 setCaption( tr("Contacts") ); 97 setCaption( tr("Contacts") );
91 setIcon( Resource::loadPixmap( "AddressBook" ) ); 98 setIcon( Resource::loadPixmap( "AddressBook" ) );
92 99
93 setToolBarsMovable( FALSE ); 100 setToolBarsMovable( FALSE );
@@ -158,13 +165,13 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
158 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); 165 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) );
159 a->addTo( searchBar ); 166 a->addTo( searchBar );
160 167
161 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 168 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
162 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 169 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
163 a->addTo( searchBar ); 170 a->addTo( searchBar );
164 171
165 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 172 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
166 QString::null, 0, this, 0 ); 173 QString::null, 0, this, 0 );
167 //a->setEnabled( FALSE ); we got support for it now :) zecke 174 //a->setEnabled( FALSE ); we got support for it now :) zecke
168 actionMail = a; 175 actionMail = a;
169 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 176 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
170 a->addTo( edit ); 177 a->addTo( edit );
@@ -220,13 +227,19 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
220 227
221 abList = new AbTable( &orderedFields, listContainer, "table" ); 228 abList = new AbTable( &orderedFields, listContainer, "table" );
222 vb->addWidget(abList); 229 vb->addWidget(abList);
223 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 230 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
224 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 231 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
225 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 232 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
226 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); 233 connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) );
234 connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
235 connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
236
237 // Maybe we should react on Wraparound and notfound ?
238 QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
239 QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
227 240
228 mView = 0; 241 mView = 0;
229 242
230 abList->load(); 243 abList->load();
231 244
232 pLabel = new LetterPicker( listContainer ); 245 pLabel = new LetterPicker( listContainer );
@@ -255,36 +268,29 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
255 mbList->insertItem( tr("Font"), fontMenu); 268 mbList->insertItem( tr("Font"), fontMenu);
256 setCentralWidget(listContainer); 269 setCentralWidget(listContainer);
257 270
258 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 271 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
259 272
260 abList->setCurrentCell( 0, 0 ); 273 abList->setCurrentCell( 0, 0 );
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 274
269 isLoading = false; 275 isLoading = false;
270} 276}
271 277
272 278
273void AddressbookWindow::slotConfig() 279void AddressbookWindow::slotConfig()
274{ 280{
275 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 281 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
276 dlg -> setUseRegExp ( useRegExp ); 282 dlg -> setUseRegExp ( useRegExp );
277 dlg -> setBeCaseSensitive( caseSensitive ); 283 dlg -> setBeCaseSensitive( caseSensitive );
278 dlg -> setSignalWrapAround( DoSignalWrapAround ); 284 dlg -> setSignalWrapAround( doNotifyWrapAround );
279 dlg -> showMaximized(); 285 dlg -> showMaximized();
280 if ( dlg -> exec() ) { 286 if ( dlg -> exec() ) {
281 qWarning ("Config Dialog accepted !"); 287 qWarning ("Config Dialog accepted !");
282 useRegExp = dlg -> useRegExp(); 288 useRegExp = dlg -> useRegExp();
283 caseSensitive = dlg -> beCaseSensitive(); 289 caseSensitive = dlg -> beCaseSensitive();
284 DoSignalWrapAround = dlg -> signalWrapAround(); 290 doNotifyWrapAround = dlg -> signalWrapAround();
285 } 291 }
286 292
287 delete dlg; 293 delete dlg;
288} 294}
289 295
290 296
@@ -370,13 +376,13 @@ AddressbookWindow::~AddressbookWindow()
370 cfg.setGroup("Font"); 376 cfg.setGroup("Font");
371 cfg.writeEntry("fontSize", startFontSize); 377 cfg.writeEntry("fontSize", startFontSize);
372 378
373 cfg.setGroup("Search"); 379 cfg.setGroup("Search");
374 cfg.writeEntry("useRegExp", useRegExp); 380 cfg.writeEntry("useRegExp", useRegExp);
375 cfg.writeEntry("caseSensitive", caseSensitive); 381 cfg.writeEntry("caseSensitive", caseSensitive);
376 cfg.writeEntry("signalWrapAround", DoSignalWrapAround); 382 cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
377} 383}
378 384
379void AddressbookWindow::slotUpdateToolbar() 385void AddressbookWindow::slotUpdateToolbar()
380{ 386{
381 OContact ce = abList->currentEntry(); 387 OContact ce = abList->currentEntry();
382 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 388 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
@@ -653,15 +659,13 @@ void AddressbookWindow::slotPersonalView()
653{ 659{
654 if (!actionPersonal->isOn()) { 660 if (!actionPersonal->isOn()) {
655 // we just turned it off 661 // we just turned it off
656 setCaption( tr("Contacts") ); 662 setCaption( tr("Contacts") );
657 actionNew->setEnabled(TRUE); 663 actionNew->setEnabled(TRUE);
658 actionTrash->setEnabled(TRUE); 664 actionTrash->setEnabled(TRUE);
659#ifndef MAKE_FOR_SHARP_ROM
660 actionFind->setEnabled(TRUE); 665 actionFind->setEnabled(TRUE);
661#endif
662 slotUpdateToolbar(); // maybe some of the above could be moved there 666 slotUpdateToolbar(); // maybe some of the above could be moved there
663 showList(); 667 showList();
664 return; 668 return;
665 } 669 }
666 670
667 // XXX need to disable some QActions. 671 // XXX need to disable some QActions.
@@ -925,30 +929,40 @@ AbLabel *AddressbookWindow::abView()
925 return mView; 929 return mView;
926} 930}
927 931
928void AddressbookWindow::slotFindOpen() 932void AddressbookWindow::slotFindOpen()
929{ 933{
930 searchBar->show(); 934 searchBar->show();
935 abList -> inSearch();
931 searchEdit->setFocus(); 936 searchEdit->setFocus();
932} 937}
933void AddressbookWindow::slotFindClose() 938void AddressbookWindow::slotFindClose()
934{ 939{
935 searchBar->hide(); 940 searchBar->hide();
941 abList -> offSearch();
936 abList->setFocus(); 942 abList->setFocus();
937} 943}
938void AddressbookWindow::slotFindNext() 944void AddressbookWindow::slotFindNext()
939{ 945{
940 if ( centralWidget() == abView() ) 946 if ( centralWidget() == abView() )
941 showList(); 947 showList();
942 948
943 // Maybe we should react on Wraparound and notfound ?
944 // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
945 // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
946
947 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false); 949 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
948 950
951 searchEdit->clearFocus();
952 abList->setFocus();
953 if ( abList->numSelections() )
954 abList->clearSelection();
955
956}
957void AddressbookWindow::slotFindPrevious()
958{
959 if ( centralWidget() == abView() )
960 showList();
961
962 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
949 963
950 if ( abList->numSelections() ) 964 if ( abList->numSelections() )
951 abList->clearSelection(); 965 abList->clearSelection();
952 966
953} 967}
954 968
@@ -956,12 +970,30 @@ void AddressbookWindow::slotFind()
956{ 970{
957 971
958 abList->clearFindRow(); 972 abList->clearFindRow();
959 slotFindNext(); 973 slotFindNext();
960} 974}
961 975
976void AddressbookWindow::slotNotFound()
977{
978 qWarning("Got notfound signal !");
979 QMessageBox::information( this, tr( "Not Found" ),
980 tr( "Unable to find a contact for this" ) + "\n"
981 + tr( "search pattern !" ) );
982
983
984}
985void AddressbookWindow::slotWrapAround()
986{
987 qWarning("Got wrap signal !");
988 if ( doNotifyWrapAround )
989 QMessageBox::information( this, tr( "End of list" ),
990 tr( "End of list. Wrap around now.. !" ) + "\n" );
991
992}
993
962void AddressbookWindow::slotSetCategory( int c ) 994void AddressbookWindow::slotSetCategory( int c )
963{ 995{
964 996
965 QString cat, book; 997 QString cat, book;
966 998
967 if ( c <= 0 ) 999 if ( c <= 0 )