Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 66 |
1 files changed, 49 insertions, 17 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 | ||
76 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 76 | AddressbookWindow::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 ); |
@@ -221,12 +228,18 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 ); |
@@ -256,35 +269,28 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | 274 | ||
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 | |||
269 | isLoading = false; | 275 | isLoading = false; |
270 | } | 276 | } |
271 | 277 | ||
272 | 278 | ||
273 | void AddressbookWindow::slotConfig() | 279 | void 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 | ||
379 | void AddressbookWindow::slotUpdateToolbar() | 385 | void 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 | ||
928 | void AddressbookWindow::slotFindOpen() | 932 | void AddressbookWindow::slotFindOpen() |
929 | { | 933 | { |
930 | searchBar->show(); | 934 | searchBar->show(); |
935 | abList -> inSearch(); | ||
931 | searchEdit->setFocus(); | 936 | searchEdit->setFocus(); |
932 | } | 937 | } |
933 | void AddressbookWindow::slotFindClose() | 938 | void AddressbookWindow::slotFindClose() |
934 | { | 939 | { |
935 | searchBar->hide(); | 940 | searchBar->hide(); |
941 | abList -> offSearch(); | ||
936 | abList->setFocus(); | 942 | abList->setFocus(); |
937 | } | 943 | } |
938 | void AddressbookWindow::slotFindNext() | 944 | void 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 | } | ||
957 | void 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 | ||
976 | void 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 | } | ||
985 | void 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 | |||
962 | void AddressbookWindow::slotSetCategory( int c ) | 994 | void 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 ) |